2 * Hardware definitions for Palm Zire72
5 * Vladimir "Farcaller" Pouzanov <farcaller@gmail.com>
6 * Sergey Lapin <slapin@ossfans.org>
7 * Alex Osborne <bobofdoom@gmail.com>
8 * Jan Herman <2hp@seznam.cz>
10 * Rewrite for mainline:
11 * Marek Vasut <marek.vasut@gmail.com>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
17 * (find more info at www.hackndev.com)
21 #include <linux/platform_device.h>
22 #include <linux/sysdev.h>
23 #include <linux/delay.h>
24 #include <linux/irq.h>
25 #include <linux/gpio_keys.h>
26 #include <linux/input.h>
27 #include <linux/pda_power.h>
28 #include <linux/pwm_backlight.h>
29 #include <linux/gpio.h>
30 #include <linux/wm97xx_batt.h>
31 #include <linux/power_supply.h>
32 #include <linux/usb/gpio_vbus.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
38 #include <mach/pxa27x.h>
39 #include <mach/audio.h>
40 #include <mach/palmz72.h>
42 #include <mach/pxafb.h>
43 #include <mach/irda.h>
44 #include <mach/pxa27x_keypad.h>
46 #include <mach/palmasoc.h>
53 /******************************************************************************
55 ******************************************************************************/
56 static unsigned long palmz72_pin_config
[] __initdata
= {
64 GPIO14_GPIO
, /* SD detect */
65 GPIO115_GPIO
, /* SD RO */
66 GPIO98_GPIO
, /* SD power */
70 GPIO29_AC97_SDATA_IN_0
,
71 GPIO30_AC97_SDATA_OUT
,
77 GPIO49_GPIO
, /* ir disable */
85 GPIO15_GPIO
, /* usb detect */
86 GPIO95_GPIO
, /* usb pullup */
89 GPIO100_KP_MKIN_0
| WAKEUP_ON_LEVEL_HIGH
,
90 GPIO101_KP_MKIN_1
| WAKEUP_ON_LEVEL_HIGH
,
91 GPIO102_KP_MKIN_2
| WAKEUP_ON_LEVEL_HIGH
,
92 GPIO97_KP_MKIN_3
| WAKEUP_ON_LEVEL_HIGH
,
100 GPIO20_GPIO
, /* bl power */
101 GPIO21_GPIO
, /* LCD border switch */
102 GPIO22_GPIO
, /* LCD border color */
103 GPIO96_GPIO
, /* lcd power */
106 GPIO0_GPIO
| WAKEUP_ON_LEVEL_HIGH
, /* power detect */
107 GPIO88_GPIO
, /* green led */
108 GPIO27_GPIO
, /* WM9712 IRQ */
111 /******************************************************************************
112 * SD/MMC card controller
113 ******************************************************************************/
114 /* SD_POWER is not actually power, but it is more like chip
115 * select, i.e. it is inverted */
116 static struct pxamci_platform_data palmz72_mci_platform_data
= {
117 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
118 .gpio_card_detect
= GPIO_NR_PALMZ72_SD_DETECT_N
,
119 .gpio_card_ro
= GPIO_NR_PALMZ72_SD_RO
,
120 .gpio_power
= GPIO_NR_PALMZ72_SD_POWER_N
,
121 .gpio_power_invert
= 1,
124 /******************************************************************************
126 ******************************************************************************/
127 static unsigned int palmz72_matrix_keys
[] = {
128 KEY(0, 0, KEY_POWER
),
130 KEY(0, 2, KEY_ENTER
),
139 KEY(3, 0, KEY_RIGHT
),
143 static struct pxa27x_keypad_platform_data palmz72_keypad_platform_data
= {
144 .matrix_key_rows
= 4,
145 .matrix_key_cols
= 3,
146 .matrix_key_map
= palmz72_matrix_keys
,
147 .matrix_key_map_size
= ARRAY_SIZE(palmz72_matrix_keys
),
149 .debounce_interval
= 30,
152 /******************************************************************************
154 ******************************************************************************/
155 static int palmz72_backlight_init(struct device
*dev
)
159 ret
= gpio_request(GPIO_NR_PALMZ72_BL_POWER
, "BL POWER");
162 ret
= gpio_direction_output(GPIO_NR_PALMZ72_BL_POWER
, 0);
165 ret
= gpio_request(GPIO_NR_PALMZ72_LCD_POWER
, "LCD POWER");
168 ret
= gpio_direction_output(GPIO_NR_PALMZ72_LCD_POWER
, 0);
174 gpio_free(GPIO_NR_PALMZ72_LCD_POWER
);
176 gpio_free(GPIO_NR_PALMZ72_BL_POWER
);
181 static int palmz72_backlight_notify(struct device
*dev
, int brightness
)
183 gpio_set_value(GPIO_NR_PALMZ72_BL_POWER
, brightness
);
184 gpio_set_value(GPIO_NR_PALMZ72_LCD_POWER
, brightness
);
188 static void palmz72_backlight_exit(struct device
*dev
)
190 gpio_free(GPIO_NR_PALMZ72_BL_POWER
);
191 gpio_free(GPIO_NR_PALMZ72_LCD_POWER
);
194 static struct platform_pwm_backlight_data palmz72_backlight_data
= {
196 .max_brightness
= PALMZ72_MAX_INTENSITY
,
197 .dft_brightness
= PALMZ72_MAX_INTENSITY
,
198 .pwm_period_ns
= PALMZ72_PERIOD_NS
,
199 .init
= palmz72_backlight_init
,
200 .notify
= palmz72_backlight_notify
,
201 .exit
= palmz72_backlight_exit
,
204 static struct platform_device palmz72_backlight
= {
205 .name
= "pwm-backlight",
207 .parent
= &pxa27x_device_pwm0
.dev
,
208 .platform_data
= &palmz72_backlight_data
,
212 /******************************************************************************
214 ******************************************************************************/
215 static struct pxaficp_platform_data palmz72_ficp_platform_data
= {
216 .gpio_pwdown
= GPIO_NR_PALMZ72_IR_DISABLE
,
217 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
220 /******************************************************************************
222 ******************************************************************************/
223 static struct gpio_led gpio_leds
[] = {
225 .name
= "palmz72:green:led",
226 .default_trigger
= "none",
227 .gpio
= GPIO_NR_PALMZ72_LED_GREEN
,
231 static struct gpio_led_platform_data gpio_led_info
= {
233 .num_leds
= ARRAY_SIZE(gpio_leds
),
236 static struct platform_device palmz72_leds
= {
240 .platform_data
= &gpio_led_info
,
244 /******************************************************************************
246 ******************************************************************************/
247 static struct gpio_vbus_mach_info palmz72_udc_info
= {
248 .gpio_vbus
= GPIO_NR_PALMZ72_USB_DETECT_N
,
249 .gpio_pullup
= GPIO_NR_PALMZ72_USB_PULLUP
,
252 static struct platform_device palmz72_gpio_vbus
= {
256 .platform_data
= &palmz72_udc_info
,
260 /******************************************************************************
262 ******************************************************************************/
263 static int power_supply_init(struct device
*dev
)
267 ret
= gpio_request(GPIO_NR_PALMZ72_POWER_DETECT
, "CABLE_STATE_AC");
270 ret
= gpio_direction_input(GPIO_NR_PALMZ72_POWER_DETECT
);
274 ret
= gpio_request(GPIO_NR_PALMZ72_USB_DETECT_N
, "CABLE_STATE_USB");
277 ret
= gpio_direction_input(GPIO_NR_PALMZ72_USB_DETECT_N
);
283 gpio_free(GPIO_NR_PALMZ72_USB_DETECT_N
);
285 gpio_free(GPIO_NR_PALMZ72_POWER_DETECT
);
290 static int palmz72_is_ac_online(void)
292 return gpio_get_value(GPIO_NR_PALMZ72_POWER_DETECT
);
295 static int palmz72_is_usb_online(void)
297 return !gpio_get_value(GPIO_NR_PALMZ72_USB_DETECT_N
);
300 static void power_supply_exit(struct device
*dev
)
302 gpio_free(GPIO_NR_PALMZ72_USB_DETECT_N
);
303 gpio_free(GPIO_NR_PALMZ72_POWER_DETECT
);
306 static char *palmz72_supplicants
[] = {
310 static struct pda_power_pdata power_supply_info
= {
311 .init
= power_supply_init
,
312 .is_ac_online
= palmz72_is_ac_online
,
313 .is_usb_online
= palmz72_is_usb_online
,
314 .exit
= power_supply_exit
,
315 .supplied_to
= palmz72_supplicants
,
316 .num_supplicants
= ARRAY_SIZE(palmz72_supplicants
),
319 static struct platform_device power_supply
= {
323 .platform_data
= &power_supply_info
,
327 /******************************************************************************
329 ******************************************************************************/
330 static struct wm97xx_batt_info wm97xx_batt_pdata
= {
331 .batt_aux
= WM97XX_AUX_ID3
,
332 .temp_aux
= WM97XX_AUX_ID2
,
334 .max_voltage
= PALMZ72_BAT_MAX_VOLTAGE
,
335 .min_voltage
= PALMZ72_BAT_MIN_VOLTAGE
,
340 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LIPO
,
341 .batt_name
= "main-batt",
344 /******************************************************************************
346 ******************************************************************************/
347 static struct platform_device palmz72_asoc
= {
348 .name
= "palm27x-asoc",
352 /******************************************************************************
354 ******************************************************************************/
355 static struct pxafb_mode_info palmz72_lcd_modes
[] = {
372 static struct pxafb_mach_info palmz72_lcd_screen
= {
373 .modes
= palmz72_lcd_modes
,
374 .num_modes
= ARRAY_SIZE(palmz72_lcd_modes
),
375 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
380 /* We have some black magic here
381 * PalmOS ROM on recover expects special struct physical address
382 * to be transferred via PSPR. Using this struct PalmOS restores
383 * its state after sleep. As for Linux, we need to setup it the
384 * same way. More than that, PalmOS ROM changes some values in memory.
385 * For now only one location is found, which needs special treatment.
386 * Thanks to Alex Osborne, Andrzej Zaborowski, and lots of other people
387 * for reading backtraces for me :)
390 #define PALMZ72_SAVE_DWORD ((unsigned long *)0xc0000050)
392 static struct palmz72_resume_info palmz72_resume_info
= {
396 /* reset state, MMU off etc */
404 static unsigned long store_ptr
;
406 /* sys_device for Palm Zire 72 PM */
408 static int palmz72_pm_suspend(struct sys_device
*dev
, pm_message_t msg
)
410 /* setup the resume_info struct for the original bootloader */
411 palmz72_resume_info
.resume_addr
= (u32
) pxa_cpu_resume
;
413 /* Storing memory touched by ROM */
414 store_ptr
= *PALMZ72_SAVE_DWORD
;
416 /* Setting PSPR to a proper value */
417 PSPR
= virt_to_phys(&palmz72_resume_info
);
422 static int palmz72_pm_resume(struct sys_device
*dev
)
424 *PALMZ72_SAVE_DWORD
= store_ptr
;
428 static struct sysdev_class palmz72_pm_sysclass
= {
429 .name
= "palmz72_pm",
430 .suspend
= palmz72_pm_suspend
,
431 .resume
= palmz72_pm_resume
,
434 static struct sys_device palmz72_pm_device
= {
435 .cls
= &palmz72_pm_sysclass
,
438 static int __init
palmz72_pm_init(void)
441 if (machine_is_palmz72()) {
442 ret
= sysdev_class_register(&palmz72_pm_sysclass
);
444 ret
= sysdev_register(&palmz72_pm_device
);
449 device_initcall(palmz72_pm_init
);
452 /******************************************************************************
454 ******************************************************************************/
455 static struct platform_device
*devices
[] __initdata
= {
463 /* setup udc GPIOs initial state */
464 static void __init
palmz72_udc_init(void)
466 if (!gpio_request(GPIO_NR_PALMZ72_USB_PULLUP
, "USB Pullup")) {
467 gpio_direction_output(GPIO_NR_PALMZ72_USB_PULLUP
, 0);
468 gpio_free(GPIO_NR_PALMZ72_USB_PULLUP
);
472 static void __init
palmz72_init(void)
474 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmz72_pin_config
));
476 pxa_set_ffuart_info(NULL
);
477 pxa_set_btuart_info(NULL
);
478 pxa_set_stuart_info(NULL
);
480 set_pxa_fb_info(&palmz72_lcd_screen
);
481 pxa_set_mci_info(&palmz72_mci_platform_data
);
483 pxa_set_ac97_info(NULL
);
484 pxa_set_ficp_info(&palmz72_ficp_platform_data
);
485 pxa_set_keypad_info(&palmz72_keypad_platform_data
);
486 wm97xx_bat_set_pdata(&wm97xx_batt_pdata
);
488 platform_add_devices(devices
, ARRAY_SIZE(devices
));
491 MACHINE_START(PALMZ72
, "Palm Zire72")
492 .phys_io
= 0x40000000,
493 .io_pg_offst
= io_p2v(0x40000000),
494 .boot_params
= 0xa0000100,
495 .map_io
= pxa_map_io
,
496 .init_irq
= pxa27x_init_irq
,
498 .init_machine
= palmz72_init