2 * Hardware definitions for Palm LifeDrive
4 * Author: Marek Vasut <marek.vasut@gmail.com>
7 * Alex Osborne <ato@meshy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 * (find more info at www.hackndev.com)
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/irq.h>
20 #include <linux/gpio_keys.h>
21 #include <linux/input.h>
22 #include <linux/pda_power.h>
23 #include <linux/pwm_backlight.h>
24 #include <linux/gpio.h>
25 #include <linux/wm97xx_batt.h>
26 #include <linux/power_supply.h>
27 #include <linux/sysdev.h>
28 #include <linux/mtd/mtd.h>
29 #include <linux/mtd/partitions.h>
30 #include <linux/mtd/physmap.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/palmld.h>
40 #include <mach/pxafb.h>
41 #include <mach/irda.h>
42 #include <mach/pxa27x_keypad.h>
43 #include <mach/palmasoc.h>
48 /******************************************************************************
50 ******************************************************************************/
51 static unsigned long palmld_pin_config[] __initdata = {
59 GPIO14_GPIO, /* SD detect */
60 GPIO114_GPIO, /* SD power */
61 GPIO116_GPIO, /* SD r/o switch */
65 GPIO29_AC97_SDATA_IN_0,
66 GPIO30_AC97_SDATA_OUT,
72 GPIO108_GPIO, /* ir disable */
77 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
78 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
79 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
80 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
111 GPIO10_GPIO, /* hotsync button */
112 GPIO12_GPIO, /* power switch */
113 GPIO15_GPIO, /* lock switch */
116 GPIO52_GPIO, /* green led */
117 GPIO94_GPIO, /* orange led */
130 GPIO36_GPIO, /* wifi power */
131 GPIO38_GPIO, /* wifi ready */
132 GPIO81_GPIO, /* wifi reset */
139 GPIO98_GPIO, /* HDD reset */
140 GPIO115_GPIO, /* HDD power */
143 GPIO13_GPIO, /* earphone detect */
146 /******************************************************************************
148 ******************************************************************************/
149 static struct mtd_partition palmld_partitions[] = {
152 .offset = 0x00000000,
153 .size = MTDPART_SIZ_FULL,
158 static struct physmap_flash_data palmld_flash_data[] = {
160 .width = 2, /* bankwidth in bytes */
161 .parts = palmld_partitions,
162 .nr_parts = ARRAY_SIZE(palmld_partitions)
166 static struct resource palmld_flash_resource = {
167 .start = PXA_CS0_PHYS,
168 .end = PXA_CS0_PHYS + SZ_4M - 1,
169 .flags = IORESOURCE_MEM,
172 static struct platform_device palmld_flash = {
173 .name = "physmap-flash",
175 .resource = &palmld_flash_resource,
178 .platform_data = palmld_flash_data,
182 /******************************************************************************
183 * SD/MMC card controller
184 ******************************************************************************/
185 static struct pxamci_platform_data palmld_mci_platform_data = {
186 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
187 .gpio_card_detect = GPIO_NR_PALMLD_SD_DETECT_N,
188 .gpio_card_ro = GPIO_NR_PALMLD_SD_READONLY,
189 .gpio_power = GPIO_NR_PALMLD_SD_POWER,
193 /******************************************************************************
195 ******************************************************************************/
196 static unsigned int palmld_matrix_keys[] = {
202 KEY(1, 2, KEY_RIGHT),
209 KEY(3, 1, KEY_ENTER),
213 static struct pxa27x_keypad_platform_data palmld_keypad_platform_data = {
214 .matrix_key_rows = 4,
215 .matrix_key_cols = 3,
216 .matrix_key_map = palmld_matrix_keys,
217 .matrix_key_map_size = ARRAY_SIZE(palmld_matrix_keys),
219 .debounce_interval = 30,
222 /******************************************************************************
224 ******************************************************************************/
225 static struct gpio_keys_button palmld_pxa_buttons[] = {
226 {KEY_F8, GPIO_NR_PALMLD_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
227 {KEY_F9, GPIO_NR_PALMLD_LOCK_SWITCH, 0, "Lock Switch" },
228 {KEY_POWER, GPIO_NR_PALMLD_POWER_SWITCH, 0, "Power Switch" },
231 static struct gpio_keys_platform_data palmld_pxa_keys_data = {
232 .buttons = palmld_pxa_buttons,
233 .nbuttons = ARRAY_SIZE(palmld_pxa_buttons),
236 static struct platform_device palmld_pxa_keys = {
240 .platform_data = &palmld_pxa_keys_data,
244 /******************************************************************************
246 ******************************************************************************/
247 static int palmld_backlight_init(struct device *dev)
251 ret = gpio_request(GPIO_NR_PALMLD_BL_POWER, "BL POWER");
254 ret = gpio_direction_output(GPIO_NR_PALMLD_BL_POWER, 0);
257 ret = gpio_request(GPIO_NR_PALMLD_LCD_POWER, "LCD POWER");
260 ret = gpio_direction_output(GPIO_NR_PALMLD_LCD_POWER, 0);
266 gpio_free(GPIO_NR_PALMLD_LCD_POWER);
268 gpio_free(GPIO_NR_PALMLD_BL_POWER);
273 static int palmld_backlight_notify(struct device *dev, int brightness)
275 gpio_set_value(GPIO_NR_PALMLD_BL_POWER, brightness);
276 gpio_set_value(GPIO_NR_PALMLD_LCD_POWER, brightness);
280 static void palmld_backlight_exit(struct device *dev)
282 gpio_free(GPIO_NR_PALMLD_BL_POWER);
283 gpio_free(GPIO_NR_PALMLD_LCD_POWER);
286 static struct platform_pwm_backlight_data palmld_backlight_data = {
288 .max_brightness = PALMLD_MAX_INTENSITY,
289 .dft_brightness = PALMLD_MAX_INTENSITY,
290 .pwm_period_ns = PALMLD_PERIOD_NS,
291 .init = palmld_backlight_init,
292 .notify = palmld_backlight_notify,
293 .exit = palmld_backlight_exit,
296 static struct platform_device palmld_backlight = {
297 .name = "pwm-backlight",
299 .parent = &pxa27x_device_pwm0.dev,
300 .platform_data = &palmld_backlight_data,
304 /******************************************************************************
306 ******************************************************************************/
307 static struct pxaficp_platform_data palmld_ficp_platform_data = {
308 .gpio_pwdown = GPIO_NR_PALMLD_IR_DISABLE,
309 .transceiver_cap = IR_SIRMODE | IR_OFF,
312 /******************************************************************************
314 ******************************************************************************/
315 struct gpio_led gpio_leds[] = {
317 .name = "palmld:green:led",
318 .default_trigger = "none",
319 .gpio = GPIO_NR_PALMLD_LED_GREEN,
321 .name = "palmld:amber:led",
322 .default_trigger = "none",
323 .gpio = GPIO_NR_PALMLD_LED_AMBER,
327 static struct gpio_led_platform_data gpio_led_info = {
329 .num_leds = ARRAY_SIZE(gpio_leds),
332 static struct platform_device palmld_leds = {
336 .platform_data = &gpio_led_info,
340 /******************************************************************************
342 ******************************************************************************/
343 static int power_supply_init(struct device *dev)
347 ret = gpio_request(GPIO_NR_PALMLD_POWER_DETECT, "CABLE_STATE_AC");
350 ret = gpio_direction_input(GPIO_NR_PALMLD_POWER_DETECT);
354 ret = gpio_request(GPIO_NR_PALMLD_USB_DETECT_N, "CABLE_STATE_USB");
357 ret = gpio_direction_input(GPIO_NR_PALMLD_USB_DETECT_N);
364 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N);
366 gpio_free(GPIO_NR_PALMLD_POWER_DETECT);
371 static int palmld_is_ac_online(void)
373 return gpio_get_value(GPIO_NR_PALMLD_POWER_DETECT);
376 static int palmld_is_usb_online(void)
378 return !gpio_get_value(GPIO_NR_PALMLD_USB_DETECT_N);
381 static void power_supply_exit(struct device *dev)
383 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N);
384 gpio_free(GPIO_NR_PALMLD_POWER_DETECT);
387 static char *palmld_supplicants[] = {
391 static struct pda_power_pdata power_supply_info = {
392 .init = power_supply_init,
393 .is_ac_online = palmld_is_ac_online,
394 .is_usb_online = palmld_is_usb_online,
395 .exit = power_supply_exit,
396 .supplied_to = palmld_supplicants,
397 .num_supplicants = ARRAY_SIZE(palmld_supplicants),
400 static struct platform_device power_supply = {
404 .platform_data = &power_supply_info,
408 /******************************************************************************
410 ******************************************************************************/
411 static struct wm97xx_batt_info wm97xx_batt_pdata = {
412 .batt_aux = WM97XX_AUX_ID3,
413 .temp_aux = WM97XX_AUX_ID2,
415 .max_voltage = PALMLD_BAT_MAX_VOLTAGE,
416 .min_voltage = PALMLD_BAT_MIN_VOLTAGE,
421 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
422 .batt_name = "main-batt",
425 /******************************************************************************
427 ******************************************************************************/
428 static struct palm27x_asoc_info palmld_asoc_pdata = {
429 .jack_gpio = GPIO_NR_PALMLD_EARPHONE_DETECT,
432 static pxa2xx_audio_ops_t palmld_ac97_pdata = {
436 static struct platform_device palmld_asoc = {
437 .name = "palm27x-asoc",
440 .platform_data = &palmld_asoc_pdata,
444 /******************************************************************************
446 ******************************************************************************/
447 static struct platform_device palmld_hdd = {
448 .name = "pata_palmld",
452 /******************************************************************************
454 ******************************************************************************/
455 static struct pxafb_mode_info palmld_lcd_modes[] = {
472 static struct pxafb_mach_info palmld_lcd_screen = {
473 .modes = palmld_lcd_modes,
474 .num_modes = ARRAY_SIZE(palmld_lcd_modes),
475 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
478 /******************************************************************************
479 * Power management - standby
480 ******************************************************************************/
481 static void __init palmld_pm_init(void)
483 static u32 resume[] = {
484 0xe3a00101, /* mov r0, #0x40000000 */
485 0xe380060f, /* orr r0, r0, #0x00f00000 */
486 0xe590f008, /* ldr pc, [r0, #0x08] */
489 /* copy the bootloader */
490 memcpy(phys_to_virt(PALMLD_STR_BASE), resume, sizeof(resume));
493 /******************************************************************************
495 ******************************************************************************/
496 static struct platform_device *devices[] __initdata = {
497 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
508 static struct map_desc palmld_io_desc[] __initdata = {
510 .virtual = PALMLD_IDE_VIRT,
511 .pfn = __phys_to_pfn(PALMLD_IDE_PHYS),
512 .length = PALMLD_IDE_SIZE,
516 .virtual = PALMLD_USB_VIRT,
517 .pfn = __phys_to_pfn(PALMLD_USB_PHYS),
518 .length = PALMLD_USB_SIZE,
523 static void __init palmld_map_io(void)
526 iotable_init(palmld_io_desc, ARRAY_SIZE(palmld_io_desc));
529 static void __init palmld_init(void)
531 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmld_pin_config));
533 pxa_set_ffuart_info(NULL);
534 pxa_set_btuart_info(NULL);
535 pxa_set_stuart_info(NULL);
538 set_pxa_fb_info(&palmld_lcd_screen);
539 pxa_set_mci_info(&palmld_mci_platform_data);
540 pxa_set_ac97_info(&palmld_ac97_pdata);
541 pxa_set_ficp_info(&palmld_ficp_platform_data);
542 pxa_set_keypad_info(&palmld_keypad_platform_data);
543 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
545 platform_add_devices(devices, ARRAY_SIZE(devices));
548 MACHINE_START(PALMLD, "Palm LifeDrive")
549 .phys_io = PALMLD_PHYS_IO_START,
550 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
551 .boot_params = 0xa0000100,
552 .map_io = palmld_map_io,
553 .init_irq = pxa27x_init_irq,
555 .init_machine = palmld_init