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 struct pxamci_platform_data treo680_mci_platform_data = {
157 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
158 .gpio_card_detect = GPIO_NR_TREO680_SD_DETECT_N,
159 .gpio_card_ro = GPIO_NR_TREO680_SD_READONLY,
160 .gpio_power = GPIO_NR_TREO680_SD_POWER,
163 /******************************************************************************
165 ******************************************************************************/
166 static unsigned int treo680_matrix_keys[] = {
167 KEY(0, 0, KEY_F8), /* Red/Off/Power */
169 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
175 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
176 KEY(1, 1, KEY_RIGHT),
177 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
182 KEY(2, 0, KEY_F1), /* Phone */
189 KEY(3, 0, KEY_F10), /* Calendar */
191 KEY(3, 2, KEY_SPACE),
196 KEY(4, 0, KEY_F12), /* Mail */
197 KEY(4, 1, KEY_KPENTER),
198 KEY(4, 2, KEY_RIGHTALT), /* Alt */
203 KEY(5, 0, KEY_F9), /* Home */
204 KEY(5, 1, KEY_PAGEUP), /* Side up */
210 KEY(6, 0, KEY_TAB), /* Side Activate */
211 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
212 KEY(6, 2, KEY_ENTER),
217 KEY(7, 0, KEY_F6), /* Green/Call */
219 KEY(7, 2, KEY_BACKSPACE),
225 static struct pxa27x_keypad_platform_data treo680_keypad_platform_data = {
226 .matrix_key_rows = 8,
227 .matrix_key_cols = 7,
228 .matrix_key_map = treo680_matrix_keys,
229 .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys),
230 .direct_key_map = { KEY_CONNECT },
233 .debounce_interval = 30,
236 /******************************************************************************
238 ******************************************************************************/
240 static pxa2xx_audio_ops_t treo680_ac97_pdata = {
244 /******************************************************************************
246 ******************************************************************************/
247 static int treo680_backlight_init(struct device *dev)
251 ret = gpio_request(GPIO_NR_TREO680_BL_POWER, "BL POWER");
254 ret = gpio_direction_output(GPIO_NR_TREO680_BL_POWER, 0);
257 ret = gpio_request(GPIO_NR_TREO680_LCD_POWER, "LCD POWER");
260 ret = gpio_direction_output(GPIO_NR_TREO680_LCD_POWER, 0);
266 gpio_free(GPIO_NR_TREO680_LCD_POWER);
268 gpio_free(GPIO_NR_TREO680_BL_POWER);
273 static int treo680_backlight_notify(int brightness)
275 gpio_set_value(GPIO_NR_TREO680_BL_POWER, brightness);
276 return TREO680_MAX_INTENSITY - brightness;
279 static void treo680_backlight_exit(struct device *dev)
281 gpio_free(GPIO_NR_TREO680_BL_POWER);
282 gpio_free(GPIO_NR_TREO680_LCD_POWER);
285 static struct platform_pwm_backlight_data treo680_backlight_data = {
287 .max_brightness = TREO680_MAX_INTENSITY,
288 .dft_brightness = TREO680_DEFAULT_INTENSITY,
289 .pwm_period_ns = TREO680_PERIOD_NS,
290 .init = treo680_backlight_init,
291 .notify = treo680_backlight_notify,
292 .exit = treo680_backlight_exit,
295 static struct platform_device treo680_backlight = {
296 .name = "pwm-backlight",
298 .parent = &pxa27x_device_pwm0.dev,
299 .platform_data = &treo680_backlight_data,
303 /******************************************************************************
305 ******************************************************************************/
306 static void treo680_transceiver_mode(struct device *dev, int mode)
308 gpio_set_value(GPIO_NR_TREO680_IR_EN, mode & IR_OFF);
309 pxa2xx_transceiver_mode(dev, mode);
312 static int treo680_irda_startup(struct device *dev)
316 err = gpio_request(GPIO_NR_TREO680_IR_EN, "Ir port disable");
320 err = gpio_direction_output(GPIO_NR_TREO680_IR_EN, 1);
327 dev_err(dev, "treo680_irda: cannot change IR gpio direction\n");
328 gpio_free(GPIO_NR_TREO680_IR_EN);
330 dev_err(dev, "treo680_irda: cannot allocate IR gpio\n");
334 static void treo680_irda_shutdown(struct device *dev)
336 gpio_free(GPIO_NR_TREO680_IR_EN);
339 static struct pxaficp_platform_data treo680_ficp_info = {
340 .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF,
341 .startup = treo680_irda_startup,
342 .shutdown = treo680_irda_shutdown,
343 .transceiver_mode = treo680_transceiver_mode,
346 /******************************************************************************
348 ******************************************************************************/
349 static struct pxa2xx_udc_mach_info treo680_udc_info __initdata = {
350 .gpio_vbus = GPIO_NR_TREO680_USB_DETECT,
351 .gpio_vbus_inverted = 1,
352 .gpio_pullup = GPIO_NR_TREO680_USB_PULLUP,
356 /******************************************************************************
358 ******************************************************************************/
359 static struct pxaohci_platform_data treo680_ohci_info = {
360 .port_mode = PMM_PERPORT_MODE,
361 .flags = ENABLE_PORT1 | ENABLE_PORT3,
365 /******************************************************************************
367 ******************************************************************************/
368 static int power_supply_init(struct device *dev)
372 ret = gpio_request(GPIO_NR_TREO680_POWER_DETECT, "CABLE_STATE_AC");
375 ret = gpio_direction_input(GPIO_NR_TREO680_POWER_DETECT);
382 gpio_free(GPIO_NR_TREO680_POWER_DETECT);
387 static int treo680_is_ac_online(void)
389 return gpio_get_value(GPIO_NR_TREO680_POWER_DETECT);
392 static void power_supply_exit(struct device *dev)
394 gpio_free(GPIO_NR_TREO680_POWER_DETECT);
397 static char *treo680_supplicants[] = {
401 static struct pda_power_pdata power_supply_info = {
402 .init = power_supply_init,
403 .is_ac_online = treo680_is_ac_online,
404 .exit = power_supply_exit,
405 .supplied_to = treo680_supplicants,
406 .num_supplicants = ARRAY_SIZE(treo680_supplicants),
409 static struct platform_device power_supply = {
413 .platform_data = &power_supply_info,
417 /******************************************************************************
419 ******************************************************************************/
420 static struct gpio_led gpio_leds[] = {
422 .name = "treo680:vibra:vibra",
423 .default_trigger = "none",
424 .gpio = GPIO_NR_TREO680_VIBRATE_EN,
427 .name = "treo680:green:led",
428 .default_trigger = "mmc0",
429 .gpio = GPIO_NR_TREO680_GREEN_LED,
432 .name = "treo680:keybbl:keybbl",
433 .default_trigger = "none",
434 .gpio = GPIO_NR_TREO680_KEYB_BL,
438 static struct gpio_led_platform_data gpio_led_info = {
440 .num_leds = ARRAY_SIZE(gpio_leds),
443 static struct platform_device treo680_leds = {
447 .platform_data = &gpio_led_info,
452 /******************************************************************************
454 ******************************************************************************/
455 /* TODO: add support for 324x324 */
456 static struct pxafb_mode_info treo680_lcd_modes[] = {
473 static struct pxafb_mach_info treo680_lcd_screen = {
474 .modes = treo680_lcd_modes,
475 .num_modes = ARRAY_SIZE(treo680_lcd_modes),
476 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
479 /******************************************************************************
480 * Power management - standby
481 ******************************************************************************/
482 static void __init treo680_pm_init(void)
484 static u32 resume[] = {
485 0xe3a00101, /* mov r0, #0x40000000 */
486 0xe380060f, /* orr r0, r0, #0x00f00000 */
487 0xe590f008, /* ldr pc, [r0, #0x08] */
490 /* this is where the bootloader jumps */
491 memcpy(phys_to_virt(TREO680_STR_BASE), resume, sizeof(resume));
494 /******************************************************************************
496 ******************************************************************************/
497 static struct platform_device *devices[] __initdata = {
503 /* setup udc GPIOs initial state */
504 static void __init treo680_udc_init(void)
506 if (!gpio_request(GPIO_NR_TREO680_USB_PULLUP, "UDC Vbus")) {
507 gpio_direction_output(GPIO_NR_TREO680_USB_PULLUP, 1);
508 gpio_free(GPIO_NR_TREO680_USB_PULLUP);
512 static void __init treo680_init(void)
515 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
516 pxa_set_keypad_info(&treo680_keypad_platform_data);
517 set_pxa_fb_info(&treo680_lcd_screen);
518 pxa_set_mci_info(&treo680_mci_platform_data);
520 pxa_set_udc_info(&treo680_udc_info);
521 pxa_set_ac97_info(&treo680_ac97_pdata);
522 pxa_set_ficp_info(&treo680_ficp_info);
523 pxa_set_ohci_info(&treo680_ohci_info);
525 platform_add_devices(devices, ARRAY_SIZE(devices));
528 MACHINE_START(TREO680, "Palm Treo 680")
529 .phys_io = TREO680_PHYS_IO_START,
530 .io_pg_offst = io_p2v(0x40000000),
531 .boot_params = 0xa0000100,
532 .map_io = pxa_map_io,
533 .init_irq = pxa27x_init_irq,
535 .init_machine = treo680_init,