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,
92 GPIO10_GPIO, /* hotsync button */
93 GPIO12_GPIO, /* power switch */
94 GPIO15_GPIO, /* lock switch */
97 GPIO52_GPIO, /* green led */
98 GPIO94_GPIO, /* orange led */
111 GPIO36_GPIO, /* wifi power */
112 GPIO38_GPIO, /* wifi ready */
113 GPIO81_GPIO, /* wifi reset */
120 GPIO98_GPIO, /* HDD reset */
121 GPIO115_GPIO, /* HDD power */
124 GPIO13_GPIO, /* earphone detect */
127 /******************************************************************************
129 ******************************************************************************/
130 static struct mtd_partition palmld_partitions[] = {
133 .offset = 0x00000000,
134 .size = MTDPART_SIZ_FULL,
139 static struct physmap_flash_data palmld_flash_data[] = {
141 .width = 2, /* bankwidth in bytes */
142 .parts = palmld_partitions,
143 .nr_parts = ARRAY_SIZE(palmld_partitions)
147 static struct resource palmld_flash_resource = {
148 .start = PXA_CS0_PHYS,
149 .end = PXA_CS0_PHYS + SZ_4M - 1,
150 .flags = IORESOURCE_MEM,
153 static struct platform_device palmld_flash = {
154 .name = "physmap-flash",
156 .resource = &palmld_flash_resource,
159 .platform_data = palmld_flash_data,
163 /******************************************************************************
164 * SD/MMC card controller
165 ******************************************************************************/
166 static struct pxamci_platform_data palmld_mci_platform_data = {
167 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
168 .gpio_card_detect = GPIO_NR_PALMLD_SD_DETECT_N,
169 .gpio_card_ro = GPIO_NR_PALMLD_SD_READONLY,
170 .gpio_power = GPIO_NR_PALMLD_SD_POWER,
171 .detect_delay_ms = 200,
174 /******************************************************************************
176 ******************************************************************************/
177 static unsigned int palmld_matrix_keys[] = {
183 KEY(1, 2, KEY_RIGHT),
190 KEY(3, 1, KEY_ENTER),
194 static struct pxa27x_keypad_platform_data palmld_keypad_platform_data = {
195 .matrix_key_rows = 4,
196 .matrix_key_cols = 3,
197 .matrix_key_map = palmld_matrix_keys,
198 .matrix_key_map_size = ARRAY_SIZE(palmld_matrix_keys),
200 .debounce_interval = 30,
203 /******************************************************************************
205 ******************************************************************************/
206 static struct gpio_keys_button palmld_pxa_buttons[] = {
207 {KEY_F8, GPIO_NR_PALMLD_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
208 {KEY_F9, GPIO_NR_PALMLD_LOCK_SWITCH, 0, "Lock Switch" },
209 {KEY_POWER, GPIO_NR_PALMLD_POWER_SWITCH, 0, "Power Switch" },
212 static struct gpio_keys_platform_data palmld_pxa_keys_data = {
213 .buttons = palmld_pxa_buttons,
214 .nbuttons = ARRAY_SIZE(palmld_pxa_buttons),
217 static struct platform_device palmld_pxa_keys = {
221 .platform_data = &palmld_pxa_keys_data,
225 /******************************************************************************
227 ******************************************************************************/
228 static int palmld_backlight_init(struct device *dev)
232 ret = gpio_request(GPIO_NR_PALMLD_BL_POWER, "BL POWER");
235 ret = gpio_direction_output(GPIO_NR_PALMLD_BL_POWER, 0);
238 ret = gpio_request(GPIO_NR_PALMLD_LCD_POWER, "LCD POWER");
241 ret = gpio_direction_output(GPIO_NR_PALMLD_LCD_POWER, 0);
247 gpio_free(GPIO_NR_PALMLD_LCD_POWER);
249 gpio_free(GPIO_NR_PALMLD_BL_POWER);
254 static int palmld_backlight_notify(struct device *dev, int brightness)
256 gpio_set_value(GPIO_NR_PALMLD_BL_POWER, brightness);
257 gpio_set_value(GPIO_NR_PALMLD_LCD_POWER, brightness);
261 static void palmld_backlight_exit(struct device *dev)
263 gpio_free(GPIO_NR_PALMLD_BL_POWER);
264 gpio_free(GPIO_NR_PALMLD_LCD_POWER);
267 static struct platform_pwm_backlight_data palmld_backlight_data = {
269 .max_brightness = PALMLD_MAX_INTENSITY,
270 .dft_brightness = PALMLD_MAX_INTENSITY,
271 .pwm_period_ns = PALMLD_PERIOD_NS,
272 .init = palmld_backlight_init,
273 .notify = palmld_backlight_notify,
274 .exit = palmld_backlight_exit,
277 static struct platform_device palmld_backlight = {
278 .name = "pwm-backlight",
280 .parent = &pxa27x_device_pwm0.dev,
281 .platform_data = &palmld_backlight_data,
285 /******************************************************************************
287 ******************************************************************************/
288 static struct pxaficp_platform_data palmld_ficp_platform_data = {
289 .gpio_pwdown = GPIO_NR_PALMLD_IR_DISABLE,
290 .transceiver_cap = IR_SIRMODE | IR_OFF,
293 /******************************************************************************
295 ******************************************************************************/
296 struct gpio_led gpio_leds[] = {
298 .name = "palmld:green:led",
299 .default_trigger = "none",
300 .gpio = GPIO_NR_PALMLD_LED_GREEN,
302 .name = "palmld:amber:led",
303 .default_trigger = "none",
304 .gpio = GPIO_NR_PALMLD_LED_AMBER,
308 static struct gpio_led_platform_data gpio_led_info = {
310 .num_leds = ARRAY_SIZE(gpio_leds),
313 static struct platform_device palmld_leds = {
317 .platform_data = &gpio_led_info,
321 /******************************************************************************
323 ******************************************************************************/
324 static int power_supply_init(struct device *dev)
328 ret = gpio_request(GPIO_NR_PALMLD_POWER_DETECT, "CABLE_STATE_AC");
331 ret = gpio_direction_input(GPIO_NR_PALMLD_POWER_DETECT);
335 ret = gpio_request(GPIO_NR_PALMLD_USB_DETECT_N, "CABLE_STATE_USB");
338 ret = gpio_direction_input(GPIO_NR_PALMLD_USB_DETECT_N);
345 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N);
347 gpio_free(GPIO_NR_PALMLD_POWER_DETECT);
352 static int palmld_is_ac_online(void)
354 return gpio_get_value(GPIO_NR_PALMLD_POWER_DETECT);
357 static int palmld_is_usb_online(void)
359 return !gpio_get_value(GPIO_NR_PALMLD_USB_DETECT_N);
362 static void power_supply_exit(struct device *dev)
364 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N);
365 gpio_free(GPIO_NR_PALMLD_POWER_DETECT);
368 static char *palmld_supplicants[] = {
372 static struct pda_power_pdata power_supply_info = {
373 .init = power_supply_init,
374 .is_ac_online = palmld_is_ac_online,
375 .is_usb_online = palmld_is_usb_online,
376 .exit = power_supply_exit,
377 .supplied_to = palmld_supplicants,
378 .num_supplicants = ARRAY_SIZE(palmld_supplicants),
381 static struct platform_device power_supply = {
385 .platform_data = &power_supply_info,
389 /******************************************************************************
391 ******************************************************************************/
392 static struct wm97xx_batt_info wm97xx_batt_pdata = {
393 .batt_aux = WM97XX_AUX_ID3,
394 .temp_aux = WM97XX_AUX_ID2,
396 .max_voltage = PALMLD_BAT_MAX_VOLTAGE,
397 .min_voltage = PALMLD_BAT_MIN_VOLTAGE,
402 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
403 .batt_name = "main-batt",
406 /******************************************************************************
408 ******************************************************************************/
409 static struct palm27x_asoc_info palmld_asoc_pdata = {
410 .jack_gpio = GPIO_NR_PALMLD_EARPHONE_DETECT,
413 static pxa2xx_audio_ops_t palmld_ac97_pdata = {
417 static struct platform_device palmld_asoc = {
418 .name = "palm27x-asoc",
421 .platform_data = &palmld_asoc_pdata,
425 /******************************************************************************
427 ******************************************************************************/
428 static struct platform_device palmld_hdd = {
429 .name = "pata_palmld",
433 /******************************************************************************
435 ******************************************************************************/
436 static struct pxafb_mode_info palmld_lcd_modes[] = {
453 static struct pxafb_mach_info palmld_lcd_screen = {
454 .modes = palmld_lcd_modes,
455 .num_modes = ARRAY_SIZE(palmld_lcd_modes),
456 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
459 /******************************************************************************
460 * Power management - standby
461 ******************************************************************************/
462 static void __init palmld_pm_init(void)
464 static u32 resume[] = {
465 0xe3a00101, /* mov r0, #0x40000000 */
466 0xe380060f, /* orr r0, r0, #0x00f00000 */
467 0xe590f008, /* ldr pc, [r0, #0x08] */
470 /* copy the bootloader */
471 memcpy(phys_to_virt(PALMLD_STR_BASE), resume, sizeof(resume));
474 /******************************************************************************
476 ******************************************************************************/
477 static struct platform_device *devices[] __initdata = {
478 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
489 static struct map_desc palmld_io_desc[] __initdata = {
491 .virtual = PALMLD_IDE_VIRT,
492 .pfn = __phys_to_pfn(PALMLD_IDE_PHYS),
493 .length = PALMLD_IDE_SIZE,
497 .virtual = PALMLD_USB_VIRT,
498 .pfn = __phys_to_pfn(PALMLD_USB_PHYS),
499 .length = PALMLD_USB_SIZE,
504 static void __init palmld_map_io(void)
507 iotable_init(palmld_io_desc, ARRAY_SIZE(palmld_io_desc));
510 static void __init palmld_init(void)
512 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmld_pin_config));
514 pxa_set_ffuart_info(NULL);
515 pxa_set_btuart_info(NULL);
516 pxa_set_stuart_info(NULL);
519 set_pxa_fb_info(&palmld_lcd_screen);
520 pxa_set_mci_info(&palmld_mci_platform_data);
521 pxa_set_ac97_info(&palmld_ac97_pdata);
522 pxa_set_ficp_info(&palmld_ficp_platform_data);
523 pxa_set_keypad_info(&palmld_keypad_platform_data);
524 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
526 platform_add_devices(devices, ARRAY_SIZE(devices));
529 MACHINE_START(PALMLD, "Palm LifeDrive")
530 .phys_io = PALMLD_PHYS_IO_START,
531 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
532 .boot_params = 0xa0000100,
533 .map_io = palmld_map_io,
534 .init_irq = pxa27x_init_irq,
536 .init_machine = palmld_init