2 * Hardware definitions for Palm Treo smartphones
6 * Palm Centro 685 (GSM)
8 * Author: Tomas Cech <sleep_walker@suse.cz>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * (find more info at www.hackndev.com)
18 #include <linux/platform_device.h>
19 #include <linux/delay.h>
20 #include <linux/irq.h>
21 #include <linux/gpio_keys.h>
22 #include <linux/input.h>
23 #include <linux/pda_power.h>
24 #include <linux/pwm_backlight.h>
25 #include <linux/gpio.h>
26 #include <linux/wm97xx_batt.h>
27 #include <linux/power_supply.h>
28 #include <linux/sysdev.h>
29 #include <linux/w1-gpio.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
35 #include <mach/pxa27x.h>
36 #include <mach/pxa27x-udc.h>
37 #include <mach/audio.h>
38 #include <mach/palmtreo.h>
40 #include <mach/pxafb.h>
41 #include <mach/irda.h>
42 #include <mach/pxa27x_keypad.h>
44 #include <mach/ohci.h>
45 #include <mach/pxa2xx-regs.h>
46 #include <mach/palmasoc.h>
47 #include <mach/camera.h>
49 #include <sound/pxa2xx-lib.h>
54 /******************************************************************************
56 ******************************************************************************/
57 static unsigned long treo_pin_config
[] __initdata
= {
65 GPIO113_GPIO
, /* SD detect */
69 GPIO29_AC97_SDATA_IN_0
,
70 GPIO30_AC97_SDATA_OUT
,
83 GPIO1_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* usb detect */
92 GPIO103_KP_MKOUT_0
| MFP_LPM_DRIVE_HIGH
,
99 GPIO93_KP_DKIN_0
| WAKEUP_ON_LEVEL_HIGH
, /* Hotsync button */
102 GPIOxx_LCD_TFT_16BPP
,
104 /* Quick Capture Interface */
123 GPIO14_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* GSM host wake up */
130 GPIO0_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* external power detect */
131 GPIO15_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* silent switch */
132 GPIO116_GPIO
, /* headphone detect */
133 GPIO11_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* bluetooth host wake up */
136 #ifdef CONFIG_MACH_TREO680
137 static unsigned long treo680_pin_config
[] __initdata
= {
138 GPIO33_GPIO
, /* SD read only */
140 /* MATRIX KEYPAD - different wake up source */
141 GPIO100_KP_MKIN_0
| WAKEUP_ON_LEVEL_HIGH
,
144 #endif /* CONFIG_MACH_TREO680 */
146 #ifdef CONFIG_MACH_CENTRO
147 static unsigned long centro685_pin_config
[] __initdata
= {
148 /* Bluetooth attached to BT UART*/
149 MFP_CFG_OUT(GPIO80
, AF0
, DRIVE_LOW
), /* power: LOW = off */
155 /* MATRIX KEYPAD - different wake up source */
157 GPIO99_KP_MKIN_5
| WAKEUP_ON_LEVEL_HIGH
,
159 #endif /* CONFIG_MACH_CENTRO */
161 /******************************************************************************
162 * SD/MMC card controller
163 ******************************************************************************/
164 #ifdef CONFIG_MACH_TREO680
165 static struct pxamci_platform_data treo680_mci_platform_data
= {
166 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
167 .gpio_card_detect
= GPIO_NR_TREO_SD_DETECT_N
,
168 .gpio_card_ro
= GPIO_NR_TREO680_SD_READONLY
,
169 .gpio_power
= GPIO_NR_TREO680_SD_POWER
,
171 #endif /* CONFIG_MACH_TREO680 */
173 #ifdef CONFIG_MACH_CENTRO
174 static struct pxamci_platform_data centro_mci_platform_data
= {
175 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
176 .gpio_card_detect
= GPIO_NR_TREO_SD_DETECT_N
,
178 .gpio_power
= GPIO_NR_CENTRO_SD_POWER
,
179 .gpio_power_invert
= 1,
181 #endif /* CONFIG_MACH_CENTRO */
183 /******************************************************************************
185 ******************************************************************************/
186 #ifdef CONFIG_MACH_TREO680
187 static unsigned int treo680_matrix_keys
[] = {
188 KEY(0, 0, KEY_F8
), /* Red/Off/Power */
190 KEY(0, 2, KEY_LEFTCTRL
), /* Alternate */
196 KEY(1, 0, KEY_RIGHTCTRL
), /* Menu */
197 KEY(1, 1, KEY_RIGHT
),
198 KEY(1, 2, KEY_LEFTSHIFT
), /* Left shift */
203 KEY(2, 0, KEY_F1
), /* Phone */
210 KEY(3, 0, KEY_F10
), /* Calendar */
212 KEY(3, 2, KEY_SPACE
),
217 KEY(4, 0, KEY_F12
), /* Mail */
218 KEY(4, 1, KEY_KPENTER
),
219 KEY(4, 2, KEY_RIGHTALT
), /* Alt */
224 KEY(5, 0, KEY_F9
), /* Home */
225 KEY(5, 1, KEY_PAGEUP
), /* Side up */
231 KEY(6, 0, KEY_TAB
), /* Side Activate */
232 KEY(6, 1, KEY_PAGEDOWN
), /* Side down */
233 KEY(6, 2, KEY_ENTER
),
238 KEY(7, 0, KEY_F6
), /* Green/Call */
240 KEY(7, 2, KEY_BACKSPACE
),
246 static struct pxa27x_keypad_platform_data treo680_keypad_platform_data
= {
247 .matrix_key_rows
= 8,
248 .matrix_key_cols
= 7,
249 .matrix_key_map
= treo680_matrix_keys
,
250 .matrix_key_map_size
= ARRAY_SIZE(treo680_matrix_keys
),
251 .direct_key_map
= { KEY_CONNECT
},
254 .debounce_interval
= 30,
256 #endif /* CONFIG_MACH_TREO680 */
258 #ifdef CONFIG_MACH_CENTRO
259 static unsigned int centro_matrix_keys
[] = {
260 KEY(0, 0, KEY_F9
), /* Home */
262 KEY(0, 2, KEY_LEFTCTRL
), /* Alternate */
268 KEY(1, 0, KEY_RIGHTCTRL
), /* Menu */
269 KEY(1, 1, KEY_RIGHT
),
270 KEY(1, 2, KEY_LEFTSHIFT
), /* Left shift */
275 KEY(2, 0, KEY_F1
), /* Phone */
282 KEY(3, 0, KEY_F10
), /* Calendar */
284 KEY(3, 2, KEY_SPACE
),
289 KEY(4, 0, KEY_F12
), /* Mail */
290 KEY(4, 1, KEY_KPENTER
),
291 KEY(4, 2, KEY_RIGHTALT
), /* Alt */
296 KEY(5, 0, KEY_F8
), /* Red/Off/Power */
297 KEY(5, 1, KEY_PAGEUP
), /* Side up */
303 KEY(6, 0, KEY_TAB
), /* Side Activate */
304 KEY(6, 1, KEY_PAGEDOWN
), /* Side down */
305 KEY(6, 2, KEY_ENTER
),
310 KEY(7, 0, KEY_F6
), /* Green/Call */
312 KEY(7, 2, KEY_BACKSPACE
),
318 static struct pxa27x_keypad_platform_data centro_keypad_platform_data
= {
319 .matrix_key_rows
= 8,
320 .matrix_key_cols
= 7,
321 .matrix_key_map
= centro_matrix_keys
,
322 .matrix_key_map_size
= ARRAY_SIZE(centro_matrix_keys
),
323 .direct_key_map
= { KEY_CONNECT
},
326 .debounce_interval
= 30,
328 #endif /* CONFIG_MACH_CENTRO */
330 /******************************************************************************
332 ******************************************************************************/
334 static pxa2xx_audio_ops_t treo_ac97_pdata
= {
338 /******************************************************************************
340 ******************************************************************************/
341 static int treo_backlight_init(struct device
*dev
)
345 ret
= gpio_request(GPIO_NR_TREO_BL_POWER
, "BL POWER");
348 ret
= gpio_direction_output(GPIO_NR_TREO_BL_POWER
, 0);
355 gpio_free(GPIO_NR_TREO_BL_POWER
);
360 static int treo_backlight_notify(struct device
*dev
, int brightness
)
362 gpio_set_value(GPIO_NR_TREO_BL_POWER
, brightness
);
363 return TREO_MAX_INTENSITY
- brightness
;
366 static void treo_backlight_exit(struct device
*dev
)
368 gpio_free(GPIO_NR_TREO_BL_POWER
);
371 static struct platform_pwm_backlight_data treo_backlight_data
= {
373 .max_brightness
= TREO_MAX_INTENSITY
,
374 .dft_brightness
= TREO_DEFAULT_INTENSITY
,
375 .pwm_period_ns
= TREO_PERIOD_NS
,
376 .init
= treo_backlight_init
,
377 .notify
= treo_backlight_notify
,
378 .exit
= treo_backlight_exit
,
381 static struct platform_device treo_backlight
= {
382 .name
= "pwm-backlight",
384 .parent
= &pxa27x_device_pwm0
.dev
,
385 .platform_data
= &treo_backlight_data
,
389 /******************************************************************************
391 ******************************************************************************/
392 static struct pxaficp_platform_data treo_ficp_info
= {
393 .gpio_pwdown
= GPIO_NR_TREO_IR_EN
,
394 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
397 /******************************************************************************
399 ******************************************************************************/
400 static struct pxa2xx_udc_mach_info treo_udc_info __initdata
= {
401 .gpio_vbus
= GPIO_NR_TREO_USB_DETECT
,
402 .gpio_vbus_inverted
= 1,
403 .gpio_pullup
= GPIO_NR_TREO_USB_PULLUP
,
407 /******************************************************************************
409 ******************************************************************************/
410 #ifdef CONFIG_MACH_TREO680
411 static struct pxaohci_platform_data treo680_ohci_info
= {
412 .port_mode
= PMM_PERPORT_MODE
,
413 .flags
= ENABLE_PORT1
| ENABLE_PORT3
,
416 #endif /* CONFIG_MACH_TREO680 */
418 /******************************************************************************
420 ******************************************************************************/
421 static int power_supply_init(struct device
*dev
)
425 ret
= gpio_request(GPIO_NR_TREO_POWER_DETECT
, "CABLE_STATE_AC");
428 ret
= gpio_direction_input(GPIO_NR_TREO_POWER_DETECT
);
435 gpio_free(GPIO_NR_TREO_POWER_DETECT
);
440 static int treo_is_ac_online(void)
442 return gpio_get_value(GPIO_NR_TREO_POWER_DETECT
);
445 static void power_supply_exit(struct device
*dev
)
447 gpio_free(GPIO_NR_TREO_POWER_DETECT
);
450 static char *treo_supplicants
[] = {
454 static struct pda_power_pdata power_supply_info
= {
455 .init
= power_supply_init
,
456 .is_ac_online
= treo_is_ac_online
,
457 .exit
= power_supply_exit
,
458 .supplied_to
= treo_supplicants
,
459 .num_supplicants
= ARRAY_SIZE(treo_supplicants
),
462 static struct platform_device power_supply
= {
466 .platform_data
= &power_supply_info
,
470 /******************************************************************************
472 ******************************************************************************/
473 #ifdef CONFIG_MACH_TREO680
474 static struct gpio_led treo680_gpio_leds
[] = {
476 .name
= "treo680:vibra:vibra",
477 .default_trigger
= "none",
478 .gpio
= GPIO_NR_TREO680_VIBRATE_EN
,
481 .name
= "treo680:green:led",
482 .default_trigger
= "mmc0",
483 .gpio
= GPIO_NR_TREO_GREEN_LED
,
486 .name
= "treo680:white:keybbl",
487 .default_trigger
= "none",
488 .gpio
= GPIO_NR_TREO680_KEYB_BL
,
492 static struct gpio_led_platform_data treo680_gpio_led_info
= {
493 .leds
= treo680_gpio_leds
,
494 .num_leds
= ARRAY_SIZE(treo680_gpio_leds
),
497 static struct platform_device treo680_leds
= {
501 .platform_data
= &treo680_gpio_led_info
,
504 #endif /* CONFIG_MACH_TREO680 */
506 #ifdef CONFIG_MACH_CENTRO
507 static struct gpio_led centro_gpio_leds
[] = {
509 .name
= "centro:vibra:vibra",
510 .default_trigger
= "none",
511 .gpio
= GPIO_NR_CENTRO_VIBRATE_EN
,
514 .name
= "centro:green:led",
515 .default_trigger
= "mmc0",
516 .gpio
= GPIO_NR_TREO_GREEN_LED
,
519 .name
= "centro:white:keybbl",
520 .default_trigger
= "none",
522 .gpio
= GPIO_NR_CENTRO_KEYB_BL
,
526 static struct gpio_led_platform_data centro_gpio_led_info
= {
527 .leds
= centro_gpio_leds
,
528 .num_leds
= ARRAY_SIZE(centro_gpio_leds
),
531 static struct platform_device centro_leds
= {
535 .platform_data
= ¢ro_gpio_led_info
,
538 #endif /* CONFIG_MACH_CENTRO */
540 /******************************************************************************
542 ******************************************************************************/
543 /* TODO: add support for 324x324 */
544 static struct pxafb_mode_info treo_lcd_modes
[] = {
561 static void treo_lcd_power(int on
, struct fb_var_screeninfo
*info
)
563 gpio_set_value(GPIO_NR_TREO_BL_POWER
, on
);
566 static struct pxafb_mach_info treo_lcd_screen
= {
567 .modes
= treo_lcd_modes
,
568 .num_modes
= ARRAY_SIZE(treo_lcd_modes
),
569 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
572 /******************************************************************************
573 * Power management - standby
574 ******************************************************************************/
575 static void __init
treo_pm_init(void)
577 static u32 resume
[] = {
578 0xe3a00101, /* mov r0, #0x40000000 */
579 0xe380060f, /* orr r0, r0, #0x00f00000 */
580 0xe590f008, /* ldr pc, [r0, #0x08] */
583 /* this is where the bootloader jumps */
584 memcpy(phys_to_virt(TREO_STR_BASE
), resume
, sizeof(resume
));
587 /******************************************************************************
589 ******************************************************************************/
590 static struct platform_device
*treo_devices
[] __initdata
= {
595 #ifdef CONFIG_MACH_TREO680
596 static struct platform_device
*treo680_devices
[] __initdata
= {
599 #endif /* CONFIG_MACH_TREO680 */
601 #ifdef CONFIG_MACH_CENTRO
602 static struct platform_device
*centro_devices
[] __initdata
= {
605 #endif /* CONFIG_MACH_CENTRO */
607 /* setup udc GPIOs initial state */
608 static void __init
treo_udc_init(void)
610 if (!gpio_request(GPIO_NR_TREO_USB_PULLUP
, "UDC Vbus")) {
611 gpio_direction_output(GPIO_NR_TREO_USB_PULLUP
, 1);
612 gpio_free(GPIO_NR_TREO_USB_PULLUP
);
616 static void __init
treo_lcd_power_init(void)
620 ret
= gpio_request(GPIO_NR_TREO_LCD_POWER
, "LCD POWER");
622 pr_err("Treo680: LCD power GPIO request failed!\n");
626 ret
= gpio_direction_output(GPIO_NR_TREO_LCD_POWER
, 0);
628 pr_err("Treo680: setting LCD power GPIO direction failed!\n");
629 gpio_free(GPIO_NR_TREO_LCD_POWER
);
633 treo_lcd_screen
.pxafb_lcd_power
= treo_lcd_power
;
636 static void __init
treo_init(void)
638 pxa_set_ffuart_info(NULL
);
639 pxa_set_btuart_info(NULL
);
640 pxa_set_stuart_info(NULL
);
643 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config
));
644 treo_lcd_power_init();
645 set_pxa_fb_info(&treo_lcd_screen
);
647 pxa_set_udc_info(&treo_udc_info
);
648 pxa_set_ac97_info(&treo_ac97_pdata
);
649 pxa_set_ficp_info(&treo_ficp_info
);
651 platform_add_devices(ARRAY_AND_SIZE(treo_devices
));
654 #ifdef CONFIG_MACH_TREO680
655 static void __init
treo680_init(void)
658 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config
));
659 pxa_set_mci_info(&treo680_mci_platform_data
);
660 pxa_set_keypad_info(&treo680_keypad_platform_data
);
661 pxa_set_ohci_info(&treo680_ohci_info
);
663 platform_add_devices(ARRAY_AND_SIZE(treo680_devices
));
666 MACHINE_START(TREO680
, "Palm Treo 680")
667 .phys_io
= TREO_PHYS_IO_START
,
668 .io_pg_offst
= io_p2v(0x40000000),
669 .boot_params
= 0xa0000100,
670 .map_io
= pxa_map_io
,
671 .init_irq
= pxa27x_init_irq
,
673 .init_machine
= treo680_init
,
675 #endif /* CONFIG_MACH_TREO680 */
677 #ifdef CONFIG_MACH_CENTRO
678 static void __init
centro_init(void)
681 pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config
));
682 pxa_set_mci_info(¢ro_mci_platform_data
);
684 pxa_set_keypad_info(¢ro_keypad_platform_data
);
686 platform_add_devices(ARRAY_AND_SIZE(centro_devices
));
689 MACHINE_START(CENTRO
, "Palm Centro 685")
690 .phys_io
= TREO_PHYS_IO_START
,
691 .io_pg_offst
= io_p2v(0x40000000),
692 .boot_params
= 0xa0000100,
693 .map_io
= pxa_map_io
,
694 .init_irq
= pxa27x_init_irq
,
696 .init_machine
= centro_init
,
698 #endif /* CONFIG_MACH_CENTRO */