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
,
67 GPIO108_GPIO
, /* ir disable */
72 GPIO100_KP_MKIN_0
| WAKEUP_ON_LEVEL_HIGH
,
73 GPIO101_KP_MKIN_1
| WAKEUP_ON_LEVEL_HIGH
,
74 GPIO102_KP_MKIN_2
| WAKEUP_ON_LEVEL_HIGH
,
75 GPIO97_KP_MKIN_3
| WAKEUP_ON_LEVEL_HIGH
,
106 GPIO10_GPIO
, /* hotsync button */
107 GPIO12_GPIO
, /* power switch */
108 GPIO15_GPIO
, /* lock switch */
111 GPIO52_GPIO
, /* green led */
112 GPIO94_GPIO
, /* orange led */
125 GPIO36_GPIO
, /* wifi power */
126 GPIO38_GPIO
, /* wifi ready */
127 GPIO81_GPIO
, /* wifi reset */
130 GPIO95_GPIO
, /* HDD irq */
131 GPIO115_GPIO
, /* HDD power */
134 GPIO13_GPIO
, /* earphone detect */
137 /******************************************************************************
138 * SD/MMC card controller
139 ******************************************************************************/
140 static int palmld_mci_init(struct device
*dev
, irq_handler_t palmld_detect_int
,
145 /* Setup an interrupt for detecting card insert/remove events */
146 err
= gpio_request(GPIO_NR_PALMLD_SD_DETECT_N
, "SD IRQ");
149 err
= gpio_direction_input(GPIO_NR_PALMLD_SD_DETECT_N
);
152 err
= request_irq(gpio_to_irq(GPIO_NR_PALMLD_SD_DETECT_N
),
153 palmld_detect_int
, IRQF_DISABLED
| IRQF_SAMPLE_RANDOM
|
154 IRQF_TRIGGER_FALLING
| IRQF_TRIGGER_RISING
,
155 "SD/MMC card detect", data
);
157 printk(KERN_ERR
"%s: cannot request SD/MMC card detect IRQ\n",
162 err
= gpio_request(GPIO_NR_PALMLD_SD_POWER
, "SD_POWER");
165 err
= gpio_direction_output(GPIO_NR_PALMLD_SD_POWER
, 0);
169 err
= gpio_request(GPIO_NR_PALMLD_SD_READONLY
, "SD_READONLY");
172 err
= gpio_direction_input(GPIO_NR_PALMLD_SD_READONLY
);
176 printk(KERN_DEBUG
"%s: irq registered\n", __func__
);
181 gpio_free(GPIO_NR_PALMLD_SD_READONLY
);
183 gpio_free(GPIO_NR_PALMLD_SD_POWER
);
185 free_irq(gpio_to_irq(GPIO_NR_PALMLD_SD_DETECT_N
), data
);
187 gpio_free(GPIO_NR_PALMLD_SD_DETECT_N
);
192 static void palmld_mci_exit(struct device
*dev
, void *data
)
194 gpio_free(GPIO_NR_PALMLD_SD_READONLY
);
195 gpio_free(GPIO_NR_PALMLD_SD_POWER
);
196 free_irq(gpio_to_irq(GPIO_NR_PALMLD_SD_DETECT_N
), data
);
197 gpio_free(GPIO_NR_PALMLD_SD_DETECT_N
);
200 static void palmld_mci_power(struct device
*dev
, unsigned int vdd
)
202 struct pxamci_platform_data
*p_d
= dev
->platform_data
;
203 gpio_set_value(GPIO_NR_PALMLD_SD_POWER
, p_d
->ocr_mask
& (1 << vdd
));
206 static int palmld_mci_get_ro(struct device
*dev
)
208 return gpio_get_value(GPIO_NR_PALMLD_SD_READONLY
);
211 static struct pxamci_platform_data palmld_mci_platform_data
= {
212 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
213 .setpower
= palmld_mci_power
,
214 .get_ro
= palmld_mci_get_ro
,
215 .init
= palmld_mci_init
,
216 .exit
= palmld_mci_exit
,
219 /******************************************************************************
221 ******************************************************************************/
222 static unsigned int palmld_matrix_keys
[] = {
228 KEY(1, 2, KEY_RIGHT
),
235 KEY(3, 1, KEY_ENTER
),
239 static struct pxa27x_keypad_platform_data palmld_keypad_platform_data
= {
240 .matrix_key_rows
= 4,
241 .matrix_key_cols
= 3,
242 .matrix_key_map
= palmld_matrix_keys
,
243 .matrix_key_map_size
= ARRAY_SIZE(palmld_matrix_keys
),
245 .debounce_interval
= 30,
248 /******************************************************************************
250 ******************************************************************************/
251 static struct gpio_keys_button palmld_pxa_buttons
[] = {
252 {KEY_F8
, GPIO_NR_PALMLD_HOTSYNC_BUTTON_N
, 1, "HotSync Button" },
253 {KEY_F9
, GPIO_NR_PALMLD_LOCK_SWITCH
, 0, "Lock Switch" },
254 {KEY_POWER
, GPIO_NR_PALMLD_POWER_SWITCH
, 0, "Power Switch" },
257 static struct gpio_keys_platform_data palmld_pxa_keys_data
= {
258 .buttons
= palmld_pxa_buttons
,
259 .nbuttons
= ARRAY_SIZE(palmld_pxa_buttons
),
262 static struct platform_device palmld_pxa_keys
= {
266 .platform_data
= &palmld_pxa_keys_data
,
270 /******************************************************************************
272 ******************************************************************************/
273 static int palmld_backlight_init(struct device
*dev
)
277 ret
= gpio_request(GPIO_NR_PALMLD_BL_POWER
, "BL POWER");
280 ret
= gpio_direction_output(GPIO_NR_PALMLD_BL_POWER
, 0);
283 ret
= gpio_request(GPIO_NR_PALMLD_LCD_POWER
, "LCD POWER");
286 ret
= gpio_direction_output(GPIO_NR_PALMLD_LCD_POWER
, 0);
292 gpio_free(GPIO_NR_PALMLD_LCD_POWER
);
294 gpio_free(GPIO_NR_PALMLD_BL_POWER
);
299 static int palmld_backlight_notify(int brightness
)
301 gpio_set_value(GPIO_NR_PALMLD_BL_POWER
, brightness
);
302 gpio_set_value(GPIO_NR_PALMLD_LCD_POWER
, brightness
);
306 static void palmld_backlight_exit(struct device
*dev
)
308 gpio_free(GPIO_NR_PALMLD_BL_POWER
);
309 gpio_free(GPIO_NR_PALMLD_LCD_POWER
);
312 static struct platform_pwm_backlight_data palmld_backlight_data
= {
314 .max_brightness
= PALMLD_MAX_INTENSITY
,
315 .dft_brightness
= PALMLD_MAX_INTENSITY
,
316 .pwm_period_ns
= PALMLD_PERIOD_NS
,
317 .init
= palmld_backlight_init
,
318 .notify
= palmld_backlight_notify
,
319 .exit
= palmld_backlight_exit
,
322 static struct platform_device palmld_backlight
= {
323 .name
= "pwm-backlight",
325 .parent
= &pxa27x_device_pwm0
.dev
,
326 .platform_data
= &palmld_backlight_data
,
330 /******************************************************************************
332 ******************************************************************************/
333 static int palmld_irda_startup(struct device
*dev
)
336 err
= gpio_request(GPIO_NR_PALMLD_IR_DISABLE
, "IR DISABLE");
339 err
= gpio_direction_output(GPIO_NR_PALMLD_IR_DISABLE
, 1);
341 gpio_free(GPIO_NR_PALMLD_IR_DISABLE
);
346 static void palmld_irda_shutdown(struct device
*dev
)
348 gpio_free(GPIO_NR_PALMLD_IR_DISABLE
);
351 static void palmld_irda_transceiver_mode(struct device
*dev
, int mode
)
353 gpio_set_value(GPIO_NR_PALMLD_IR_DISABLE
, mode
& IR_OFF
);
354 pxa2xx_transceiver_mode(dev
, mode
);
357 static struct pxaficp_platform_data palmld_ficp_platform_data
= {
358 .startup
= palmld_irda_startup
,
359 .shutdown
= palmld_irda_shutdown
,
360 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
361 .transceiver_mode
= palmld_irda_transceiver_mode
,
364 /******************************************************************************
366 ******************************************************************************/
367 struct gpio_led gpio_leds
[] = {
369 .name
= "palmld:green:led",
370 .default_trigger
= "none",
371 .gpio
= GPIO_NR_PALMLD_LED_GREEN
,
373 .name
= "palmld:amber:led",
374 .default_trigger
= "none",
375 .gpio
= GPIO_NR_PALMLD_LED_AMBER
,
379 static struct gpio_led_platform_data gpio_led_info
= {
381 .num_leds
= ARRAY_SIZE(gpio_leds
),
384 static struct platform_device palmld_leds
= {
388 .platform_data
= &gpio_led_info
,
392 /******************************************************************************
394 ******************************************************************************/
395 static int power_supply_init(struct device
*dev
)
399 ret
= gpio_request(GPIO_NR_PALMLD_POWER_DETECT
, "CABLE_STATE_AC");
402 ret
= gpio_direction_input(GPIO_NR_PALMLD_POWER_DETECT
);
406 ret
= gpio_request(GPIO_NR_PALMLD_USB_DETECT_N
, "CABLE_STATE_USB");
409 ret
= gpio_direction_input(GPIO_NR_PALMLD_USB_DETECT_N
);
416 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N
);
418 gpio_free(GPIO_NR_PALMLD_POWER_DETECT
);
423 static int palmld_is_ac_online(void)
425 return gpio_get_value(GPIO_NR_PALMLD_POWER_DETECT
);
428 static int palmld_is_usb_online(void)
430 return !gpio_get_value(GPIO_NR_PALMLD_USB_DETECT_N
);
433 static void power_supply_exit(struct device
*dev
)
435 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N
);
436 gpio_free(GPIO_NR_PALMLD_POWER_DETECT
);
439 static char *palmld_supplicants
[] = {
443 static struct pda_power_pdata power_supply_info
= {
444 .init
= power_supply_init
,
445 .is_ac_online
= palmld_is_ac_online
,
446 .is_usb_online
= palmld_is_usb_online
,
447 .exit
= power_supply_exit
,
448 .supplied_to
= palmld_supplicants
,
449 .num_supplicants
= ARRAY_SIZE(palmld_supplicants
),
452 static struct platform_device power_supply
= {
456 .platform_data
= &power_supply_info
,
460 /******************************************************************************
462 ******************************************************************************/
463 static struct wm97xx_batt_info wm97xx_batt_pdata
= {
464 .batt_aux
= WM97XX_AUX_ID3
,
465 .temp_aux
= WM97XX_AUX_ID2
,
467 .max_voltage
= PALMLD_BAT_MAX_VOLTAGE
,
468 .min_voltage
= PALMLD_BAT_MIN_VOLTAGE
,
473 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LIPO
,
474 .batt_name
= "main-batt",
477 /******************************************************************************
479 ******************************************************************************/
480 static struct palm27x_asoc_info palmld_asoc_pdata
= {
481 .jack_gpio
= GPIO_NR_PALMLD_EARPHONE_DETECT
,
484 static pxa2xx_audio_ops_t palmld_ac97_pdata
= {
488 static struct platform_device palmld_asoc
= {
489 .name
= "palm27x-asoc",
492 .platform_data
= &palmld_asoc_pdata
,
496 /******************************************************************************
498 ******************************************************************************/
499 static struct pxafb_mode_info palmld_lcd_modes
[] = {
516 static struct pxafb_mach_info palmld_lcd_screen
= {
517 .modes
= palmld_lcd_modes
,
518 .num_modes
= ARRAY_SIZE(palmld_lcd_modes
),
519 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
522 /******************************************************************************
523 * Power management - standby
524 ******************************************************************************/
526 static u32
*addr __initdata
;
527 static u32 resume
[3] __initdata
= {
528 0xe3a00101, /* mov r0, #0x40000000 */
529 0xe380060f, /* orr r0, r0, #0x00f00000 */
530 0xe590f008, /* ldr pc, [r0, #0x08] */
533 static int __init
palmld_pm_init(void)
537 /* this is where the bootloader jumps */
538 addr
= phys_to_virt(PALMLD_STR_BASE
);
540 for (i
= 0; i
< 3; i
++)
546 device_initcall(palmld_pm_init
);
549 /******************************************************************************
551 ******************************************************************************/
552 static struct platform_device
*devices
[] __initdata
= {
553 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
562 static struct map_desc palmld_io_desc
[] __initdata
= {
564 .virtual = PALMLD_IDE_VIRT
,
565 .pfn
= __phys_to_pfn(PALMLD_IDE_PHYS
),
566 .length
= PALMLD_IDE_SIZE
,
570 .virtual = PALMLD_USB_VIRT
,
571 .pfn
= __phys_to_pfn(PALMLD_USB_PHYS
),
572 .length
= PALMLD_USB_SIZE
,
577 static void __init
palmld_map_io(void)
580 iotable_init(palmld_io_desc
, ARRAY_SIZE(palmld_io_desc
));
583 static void __init
palmld_init(void)
585 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmld_pin_config
));
587 set_pxa_fb_info(&palmld_lcd_screen
);
588 pxa_set_mci_info(&palmld_mci_platform_data
);
589 pxa_set_ac97_info(&palmld_ac97_pdata
);
590 pxa_set_ficp_info(&palmld_ficp_platform_data
);
591 pxa_set_keypad_info(&palmld_keypad_platform_data
);
592 wm97xx_bat_set_pdata(&wm97xx_batt_pdata
);
594 platform_add_devices(devices
, ARRAY_SIZE(devices
));
597 MACHINE_START(PALMLD
, "Palm LifeDrive")
598 .phys_io
= PALMLD_PHYS_IO_START
,
599 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
600 .boot_params
= 0xa0000100,
601 .map_io
= palmld_map_io
,
602 .init_irq
= pxa27x_init_irq
,
604 .init_machine
= palmld_init