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>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
33 #include <mach/pxa27x.h>
34 #include <mach/audio.h>
35 #include <mach/palmld.h>
37 #include <mach/pxafb.h>
38 #include <mach/irda.h>
39 #include <mach/pxa27x_keypad.h>
40 #include <mach/palmasoc.h>
45 /******************************************************************************
47 ******************************************************************************/
48 static unsigned long palmld_pin_config[] __initdata = {
56 GPIO14_GPIO, /* SD detect */
57 GPIO114_GPIO, /* SD power */
58 GPIO116_GPIO, /* SD r/o switch */
62 GPIO29_AC97_SDATA_IN_0,
63 GPIO30_AC97_SDATA_OUT,
69 GPIO108_GPIO, /* ir disable */
74 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
75 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
76 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
77 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
108 GPIO10_GPIO, /* hotsync button */
109 GPIO12_GPIO, /* power switch */
110 GPIO15_GPIO, /* lock switch */
113 GPIO52_GPIO, /* green led */
114 GPIO94_GPIO, /* orange led */
127 GPIO36_GPIO, /* wifi power */
128 GPIO38_GPIO, /* wifi ready */
129 GPIO81_GPIO, /* wifi reset */
136 GPIO98_GPIO, /* HDD reset */
137 GPIO115_GPIO, /* HDD power */
140 GPIO13_GPIO, /* earphone detect */
143 /******************************************************************************
144 * SD/MMC card controller
145 ******************************************************************************/
146 static struct pxamci_platform_data palmld_mci_platform_data = {
147 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
148 .gpio_card_detect = GPIO_NR_PALMLD_SD_DETECT_N,
149 .gpio_card_ro = GPIO_NR_PALMLD_SD_READONLY,
150 .gpio_power = GPIO_NR_PALMLD_SD_POWER,
154 /******************************************************************************
156 ******************************************************************************/
157 static unsigned int palmld_matrix_keys[] = {
163 KEY(1, 2, KEY_RIGHT),
170 KEY(3, 1, KEY_ENTER),
174 static struct pxa27x_keypad_platform_data palmld_keypad_platform_data = {
175 .matrix_key_rows = 4,
176 .matrix_key_cols = 3,
177 .matrix_key_map = palmld_matrix_keys,
178 .matrix_key_map_size = ARRAY_SIZE(palmld_matrix_keys),
180 .debounce_interval = 30,
183 /******************************************************************************
185 ******************************************************************************/
186 static struct gpio_keys_button palmld_pxa_buttons[] = {
187 {KEY_F8, GPIO_NR_PALMLD_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
188 {KEY_F9, GPIO_NR_PALMLD_LOCK_SWITCH, 0, "Lock Switch" },
189 {KEY_POWER, GPIO_NR_PALMLD_POWER_SWITCH, 0, "Power Switch" },
192 static struct gpio_keys_platform_data palmld_pxa_keys_data = {
193 .buttons = palmld_pxa_buttons,
194 .nbuttons = ARRAY_SIZE(palmld_pxa_buttons),
197 static struct platform_device palmld_pxa_keys = {
201 .platform_data = &palmld_pxa_keys_data,
205 /******************************************************************************
207 ******************************************************************************/
208 static int palmld_backlight_init(struct device *dev)
212 ret = gpio_request(GPIO_NR_PALMLD_BL_POWER, "BL POWER");
215 ret = gpio_direction_output(GPIO_NR_PALMLD_BL_POWER, 0);
218 ret = gpio_request(GPIO_NR_PALMLD_LCD_POWER, "LCD POWER");
221 ret = gpio_direction_output(GPIO_NR_PALMLD_LCD_POWER, 0);
227 gpio_free(GPIO_NR_PALMLD_LCD_POWER);
229 gpio_free(GPIO_NR_PALMLD_BL_POWER);
234 static int palmld_backlight_notify(int brightness)
236 gpio_set_value(GPIO_NR_PALMLD_BL_POWER, brightness);
237 gpio_set_value(GPIO_NR_PALMLD_LCD_POWER, brightness);
241 static void palmld_backlight_exit(struct device *dev)
243 gpio_free(GPIO_NR_PALMLD_BL_POWER);
244 gpio_free(GPIO_NR_PALMLD_LCD_POWER);
247 static struct platform_pwm_backlight_data palmld_backlight_data = {
249 .max_brightness = PALMLD_MAX_INTENSITY,
250 .dft_brightness = PALMLD_MAX_INTENSITY,
251 .pwm_period_ns = PALMLD_PERIOD_NS,
252 .init = palmld_backlight_init,
253 .notify = palmld_backlight_notify,
254 .exit = palmld_backlight_exit,
257 static struct platform_device palmld_backlight = {
258 .name = "pwm-backlight",
260 .parent = &pxa27x_device_pwm0.dev,
261 .platform_data = &palmld_backlight_data,
265 /******************************************************************************
267 ******************************************************************************/
268 static int palmld_irda_startup(struct device *dev)
271 err = gpio_request(GPIO_NR_PALMLD_IR_DISABLE, "IR DISABLE");
274 err = gpio_direction_output(GPIO_NR_PALMLD_IR_DISABLE, 1);
276 gpio_free(GPIO_NR_PALMLD_IR_DISABLE);
281 static void palmld_irda_shutdown(struct device *dev)
283 gpio_free(GPIO_NR_PALMLD_IR_DISABLE);
286 static void palmld_irda_transceiver_mode(struct device *dev, int mode)
288 gpio_set_value(GPIO_NR_PALMLD_IR_DISABLE, mode & IR_OFF);
289 pxa2xx_transceiver_mode(dev, mode);
292 static struct pxaficp_platform_data palmld_ficp_platform_data = {
293 .startup = palmld_irda_startup,
294 .shutdown = palmld_irda_shutdown,
295 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
296 .transceiver_mode = palmld_irda_transceiver_mode,
299 /******************************************************************************
301 ******************************************************************************/
302 struct gpio_led gpio_leds[] = {
304 .name = "palmld:green:led",
305 .default_trigger = "none",
306 .gpio = GPIO_NR_PALMLD_LED_GREEN,
308 .name = "palmld:amber:led",
309 .default_trigger = "none",
310 .gpio = GPIO_NR_PALMLD_LED_AMBER,
314 static struct gpio_led_platform_data gpio_led_info = {
316 .num_leds = ARRAY_SIZE(gpio_leds),
319 static struct platform_device palmld_leds = {
323 .platform_data = &gpio_led_info,
327 /******************************************************************************
329 ******************************************************************************/
330 static int power_supply_init(struct device *dev)
334 ret = gpio_request(GPIO_NR_PALMLD_POWER_DETECT, "CABLE_STATE_AC");
337 ret = gpio_direction_input(GPIO_NR_PALMLD_POWER_DETECT);
341 ret = gpio_request(GPIO_NR_PALMLD_USB_DETECT_N, "CABLE_STATE_USB");
344 ret = gpio_direction_input(GPIO_NR_PALMLD_USB_DETECT_N);
351 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N);
353 gpio_free(GPIO_NR_PALMLD_POWER_DETECT);
358 static int palmld_is_ac_online(void)
360 return gpio_get_value(GPIO_NR_PALMLD_POWER_DETECT);
363 static int palmld_is_usb_online(void)
365 return !gpio_get_value(GPIO_NR_PALMLD_USB_DETECT_N);
368 static void power_supply_exit(struct device *dev)
370 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N);
371 gpio_free(GPIO_NR_PALMLD_POWER_DETECT);
374 static char *palmld_supplicants[] = {
378 static struct pda_power_pdata power_supply_info = {
379 .init = power_supply_init,
380 .is_ac_online = palmld_is_ac_online,
381 .is_usb_online = palmld_is_usb_online,
382 .exit = power_supply_exit,
383 .supplied_to = palmld_supplicants,
384 .num_supplicants = ARRAY_SIZE(palmld_supplicants),
387 static struct platform_device power_supply = {
391 .platform_data = &power_supply_info,
395 /******************************************************************************
397 ******************************************************************************/
398 static struct wm97xx_batt_info wm97xx_batt_pdata = {
399 .batt_aux = WM97XX_AUX_ID3,
400 .temp_aux = WM97XX_AUX_ID2,
402 .max_voltage = PALMLD_BAT_MAX_VOLTAGE,
403 .min_voltage = PALMLD_BAT_MIN_VOLTAGE,
408 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
409 .batt_name = "main-batt",
412 /******************************************************************************
414 ******************************************************************************/
415 static struct palm27x_asoc_info palmld_asoc_pdata = {
416 .jack_gpio = GPIO_NR_PALMLD_EARPHONE_DETECT,
419 static pxa2xx_audio_ops_t palmld_ac97_pdata = {
423 static struct platform_device palmld_asoc = {
424 .name = "palm27x-asoc",
427 .platform_data = &palmld_asoc_pdata,
431 /******************************************************************************
433 ******************************************************************************/
434 static struct platform_device palmld_hdd = {
435 .name = "pata_palmld",
439 /******************************************************************************
441 ******************************************************************************/
442 static struct pxafb_mode_info palmld_lcd_modes[] = {
459 static struct pxafb_mach_info palmld_lcd_screen = {
460 .modes = palmld_lcd_modes,
461 .num_modes = ARRAY_SIZE(palmld_lcd_modes),
462 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
465 /******************************************************************************
466 * Power management - standby
467 ******************************************************************************/
468 static void __init palmld_pm_init(void)
470 static u32 resume[] = {
471 0xe3a00101, /* mov r0, #0x40000000 */
472 0xe380060f, /* orr r0, r0, #0x00f00000 */
473 0xe590f008, /* ldr pc, [r0, #0x08] */
476 /* copy the bootloader */
477 memcpy(phys_to_virt(PALMLD_STR_BASE), resume, sizeof(resume));
480 /******************************************************************************
482 ******************************************************************************/
483 static struct platform_device *devices[] __initdata = {
484 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
494 static struct map_desc palmld_io_desc[] __initdata = {
496 .virtual = PALMLD_IDE_VIRT,
497 .pfn = __phys_to_pfn(PALMLD_IDE_PHYS),
498 .length = PALMLD_IDE_SIZE,
502 .virtual = PALMLD_USB_VIRT,
503 .pfn = __phys_to_pfn(PALMLD_USB_PHYS),
504 .length = PALMLD_USB_SIZE,
509 static void __init palmld_map_io(void)
512 iotable_init(palmld_io_desc, ARRAY_SIZE(palmld_io_desc));
515 static void __init palmld_init(void)
517 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmld_pin_config));
520 set_pxa_fb_info(&palmld_lcd_screen);
521 pxa_set_mci_info(&palmld_mci_platform_data);
522 pxa_set_ac97_info(&palmld_ac97_pdata);
523 pxa_set_ficp_info(&palmld_ficp_platform_data);
524 pxa_set_keypad_info(&palmld_keypad_platform_data);
525 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
527 platform_add_devices(devices, ARRAY_SIZE(devices));
530 MACHINE_START(PALMLD, "Palm LifeDrive")
531 .phys_io = PALMLD_PHYS_IO_START,
532 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
533 .boot_params = 0xa0000100,
534 .map_io = palmld_map_io,
535 .init_irq = pxa27x_init_irq,
537 .init_machine = palmld_init