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/input.h>
0019 #include <linux/memblock.h>
0020 #include <linux/pda_power.h>
0021 #include <linux/pwm_backlight.h>
0022 #include <linux/gpio.h>
0023 #include <linux/power_supply.h>
0024 #include <linux/w1-gpio.h>
0025
0026 #include <asm/mach-types.h>
0027 #include <asm/mach/arch.h>
0028 #include <asm/mach/map.h>
0029
0030 #include "pxa27x.h"
0031 #include "pxa27x-udc.h"
0032 #include <linux/platform_data/asoc-pxa.h>
0033 #include "palmtreo.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 <linux/platform_data/keypad-pxa27x.h>
0038 #include "udc.h"
0039 #include <linux/platform_data/usb-ohci-pxa27x.h>
0040 #include "pxa2xx-regs.h"
0041 #include <linux/platform_data/asoc-palm27x.h>
0042 #include <linux/platform_data/media/camera-pxa.h>
0043 #include "palm27x.h"
0044
0045 #include <sound/pxa2xx-lib.h>
0046
0047 #include "generic.h"
0048 #include "devices.h"
0049
0050
0051
0052
0053 static unsigned long treo_pin_config[] __initdata = {
0054
0055 GPIO32_MMC_CLK,
0056 GPIO92_MMC_DAT_0,
0057 GPIO109_MMC_DAT_1,
0058 GPIO110_MMC_DAT_2,
0059 GPIO111_MMC_DAT_3,
0060 GPIO112_MMC_CMD,
0061 GPIO113_GPIO,
0062
0063
0064 GPIO28_AC97_BITCLK,
0065 GPIO29_AC97_SDATA_IN_0,
0066 GPIO30_AC97_SDATA_OUT,
0067 GPIO31_AC97_SYNC,
0068 GPIO89_AC97_SYSCLK,
0069 GPIO95_AC97_nRESET,
0070
0071
0072 GPIO46_FICP_RXD,
0073 GPIO47_FICP_TXD,
0074
0075
0076 GPIO16_PWM0_OUT,
0077
0078
0079 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
0080
0081
0082 GPIO101_KP_MKIN_1,
0083 GPIO102_KP_MKIN_2,
0084 GPIO97_KP_MKIN_3,
0085 GPIO98_KP_MKIN_4,
0086 GPIO91_KP_MKIN_6,
0087 GPIO13_KP_MKIN_7,
0088 GPIO103_KP_MKOUT_0 | MFP_LPM_DRIVE_HIGH,
0089 GPIO104_KP_MKOUT_1,
0090 GPIO105_KP_MKOUT_2,
0091 GPIO106_KP_MKOUT_3,
0092 GPIO107_KP_MKOUT_4,
0093 GPIO108_KP_MKOUT_5,
0094 GPIO96_KP_MKOUT_6,
0095 GPIO93_KP_DKIN_0 | WAKEUP_ON_LEVEL_HIGH,
0096
0097
0098 GPIO84_CIF_FV,
0099 GPIO85_CIF_LV,
0100 GPIO53_CIF_MCLK,
0101 GPIO54_CIF_PCLK,
0102 GPIO81_CIF_DD_0,
0103 GPIO55_CIF_DD_1,
0104 GPIO51_CIF_DD_2,
0105 GPIO50_CIF_DD_3,
0106 GPIO52_CIF_DD_4,
0107 GPIO48_CIF_DD_5,
0108 GPIO17_CIF_DD_6,
0109 GPIO12_CIF_DD_7,
0110
0111
0112 GPIO117_I2C_SCL,
0113 GPIO118_I2C_SDA,
0114
0115
0116 GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH,
0117 GPIO34_FFUART_RXD,
0118 GPIO35_FFUART_CTS,
0119 GPIO39_FFUART_TXD,
0120 GPIO41_FFUART_RTS,
0121
0122
0123 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH,
0124 GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH,
0125 GPIO116_GPIO,
0126 GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH,
0127 };
0128
0129 #ifdef CONFIG_MACH_TREO680
0130 static unsigned long treo680_pin_config[] __initdata = {
0131 GPIO33_GPIO,
0132
0133
0134 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
0135 GPIO99_KP_MKIN_5,
0136
0137
0138 GPIOxx_LCD_16BPP,
0139 GPIO74_LCD_FCLK,
0140 GPIO75_LCD_LCLK,
0141 GPIO76_LCD_PCLK,
0142 };
0143 #endif
0144
0145 #ifdef CONFIG_MACH_CENTRO
0146 static unsigned long centro685_pin_config[] __initdata = {
0147
0148 MFP_CFG_OUT(GPIO80, AF0, DRIVE_LOW),
0149 GPIO42_BTUART_RXD,
0150 GPIO43_BTUART_TXD,
0151 GPIO44_BTUART_CTS,
0152 GPIO45_BTUART_RTS,
0153
0154
0155 GPIO100_KP_MKIN_0,
0156 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
0157
0158
0159 GPIOxx_LCD_TFT_16BPP,
0160 };
0161 #endif
0162
0163
0164
0165
0166 #if IS_ENABLED(CONFIG_KEYBOARD_PXA27x)
0167 static const unsigned int treo680_matrix_keys[] = {
0168 KEY(0, 0, KEY_F8),
0169 KEY(0, 1, KEY_LEFT),
0170 KEY(0, 2, KEY_LEFTCTRL),
0171 KEY(0, 3, KEY_L),
0172 KEY(0, 4, KEY_A),
0173 KEY(0, 5, KEY_Q),
0174 KEY(0, 6, KEY_P),
0175
0176 KEY(1, 0, KEY_RIGHTCTRL),
0177 KEY(1, 1, KEY_RIGHT),
0178 KEY(1, 2, KEY_LEFTSHIFT),
0179 KEY(1, 3, KEY_Z),
0180 KEY(1, 4, KEY_S),
0181 KEY(1, 5, KEY_W),
0182
0183 KEY(2, 0, KEY_F1),
0184 KEY(2, 1, KEY_UP),
0185 KEY(2, 2, KEY_0),
0186 KEY(2, 3, KEY_X),
0187 KEY(2, 4, KEY_D),
0188 KEY(2, 5, KEY_E),
0189
0190 KEY(3, 0, KEY_F10),
0191 KEY(3, 1, KEY_DOWN),
0192 KEY(3, 2, KEY_SPACE),
0193 KEY(3, 3, KEY_C),
0194 KEY(3, 4, KEY_F),
0195 KEY(3, 5, KEY_R),
0196
0197 KEY(4, 0, KEY_F12),
0198 KEY(4, 1, KEY_KPENTER),
0199 KEY(4, 2, KEY_RIGHTALT),
0200 KEY(4, 3, KEY_V),
0201 KEY(4, 4, KEY_G),
0202 KEY(4, 5, KEY_T),
0203
0204 KEY(5, 0, KEY_F9),
0205 KEY(5, 1, KEY_PAGEUP),
0206 KEY(5, 2, KEY_DOT),
0207 KEY(5, 3, KEY_B),
0208 KEY(5, 4, KEY_H),
0209 KEY(5, 5, KEY_Y),
0210
0211 KEY(6, 0, KEY_TAB),
0212 KEY(6, 1, KEY_PAGEDOWN),
0213 KEY(6, 2, KEY_ENTER),
0214 KEY(6, 3, KEY_N),
0215 KEY(6, 4, KEY_J),
0216 KEY(6, 5, KEY_U),
0217
0218 KEY(7, 0, KEY_F6),
0219 KEY(7, 1, KEY_O),
0220 KEY(7, 2, KEY_BACKSPACE),
0221 KEY(7, 3, KEY_M),
0222 KEY(7, 4, KEY_K),
0223 KEY(7, 5, KEY_I),
0224 };
0225
0226 static const unsigned int centro_matrix_keys[] = {
0227 KEY(0, 0, KEY_F9),
0228 KEY(0, 1, KEY_LEFT),
0229 KEY(0, 2, KEY_LEFTCTRL),
0230 KEY(0, 3, KEY_L),
0231 KEY(0, 4, KEY_A),
0232 KEY(0, 5, KEY_Q),
0233 KEY(0, 6, KEY_P),
0234
0235 KEY(1, 0, KEY_RIGHTCTRL),
0236 KEY(1, 1, KEY_RIGHT),
0237 KEY(1, 2, KEY_LEFTSHIFT),
0238 KEY(1, 3, KEY_Z),
0239 KEY(1, 4, KEY_S),
0240 KEY(1, 5, KEY_W),
0241
0242 KEY(2, 0, KEY_F1),
0243 KEY(2, 1, KEY_UP),
0244 KEY(2, 2, KEY_0),
0245 KEY(2, 3, KEY_X),
0246 KEY(2, 4, KEY_D),
0247 KEY(2, 5, KEY_E),
0248
0249 KEY(3, 0, KEY_F10),
0250 KEY(3, 1, KEY_DOWN),
0251 KEY(3, 2, KEY_SPACE),
0252 KEY(3, 3, KEY_C),
0253 KEY(3, 4, KEY_F),
0254 KEY(3, 5, KEY_R),
0255
0256 KEY(4, 0, KEY_F12),
0257 KEY(4, 1, KEY_KPENTER),
0258 KEY(4, 2, KEY_RIGHTALT),
0259 KEY(4, 3, KEY_V),
0260 KEY(4, 4, KEY_G),
0261 KEY(4, 5, KEY_T),
0262
0263 KEY(5, 0, KEY_F8),
0264 KEY(5, 1, KEY_PAGEUP),
0265 KEY(5, 2, KEY_DOT),
0266 KEY(5, 3, KEY_B),
0267 KEY(5, 4, KEY_H),
0268 KEY(5, 5, KEY_Y),
0269
0270 KEY(6, 0, KEY_TAB),
0271 KEY(6, 1, KEY_PAGEDOWN),
0272 KEY(6, 2, KEY_ENTER),
0273 KEY(6, 3, KEY_N),
0274 KEY(6, 4, KEY_J),
0275 KEY(6, 5, KEY_U),
0276
0277 KEY(7, 0, KEY_F6),
0278 KEY(7, 1, KEY_O),
0279 KEY(7, 2, KEY_BACKSPACE),
0280 KEY(7, 3, KEY_M),
0281 KEY(7, 4, KEY_K),
0282 KEY(7, 5, KEY_I),
0283 };
0284
0285 static struct matrix_keymap_data treo680_matrix_keymap_data = {
0286 .keymap = treo680_matrix_keys,
0287 .keymap_size = ARRAY_SIZE(treo680_matrix_keys),
0288 };
0289
0290 static struct matrix_keymap_data centro_matrix_keymap_data = {
0291 .keymap = centro_matrix_keys,
0292 .keymap_size = ARRAY_SIZE(centro_matrix_keys),
0293 };
0294
0295 static struct pxa27x_keypad_platform_data treo680_keypad_pdata = {
0296 .matrix_key_rows = 8,
0297 .matrix_key_cols = 7,
0298 .matrix_keymap_data = &treo680_matrix_keymap_data,
0299 .direct_key_map = { KEY_CONNECT },
0300 .direct_key_num = 1,
0301
0302 .debounce_interval = 30,
0303 };
0304
0305 static void __init palmtreo_kpc_init(void)
0306 {
0307 static struct pxa27x_keypad_platform_data *data = &treo680_keypad_pdata;
0308
0309 if (machine_is_centro())
0310 data->matrix_keymap_data = ¢ro_matrix_keymap_data;
0311
0312 pxa_set_keypad_info(&treo680_keypad_pdata);
0313 }
0314 #else
0315 static inline void palmtreo_kpc_init(void) {}
0316 #endif
0317
0318
0319
0320
0321 #if IS_ENABLED(CONFIG_USB_OHCI_HCD)
0322 static struct pxaohci_platform_data treo680_ohci_info = {
0323 .port_mode = PMM_PERPORT_MODE,
0324 .flags = ENABLE_PORT1 | ENABLE_PORT3,
0325 .power_budget = 0,
0326 };
0327
0328 static void __init palmtreo_uhc_init(void)
0329 {
0330 if (machine_is_treo680())
0331 pxa_set_ohci_info(&treo680_ohci_info);
0332 }
0333 #else
0334 static inline void palmtreo_uhc_init(void) {}
0335 #endif
0336
0337
0338
0339
0340 static struct gpio_led treo680_gpio_leds[] = {
0341 {
0342 .name = "treo680:vibra:vibra",
0343 .default_trigger = "none",
0344 .gpio = GPIO_NR_TREO680_VIBRATE_EN,
0345 },
0346 {
0347 .name = "treo680:green:led",
0348 .default_trigger = "mmc0",
0349 .gpio = GPIO_NR_TREO_GREEN_LED,
0350 },
0351 {
0352 .name = "treo680:white:keybbl",
0353 .default_trigger = "none",
0354 .gpio = GPIO_NR_TREO680_KEYB_BL,
0355 },
0356 };
0357
0358 static struct gpio_led_platform_data treo680_gpio_led_info = {
0359 .leds = treo680_gpio_leds,
0360 .num_leds = ARRAY_SIZE(treo680_gpio_leds),
0361 };
0362
0363 static struct gpio_led centro_gpio_leds[] = {
0364 {
0365 .name = "centro:vibra:vibra",
0366 .default_trigger = "none",
0367 .gpio = GPIO_NR_CENTRO_VIBRATE_EN,
0368 },
0369 {
0370 .name = "centro:green:led",
0371 .default_trigger = "mmc0",
0372 .gpio = GPIO_NR_TREO_GREEN_LED,
0373 },
0374 {
0375 .name = "centro:white:keybbl",
0376 .default_trigger = "none",
0377 .active_low = 1,
0378 .gpio = GPIO_NR_CENTRO_KEYB_BL,
0379 },
0380 };
0381
0382 static struct gpio_led_platform_data centro_gpio_led_info = {
0383 .leds = centro_gpio_leds,
0384 .num_leds = ARRAY_SIZE(centro_gpio_leds),
0385 };
0386
0387 static struct platform_device palmtreo_leds = {
0388 .name = "leds-gpio",
0389 .id = -1,
0390 };
0391
0392 static void __init palmtreo_leds_init(void)
0393 {
0394 if (machine_is_centro())
0395 palmtreo_leds.dev.platform_data = ¢ro_gpio_led_info;
0396 else if (machine_is_treo680())
0397 palmtreo_leds.dev.platform_data = &treo680_gpio_led_info;
0398
0399 platform_device_register(&palmtreo_leds);
0400 }
0401
0402
0403
0404
0405 static void __init treo_reserve(void)
0406 {
0407 memblock_reserve(0xa0000000, 0x1000);
0408 memblock_reserve(0xa2000000, 0x1000);
0409 }
0410
0411 static void __init palmphone_common_init(void)
0412 {
0413 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config));
0414 pxa_set_ffuart_info(NULL);
0415 pxa_set_btuart_info(NULL);
0416 pxa_set_stuart_info(NULL);
0417 palm27x_pm_init(TREO_STR_BASE);
0418 palm27x_lcd_init(GPIO_NR_TREO_BL_POWER, &palm_320x320_new_lcd_mode);
0419 palm27x_udc_init(GPIO_NR_TREO_USB_DETECT, GPIO_NR_TREO_USB_PULLUP, 1);
0420 palm27x_irda_init(GPIO_NR_TREO_IR_EN);
0421 palm27x_ac97_init(-1, -1, -1, 95);
0422 palm27x_pwm_init(GPIO_NR_TREO_BL_POWER, -1);
0423 palm27x_power_init(GPIO_NR_TREO_POWER_DETECT, -1);
0424 palm27x_pmic_init();
0425 palmtreo_kpc_init();
0426 palmtreo_uhc_init();
0427 palmtreo_leds_init();
0428 }
0429
0430 #ifdef CONFIG_MACH_TREO680
0431 void __init treo680_gpio_init(void)
0432 {
0433 unsigned int gpio;
0434
0435
0436 const unsigned long lcd_flags = GPIOF_INIT_HIGH | GPIOF_DIR_OUT;
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449 gpio = GPIO_NR_TREO680_LCD_POWER;
0450 if (gpio_request_one(gpio, lcd_flags, "LCD power") < 0)
0451 goto fail;
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461 gpio = GPIO_NR_TREO680_LCD_EN;
0462 if (gpio_request_one(gpio, lcd_flags, "LCD enable") < 0)
0463 goto fail;
0464 gpio = GPIO_NR_TREO680_LCD_EN_N;
0465 if (gpio_request_one(gpio, lcd_flags, "LCD enable_n") < 0)
0466 goto fail;
0467
0468
0469 gpio_set_value(GPIO_NR_TREO680_LCD_EN_N, 0);
0470
0471 return;
0472 fail:
0473 pr_err("gpio %d initialization failed\n", gpio);
0474 gpio_free(GPIO_NR_TREO680_LCD_POWER);
0475 gpio_free(GPIO_NR_TREO680_LCD_EN);
0476 gpio_free(GPIO_NR_TREO680_LCD_EN_N);
0477 }
0478
0479 static struct gpiod_lookup_table treo680_mci_gpio_table = {
0480 .dev_id = "pxa2xx-mci.0",
0481 .table = {
0482 GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO_SD_DETECT_N,
0483 "cd", GPIO_ACTIVE_LOW),
0484 GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO680_SD_READONLY,
0485 "wp", GPIO_ACTIVE_LOW),
0486 GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO680_SD_POWER,
0487 "power", GPIO_ACTIVE_HIGH),
0488 { },
0489 },
0490 };
0491
0492 static void __init treo680_init(void)
0493 {
0494 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
0495 palmphone_common_init();
0496 treo680_gpio_init();
0497 palm27x_mmc_init(&treo680_mci_gpio_table);
0498 }
0499 #endif
0500
0501 #ifdef CONFIG_MACH_CENTRO
0502
0503 static struct gpiod_lookup_table centro685_mci_gpio_table = {
0504 .dev_id = "pxa2xx-mci.0",
0505 .table = {
0506 GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO_SD_DETECT_N,
0507 "cd", GPIO_ACTIVE_LOW),
0508 GPIO_LOOKUP("gpio-pxa", GPIO_NR_CENTRO_SD_POWER,
0509 "power", GPIO_ACTIVE_LOW),
0510 { },
0511 },
0512 };
0513
0514 static void __init centro_init(void)
0515 {
0516 pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config));
0517 palmphone_common_init();
0518 palm27x_mmc_init(¢ro685_mci_gpio_table);
0519 }
0520 #endif
0521
0522 #ifdef CONFIG_MACH_TREO680
0523 MACHINE_START(TREO680, "Palm Treo 680")
0524 .atag_offset = 0x100,
0525 .map_io = pxa27x_map_io,
0526 .reserve = treo_reserve,
0527 .nr_irqs = PXA_NR_IRQS,
0528 .init_irq = pxa27x_init_irq,
0529 .handle_irq = pxa27x_handle_irq,
0530 .init_time = pxa_timer_init,
0531 .init_machine = treo680_init,
0532 .restart = pxa_restart,
0533 MACHINE_END
0534 #endif
0535
0536 #ifdef CONFIG_MACH_CENTRO
0537 MACHINE_START(CENTRO, "Palm Centro 685")
0538 .atag_offset = 0x100,
0539 .map_io = pxa27x_map_io,
0540 .reserve = treo_reserve,
0541 .nr_irqs = PXA_NR_IRQS,
0542 .init_irq = pxa27x_init_irq,
0543 .handle_irq = pxa27x_handle_irq,
0544 .init_time = pxa_timer_init,
0545 .init_machine = centro_init,
0546 .restart = pxa_restart,
0547 MACHINE_END
0548 #endif