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.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 */
79 GPIO5_GPIO
, /* notes */
80 GPIO7_GPIO
, /* tasks */
81 GPIO11_GPIO
, /* calendar */
82 GPIO13_GPIO
, /* contacts */
83 GPIO14_GPIO
, /* center */
84 GPIO19_GPIO
, /* left */
85 GPIO20_GPIO
, /* right */
86 GPIO21_GPIO
, /* down */
90 GPIO1_RST
, /* reset */
91 GPIO4_GPIO
, /* Hotsync button */
92 GPIO9_GPIO
, /* power detect */
93 GPIO15_GPIO
, /* earphone detect */
94 GPIO37_GPIO
, /* LCD power */
95 GPIO56_GPIO
, /* Backlight power */
98 /******************************************************************************
99 * SD/MMC card controller
100 ******************************************************************************/
101 static struct pxamci_platform_data palmte2_mci_platform_data
= {
102 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
103 .gpio_card_detect
= GPIO_NR_PALMTE2_SD_DETECT_N
,
104 .gpio_card_ro
= GPIO_NR_PALMTE2_SD_READONLY
,
105 .gpio_power
= GPIO_NR_PALMTE2_SD_POWER
,
108 /******************************************************************************
110 ******************************************************************************/
111 static struct gpio_keys_button palmte2_pxa_buttons
[] = {
112 {KEY_F1
, GPIO_NR_PALMTE2_KEY_CONTACTS
, 1, "Contacts" },
113 {KEY_F2
, GPIO_NR_PALMTE2_KEY_CALENDAR
, 1, "Calendar" },
114 {KEY_F3
, GPIO_NR_PALMTE2_KEY_TASKS
, 1, "Tasks" },
115 {KEY_F4
, GPIO_NR_PALMTE2_KEY_NOTES
, 1, "Notes" },
116 {KEY_ENTER
, GPIO_NR_PALMTE2_KEY_CENTER
, 1, "Center" },
117 {KEY_LEFT
, GPIO_NR_PALMTE2_KEY_LEFT
, 1, "Left" },
118 {KEY_RIGHT
, GPIO_NR_PALMTE2_KEY_RIGHT
, 1, "Right" },
119 {KEY_DOWN
, GPIO_NR_PALMTE2_KEY_DOWN
, 1, "Down" },
120 {KEY_UP
, GPIO_NR_PALMTE2_KEY_UP
, 1, "Up" },
123 static struct gpio_keys_platform_data palmte2_pxa_keys_data
= {
124 .buttons
= palmte2_pxa_buttons
,
125 .nbuttons
= ARRAY_SIZE(palmte2_pxa_buttons
),
128 static struct platform_device palmte2_pxa_keys
= {
132 .platform_data
= &palmte2_pxa_keys_data
,
136 /******************************************************************************
138 ******************************************************************************/
139 static int palmte2_backlight_init(struct device
*dev
)
143 ret
= gpio_request(GPIO_NR_PALMTE2_BL_POWER
, "BL POWER");
146 ret
= gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER
, 0);
149 ret
= gpio_request(GPIO_NR_PALMTE2_LCD_POWER
, "LCD POWER");
152 ret
= gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER
, 0);
158 gpio_free(GPIO_NR_PALMTE2_LCD_POWER
);
160 gpio_free(GPIO_NR_PALMTE2_BL_POWER
);
165 static int palmte2_backlight_notify(struct device
*dev
, int brightness
)
167 gpio_set_value(GPIO_NR_PALMTE2_BL_POWER
, brightness
);
168 gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER
, brightness
);
172 static void palmte2_backlight_exit(struct device
*dev
)
174 gpio_free(GPIO_NR_PALMTE2_BL_POWER
);
175 gpio_free(GPIO_NR_PALMTE2_LCD_POWER
);
178 static struct platform_pwm_backlight_data palmte2_backlight_data
= {
180 .max_brightness
= PALMTE2_MAX_INTENSITY
,
181 .dft_brightness
= PALMTE2_MAX_INTENSITY
,
182 .pwm_period_ns
= PALMTE2_PERIOD_NS
,
183 .init
= palmte2_backlight_init
,
184 .notify
= palmte2_backlight_notify
,
185 .exit
= palmte2_backlight_exit
,
188 static struct platform_device palmte2_backlight
= {
189 .name
= "pwm-backlight",
191 .parent
= &pxa25x_device_pwm0
.dev
,
192 .platform_data
= &palmte2_backlight_data
,
196 /******************************************************************************
198 ******************************************************************************/
199 static struct pxaficp_platform_data palmte2_ficp_platform_data
= {
200 .gpio_pwdown
= GPIO_NR_PALMTE2_IR_DISABLE
,
201 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
204 /******************************************************************************
206 ******************************************************************************/
207 static struct gpio_vbus_mach_info palmte2_udc_info
= {
208 .gpio_vbus
= GPIO_NR_PALMTE2_USB_DETECT_N
,
209 .gpio_vbus_inverted
= 1,
210 .gpio_pullup
= GPIO_NR_PALMTE2_USB_PULLUP
,
213 static struct platform_device palmte2_gpio_vbus
= {
217 .platform_data
= &palmte2_udc_info
,
221 /******************************************************************************
223 ******************************************************************************/
224 static int power_supply_init(struct device
*dev
)
228 ret
= gpio_request(GPIO_NR_PALMTE2_POWER_DETECT
, "CABLE_STATE_AC");
231 ret
= gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT
);
238 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT
);
243 static int palmte2_is_ac_online(void)
245 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT
);
248 static void power_supply_exit(struct device
*dev
)
250 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT
);
253 static char *palmte2_supplicants
[] = {
257 static struct pda_power_pdata power_supply_info
= {
258 .init
= power_supply_init
,
259 .is_ac_online
= palmte2_is_ac_online
,
260 .exit
= power_supply_exit
,
261 .supplied_to
= palmte2_supplicants
,
262 .num_supplicants
= ARRAY_SIZE(palmte2_supplicants
),
265 static struct platform_device power_supply
= {
269 .platform_data
= &power_supply_info
,
273 /******************************************************************************
274 * WM97xx audio, battery
275 ******************************************************************************/
276 static struct wm97xx_batt_pdata palmte2_batt_pdata
= {
277 .batt_aux
= WM97XX_AUX_ID3
,
278 .temp_aux
= WM97XX_AUX_ID2
,
280 .max_voltage
= PALMTE2_BAT_MAX_VOLTAGE
,
281 .min_voltage
= PALMTE2_BAT_MIN_VOLTAGE
,
286 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LIPO
,
287 .batt_name
= "main-batt",
290 static struct wm97xx_pdata palmte2_wm97xx_pdata
= {
291 .batt_pdata
= &palmte2_batt_pdata
,
294 static pxa2xx_audio_ops_t palmte2_ac97_pdata
= {
295 .codec_pdata
= { &palmte2_wm97xx_pdata
, },
298 static struct palm27x_asoc_info palmte2_asoc_pdata
= {
299 .jack_gpio
= GPIO_NR_PALMTE2_EARPHONE_DETECT
,
302 static struct platform_device palmte2_asoc
= {
303 .name
= "palm27x-asoc",
306 .platform_data
= &palmte2_asoc_pdata
,
310 /******************************************************************************
312 ******************************************************************************/
313 static struct pxafb_mode_info palmte2_lcd_modes
[] = {
330 static struct pxafb_mach_info palmte2_lcd_screen
= {
331 .modes
= palmte2_lcd_modes
,
332 .num_modes
= ARRAY_SIZE(palmte2_lcd_modes
),
333 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
336 /******************************************************************************
338 ******************************************************************************/
339 static struct platform_device
*devices
[] __initdata
= {
340 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
349 /* setup udc GPIOs initial state */
350 static void __init
palmte2_udc_init(void)
352 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP
, "UDC Vbus")) {
353 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP
, 1);
354 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP
);
358 static void __init
palmte2_init(void)
360 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config
));
362 pxa_set_ffuart_info(NULL
);
363 pxa_set_btuart_info(NULL
);
364 pxa_set_stuart_info(NULL
);
366 set_pxa_fb_info(&palmte2_lcd_screen
);
367 pxa_set_mci_info(&palmte2_mci_platform_data
);
369 pxa_set_ac97_info(&palmte2_ac97_pdata
);
370 pxa_set_ficp_info(&palmte2_ficp_platform_data
);
372 platform_add_devices(devices
, ARRAY_SIZE(devices
));
375 MACHINE_START(PALMTE2
, "Palm Tungsten|E2")
376 .boot_params
= 0xa0000100,
377 .map_io
= pxa25x_map_io
,
378 .init_irq
= pxa25x_init_irq
,
380 .init_machine
= palmte2_init