2 * Hardware definitions for PalmTX
4 * Author: Marek Vasut <marek.vasut@gmail.com>
7 * Alex Osborne <ato@meshy.org>
8 * Cristiano P. <cristianop@users.sourceforge.net>
9 * Jan Herman <2hp@seznam.cz>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * (find more info at www.hackndev.com)
20 #include <linux/platform_device.h>
21 #include <linux/delay.h>
22 #include <linux/irq.h>
23 #include <linux/gpio_keys.h>
24 #include <linux/input.h>
25 #include <linux/pda_power.h>
26 #include <linux/pwm_backlight.h>
27 #include <linux/gpio.h>
28 #include <linux/wm97xx_batt.h>
29 #include <linux/power_supply.h>
30 #include <linux/usb/gpio_vbus.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
36 #include <mach/pxa27x.h>
37 #include <mach/audio.h>
38 #include <mach/palmtx.h>
40 #include <mach/pxafb.h>
41 #include <mach/irda.h>
42 #include <mach/pxa27x_keypad.h>
44 #include <mach/palmasoc.h>
49 /******************************************************************************
51 ******************************************************************************/
52 static unsigned long palmtx_pin_config[] __initdata = {
60 GPIO14_GPIO, /* SD detect */
61 GPIO114_GPIO, /* SD power */
62 GPIO115_GPIO, /* SD r/o switch */
66 GPIO29_AC97_SDATA_IN_0,
67 GPIO30_AC97_SDATA_OUT,
73 GPIO40_GPIO, /* ir disable */
81 GPIO13_GPIO, /* usb detect */
82 GPIO93_GPIO, /* usb power */
95 GPIO94_GPIO, /* wifi power 1 */
96 GPIO108_GPIO, /* wifi power 2 */
97 GPIO116_GPIO, /* wifi ready */
100 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
101 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
102 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
103 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
135 GPIO10_GPIO, /* hotsync button */
136 GPIO12_GPIO, /* power detect */
137 GPIO107_GPIO, /* earphone detect */
140 /******************************************************************************
141 * SD/MMC card controller
142 ******************************************************************************/
143 static struct pxamci_platform_data palmtx_mci_platform_data = {
144 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
145 .gpio_card_detect = GPIO_NR_PALMTX_SD_DETECT_N,
146 .gpio_card_ro = GPIO_NR_PALMTX_SD_READONLY,
147 .gpio_power = GPIO_NR_PALMTX_SD_POWER,
151 /******************************************************************************
153 ******************************************************************************/
154 static unsigned int palmtx_matrix_keys[] = {
155 KEY(0, 0, KEY_POWER),
157 KEY(0, 2, KEY_ENTER),
166 KEY(3, 0, KEY_RIGHT),
170 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
171 .matrix_key_rows = 4,
172 .matrix_key_cols = 3,
173 .matrix_key_map = palmtx_matrix_keys,
174 .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
176 .debounce_interval = 30,
179 /******************************************************************************
181 ******************************************************************************/
182 static struct gpio_keys_button palmtx_pxa_buttons[] = {
183 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
186 static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
187 .buttons = palmtx_pxa_buttons,
188 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
191 static struct platform_device palmtx_pxa_keys = {
195 .platform_data = &palmtx_pxa_keys_data,
199 /******************************************************************************
201 ******************************************************************************/
202 static int palmtx_backlight_init(struct device *dev)
206 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
209 ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
212 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
215 ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
221 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
223 gpio_free(GPIO_NR_PALMTX_BL_POWER);
228 static int palmtx_backlight_notify(int brightness)
230 gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
231 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
235 static void palmtx_backlight_exit(struct device *dev)
237 gpio_free(GPIO_NR_PALMTX_BL_POWER);
238 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
241 static struct platform_pwm_backlight_data palmtx_backlight_data = {
243 .max_brightness = PALMTX_MAX_INTENSITY,
244 .dft_brightness = PALMTX_MAX_INTENSITY,
245 .pwm_period_ns = PALMTX_PERIOD_NS,
246 .init = palmtx_backlight_init,
247 .notify = palmtx_backlight_notify,
248 .exit = palmtx_backlight_exit,
251 static struct platform_device palmtx_backlight = {
252 .name = "pwm-backlight",
254 .parent = &pxa27x_device_pwm0.dev,
255 .platform_data = &palmtx_backlight_data,
259 /******************************************************************************
261 ******************************************************************************/
262 static int palmtx_irda_startup(struct device *dev)
265 err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
268 err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
270 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
275 static void palmtx_irda_shutdown(struct device *dev)
277 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
280 static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
282 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
283 pxa2xx_transceiver_mode(dev, mode);
286 static struct pxaficp_platform_data palmtx_ficp_platform_data = {
287 .startup = palmtx_irda_startup,
288 .shutdown = palmtx_irda_shutdown,
289 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
290 .transceiver_mode = palmtx_irda_transceiver_mode,
293 /******************************************************************************
295 ******************************************************************************/
296 static struct gpio_vbus_mach_info palmtx_udc_info = {
297 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
298 .gpio_vbus_inverted = 1,
299 .gpio_pullup = GPIO_NR_PALMTX_USB_PULLUP,
302 static struct platform_device palmtx_gpio_vbus = {
306 .platform_data = &palmtx_udc_info,
310 /******************************************************************************
312 ******************************************************************************/
313 static int power_supply_init(struct device *dev)
317 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
320 ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
327 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
332 static int palmtx_is_ac_online(void)
334 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
337 static void power_supply_exit(struct device *dev)
339 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
342 static char *palmtx_supplicants[] = {
346 static struct pda_power_pdata power_supply_info = {
347 .init = power_supply_init,
348 .is_ac_online = palmtx_is_ac_online,
349 .exit = power_supply_exit,
350 .supplied_to = palmtx_supplicants,
351 .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
354 static struct platform_device power_supply = {
358 .platform_data = &power_supply_info,
362 /******************************************************************************
364 ******************************************************************************/
365 static struct wm97xx_batt_info wm97xx_batt_pdata = {
366 .batt_aux = WM97XX_AUX_ID3,
367 .temp_aux = WM97XX_AUX_ID2,
369 .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
370 .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
375 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
376 .batt_name = "main-batt",
379 /******************************************************************************
381 ******************************************************************************/
382 static struct palm27x_asoc_info palmtx_asoc_pdata = {
383 .jack_gpio = GPIO_NR_PALMTX_EARPHONE_DETECT,
386 static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
390 static struct platform_device palmtx_asoc = {
391 .name = "palm27x-asoc",
394 .platform_data = &palmtx_asoc_pdata,
398 /******************************************************************************
400 ******************************************************************************/
401 static struct pxafb_mode_info palmtx_lcd_modes[] = {
418 static struct pxafb_mach_info palmtx_lcd_screen = {
419 .modes = palmtx_lcd_modes,
420 .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
421 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
424 /******************************************************************************
425 * Power management - standby
426 ******************************************************************************/
427 static void __init palmtx_pm_init(void)
429 static u32 resume[] = {
430 0xe3a00101, /* mov r0, #0x40000000 */
431 0xe380060f, /* orr r0, r0, #0x00f00000 */
432 0xe590f008, /* ldr pc, [r0, #0x08] */
435 /* copy the bootloader */
436 memcpy(phys_to_virt(PALMTX_STR_BASE), resume, sizeof(resume));
439 /******************************************************************************
441 ******************************************************************************/
442 static struct platform_device *devices[] __initdata = {
443 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
452 static struct map_desc palmtx_io_desc[] __initdata = {
454 .virtual = PALMTX_PCMCIA_VIRT,
455 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
456 .length = PALMTX_PCMCIA_SIZE,
461 static void __init palmtx_map_io(void)
464 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
467 /* setup udc GPIOs initial state */
468 static void __init palmtx_udc_init(void)
470 if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP, "UDC Vbus")) {
471 gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP, 1);
472 gpio_free(GPIO_NR_PALMTX_USB_PULLUP);
477 static void __init palmtx_init(void)
479 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
482 set_pxa_fb_info(&palmtx_lcd_screen);
483 pxa_set_mci_info(&palmtx_mci_platform_data);
485 pxa_set_ac97_info(&palmtx_ac97_pdata);
486 pxa_set_ficp_info(&palmtx_ficp_platform_data);
487 pxa_set_keypad_info(&palmtx_keypad_platform_data);
488 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
490 platform_add_devices(devices, ARRAY_SIZE(devices));
493 MACHINE_START(PALMTX, "Palm T|X")
494 .phys_io = PALMTX_PHYS_IO_START,
495 .io_pg_offst = io_p2v(0x40000000),
496 .boot_params = 0xa0000100,
497 .map_io = palmtx_map_io,
498 .init_irq = pxa27x_init_irq,
500 .init_machine = palmtx_init