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 int palmld_mci_init(struct device
*dev
, irq_handler_t palmld_detect_int
,
151 /* Setup an interrupt for detecting card insert/remove events */
152 err
= gpio_request(GPIO_NR_PALMLD_SD_DETECT_N
, "SD IRQ");
155 err
= gpio_direction_input(GPIO_NR_PALMLD_SD_DETECT_N
);
158 err
= request_irq(gpio_to_irq(GPIO_NR_PALMLD_SD_DETECT_N
),
159 palmld_detect_int
, IRQF_DISABLED
| IRQF_SAMPLE_RANDOM
|
160 IRQF_TRIGGER_FALLING
| IRQF_TRIGGER_RISING
,
161 "SD/MMC card detect", data
);
163 printk(KERN_ERR
"%s: cannot request SD/MMC card detect IRQ\n",
168 err
= gpio_request(GPIO_NR_PALMLD_SD_POWER
, "SD_POWER");
171 err
= gpio_direction_output(GPIO_NR_PALMLD_SD_POWER
, 0);
175 err
= gpio_request(GPIO_NR_PALMLD_SD_READONLY
, "SD_READONLY");
178 err
= gpio_direction_input(GPIO_NR_PALMLD_SD_READONLY
);
182 printk(KERN_DEBUG
"%s: irq registered\n", __func__
);
187 gpio_free(GPIO_NR_PALMLD_SD_READONLY
);
189 gpio_free(GPIO_NR_PALMLD_SD_POWER
);
191 free_irq(gpio_to_irq(GPIO_NR_PALMLD_SD_DETECT_N
), data
);
193 gpio_free(GPIO_NR_PALMLD_SD_DETECT_N
);
198 static void palmld_mci_exit(struct device
*dev
, void *data
)
200 gpio_free(GPIO_NR_PALMLD_SD_READONLY
);
201 gpio_free(GPIO_NR_PALMLD_SD_POWER
);
202 free_irq(gpio_to_irq(GPIO_NR_PALMLD_SD_DETECT_N
), data
);
203 gpio_free(GPIO_NR_PALMLD_SD_DETECT_N
);
206 static void palmld_mci_power(struct device
*dev
, unsigned int vdd
)
208 struct pxamci_platform_data
*p_d
= dev
->platform_data
;
209 gpio_set_value(GPIO_NR_PALMLD_SD_POWER
, p_d
->ocr_mask
& (1 << vdd
));
212 static int palmld_mci_get_ro(struct device
*dev
)
214 return gpio_get_value(GPIO_NR_PALMLD_SD_READONLY
);
217 static struct pxamci_platform_data palmld_mci_platform_data
= {
218 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
219 .setpower
= palmld_mci_power
,
220 .get_ro
= palmld_mci_get_ro
,
221 .init
= palmld_mci_init
,
222 .exit
= palmld_mci_exit
,
225 /******************************************************************************
227 ******************************************************************************/
228 static unsigned int palmld_matrix_keys
[] = {
234 KEY(1, 2, KEY_RIGHT
),
241 KEY(3, 1, KEY_ENTER
),
245 static struct pxa27x_keypad_platform_data palmld_keypad_platform_data
= {
246 .matrix_key_rows
= 4,
247 .matrix_key_cols
= 3,
248 .matrix_key_map
= palmld_matrix_keys
,
249 .matrix_key_map_size
= ARRAY_SIZE(palmld_matrix_keys
),
251 .debounce_interval
= 30,
254 /******************************************************************************
256 ******************************************************************************/
257 static struct gpio_keys_button palmld_pxa_buttons
[] = {
258 {KEY_F8
, GPIO_NR_PALMLD_HOTSYNC_BUTTON_N
, 1, "HotSync Button" },
259 {KEY_F9
, GPIO_NR_PALMLD_LOCK_SWITCH
, 0, "Lock Switch" },
260 {KEY_POWER
, GPIO_NR_PALMLD_POWER_SWITCH
, 0, "Power Switch" },
263 static struct gpio_keys_platform_data palmld_pxa_keys_data
= {
264 .buttons
= palmld_pxa_buttons
,
265 .nbuttons
= ARRAY_SIZE(palmld_pxa_buttons
),
268 static struct platform_device palmld_pxa_keys
= {
272 .platform_data
= &palmld_pxa_keys_data
,
276 /******************************************************************************
278 ******************************************************************************/
279 static int palmld_backlight_init(struct device
*dev
)
283 ret
= gpio_request(GPIO_NR_PALMLD_BL_POWER
, "BL POWER");
286 ret
= gpio_direction_output(GPIO_NR_PALMLD_BL_POWER
, 0);
289 ret
= gpio_request(GPIO_NR_PALMLD_LCD_POWER
, "LCD POWER");
292 ret
= gpio_direction_output(GPIO_NR_PALMLD_LCD_POWER
, 0);
298 gpio_free(GPIO_NR_PALMLD_LCD_POWER
);
300 gpio_free(GPIO_NR_PALMLD_BL_POWER
);
305 static int palmld_backlight_notify(int brightness
)
307 gpio_set_value(GPIO_NR_PALMLD_BL_POWER
, brightness
);
308 gpio_set_value(GPIO_NR_PALMLD_LCD_POWER
, brightness
);
312 static void palmld_backlight_exit(struct device
*dev
)
314 gpio_free(GPIO_NR_PALMLD_BL_POWER
);
315 gpio_free(GPIO_NR_PALMLD_LCD_POWER
);
318 static struct platform_pwm_backlight_data palmld_backlight_data
= {
320 .max_brightness
= PALMLD_MAX_INTENSITY
,
321 .dft_brightness
= PALMLD_MAX_INTENSITY
,
322 .pwm_period_ns
= PALMLD_PERIOD_NS
,
323 .init
= palmld_backlight_init
,
324 .notify
= palmld_backlight_notify
,
325 .exit
= palmld_backlight_exit
,
328 static struct platform_device palmld_backlight
= {
329 .name
= "pwm-backlight",
331 .parent
= &pxa27x_device_pwm0
.dev
,
332 .platform_data
= &palmld_backlight_data
,
336 /******************************************************************************
338 ******************************************************************************/
339 static int palmld_irda_startup(struct device
*dev
)
342 err
= gpio_request(GPIO_NR_PALMLD_IR_DISABLE
, "IR DISABLE");
345 err
= gpio_direction_output(GPIO_NR_PALMLD_IR_DISABLE
, 1);
347 gpio_free(GPIO_NR_PALMLD_IR_DISABLE
);
352 static void palmld_irda_shutdown(struct device
*dev
)
354 gpio_free(GPIO_NR_PALMLD_IR_DISABLE
);
357 static void palmld_irda_transceiver_mode(struct device
*dev
, int mode
)
359 gpio_set_value(GPIO_NR_PALMLD_IR_DISABLE
, mode
& IR_OFF
);
360 pxa2xx_transceiver_mode(dev
, mode
);
363 static struct pxaficp_platform_data palmld_ficp_platform_data
= {
364 .startup
= palmld_irda_startup
,
365 .shutdown
= palmld_irda_shutdown
,
366 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
367 .transceiver_mode
= palmld_irda_transceiver_mode
,
370 /******************************************************************************
372 ******************************************************************************/
373 struct gpio_led gpio_leds
[] = {
375 .name
= "palmld:green:led",
376 .default_trigger
= "none",
377 .gpio
= GPIO_NR_PALMLD_LED_GREEN
,
379 .name
= "palmld:amber:led",
380 .default_trigger
= "none",
381 .gpio
= GPIO_NR_PALMLD_LED_AMBER
,
385 static struct gpio_led_platform_data gpio_led_info
= {
387 .num_leds
= ARRAY_SIZE(gpio_leds
),
390 static struct platform_device palmld_leds
= {
394 .platform_data
= &gpio_led_info
,
398 /******************************************************************************
400 ******************************************************************************/
401 static int power_supply_init(struct device
*dev
)
405 ret
= gpio_request(GPIO_NR_PALMLD_POWER_DETECT
, "CABLE_STATE_AC");
408 ret
= gpio_direction_input(GPIO_NR_PALMLD_POWER_DETECT
);
412 ret
= gpio_request(GPIO_NR_PALMLD_USB_DETECT_N
, "CABLE_STATE_USB");
415 ret
= gpio_direction_input(GPIO_NR_PALMLD_USB_DETECT_N
);
422 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N
);
424 gpio_free(GPIO_NR_PALMLD_POWER_DETECT
);
429 static int palmld_is_ac_online(void)
431 return gpio_get_value(GPIO_NR_PALMLD_POWER_DETECT
);
434 static int palmld_is_usb_online(void)
436 return !gpio_get_value(GPIO_NR_PALMLD_USB_DETECT_N
);
439 static void power_supply_exit(struct device
*dev
)
441 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N
);
442 gpio_free(GPIO_NR_PALMLD_POWER_DETECT
);
445 static char *palmld_supplicants
[] = {
449 static struct pda_power_pdata power_supply_info
= {
450 .init
= power_supply_init
,
451 .is_ac_online
= palmld_is_ac_online
,
452 .is_usb_online
= palmld_is_usb_online
,
453 .exit
= power_supply_exit
,
454 .supplied_to
= palmld_supplicants
,
455 .num_supplicants
= ARRAY_SIZE(palmld_supplicants
),
458 static struct platform_device power_supply
= {
462 .platform_data
= &power_supply_info
,
466 /******************************************************************************
468 ******************************************************************************/
469 static struct wm97xx_batt_info wm97xx_batt_pdata
= {
470 .batt_aux
= WM97XX_AUX_ID3
,
471 .temp_aux
= WM97XX_AUX_ID2
,
473 .max_voltage
= PALMLD_BAT_MAX_VOLTAGE
,
474 .min_voltage
= PALMLD_BAT_MIN_VOLTAGE
,
479 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LIPO
,
480 .batt_name
= "main-batt",
483 /******************************************************************************
485 ******************************************************************************/
486 static struct palm27x_asoc_info palmld_asoc_pdata
= {
487 .jack_gpio
= GPIO_NR_PALMLD_EARPHONE_DETECT
,
490 static pxa2xx_audio_ops_t palmld_ac97_pdata
= {
494 static struct platform_device palmld_asoc
= {
495 .name
= "palm27x-asoc",
498 .platform_data
= &palmld_asoc_pdata
,
502 /******************************************************************************
504 ******************************************************************************/
505 static struct platform_device palmld_hdd
= {
506 .name
= "pata_palmld",
510 /******************************************************************************
512 ******************************************************************************/
513 static struct pxafb_mode_info palmld_lcd_modes
[] = {
530 static struct pxafb_mach_info palmld_lcd_screen
= {
531 .modes
= palmld_lcd_modes
,
532 .num_modes
= ARRAY_SIZE(palmld_lcd_modes
),
533 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
536 /******************************************************************************
537 * Power management - standby
538 ******************************************************************************/
539 static void __init
palmld_pm_init(void)
541 static u32 resume
[] = {
542 0xe3a00101, /* mov r0, #0x40000000 */
543 0xe380060f, /* orr r0, r0, #0x00f00000 */
544 0xe590f008, /* ldr pc, [r0, #0x08] */
547 /* copy the bootloader */
548 memcpy(phys_to_virt(PALMLD_STR_BASE
), resume
, sizeof(resume
));
551 /******************************************************************************
553 ******************************************************************************/
554 static struct platform_device
*devices
[] __initdata
= {
555 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
565 static struct map_desc palmld_io_desc
[] __initdata
= {
567 .virtual = PALMLD_IDE_VIRT
,
568 .pfn
= __phys_to_pfn(PALMLD_IDE_PHYS
),
569 .length
= PALMLD_IDE_SIZE
,
573 .virtual = PALMLD_USB_VIRT
,
574 .pfn
= __phys_to_pfn(PALMLD_USB_PHYS
),
575 .length
= PALMLD_USB_SIZE
,
580 static void __init
palmld_map_io(void)
583 iotable_init(palmld_io_desc
, ARRAY_SIZE(palmld_io_desc
));
586 static void __init
palmld_init(void)
588 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmld_pin_config
));
591 set_pxa_fb_info(&palmld_lcd_screen
);
592 pxa_set_mci_info(&palmld_mci_platform_data
);
593 pxa_set_ac97_info(&palmld_ac97_pdata
);
594 pxa_set_ficp_info(&palmld_ficp_platform_data
);
595 pxa_set_keypad_info(&palmld_keypad_platform_data
);
596 wm97xx_bat_set_pdata(&wm97xx_batt_pdata
);
598 platform_add_devices(devices
, ARRAY_SIZE(devices
));
601 MACHINE_START(PALMLD
, "Palm LifeDrive")
602 .phys_io
= PALMLD_PHYS_IO_START
,
603 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
604 .boot_params
= 0xa0000100,
605 .map_io
= palmld_map_io
,
606 .init_irq
= pxa27x_init_irq
,
608 .init_machine
= palmld_init