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/memblock.h>
24 #include <linux/pda_power.h>
25 #include <linux/pwm_backlight.h>
26 #include <linux/gpio.h>
27 #include <linux/wm97xx_batt.h>
28 #include <linux/power_supply.h>
29 #include <linux/sysdev.h>
30 #include <linux/w1-gpio.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
36 #include <mach/pxa27x.h>
37 #include <mach/pxa27x-udc.h>
38 #include <mach/audio.h>
39 #include <mach/palmtreo.h>
41 #include <mach/pxafb.h>
42 #include <mach/irda.h>
43 #include <mach/pxa27x_keypad.h>
45 #include <mach/ohci.h>
46 #include <mach/pxa2xx-regs.h>
47 #include <mach/palmasoc.h>
48 #include <mach/camera.h>
50 #include <sound/pxa2xx-lib.h>
55 /******************************************************************************
57 ******************************************************************************/
58 static unsigned long treo_pin_config[] __initdata = {
66 GPIO113_GPIO, /* SD detect */
70 GPIO29_AC97_SDATA_IN_0,
71 GPIO30_AC97_SDATA_OUT,
84 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* usb detect */
93 GPIO103_KP_MKOUT_0 | MFP_LPM_DRIVE_HIGH,
100 GPIO93_KP_DKIN_0 | WAKEUP_ON_LEVEL_HIGH, /* Hotsync button */
103 GPIOxx_LCD_TFT_16BPP,
105 /* Quick Capture Interface */
124 GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH, /* GSM host wake up */
131 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* external power detect */
132 GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH, /* silent switch */
133 GPIO116_GPIO, /* headphone detect */
134 GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* bluetooth host wake up */
137 #ifdef CONFIG_MACH_TREO680
138 static unsigned long treo680_pin_config[] __initdata = {
139 GPIO33_GPIO, /* SD read only */
141 /* MATRIX KEYPAD - different wake up source */
142 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
145 #endif /* CONFIG_MACH_TREO680 */
147 #ifdef CONFIG_MACH_CENTRO
148 static unsigned long centro685_pin_config[] __initdata = {
149 /* Bluetooth attached to BT UART*/
150 MFP_CFG_OUT(GPIO80, AF0, DRIVE_LOW), /* power: LOW = off */
156 /* MATRIX KEYPAD - different wake up source */
158 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
160 #endif /* CONFIG_MACH_CENTRO */
162 /******************************************************************************
163 * SD/MMC card controller
164 ******************************************************************************/
165 #ifdef CONFIG_MACH_TREO680
166 static struct pxamci_platform_data treo680_mci_platform_data = {
167 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
168 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
169 .gpio_card_ro = GPIO_NR_TREO680_SD_READONLY,
170 .gpio_power = GPIO_NR_TREO680_SD_POWER,
172 #endif /* CONFIG_MACH_TREO680 */
174 #ifdef CONFIG_MACH_CENTRO
175 static struct pxamci_platform_data centro_mci_platform_data = {
176 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
177 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
179 .gpio_power = GPIO_NR_CENTRO_SD_POWER,
180 .gpio_power_invert = 1,
182 #endif /* CONFIG_MACH_CENTRO */
184 /******************************************************************************
186 ******************************************************************************/
187 #ifdef CONFIG_MACH_TREO680
188 static unsigned int treo680_matrix_keys[] = {
189 KEY(0, 0, KEY_F8), /* Red/Off/Power */
191 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
197 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
198 KEY(1, 1, KEY_RIGHT),
199 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
204 KEY(2, 0, KEY_F1), /* Phone */
211 KEY(3, 0, KEY_F10), /* Calendar */
213 KEY(3, 2, KEY_SPACE),
218 KEY(4, 0, KEY_F12), /* Mail */
219 KEY(4, 1, KEY_KPENTER),
220 KEY(4, 2, KEY_RIGHTALT), /* Alt */
225 KEY(5, 0, KEY_F9), /* Home */
226 KEY(5, 1, KEY_PAGEUP), /* Side up */
232 KEY(6, 0, KEY_TAB), /* Side Activate */
233 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
234 KEY(6, 2, KEY_ENTER),
239 KEY(7, 0, KEY_F6), /* Green/Call */
241 KEY(7, 2, KEY_BACKSPACE),
247 static struct pxa27x_keypad_platform_data treo680_keypad_platform_data = {
248 .matrix_key_rows = 8,
249 .matrix_key_cols = 7,
250 .matrix_key_map = treo680_matrix_keys,
251 .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys),
252 .direct_key_map = { KEY_CONNECT },
255 .debounce_interval = 30,
257 #endif /* CONFIG_MACH_TREO680 */
259 #ifdef CONFIG_MACH_CENTRO
260 static unsigned int centro_matrix_keys[] = {
261 KEY(0, 0, KEY_F9), /* Home */
263 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
269 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
270 KEY(1, 1, KEY_RIGHT),
271 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
276 KEY(2, 0, KEY_F1), /* Phone */
283 KEY(3, 0, KEY_F10), /* Calendar */
285 KEY(3, 2, KEY_SPACE),
290 KEY(4, 0, KEY_F12), /* Mail */
291 KEY(4, 1, KEY_KPENTER),
292 KEY(4, 2, KEY_RIGHTALT), /* Alt */
297 KEY(5, 0, KEY_F8), /* Red/Off/Power */
298 KEY(5, 1, KEY_PAGEUP), /* Side up */
304 KEY(6, 0, KEY_TAB), /* Side Activate */
305 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
306 KEY(6, 2, KEY_ENTER),
311 KEY(7, 0, KEY_F6), /* Green/Call */
313 KEY(7, 2, KEY_BACKSPACE),
319 static struct pxa27x_keypad_platform_data centro_keypad_platform_data = {
320 .matrix_key_rows = 8,
321 .matrix_key_cols = 7,
322 .matrix_key_map = centro_matrix_keys,
323 .matrix_key_map_size = ARRAY_SIZE(centro_matrix_keys),
324 .direct_key_map = { KEY_CONNECT },
327 .debounce_interval = 30,
329 #endif /* CONFIG_MACH_CENTRO */
331 /******************************************************************************
333 ******************************************************************************/
335 static pxa2xx_audio_ops_t treo_ac97_pdata = {
339 /******************************************************************************
341 ******************************************************************************/
342 static int treo_backlight_init(struct device *dev)
346 ret = gpio_request(GPIO_NR_TREO_BL_POWER, "BL POWER");
349 ret = gpio_direction_output(GPIO_NR_TREO_BL_POWER, 0);
356 gpio_free(GPIO_NR_TREO_BL_POWER);
361 static int treo_backlight_notify(struct device *dev, int brightness)
363 gpio_set_value(GPIO_NR_TREO_BL_POWER, brightness);
364 return TREO_MAX_INTENSITY - brightness;
367 static void treo_backlight_exit(struct device *dev)
369 gpio_free(GPIO_NR_TREO_BL_POWER);
372 static struct platform_pwm_backlight_data treo_backlight_data = {
374 .max_brightness = TREO_MAX_INTENSITY,
375 .dft_brightness = TREO_DEFAULT_INTENSITY,
376 .pwm_period_ns = TREO_PERIOD_NS,
377 .init = treo_backlight_init,
378 .notify = treo_backlight_notify,
379 .exit = treo_backlight_exit,
382 static struct platform_device treo_backlight = {
383 .name = "pwm-backlight",
385 .parent = &pxa27x_device_pwm0.dev,
386 .platform_data = &treo_backlight_data,
390 /******************************************************************************
392 ******************************************************************************/
393 static struct pxaficp_platform_data treo_ficp_info = {
394 .gpio_pwdown = GPIO_NR_TREO_IR_EN,
395 .transceiver_cap = IR_SIRMODE | IR_OFF,
398 /******************************************************************************
400 ******************************************************************************/
401 static struct pxa2xx_udc_mach_info treo_udc_info __initdata = {
402 .gpio_vbus = GPIO_NR_TREO_USB_DETECT,
403 .gpio_vbus_inverted = 1,
404 .gpio_pullup = GPIO_NR_TREO_USB_PULLUP,
408 /******************************************************************************
410 ******************************************************************************/
411 #ifdef CONFIG_MACH_TREO680
412 static struct pxaohci_platform_data treo680_ohci_info = {
413 .port_mode = PMM_PERPORT_MODE,
414 .flags = ENABLE_PORT1 | ENABLE_PORT3,
417 #endif /* CONFIG_MACH_TREO680 */
419 /******************************************************************************
421 ******************************************************************************/
422 static int power_supply_init(struct device *dev)
426 ret = gpio_request(GPIO_NR_TREO_POWER_DETECT, "CABLE_STATE_AC");
429 ret = gpio_direction_input(GPIO_NR_TREO_POWER_DETECT);
436 gpio_free(GPIO_NR_TREO_POWER_DETECT);
441 static int treo_is_ac_online(void)
443 return gpio_get_value(GPIO_NR_TREO_POWER_DETECT);
446 static void power_supply_exit(struct device *dev)
448 gpio_free(GPIO_NR_TREO_POWER_DETECT);
451 static char *treo_supplicants[] = {
455 static struct pda_power_pdata power_supply_info = {
456 .init = power_supply_init,
457 .is_ac_online = treo_is_ac_online,
458 .exit = power_supply_exit,
459 .supplied_to = treo_supplicants,
460 .num_supplicants = ARRAY_SIZE(treo_supplicants),
463 static struct platform_device power_supply = {
467 .platform_data = &power_supply_info,
471 /******************************************************************************
473 ******************************************************************************/
474 #ifdef CONFIG_MACH_TREO680
475 static struct gpio_led treo680_gpio_leds[] = {
477 .name = "treo680:vibra:vibra",
478 .default_trigger = "none",
479 .gpio = GPIO_NR_TREO680_VIBRATE_EN,
482 .name = "treo680:green:led",
483 .default_trigger = "mmc0",
484 .gpio = GPIO_NR_TREO_GREEN_LED,
487 .name = "treo680:white:keybbl",
488 .default_trigger = "none",
489 .gpio = GPIO_NR_TREO680_KEYB_BL,
493 static struct gpio_led_platform_data treo680_gpio_led_info = {
494 .leds = treo680_gpio_leds,
495 .num_leds = ARRAY_SIZE(treo680_gpio_leds),
498 static struct platform_device treo680_leds = {
502 .platform_data = &treo680_gpio_led_info,
505 #endif /* CONFIG_MACH_TREO680 */
507 #ifdef CONFIG_MACH_CENTRO
508 static struct gpio_led centro_gpio_leds[] = {
510 .name = "centro:vibra:vibra",
511 .default_trigger = "none",
512 .gpio = GPIO_NR_CENTRO_VIBRATE_EN,
515 .name = "centro:green:led",
516 .default_trigger = "mmc0",
517 .gpio = GPIO_NR_TREO_GREEN_LED,
520 .name = "centro:white:keybbl",
521 .default_trigger = "none",
523 .gpio = GPIO_NR_CENTRO_KEYB_BL,
527 static struct gpio_led_platform_data centro_gpio_led_info = {
528 .leds = centro_gpio_leds,
529 .num_leds = ARRAY_SIZE(centro_gpio_leds),
532 static struct platform_device centro_leds = {
536 .platform_data = ¢ro_gpio_led_info,
539 #endif /* CONFIG_MACH_CENTRO */
541 /******************************************************************************
543 ******************************************************************************/
544 /* TODO: add support for 324x324 */
545 static struct pxafb_mode_info treo_lcd_modes[] = {
562 static void treo_lcd_power(int on, struct fb_var_screeninfo *info)
564 gpio_set_value(GPIO_NR_TREO_BL_POWER, on);
567 static struct pxafb_mach_info treo_lcd_screen = {
568 .modes = treo_lcd_modes,
569 .num_modes = ARRAY_SIZE(treo_lcd_modes),
570 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
573 /******************************************************************************
574 * Power management - standby
575 ******************************************************************************/
576 static void __init treo_pm_init(void)
578 static u32 resume[] = {
579 0xe3a00101, /* mov r0, #0x40000000 */
580 0xe380060f, /* orr r0, r0, #0x00f00000 */
581 0xe590f008, /* ldr pc, [r0, #0x08] */
584 /* this is where the bootloader jumps */
585 memcpy(phys_to_virt(TREO_STR_BASE), resume, sizeof(resume));
588 /******************************************************************************
590 ******************************************************************************/
591 static struct platform_device *treo_devices[] __initdata = {
596 #ifdef CONFIG_MACH_TREO680
597 static struct platform_device *treo680_devices[] __initdata = {
600 #endif /* CONFIG_MACH_TREO680 */
602 #ifdef CONFIG_MACH_CENTRO
603 static struct platform_device *centro_devices[] __initdata = {
606 #endif /* CONFIG_MACH_CENTRO */
608 /* setup udc GPIOs initial state */
609 static void __init treo_udc_init(void)
611 if (!gpio_request(GPIO_NR_TREO_USB_PULLUP, "UDC Vbus")) {
612 gpio_direction_output(GPIO_NR_TREO_USB_PULLUP, 1);
613 gpio_free(GPIO_NR_TREO_USB_PULLUP);
617 static void __init treo_lcd_power_init(void)
621 ret = gpio_request(GPIO_NR_TREO_LCD_POWER, "LCD POWER");
623 pr_err("Treo680: LCD power GPIO request failed!\n");
627 ret = gpio_direction_output(GPIO_NR_TREO_LCD_POWER, 0);
629 pr_err("Treo680: setting LCD power GPIO direction failed!\n");
630 gpio_free(GPIO_NR_TREO_LCD_POWER);
634 treo_lcd_screen.pxafb_lcd_power = treo_lcd_power;
637 static void __init treo_reserve(void)
639 memblock_reserve(0xa0000000, 0x1000);
640 memblock_reserve(0xa2000000, 0x1000);
643 static void __init treo_init(void)
645 pxa_set_ffuart_info(NULL);
646 pxa_set_btuart_info(NULL);
647 pxa_set_stuart_info(NULL);
650 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config));
651 treo_lcd_power_init();
652 set_pxa_fb_info(&treo_lcd_screen);
654 pxa_set_udc_info(&treo_udc_info);
655 pxa_set_ac97_info(&treo_ac97_pdata);
656 pxa_set_ficp_info(&treo_ficp_info);
658 platform_add_devices(ARRAY_AND_SIZE(treo_devices));
661 #ifdef CONFIG_MACH_TREO680
662 static void __init treo680_init(void)
665 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
666 pxa_set_mci_info(&treo680_mci_platform_data);
667 pxa_set_keypad_info(&treo680_keypad_platform_data);
668 pxa_set_ohci_info(&treo680_ohci_info);
670 platform_add_devices(ARRAY_AND_SIZE(treo680_devices));
673 MACHINE_START(TREO680, "Palm Treo 680")
674 .phys_io = TREO_PHYS_IO_START,
675 .io_pg_offst = io_p2v(0x40000000),
676 .boot_params = 0xa0000100,
677 .map_io = pxa_map_io,
678 .reserve = treo_reserve,
679 .init_irq = pxa27x_init_irq,
681 .init_machine = treo680_init,
683 #endif /* CONFIG_MACH_TREO680 */
685 #ifdef CONFIG_MACH_CENTRO
686 static void __init centro_init(void)
689 pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config));
690 pxa_set_mci_info(¢ro_mci_platform_data);
692 pxa_set_keypad_info(¢ro_keypad_platform_data);
694 platform_add_devices(ARRAY_AND_SIZE(centro_devices));
697 MACHINE_START(CENTRO, "Palm Centro 685")
698 .phys_io = TREO_PHYS_IO_START,
699 .io_pg_offst = io_p2v(0x40000000),
700 .boot_params = 0xa0000100,
701 .map_io = pxa_map_io,
702 .reserve = treo_reserve,
703 .init_irq = pxa27x_init_irq,
705 .init_machine = centro_init,
707 #endif /* CONFIG_MACH_CENTRO */