2 * Hardware definitions for Palm Treo 680
4 * Author: Tomas Cech <sleep_walker@suse.cz>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * (find more info at www.hackndev.com)
14 #include <linux/platform_device.h>
15 #include <linux/delay.h>
16 #include <linux/irq.h>
17 #include <linux/gpio_keys.h>
18 #include <linux/input.h>
19 #include <linux/pda_power.h>
20 #include <linux/pwm_backlight.h>
21 #include <linux/gpio.h>
22 #include <linux/wm97xx_batt.h>
23 #include <linux/power_supply.h>
24 #include <linux/sysdev.h>
25 #include <linux/w1-gpio.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
31 #include <mach/pxa27x.h>
32 #include <mach/pxa27x-udc.h>
33 #include <mach/audio.h>
34 #include <mach/treo680.h>
36 #include <mach/pxafb.h>
37 #include <mach/irda.h>
38 #include <mach/pxa27x_keypad.h>
40 #include <mach/ohci.h>
41 #include <mach/pxa2xx-regs.h>
42 #include <mach/palmasoc.h>
43 #include <mach/camera.h>
45 #include <sound/pxa2xx-lib.h>
50 /******************************************************************************
52 ******************************************************************************/
53 static unsigned long treo680_pin_config
[] __initdata
= {
61 GPIO33_GPIO
, /* SD read only */
62 GPIO113_GPIO
, /* SD detect */
66 GPIO29_AC97_SDATA_IN_0
,
67 GPIO30_AC97_SDATA_OUT
,
80 GPIO1_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* usb detect */
83 GPIO100_KP_MKIN_0
| WAKEUP_ON_LEVEL_HIGH
,
91 GPIO103_KP_MKOUT_0
| MFP_LPM_DRIVE_HIGH
,
98 GPIO93_KP_DKIN_0
| WAKEUP_ON_LEVEL_HIGH
, /* Hotsync button */
121 /* Quick Capture Interface */
140 GPIO14_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* GSM host wake up */
147 GPIO0_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* external power detect */
148 GPIO15_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* silent switch */
149 GPIO116_GPIO
, /* headphone detect */
150 GPIO11_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* bluetooth host wake up */
153 /******************************************************************************
154 * SD/MMC card controller
155 ******************************************************************************/
156 static int treo680_mci_init(struct device
*dev
,
157 irq_handler_t treo680_detect_int
, void *data
)
161 /* Setup an interrupt for detecting card insert/remove events */
162 err
= gpio_request(GPIO_NR_TREO680_SD_DETECT_N
, "SD IRQ");
167 err
= gpio_direction_input(GPIO_NR_TREO680_SD_DETECT_N
);
171 err
= request_irq(gpio_to_irq(GPIO_NR_TREO680_SD_DETECT_N
),
172 treo680_detect_int
, IRQF_DISABLED
| IRQF_SAMPLE_RANDOM
|
173 IRQF_TRIGGER_FALLING
| IRQF_TRIGGER_RISING
,
174 "SD/MMC card detect", data
);
177 dev_err(dev
, "%s: cannot request SD/MMC card detect IRQ\n",
182 err
= gpio_request(GPIO_NR_TREO680_SD_POWER
, "SD_POWER");
186 err
= gpio_direction_output(GPIO_NR_TREO680_SD_POWER
, 1);
190 err
= gpio_request(GPIO_NR_TREO680_SD_READONLY
, "SD_READONLY");
194 err
= gpio_direction_input(GPIO_NR_TREO680_SD_READONLY
);
201 gpio_free(GPIO_NR_TREO680_SD_READONLY
);
203 gpio_free(GPIO_NR_TREO680_SD_POWER
);
205 free_irq(gpio_to_irq(GPIO_NR_TREO680_SD_DETECT_N
), data
);
207 gpio_free(GPIO_NR_TREO680_SD_DETECT_N
);
212 static void treo680_mci_exit(struct device
*dev
, void *data
)
214 gpio_free(GPIO_NR_TREO680_SD_READONLY
);
215 gpio_free(GPIO_NR_TREO680_SD_POWER
);
216 free_irq(gpio_to_irq(GPIO_NR_TREO680_SD_DETECT_N
), data
);
217 gpio_free(GPIO_NR_TREO680_SD_DETECT_N
);
220 static void treo680_mci_power(struct device
*dev
, unsigned int vdd
)
222 struct pxamci_platform_data
*p_d
= dev
->platform_data
;
223 gpio_set_value(GPIO_NR_TREO680_SD_POWER
, p_d
->ocr_mask
& (1 << vdd
));
226 static int treo680_mci_get_ro(struct device
*dev
)
228 return gpio_get_value(GPIO_NR_TREO680_SD_READONLY
);
231 static struct pxamci_platform_data treo680_mci_platform_data
= {
232 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
233 .setpower
= treo680_mci_power
,
234 .get_ro
= treo680_mci_get_ro
,
235 .init
= treo680_mci_init
,
236 .exit
= treo680_mci_exit
,
239 /******************************************************************************
241 ******************************************************************************/
242 static unsigned int treo680_matrix_keys
[] = {
243 KEY(0, 0, KEY_F8
), /* Red/Off/Power */
245 KEY(0, 2, KEY_LEFTCTRL
), /* Alternate */
251 KEY(1, 0, KEY_RIGHTCTRL
), /* Menu */
252 KEY(1, 1, KEY_RIGHT
),
253 KEY(1, 2, KEY_LEFTSHIFT
), /* Left shift */
258 KEY(2, 0, KEY_F1
), /* Phone */
265 KEY(3, 0, KEY_F10
), /* Calendar */
267 KEY(3, 2, KEY_SPACE
),
272 KEY(4, 0, KEY_F12
), /* Mail */
273 KEY(4, 1, KEY_KPENTER
),
274 KEY(4, 2, KEY_RIGHTALT
), /* Alt */
279 KEY(5, 0, KEY_F9
), /* Home */
280 KEY(5, 1, KEY_PAGEUP
), /* Side up */
286 KEY(6, 0, KEY_TAB
), /* Side Activate */
287 KEY(6, 1, KEY_PAGEDOWN
), /* Side down */
288 KEY(6, 2, KEY_ENTER
),
293 KEY(7, 0, KEY_F6
), /* Green/Call */
295 KEY(7, 2, KEY_BACKSPACE
),
301 static struct pxa27x_keypad_platform_data treo680_keypad_platform_data
= {
302 .matrix_key_rows
= 8,
303 .matrix_key_cols
= 7,
304 .matrix_key_map
= treo680_matrix_keys
,
305 .matrix_key_map_size
= ARRAY_SIZE(treo680_matrix_keys
),
306 .direct_key_map
= { KEY_CONNECT
},
309 .debounce_interval
= 30,
312 /******************************************************************************
314 ******************************************************************************/
316 static pxa2xx_audio_ops_t treo680_ac97_pdata
= {
320 /******************************************************************************
322 ******************************************************************************/
323 static int treo680_backlight_init(struct device
*dev
)
327 ret
= gpio_request(GPIO_NR_TREO680_BL_POWER
, "BL POWER");
330 ret
= gpio_direction_output(GPIO_NR_TREO680_BL_POWER
, 0);
333 ret
= gpio_request(GPIO_NR_TREO680_LCD_POWER
, "LCD POWER");
336 ret
= gpio_direction_output(GPIO_NR_TREO680_LCD_POWER
, 0);
342 gpio_free(GPIO_NR_TREO680_LCD_POWER
);
344 gpio_free(GPIO_NR_TREO680_BL_POWER
);
349 static int treo680_backlight_notify(int brightness
)
351 gpio_set_value(GPIO_NR_TREO680_BL_POWER
, brightness
);
352 return TREO680_MAX_INTENSITY
- brightness
;
355 static void treo680_backlight_exit(struct device
*dev
)
357 gpio_free(GPIO_NR_TREO680_BL_POWER
);
358 gpio_free(GPIO_NR_TREO680_LCD_POWER
);
361 static struct platform_pwm_backlight_data treo680_backlight_data
= {
363 .max_brightness
= TREO680_MAX_INTENSITY
,
364 .dft_brightness
= TREO680_DEFAULT_INTENSITY
,
365 .pwm_period_ns
= TREO680_PERIOD_NS
,
366 .init
= treo680_backlight_init
,
367 .notify
= treo680_backlight_notify
,
368 .exit
= treo680_backlight_exit
,
371 static struct platform_device treo680_backlight
= {
372 .name
= "pwm-backlight",
374 .parent
= &pxa27x_device_pwm0
.dev
,
375 .platform_data
= &treo680_backlight_data
,
379 /******************************************************************************
381 ******************************************************************************/
382 static void treo680_transceiver_mode(struct device
*dev
, int mode
)
384 gpio_set_value(GPIO_NR_TREO680_IR_EN
, mode
& IR_OFF
);
385 pxa2xx_transceiver_mode(dev
, mode
);
388 static int treo680_irda_startup(struct device
*dev
)
392 err
= gpio_request(GPIO_NR_TREO680_IR_EN
, "Ir port disable");
396 err
= gpio_direction_output(GPIO_NR_TREO680_IR_EN
, 1);
403 dev_err(dev
, "treo680_irda: cannot change IR gpio direction\n");
404 gpio_free(GPIO_NR_TREO680_IR_EN
);
406 dev_err(dev
, "treo680_irda: cannot allocate IR gpio\n");
410 static void treo680_irda_shutdown(struct device
*dev
)
412 gpio_free(GPIO_NR_TREO680_IR_EN
);
415 static struct pxaficp_platform_data treo680_ficp_info
= {
416 .transceiver_cap
= IR_FIRMODE
| IR_SIRMODE
| IR_OFF
,
417 .startup
= treo680_irda_startup
,
418 .shutdown
= treo680_irda_shutdown
,
419 .transceiver_mode
= treo680_transceiver_mode
,
422 /******************************************************************************
424 ******************************************************************************/
425 static struct pxa2xx_udc_mach_info treo680_udc_info __initdata
= {
426 .gpio_vbus
= GPIO_NR_TREO680_USB_DETECT
,
427 .gpio_vbus_inverted
= 1,
428 .gpio_pullup
= GPIO_NR_TREO680_USB_PULLUP
,
432 /******************************************************************************
434 ******************************************************************************/
435 static struct pxaohci_platform_data treo680_ohci_info
= {
436 .port_mode
= PMM_PERPORT_MODE
,
437 .flags
= ENABLE_PORT1
| ENABLE_PORT3
,
441 /******************************************************************************
443 ******************************************************************************/
444 static int power_supply_init(struct device
*dev
)
448 ret
= gpio_request(GPIO_NR_TREO680_POWER_DETECT
, "CABLE_STATE_AC");
451 ret
= gpio_direction_input(GPIO_NR_TREO680_POWER_DETECT
);
458 gpio_free(GPIO_NR_TREO680_POWER_DETECT
);
463 static int treo680_is_ac_online(void)
465 return gpio_get_value(GPIO_NR_TREO680_POWER_DETECT
);
468 static void power_supply_exit(struct device
*dev
)
470 gpio_free(GPIO_NR_TREO680_POWER_DETECT
);
473 static char *treo680_supplicants
[] = {
477 static struct pda_power_pdata power_supply_info
= {
478 .init
= power_supply_init
,
479 .is_ac_online
= treo680_is_ac_online
,
480 .exit
= power_supply_exit
,
481 .supplied_to
= treo680_supplicants
,
482 .num_supplicants
= ARRAY_SIZE(treo680_supplicants
),
485 static struct platform_device power_supply
= {
489 .platform_data
= &power_supply_info
,
493 /******************************************************************************
495 ******************************************************************************/
496 static struct gpio_led gpio_leds
[] = {
498 .name
= "treo680:vibra:vibra",
499 .default_trigger
= "none",
500 .gpio
= GPIO_NR_TREO680_VIBRATE_EN
,
503 .name
= "treo680:green:led",
504 .default_trigger
= "mmc0",
505 .gpio
= GPIO_NR_TREO680_GREEN_LED
,
508 .name
= "treo680:keybbl:keybbl",
509 .default_trigger
= "none",
510 .gpio
= GPIO_NR_TREO680_KEYB_BL
,
514 static struct gpio_led_platform_data gpio_led_info
= {
516 .num_leds
= ARRAY_SIZE(gpio_leds
),
519 static struct platform_device treo680_leds
= {
523 .platform_data
= &gpio_led_info
,
528 /******************************************************************************
530 ******************************************************************************/
531 /* TODO: add support for 324x324 */
532 static struct pxafb_mode_info treo680_lcd_modes
[] = {
549 static struct pxafb_mach_info treo680_lcd_screen
= {
550 .modes
= treo680_lcd_modes
,
551 .num_modes
= ARRAY_SIZE(treo680_lcd_modes
),
552 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
555 /******************************************************************************
556 * Power management - standby
557 ******************************************************************************/
558 static void __init
treo680_pm_init(void)
560 static u32 resume
[] = {
561 0xe3a00101, /* mov r0, #0x40000000 */
562 0xe380060f, /* orr r0, r0, #0x00f00000 */
563 0xe590f008, /* ldr pc, [r0, #0x08] */
566 /* this is where the bootloader jumps */
567 memcpy(phys_to_virt(TREO680_STR_BASE
), resume
, sizeof(resume
));
570 /******************************************************************************
572 ******************************************************************************/
573 static struct platform_device
*devices
[] __initdata
= {
579 /* setup udc GPIOs initial state */
580 static void __init
treo680_udc_init(void)
582 if (!gpio_request(GPIO_NR_TREO680_USB_PULLUP
, "UDC Vbus")) {
583 gpio_direction_output(GPIO_NR_TREO680_USB_PULLUP
, 1);
584 gpio_free(GPIO_NR_TREO680_USB_PULLUP
);
588 static void __init
treo680_init(void)
591 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config
));
592 pxa_set_keypad_info(&treo680_keypad_platform_data
);
593 set_pxa_fb_info(&treo680_lcd_screen
);
594 pxa_set_mci_info(&treo680_mci_platform_data
);
596 pxa_set_udc_info(&treo680_udc_info
);
597 pxa_set_ac97_info(&treo680_ac97_pdata
);
598 pxa_set_ficp_info(&treo680_ficp_info
);
599 pxa_set_ohci_info(&treo680_ohci_info
);
601 platform_add_devices(devices
, ARRAY_SIZE(devices
));
604 MACHINE_START(TREO680
, "Palm Treo 680")
605 .phys_io
= TREO680_PHYS_IO_START
,
606 .io_pg_offst
= io_p2v(0x40000000),
607 .boot_params
= 0xa0000100,
608 .map_io
= pxa_map_io
,
609 .init_irq
= pxa27x_init_irq
,
611 .init_machine
= treo680_init
,