2 * Hardware definitions for Palm Tungsten|T5
4 * Author: Marek Vasut <marek.vasut@gmail.com>
7 * Ales Snuparek <snuparek@atlas.cz>
8 * Justin Kendrick <twilightsentry@gmail.com>
9 * RichardT5 <richard_t5@users.sourceforge.net>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * (find more info at www.hackndev.com)
19 #include <linux/platform_device.h>
20 #include <linux/delay.h>
21 #include <linux/irq.h>
22 #include <linux/gpio_keys.h>
23 #include <linux/input.h>
24 #include <linux/pda_power.h>
25 #include <linux/pwm_backlight.h>
26 #include <linux/gpio.h>
27 #include <linux/wm97xx_batt.h>
28 #include <linux/power_supply.h>
29 #include <linux/usb/gpio_vbus.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
35 #include <mach/pxa27x.h>
36 #include <mach/audio.h>
37 #include <mach/palmt5.h>
39 #include <mach/pxafb.h>
40 #include <mach/irda.h>
41 #include <mach/pxa27x_keypad.h>
43 #include <mach/palmasoc.h>
48 /******************************************************************************
50 ******************************************************************************/
51 static unsigned long palmt5_pin_config
[] __initdata
= {
59 GPIO14_GPIO
, /* SD detect */
60 GPIO114_GPIO
, /* SD power */
61 GPIO115_GPIO
, /* SD r/o switch */
65 GPIO29_AC97_SDATA_IN_0
,
66 GPIO30_AC97_SDATA_OUT
,
72 GPIO40_GPIO
, /* ir disable */
77 GPIO15_GPIO
, /* usb detect */
78 GPIO93_GPIO
, /* usb power */
81 GPIO100_KP_MKIN_0
| WAKEUP_ON_LEVEL_HIGH
,
82 GPIO101_KP_MKIN_1
| WAKEUP_ON_LEVEL_HIGH
,
83 GPIO102_KP_MKIN_2
| WAKEUP_ON_LEVEL_HIGH
,
84 GPIO97_KP_MKIN_3
| WAKEUP_ON_LEVEL_HIGH
,
119 GPIO10_GPIO
, /* hotsync button */
120 GPIO90_GPIO
, /* power detect */
121 GPIO107_GPIO
, /* earphone detect */
124 /******************************************************************************
125 * SD/MMC card controller
126 ******************************************************************************/
127 static struct pxamci_platform_data palmt5_mci_platform_data
= {
128 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
129 .gpio_card_detect
= GPIO_NR_PALMT5_SD_DETECT_N
,
130 .gpio_card_ro
= GPIO_NR_PALMT5_SD_READONLY
,
131 .gpio_power
= GPIO_NR_PALMT5_SD_POWER
,
135 /******************************************************************************
137 ******************************************************************************/
138 static unsigned int palmt5_matrix_keys
[] = {
139 KEY(0, 0, KEY_POWER
),
141 KEY(0, 2, KEY_ENTER
),
150 KEY(3, 0, KEY_RIGHT
),
154 static struct pxa27x_keypad_platform_data palmt5_keypad_platform_data
= {
155 .matrix_key_rows
= 4,
156 .matrix_key_cols
= 3,
157 .matrix_key_map
= palmt5_matrix_keys
,
158 .matrix_key_map_size
= ARRAY_SIZE(palmt5_matrix_keys
),
160 .debounce_interval
= 30,
163 /******************************************************************************
165 ******************************************************************************/
166 static struct gpio_keys_button palmt5_pxa_buttons
[] = {
167 {KEY_F8
, GPIO_NR_PALMT5_HOTSYNC_BUTTON_N
, 1, "HotSync Button" },
170 static struct gpio_keys_platform_data palmt5_pxa_keys_data
= {
171 .buttons
= palmt5_pxa_buttons
,
172 .nbuttons
= ARRAY_SIZE(palmt5_pxa_buttons
),
175 static struct platform_device palmt5_pxa_keys
= {
179 .platform_data
= &palmt5_pxa_keys_data
,
183 /******************************************************************************
185 ******************************************************************************/
186 static int palmt5_backlight_init(struct device
*dev
)
190 ret
= gpio_request(GPIO_NR_PALMT5_BL_POWER
, "BL POWER");
193 ret
= gpio_direction_output(GPIO_NR_PALMT5_BL_POWER
, 0);
196 ret
= gpio_request(GPIO_NR_PALMT5_LCD_POWER
, "LCD POWER");
199 ret
= gpio_direction_output(GPIO_NR_PALMT5_LCD_POWER
, 0);
205 gpio_free(GPIO_NR_PALMT5_LCD_POWER
);
207 gpio_free(GPIO_NR_PALMT5_BL_POWER
);
212 static int palmt5_backlight_notify(int brightness
)
214 gpio_set_value(GPIO_NR_PALMT5_BL_POWER
, brightness
);
215 gpio_set_value(GPIO_NR_PALMT5_LCD_POWER
, brightness
);
219 static void palmt5_backlight_exit(struct device
*dev
)
221 gpio_free(GPIO_NR_PALMT5_BL_POWER
);
222 gpio_free(GPIO_NR_PALMT5_LCD_POWER
);
225 static struct platform_pwm_backlight_data palmt5_backlight_data
= {
227 .max_brightness
= PALMT5_MAX_INTENSITY
,
228 .dft_brightness
= PALMT5_MAX_INTENSITY
,
229 .pwm_period_ns
= PALMT5_PERIOD_NS
,
230 .init
= palmt5_backlight_init
,
231 .notify
= palmt5_backlight_notify
,
232 .exit
= palmt5_backlight_exit
,
235 static struct platform_device palmt5_backlight
= {
236 .name
= "pwm-backlight",
238 .parent
= &pxa27x_device_pwm0
.dev
,
239 .platform_data
= &palmt5_backlight_data
,
243 /******************************************************************************
245 ******************************************************************************/
246 static struct pxaficp_platform_data palmt5_ficp_platform_data
= {
247 .gpio_pwdown
= GPIO_NR_PALMT5_IR_DISABLE
,
248 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
251 /******************************************************************************
253 ******************************************************************************/
254 static struct gpio_vbus_mach_info palmt5_udc_info
= {
255 .gpio_vbus
= GPIO_NR_PALMT5_USB_DETECT_N
,
256 .gpio_vbus_inverted
= 1,
257 .gpio_pullup
= GPIO_NR_PALMT5_USB_PULLUP
,
260 static struct platform_device palmt5_gpio_vbus
= {
264 .platform_data
= &palmt5_udc_info
,
268 /******************************************************************************
270 ******************************************************************************/
271 static int power_supply_init(struct device
*dev
)
275 ret
= gpio_request(GPIO_NR_PALMT5_POWER_DETECT
, "CABLE_STATE_AC");
278 ret
= gpio_direction_input(GPIO_NR_PALMT5_POWER_DETECT
);
284 gpio_free(GPIO_NR_PALMT5_POWER_DETECT
);
289 static int palmt5_is_ac_online(void)
291 return gpio_get_value(GPIO_NR_PALMT5_POWER_DETECT
);
294 static void power_supply_exit(struct device
*dev
)
296 gpio_free(GPIO_NR_PALMT5_POWER_DETECT
);
299 static char *palmt5_supplicants
[] = {
303 static struct pda_power_pdata power_supply_info
= {
304 .init
= power_supply_init
,
305 .is_ac_online
= palmt5_is_ac_online
,
306 .exit
= power_supply_exit
,
307 .supplied_to
= palmt5_supplicants
,
308 .num_supplicants
= ARRAY_SIZE(palmt5_supplicants
),
311 static struct platform_device power_supply
= {
315 .platform_data
= &power_supply_info
,
319 /******************************************************************************
321 ******************************************************************************/
322 static struct wm97xx_batt_info wm97xx_batt_pdata
= {
323 .batt_aux
= WM97XX_AUX_ID3
,
324 .temp_aux
= WM97XX_AUX_ID2
,
326 .max_voltage
= PALMT5_BAT_MAX_VOLTAGE
,
327 .min_voltage
= PALMT5_BAT_MIN_VOLTAGE
,
332 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LIPO
,
333 .batt_name
= "main-batt",
336 /******************************************************************************
338 ******************************************************************************/
339 static struct palm27x_asoc_info palmt5_asoc_pdata
= {
340 .jack_gpio
= GPIO_NR_PALMT5_EARPHONE_DETECT
,
343 static pxa2xx_audio_ops_t palmt5_ac97_pdata
= {
347 static struct platform_device palmt5_asoc
= {
348 .name
= "palm27x-asoc",
351 .platform_data
= &palmt5_asoc_pdata
,
355 /******************************************************************************
357 ******************************************************************************/
358 static struct pxafb_mode_info palmt5_lcd_modes
[] = {
375 static struct pxafb_mach_info palmt5_lcd_screen
= {
376 .modes
= palmt5_lcd_modes
,
377 .num_modes
= ARRAY_SIZE(palmt5_lcd_modes
),
378 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
381 /******************************************************************************
382 * Power management - standby
383 ******************************************************************************/
384 static void __init
palmt5_pm_init(void)
386 static u32 resume
[] = {
387 0xe3a00101, /* mov r0, #0x40000000 */
388 0xe380060f, /* orr r0, r0, #0x00f00000 */
389 0xe590f008, /* ldr pc, [r0, #0x08] */
392 /* copy the bootloader */
393 memcpy(phys_to_virt(PALMT5_STR_BASE
), resume
, sizeof(resume
));
396 /******************************************************************************
398 ******************************************************************************/
399 static struct platform_device
*devices
[] __initdata
= {
400 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
409 /* setup udc GPIOs initial state */
410 static void __init
palmt5_udc_init(void)
412 if (!gpio_request(GPIO_NR_PALMT5_USB_PULLUP
, "UDC Vbus")) {
413 gpio_direction_output(GPIO_NR_PALMT5_USB_PULLUP
, 1);
414 gpio_free(GPIO_NR_PALMT5_USB_PULLUP
);
418 static void __init
palmt5_init(void)
420 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config
));
423 set_pxa_fb_info(&palmt5_lcd_screen
);
424 pxa_set_mci_info(&palmt5_mci_platform_data
);
426 pxa_set_ac97_info(&palmt5_ac97_pdata
);
427 pxa_set_ficp_info(&palmt5_ficp_platform_data
);
428 pxa_set_keypad_info(&palmt5_keypad_platform_data
);
429 wm97xx_bat_set_pdata(&wm97xx_batt_pdata
);
431 platform_add_devices(devices
, ARRAY_SIZE(devices
));
434 MACHINE_START(PALMT5
, "Palm Tungsten|T5")
435 .phys_io
= PALMT5_PHYS_IO_START
,
436 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
437 .boot_params
= 0xa0000100,
438 .map_io
= pxa_map_io
,
439 .init_irq
= pxa27x_init_irq
,
441 .init_machine
= palmt5_init