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 */
122 /* Quick Capture Interface */
141 GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH, /* GSM host wake up */
148 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* external power detect */
149 GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH, /* silent switch */
150 GPIO116_GPIO, /* headphone detect */
151 GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* bluetooth host wake up */
154 #ifdef CONFIG_MACH_TREO680
155 static unsigned long treo680_pin_config[] __initdata = {
156 GPIO33_GPIO, /* SD read only */
158 /* MATRIX KEYPAD - different wake up source */
159 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
162 #endif /* CONFIG_MACH_TREO680 */
164 #ifdef CONFIG_MACH_CENTRO
165 static unsigned long centro685_pin_config[] __initdata = {
166 /* Bluetooth attached to BT UART*/
167 MFP_CFG_OUT(GPIO80, AF0, DRIVE_LOW), /* power: LOW = off */
173 /* MATRIX KEYPAD - different wake up source */
175 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
177 #endif /* CONFIG_MACH_CENTRO */
179 /******************************************************************************
180 * SD/MMC card controller
181 ******************************************************************************/
182 #ifdef CONFIG_MACH_TREO680
183 static struct pxamci_platform_data treo680_mci_platform_data = {
184 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
185 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
186 .gpio_card_ro = GPIO_NR_TREO680_SD_READONLY,
187 .gpio_power = GPIO_NR_TREO680_SD_POWER,
189 #endif /* CONFIG_MACH_TREO680 */
191 #ifdef CONFIG_MACH_CENTRO
192 static struct pxamci_platform_data centro_mci_platform_data = {
193 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
194 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
196 .gpio_power = GPIO_NR_CENTRO_SD_POWER,
197 .gpio_power_invert = 1,
199 #endif /* CONFIG_MACH_CENTRO */
201 /******************************************************************************
203 ******************************************************************************/
204 #ifdef CONFIG_MACH_TREO680
205 static unsigned int treo680_matrix_keys[] = {
206 KEY(0, 0, KEY_F8), /* Red/Off/Power */
208 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
214 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
215 KEY(1, 1, KEY_RIGHT),
216 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
221 KEY(2, 0, KEY_F1), /* Phone */
228 KEY(3, 0, KEY_F10), /* Calendar */
230 KEY(3, 2, KEY_SPACE),
235 KEY(4, 0, KEY_F12), /* Mail */
236 KEY(4, 1, KEY_KPENTER),
237 KEY(4, 2, KEY_RIGHTALT), /* Alt */
242 KEY(5, 0, KEY_F9), /* Home */
243 KEY(5, 1, KEY_PAGEUP), /* Side up */
249 KEY(6, 0, KEY_TAB), /* Side Activate */
250 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
251 KEY(6, 2, KEY_ENTER),
256 KEY(7, 0, KEY_F6), /* Green/Call */
258 KEY(7, 2, KEY_BACKSPACE),
264 static struct pxa27x_keypad_platform_data treo680_keypad_platform_data = {
265 .matrix_key_rows = 8,
266 .matrix_key_cols = 7,
267 .matrix_key_map = treo680_matrix_keys,
268 .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys),
269 .direct_key_map = { KEY_CONNECT },
272 .debounce_interval = 30,
274 #endif /* CONFIG_MACH_TREO680 */
276 #ifdef CONFIG_MACH_CENTRO
277 static unsigned int centro_matrix_keys[] = {
278 KEY(0, 0, KEY_F9), /* Home */
280 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
286 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
287 KEY(1, 1, KEY_RIGHT),
288 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
293 KEY(2, 0, KEY_F1), /* Phone */
300 KEY(3, 0, KEY_F10), /* Calendar */
302 KEY(3, 2, KEY_SPACE),
307 KEY(4, 0, KEY_F12), /* Mail */
308 KEY(4, 1, KEY_KPENTER),
309 KEY(4, 2, KEY_RIGHTALT), /* Alt */
314 KEY(5, 0, KEY_F8), /* Red/Off/Power */
315 KEY(5, 1, KEY_PAGEUP), /* Side up */
321 KEY(6, 0, KEY_TAB), /* Side Activate */
322 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
323 KEY(6, 2, KEY_ENTER),
328 KEY(7, 0, KEY_F6), /* Green/Call */
330 KEY(7, 2, KEY_BACKSPACE),
336 static struct pxa27x_keypad_platform_data centro_keypad_platform_data = {
337 .matrix_key_rows = 8,
338 .matrix_key_cols = 7,
339 .matrix_key_map = centro_matrix_keys,
340 .matrix_key_map_size = ARRAY_SIZE(centro_matrix_keys),
341 .direct_key_map = { KEY_CONNECT },
344 .debounce_interval = 30,
346 #endif /* CONFIG_MACH_CENTRO */
348 /******************************************************************************
350 ******************************************************************************/
352 static pxa2xx_audio_ops_t treo_ac97_pdata = {
356 /******************************************************************************
358 ******************************************************************************/
359 static int treo_backlight_init(struct device *dev)
363 ret = gpio_request(GPIO_NR_TREO_BL_POWER, "BL POWER");
366 ret = gpio_direction_output(GPIO_NR_TREO_BL_POWER, 0);
373 gpio_free(GPIO_NR_TREO_BL_POWER);
378 static int treo_backlight_notify(int brightness)
380 gpio_set_value(GPIO_NR_TREO_BL_POWER, brightness);
381 return TREO_MAX_INTENSITY - brightness;
384 static void treo_backlight_exit(struct device *dev)
386 gpio_free(GPIO_NR_TREO_BL_POWER);
389 static struct platform_pwm_backlight_data treo_backlight_data = {
391 .max_brightness = TREO_MAX_INTENSITY,
392 .dft_brightness = TREO_DEFAULT_INTENSITY,
393 .pwm_period_ns = TREO_PERIOD_NS,
394 .init = treo_backlight_init,
395 .notify = treo_backlight_notify,
396 .exit = treo_backlight_exit,
399 static struct platform_device treo_backlight = {
400 .name = "pwm-backlight",
402 .parent = &pxa27x_device_pwm0.dev,
403 .platform_data = &treo_backlight_data,
407 /******************************************************************************
409 ******************************************************************************/
410 static struct pxaficp_platform_data treo_ficp_info = {
411 .gpio_pwdown = GPIO_NR_TREO_IR_EN,
412 .transceiver_cap = IR_SIRMODE | IR_OFF,
415 /******************************************************************************
417 ******************************************************************************/
418 static struct pxa2xx_udc_mach_info treo_udc_info __initdata = {
419 .gpio_vbus = GPIO_NR_TREO_USB_DETECT,
420 .gpio_vbus_inverted = 1,
421 .gpio_pullup = GPIO_NR_TREO_USB_PULLUP,
425 /******************************************************************************
427 ******************************************************************************/
428 #ifdef CONFIG_MACH_TREO680
429 static struct pxaohci_platform_data treo680_ohci_info = {
430 .port_mode = PMM_PERPORT_MODE,
431 .flags = ENABLE_PORT1 | ENABLE_PORT3,
434 #endif /* CONFIG_MACH_TREO680 */
436 /******************************************************************************
438 ******************************************************************************/
439 static int power_supply_init(struct device *dev)
443 ret = gpio_request(GPIO_NR_TREO_POWER_DETECT, "CABLE_STATE_AC");
446 ret = gpio_direction_input(GPIO_NR_TREO_POWER_DETECT);
453 gpio_free(GPIO_NR_TREO_POWER_DETECT);
458 static int treo_is_ac_online(void)
460 return gpio_get_value(GPIO_NR_TREO_POWER_DETECT);
463 static void power_supply_exit(struct device *dev)
465 gpio_free(GPIO_NR_TREO_POWER_DETECT);
468 static char *treo_supplicants[] = {
472 static struct pda_power_pdata power_supply_info = {
473 .init = power_supply_init,
474 .is_ac_online = treo_is_ac_online,
475 .exit = power_supply_exit,
476 .supplied_to = treo_supplicants,
477 .num_supplicants = ARRAY_SIZE(treo_supplicants),
480 static struct platform_device power_supply = {
484 .platform_data = &power_supply_info,
488 /******************************************************************************
490 ******************************************************************************/
491 #ifdef CONFIG_MACH_TREO680
492 static struct gpio_led treo680_gpio_leds[] = {
494 .name = "treo680:vibra:vibra",
495 .default_trigger = "none",
496 .gpio = GPIO_NR_TREO680_VIBRATE_EN,
499 .name = "treo680:green:led",
500 .default_trigger = "mmc0",
501 .gpio = GPIO_NR_TREO_GREEN_LED,
504 .name = "treo680:white:keybbl",
505 .default_trigger = "none",
506 .gpio = GPIO_NR_TREO680_KEYB_BL,
510 static struct gpio_led_platform_data treo680_gpio_led_info = {
511 .leds = treo680_gpio_leds,
512 .num_leds = ARRAY_SIZE(treo680_gpio_leds),
515 static struct platform_device treo680_leds = {
519 .platform_data = &treo680_gpio_led_info,
522 #endif /* CONFIG_MACH_TREO680 */
524 #ifdef CONFIG_MACH_CENTRO
525 static struct gpio_led centro_gpio_leds[] = {
527 .name = "centro:vibra:vibra",
528 .default_trigger = "none",
529 .gpio = GPIO_NR_CENTRO_VIBRATE_EN,
532 .name = "centro:green:led",
533 .default_trigger = "mmc0",
534 .gpio = GPIO_NR_TREO_GREEN_LED,
537 .name = "centro:white:keybbl",
538 .default_trigger = "none",
540 .gpio = GPIO_NR_CENTRO_KEYB_BL,
544 static struct gpio_led_platform_data centro_gpio_led_info = {
545 .leds = centro_gpio_leds,
546 .num_leds = ARRAY_SIZE(centro_gpio_leds),
549 static struct platform_device centro_leds = {
553 .platform_data = ¢ro_gpio_led_info,
556 #endif /* CONFIG_MACH_CENTRO */
558 /******************************************************************************
560 ******************************************************************************/
561 /* TODO: add support for 324x324 */
562 static struct pxafb_mode_info treo_lcd_modes[] = {
579 static void treo_lcd_power(int on, struct fb_var_screeninfo *info)
581 gpio_set_value(GPIO_NR_TREO_BL_POWER, on);
584 static struct pxafb_mach_info treo_lcd_screen = {
585 .modes = treo_lcd_modes,
586 .num_modes = ARRAY_SIZE(treo_lcd_modes),
587 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
590 /******************************************************************************
591 * Power management - standby
592 ******************************************************************************/
593 static void __init treo_pm_init(void)
595 static u32 resume[] = {
596 0xe3a00101, /* mov r0, #0x40000000 */
597 0xe380060f, /* orr r0, r0, #0x00f00000 */
598 0xe590f008, /* ldr pc, [r0, #0x08] */
601 /* this is where the bootloader jumps */
602 memcpy(phys_to_virt(TREO_STR_BASE), resume, sizeof(resume));
605 /******************************************************************************
607 ******************************************************************************/
608 static struct platform_device *treo_devices[] __initdata = {
613 #ifdef CONFIG_MACH_TREO680
614 static struct platform_device *treo680_devices[] __initdata = {
617 #endif /* CONFIG_MACH_TREO680 */
619 #ifdef CONFIG_MACH_CENTRO
620 static struct platform_device *centro_devices[] __initdata = {
623 #endif /* CONFIG_MACH_CENTRO */
625 /* setup udc GPIOs initial state */
626 static void __init treo_udc_init(void)
628 if (!gpio_request(GPIO_NR_TREO_USB_PULLUP, "UDC Vbus")) {
629 gpio_direction_output(GPIO_NR_TREO_USB_PULLUP, 1);
630 gpio_free(GPIO_NR_TREO_USB_PULLUP);
634 static void __init treo_lcd_power_init(void)
638 ret = gpio_request(GPIO_NR_TREO_LCD_POWER, "LCD POWER");
640 pr_err("Treo680: LCD power GPIO request failed!\n");
644 ret = gpio_direction_output(GPIO_NR_TREO_LCD_POWER, 0);
646 pr_err("Treo680: setting LCD power GPIO direction failed!\n");
647 gpio_free(GPIO_NR_TREO_LCD_POWER);
651 treo_lcd_screen.pxafb_lcd_power = treo_lcd_power;
654 static void __init treo_init(void)
656 pxa_set_ffuart_info(NULL);
657 pxa_set_btuart_info(NULL);
658 pxa_set_stuart_info(NULL);
661 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config));
662 treo_lcd_power_init();
663 set_pxa_fb_info(&treo_lcd_screen);
665 pxa_set_udc_info(&treo_udc_info);
666 pxa_set_ac97_info(&treo_ac97_pdata);
667 pxa_set_ficp_info(&treo_ficp_info);
669 platform_add_devices(ARRAY_AND_SIZE(treo_devices));
672 #ifdef CONFIG_MACH_TREO680
673 static void __init treo680_init(void)
676 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
677 pxa_set_mci_info(&treo680_mci_platform_data);
678 pxa_set_keypad_info(&treo680_keypad_platform_data);
679 pxa_set_ohci_info(&treo680_ohci_info);
681 platform_add_devices(ARRAY_AND_SIZE(treo680_devices));
684 MACHINE_START(TREO680, "Palm Treo 680")
685 .phys_io = TREO_PHYS_IO_START,
686 .io_pg_offst = io_p2v(0x40000000),
687 .boot_params = 0xa0000100,
688 .map_io = pxa_map_io,
689 .init_irq = pxa27x_init_irq,
691 .init_machine = treo680_init,
693 #endif /* CONFIG_MACH_TREO680 */
695 #ifdef CONFIG_MACH_CENTRO
696 static void __init centro_init(void)
699 pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config));
700 pxa_set_mci_info(¢ro_mci_platform_data);
702 pxa_set_keypad_info(¢ro_keypad_platform_data);
704 platform_add_devices(ARRAY_AND_SIZE(centro_devices));
707 MACHINE_START(CENTRO, "Palm Centro 685")
708 .phys_io = TREO_PHYS_IO_START,
709 .io_pg_offst = io_p2v(0x40000000),
710 .boot_params = 0xa0000100,
711 .map_io = pxa_map_io,
712 .init_irq = pxa27x_init_irq,
714 .init_machine = centro_init,
716 #endif /* CONFIG_MACH_CENTRO */