0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <linux/platform_device.h>
0015 #include <linux/delay.h>
0016 #include <linux/irq.h>
0017 #include <linux/gpio_keys.h>
0018 #include <linux/gpio/machine.h>
0019 #include <linux/input.h>
0020 #include <linux/pda_power.h>
0021 #include <linux/pwm.h>
0022 #include <linux/pwm_backlight.h>
0023 #include <linux/gpio.h>
0024 #include <linux/wm97xx.h>
0025 #include <linux/power_supply.h>
0026
0027 #include <asm/mach-types.h>
0028 #include <asm/mach/arch.h>
0029 #include <asm/mach/map.h>
0030
0031 #include "pxa25x.h"
0032 #include <linux/platform_data/asoc-pxa.h>
0033 #include "palmte2.h"
0034 #include <linux/platform_data/mmc-pxamci.h>
0035 #include <linux/platform_data/video-pxafb.h>
0036 #include <linux/platform_data/irda-pxaficp.h>
0037 #include "udc.h"
0038 #include <linux/platform_data/asoc-palm27x.h>
0039
0040 #include "generic.h"
0041 #include "devices.h"
0042
0043
0044
0045
0046 static unsigned long palmte2_pin_config[] __initdata = {
0047
0048 GPIO6_MMC_CLK,
0049 GPIO8_MMC_CS0,
0050 GPIO10_GPIO,
0051 GPIO55_GPIO,
0052 GPIO51_GPIO,
0053
0054
0055 GPIO28_AC97_BITCLK,
0056 GPIO29_AC97_SDATA_IN_0,
0057 GPIO30_AC97_SDATA_OUT,
0058 GPIO31_AC97_SYNC,
0059
0060
0061 GPIO16_PWM0_OUT,
0062
0063
0064 GPIO15_GPIO,
0065 GPIO53_GPIO,
0066
0067
0068 GPIO48_GPIO,
0069 GPIO46_FICP_RXD,
0070 GPIO47_FICP_TXD,
0071
0072
0073 GPIOxx_LCD_TFT_16BPP,
0074
0075
0076 GPIO5_GPIO,
0077 GPIO7_GPIO,
0078 GPIO11_GPIO,
0079 GPIO13_GPIO,
0080 GPIO14_GPIO,
0081 GPIO19_GPIO,
0082 GPIO20_GPIO,
0083 GPIO21_GPIO,
0084 GPIO22_GPIO,
0085
0086
0087 GPIO1_RST,
0088 GPIO4_GPIO,
0089 GPIO9_GPIO,
0090 GPIO15_GPIO,
0091 GPIO37_GPIO,
0092 GPIO56_GPIO,
0093 };
0094
0095
0096
0097
0098 static struct pxamci_platform_data palmte2_mci_platform_data = {
0099 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
0100 };
0101
0102 static struct gpiod_lookup_table palmte2_mci_gpio_table = {
0103 .dev_id = "pxa2xx-mci.0",
0104 .table = {
0105 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_DETECT_N,
0106 "cd", GPIO_ACTIVE_LOW),
0107 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_READONLY,
0108 "wp", GPIO_ACTIVE_LOW),
0109 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_POWER,
0110 "power", GPIO_ACTIVE_HIGH),
0111 { },
0112 },
0113 };
0114
0115 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
0116
0117
0118
0119 static struct gpio_keys_button palmte2_pxa_buttons[] = {
0120 {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
0121 {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
0122 {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
0123 {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
0124 {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
0125 {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
0126 {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
0127 {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
0128 {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
0129 };
0130
0131 static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
0132 .buttons = palmte2_pxa_buttons,
0133 .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
0134 };
0135
0136 static struct platform_device palmte2_pxa_keys = {
0137 .name = "gpio-keys",
0138 .id = -1,
0139 .dev = {
0140 .platform_data = &palmte2_pxa_keys_data,
0141 },
0142 };
0143 #endif
0144
0145
0146
0147
0148 static struct pwm_lookup palmte2_pwm_lookup[] = {
0149 PWM_LOOKUP("pxa25x-pwm.0", 0, "pwm-backlight.0", NULL,
0150 PALMTE2_PERIOD_NS, PWM_POLARITY_NORMAL),
0151 };
0152
0153 static struct gpio palmte_bl_gpios[] = {
0154 { GPIO_NR_PALMTE2_BL_POWER, GPIOF_INIT_LOW, "Backlight power" },
0155 { GPIO_NR_PALMTE2_LCD_POWER, GPIOF_INIT_LOW, "LCD power" },
0156 };
0157
0158 static int palmte2_backlight_init(struct device *dev)
0159 {
0160 return gpio_request_array(ARRAY_AND_SIZE(palmte_bl_gpios));
0161 }
0162
0163 static int palmte2_backlight_notify(struct device *dev, int brightness)
0164 {
0165 gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
0166 gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
0167 return brightness;
0168 }
0169
0170 static void palmte2_backlight_exit(struct device *dev)
0171 {
0172 gpio_free_array(ARRAY_AND_SIZE(palmte_bl_gpios));
0173 }
0174
0175 static struct platform_pwm_backlight_data palmte2_backlight_data = {
0176 .max_brightness = PALMTE2_MAX_INTENSITY,
0177 .dft_brightness = PALMTE2_MAX_INTENSITY,
0178 .init = palmte2_backlight_init,
0179 .notify = palmte2_backlight_notify,
0180 .exit = palmte2_backlight_exit,
0181 };
0182
0183 static struct platform_device palmte2_backlight = {
0184 .name = "pwm-backlight",
0185 .dev = {
0186 .parent = &pxa25x_device_pwm0.dev,
0187 .platform_data = &palmte2_backlight_data,
0188 },
0189 };
0190
0191
0192
0193
0194 static struct pxaficp_platform_data palmte2_ficp_platform_data = {
0195 .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE,
0196 .transceiver_cap = IR_SIRMODE | IR_OFF,
0197 };
0198
0199
0200
0201
0202 static struct gpiod_lookup_table palmte2_udc_gpiod_table = {
0203 .dev_id = "gpio-vbus",
0204 .table = {
0205 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_USB_DETECT_N,
0206 "vbus", GPIO_ACTIVE_LOW),
0207 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_USB_PULLUP,
0208 "pullup", GPIO_ACTIVE_HIGH),
0209 { },
0210 },
0211 };
0212
0213 static struct platform_device palmte2_gpio_vbus = {
0214 .name = "gpio-vbus",
0215 .id = -1,
0216 };
0217
0218
0219
0220
0221 static int power_supply_init(struct device *dev)
0222 {
0223 int ret;
0224
0225 ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
0226 if (ret)
0227 goto err1;
0228 ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
0229 if (ret)
0230 goto err2;
0231
0232 return 0;
0233
0234 err2:
0235 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
0236 err1:
0237 return ret;
0238 }
0239
0240 static int palmte2_is_ac_online(void)
0241 {
0242 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
0243 }
0244
0245 static void power_supply_exit(struct device *dev)
0246 {
0247 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
0248 }
0249
0250 static char *palmte2_supplicants[] = {
0251 "main-battery",
0252 };
0253
0254 static struct pda_power_pdata power_supply_info = {
0255 .init = power_supply_init,
0256 .is_ac_online = palmte2_is_ac_online,
0257 .exit = power_supply_exit,
0258 .supplied_to = palmte2_supplicants,
0259 .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
0260 };
0261
0262 static struct platform_device power_supply = {
0263 .name = "pda-power",
0264 .id = -1,
0265 .dev = {
0266 .platform_data = &power_supply_info,
0267 },
0268 };
0269
0270
0271
0272
0273 static struct wm97xx_batt_pdata palmte2_batt_pdata = {
0274 .batt_aux = WM97XX_AUX_ID3,
0275 .temp_aux = WM97XX_AUX_ID2,
0276 .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
0277 .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
0278 .batt_mult = 1000,
0279 .batt_div = 414,
0280 .temp_mult = 1,
0281 .temp_div = 1,
0282 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
0283 .batt_name = "main-batt",
0284 };
0285
0286 static struct wm97xx_pdata palmte2_wm97xx_pdata = {
0287 .batt_pdata = &palmte2_batt_pdata,
0288 };
0289
0290 static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
0291 .codec_pdata = { &palmte2_wm97xx_pdata, },
0292 };
0293
0294 static struct palm27x_asoc_info palmte2_asoc_pdata = {
0295 .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
0296 };
0297
0298 static struct platform_device palmte2_asoc = {
0299 .name = "palm27x-asoc",
0300 .id = -1,
0301 .dev = {
0302 .platform_data = &palmte2_asoc_pdata,
0303 },
0304 };
0305
0306
0307
0308
0309 static struct pxafb_mode_info palmte2_lcd_modes[] = {
0310 {
0311 .pixclock = 77757,
0312 .xres = 320,
0313 .yres = 320,
0314 .bpp = 16,
0315
0316 .left_margin = 28,
0317 .right_margin = 7,
0318 .upper_margin = 7,
0319 .lower_margin = 5,
0320
0321 .hsync_len = 4,
0322 .vsync_len = 1,
0323 },
0324 };
0325
0326 static struct pxafb_mach_info palmte2_lcd_screen = {
0327 .modes = palmte2_lcd_modes,
0328 .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
0329 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
0330 };
0331
0332
0333
0334
0335 static struct platform_device *devices[] __initdata = {
0336 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
0337 &palmte2_pxa_keys,
0338 #endif
0339 &palmte2_backlight,
0340 &power_supply,
0341 &palmte2_asoc,
0342 &palmte2_gpio_vbus,
0343 };
0344
0345
0346 static void __init palmte2_udc_init(void)
0347 {
0348 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
0349 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
0350 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
0351 }
0352 }
0353
0354 static void __init palmte2_init(void)
0355 {
0356 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
0357
0358 pxa_set_ffuart_info(NULL);
0359 pxa_set_btuart_info(NULL);
0360 pxa_set_stuart_info(NULL);
0361
0362 pxa_set_fb_info(NULL, &palmte2_lcd_screen);
0363 gpiod_add_lookup_table(&palmte2_mci_gpio_table);
0364 pxa_set_mci_info(&palmte2_mci_platform_data);
0365 palmte2_udc_init();
0366 pxa_set_ac97_info(&palmte2_ac97_pdata);
0367 pxa_set_ficp_info(&palmte2_ficp_platform_data);
0368
0369 pwm_add_table(palmte2_pwm_lookup, ARRAY_SIZE(palmte2_pwm_lookup));
0370 gpiod_add_lookup_table(&palmte2_udc_gpiod_table);
0371 platform_add_devices(devices, ARRAY_SIZE(devices));
0372 }
0373
0374 MACHINE_START(PALMTE2, "Palm Tungsten|E2")
0375 .atag_offset = 0x100,
0376 .map_io = pxa25x_map_io,
0377 .nr_irqs = PXA_NR_IRQS,
0378 .init_irq = pxa25x_init_irq,
0379 .handle_irq = pxa25x_handle_irq,
0380 .init_time = pxa_timer_init,
0381 .init_machine = palmte2_init,
0382 .restart = pxa_restart,
0383 MACHINE_END