2 * Hardware definitions for Palm Tungsten|E2
5 * Carlos Eduardo Medaglia Dyonisio <cadu@nerdfeliz.com>
7 * Rewrite for mainline:
8 * Marek Vasut <marek.vasut@gmail.com>
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/usb/gpio_vbus.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
34 #include <mach/audio.h>
35 #include <mach/palmte2.h>
37 #include <mach/pxafb.h>
38 #include <mach/mfp-pxa25x.h>
39 #include <mach/irda.h>
41 #include <mach/palmasoc.h>
46 /******************************************************************************
48 ******************************************************************************/
49 static unsigned long palmte2_pin_config
[] __initdata
= {
53 GPIO10_GPIO
, /* SD detect */
54 GPIO55_GPIO
, /* SD power */
55 GPIO51_GPIO
, /* SD r/o switch */
59 GPIO29_AC97_SDATA_IN_0
,
60 GPIO30_AC97_SDATA_OUT
,
67 GPIO15_GPIO
, /* usb detect */
68 GPIO53_GPIO
, /* usb power */
71 GPIO48_GPIO
, /* ir disable */
98 GPIO5_GPIO
, /* notes */
99 GPIO7_GPIO
, /* tasks */
100 GPIO11_GPIO
, /* calendar */
101 GPIO13_GPIO
, /* contacts */
102 GPIO14_GPIO
, /* center */
103 GPIO19_GPIO
, /* left */
104 GPIO20_GPIO
, /* right */
105 GPIO21_GPIO
, /* down */
106 GPIO22_GPIO
, /* up */
109 GPIO1_RST
, /* reset */
110 GPIO4_GPIO
, /* Hotsync button */
111 GPIO9_GPIO
, /* power detect */
112 GPIO15_GPIO
, /* earphone detect */
113 GPIO37_GPIO
, /* LCD power */
114 GPIO56_GPIO
, /* Backlight power */
117 /******************************************************************************
118 * SD/MMC card controller
119 ******************************************************************************/
120 static struct pxamci_platform_data palmte2_mci_platform_data
= {
121 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
122 .gpio_card_detect
= GPIO_NR_PALMTE2_SD_DETECT_N
,
123 .gpio_card_ro
= GPIO_NR_PALMTE2_SD_READONLY
,
124 .gpio_power
= GPIO_NR_PALMTE2_SD_POWER
,
127 /******************************************************************************
129 ******************************************************************************/
130 static struct gpio_keys_button palmte2_pxa_buttons
[] = {
131 {KEY_F1
, GPIO_NR_PALMTE2_KEY_CONTACTS
, 1, "Contacts" },
132 {KEY_F2
, GPIO_NR_PALMTE2_KEY_CALENDAR
, 1, "Calendar" },
133 {KEY_F3
, GPIO_NR_PALMTE2_KEY_TASKS
, 1, "Tasks" },
134 {KEY_F4
, GPIO_NR_PALMTE2_KEY_NOTES
, 1, "Notes" },
135 {KEY_ENTER
, GPIO_NR_PALMTE2_KEY_CENTER
, 1, "Center" },
136 {KEY_LEFT
, GPIO_NR_PALMTE2_KEY_LEFT
, 1, "Left" },
137 {KEY_RIGHT
, GPIO_NR_PALMTE2_KEY_RIGHT
, 1, "Right" },
138 {KEY_DOWN
, GPIO_NR_PALMTE2_KEY_DOWN
, 1, "Down" },
139 {KEY_UP
, GPIO_NR_PALMTE2_KEY_UP
, 1, "Up" },
142 static struct gpio_keys_platform_data palmte2_pxa_keys_data
= {
143 .buttons
= palmte2_pxa_buttons
,
144 .nbuttons
= ARRAY_SIZE(palmte2_pxa_buttons
),
147 static struct platform_device palmte2_pxa_keys
= {
151 .platform_data
= &palmte2_pxa_keys_data
,
155 /******************************************************************************
157 ******************************************************************************/
158 static int palmte2_backlight_init(struct device
*dev
)
162 ret
= gpio_request(GPIO_NR_PALMTE2_BL_POWER
, "BL POWER");
165 ret
= gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER
, 0);
168 ret
= gpio_request(GPIO_NR_PALMTE2_LCD_POWER
, "LCD POWER");
171 ret
= gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER
, 0);
177 gpio_free(GPIO_NR_PALMTE2_LCD_POWER
);
179 gpio_free(GPIO_NR_PALMTE2_BL_POWER
);
184 static int palmte2_backlight_notify(int brightness
)
186 gpio_set_value(GPIO_NR_PALMTE2_BL_POWER
, brightness
);
187 gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER
, brightness
);
191 static void palmte2_backlight_exit(struct device
*dev
)
193 gpio_free(GPIO_NR_PALMTE2_BL_POWER
);
194 gpio_free(GPIO_NR_PALMTE2_LCD_POWER
);
197 static struct platform_pwm_backlight_data palmte2_backlight_data
= {
199 .max_brightness
= PALMTE2_MAX_INTENSITY
,
200 .dft_brightness
= PALMTE2_MAX_INTENSITY
,
201 .pwm_period_ns
= PALMTE2_PERIOD_NS
,
202 .init
= palmte2_backlight_init
,
203 .notify
= palmte2_backlight_notify
,
204 .exit
= palmte2_backlight_exit
,
207 static struct platform_device palmte2_backlight
= {
208 .name
= "pwm-backlight",
210 .parent
= &pxa25x_device_pwm0
.dev
,
211 .platform_data
= &palmte2_backlight_data
,
215 /******************************************************************************
217 ******************************************************************************/
218 static struct pxaficp_platform_data palmte2_ficp_platform_data
= {
219 .gpio_pwdown
= GPIO_NR_PALMTE2_IR_DISABLE
,
220 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
223 /******************************************************************************
225 ******************************************************************************/
226 static struct gpio_vbus_mach_info palmte2_udc_info
= {
227 .gpio_vbus
= GPIO_NR_PALMTE2_USB_DETECT_N
,
228 .gpio_vbus_inverted
= 1,
229 .gpio_pullup
= GPIO_NR_PALMTE2_USB_PULLUP
,
232 static struct platform_device palmte2_gpio_vbus
= {
236 .platform_data
= &palmte2_udc_info
,
240 /******************************************************************************
242 ******************************************************************************/
243 static int power_supply_init(struct device
*dev
)
247 ret
= gpio_request(GPIO_NR_PALMTE2_POWER_DETECT
, "CABLE_STATE_AC");
250 ret
= gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT
);
257 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT
);
262 static int palmte2_is_ac_online(void)
264 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT
);
267 static void power_supply_exit(struct device
*dev
)
269 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT
);
272 static char *palmte2_supplicants
[] = {
276 static struct pda_power_pdata power_supply_info
= {
277 .init
= power_supply_init
,
278 .is_ac_online
= palmte2_is_ac_online
,
279 .exit
= power_supply_exit
,
280 .supplied_to
= palmte2_supplicants
,
281 .num_supplicants
= ARRAY_SIZE(palmte2_supplicants
),
284 static struct platform_device power_supply
= {
288 .platform_data
= &power_supply_info
,
292 /******************************************************************************
294 ******************************************************************************/
295 static struct wm97xx_batt_info wm97xx_batt_pdata
= {
296 .batt_aux
= WM97XX_AUX_ID3
,
297 .temp_aux
= WM97XX_AUX_ID2
,
299 .max_voltage
= PALMTE2_BAT_MAX_VOLTAGE
,
300 .min_voltage
= PALMTE2_BAT_MIN_VOLTAGE
,
305 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LIPO
,
306 .batt_name
= "main-batt",
309 /******************************************************************************
311 ******************************************************************************/
312 static struct palm27x_asoc_info palmte2_asoc_pdata
= {
313 .jack_gpio
= GPIO_NR_PALMTE2_EARPHONE_DETECT
,
316 static struct platform_device palmte2_asoc
= {
317 .name
= "palm27x-asoc",
320 .platform_data
= &palmte2_asoc_pdata
,
324 /******************************************************************************
326 ******************************************************************************/
327 static struct pxafb_mode_info palmte2_lcd_modes
[] = {
344 static struct pxafb_mach_info palmte2_lcd_screen
= {
345 .modes
= palmte2_lcd_modes
,
346 .num_modes
= ARRAY_SIZE(palmte2_lcd_modes
),
347 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
350 /******************************************************************************
352 ******************************************************************************/
353 static struct platform_device
*devices
[] __initdata
= {
354 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
363 /* setup udc GPIOs initial state */
364 static void __init
palmte2_udc_init(void)
366 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP
, "UDC Vbus")) {
367 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP
, 1);
368 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP
);
372 static void __init
palmte2_init(void)
374 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config
));
376 set_pxa_fb_info(&palmte2_lcd_screen
);
377 pxa_set_mci_info(&palmte2_mci_platform_data
);
379 pxa_set_ac97_info(NULL
);
380 pxa_set_ficp_info(&palmte2_ficp_platform_data
);
381 wm97xx_bat_set_pdata(&wm97xx_batt_pdata
);
383 platform_add_devices(devices
, ARRAY_SIZE(devices
));
386 MACHINE_START(PALMTE2
, "Palm Tungsten|E2")
387 .phys_io
= 0x40000000,
388 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
389 .boot_params
= 0xa0000100,
390 .map_io
= pxa_map_io
,
391 .init_irq
= pxa25x_init_irq
,
393 .init_machine
= palmte2_init