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>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
32 #include <mach/pxa27x.h>
33 #include <mach/audio.h>
34 #include <mach/palmld.h>
36 #include <mach/pxafb.h>
37 #include <mach/irda.h>
38 #include <mach/pxa27x_keypad.h>
39 #include <mach/palmasoc.h>
44 /******************************************************************************
46 ******************************************************************************/
47 static unsigned long palmld_pin_config[] __initdata = {
55 GPIO14_GPIO, /* SD detect */
56 GPIO114_GPIO, /* SD power */
57 GPIO116_GPIO, /* SD r/o switch */
61 GPIO29_AC97_SDATA_IN_0,
62 GPIO30_AC97_SDATA_OUT,
66 GPIO108_GPIO, /* ir disable */
105 GPIO10_GPIO, /* hotsync button */
106 GPIO12_GPIO, /* power switch */
107 GPIO15_GPIO, /* lock switch */
110 GPIO52_GPIO, /* green led */
111 GPIO94_GPIO, /* orange led */
124 GPIO36_GPIO, /* wifi power */
125 GPIO38_GPIO, /* wifi ready */
126 GPIO81_GPIO, /* wifi reset */
129 GPIO95_GPIO, /* HDD irq */
130 GPIO115_GPIO, /* HDD power */
133 GPIO13_GPIO, /* earphone detect */
136 /******************************************************************************
137 * SD/MMC card controller
138 ******************************************************************************/
139 static int palmld_mci_init(struct device *dev, irq_handler_t palmld_detect_int,
144 /* Setup an interrupt for detecting card insert/remove events */
145 err = gpio_request(GPIO_NR_PALMLD_SD_DETECT_N, "SD IRQ");
148 err = gpio_direction_input(GPIO_NR_PALMLD_SD_DETECT_N);
151 err = request_irq(gpio_to_irq(GPIO_NR_PALMLD_SD_DETECT_N),
152 palmld_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
153 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
154 "SD/MMC card detect", data);
156 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
161 err = gpio_request(GPIO_NR_PALMLD_SD_POWER, "SD_POWER");
164 err = gpio_direction_output(GPIO_NR_PALMLD_SD_POWER, 0);
168 err = gpio_request(GPIO_NR_PALMLD_SD_READONLY, "SD_READONLY");
171 err = gpio_direction_input(GPIO_NR_PALMLD_SD_READONLY);
175 printk(KERN_DEBUG "%s: irq registered\n", __func__);
180 gpio_free(GPIO_NR_PALMLD_SD_READONLY);
182 gpio_free(GPIO_NR_PALMLD_SD_POWER);
184 free_irq(gpio_to_irq(GPIO_NR_PALMLD_SD_DETECT_N), data);
186 gpio_free(GPIO_NR_PALMLD_SD_DETECT_N);
191 static void palmld_mci_exit(struct device *dev, void *data)
193 gpio_free(GPIO_NR_PALMLD_SD_READONLY);
194 gpio_free(GPIO_NR_PALMLD_SD_POWER);
195 free_irq(gpio_to_irq(GPIO_NR_PALMLD_SD_DETECT_N), data);
196 gpio_free(GPIO_NR_PALMLD_SD_DETECT_N);
199 static void palmld_mci_power(struct device *dev, unsigned int vdd)
201 struct pxamci_platform_data *p_d = dev->platform_data;
202 gpio_set_value(GPIO_NR_PALMLD_SD_POWER, p_d->ocr_mask & (1 << vdd));
205 static int palmld_mci_get_ro(struct device *dev)
207 return gpio_get_value(GPIO_NR_PALMLD_SD_READONLY);
210 static struct pxamci_platform_data palmld_mci_platform_data = {
211 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
212 .setpower = palmld_mci_power,
213 .get_ro = palmld_mci_get_ro,
214 .init = palmld_mci_init,
215 .exit = palmld_mci_exit,
218 /******************************************************************************
220 ******************************************************************************/
221 static unsigned int palmld_matrix_keys[] = {
227 KEY(1, 2, KEY_RIGHT),
234 KEY(3, 1, KEY_ENTER),
238 static struct pxa27x_keypad_platform_data palmld_keypad_platform_data = {
239 .matrix_key_rows = 4,
240 .matrix_key_cols = 3,
241 .matrix_key_map = palmld_matrix_keys,
242 .matrix_key_map_size = ARRAY_SIZE(palmld_matrix_keys),
244 .debounce_interval = 30,
247 /******************************************************************************
249 ******************************************************************************/
250 static struct gpio_keys_button palmld_pxa_buttons[] = {
251 {KEY_F8, GPIO_NR_PALMLD_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
252 {KEY_F9, GPIO_NR_PALMLD_LOCK_SWITCH, 0, "Lock Switch" },
253 {KEY_POWER, GPIO_NR_PALMLD_POWER_SWITCH, 0, "Power Switch" },
256 static struct gpio_keys_platform_data palmld_pxa_keys_data = {
257 .buttons = palmld_pxa_buttons,
258 .nbuttons = ARRAY_SIZE(palmld_pxa_buttons),
261 static struct platform_device palmld_pxa_keys = {
265 .platform_data = &palmld_pxa_keys_data,
269 /******************************************************************************
271 ******************************************************************************/
272 static int palmld_backlight_init(struct device *dev)
276 ret = gpio_request(GPIO_NR_PALMLD_BL_POWER, "BL POWER");
279 ret = gpio_direction_output(GPIO_NR_PALMLD_BL_POWER, 0);
282 ret = gpio_request(GPIO_NR_PALMLD_LCD_POWER, "LCD POWER");
285 ret = gpio_direction_output(GPIO_NR_PALMLD_LCD_POWER, 0);
291 gpio_free(GPIO_NR_PALMLD_LCD_POWER);
293 gpio_free(GPIO_NR_PALMLD_BL_POWER);
298 static int palmld_backlight_notify(int brightness)
300 gpio_set_value(GPIO_NR_PALMLD_BL_POWER, brightness);
301 gpio_set_value(GPIO_NR_PALMLD_LCD_POWER, brightness);
305 static void palmld_backlight_exit(struct device *dev)
307 gpio_free(GPIO_NR_PALMLD_BL_POWER);
308 gpio_free(GPIO_NR_PALMLD_LCD_POWER);
311 static struct platform_pwm_backlight_data palmld_backlight_data = {
313 .max_brightness = PALMLD_MAX_INTENSITY,
314 .dft_brightness = PALMLD_MAX_INTENSITY,
315 .pwm_period_ns = PALMLD_PERIOD_NS,
316 .init = palmld_backlight_init,
317 .notify = palmld_backlight_notify,
318 .exit = palmld_backlight_exit,
321 static struct platform_device palmld_backlight = {
322 .name = "pwm-backlight",
324 .parent = &pxa27x_device_pwm0.dev,
325 .platform_data = &palmld_backlight_data,
329 /******************************************************************************
331 ******************************************************************************/
332 static int palmld_irda_startup(struct device *dev)
335 err = gpio_request(GPIO_NR_PALMLD_IR_DISABLE, "IR DISABLE");
338 err = gpio_direction_output(GPIO_NR_PALMLD_IR_DISABLE, 1);
340 gpio_free(GPIO_NR_PALMLD_IR_DISABLE);
345 static void palmld_irda_shutdown(struct device *dev)
347 gpio_free(GPIO_NR_PALMLD_IR_DISABLE);
350 static void palmld_irda_transceiver_mode(struct device *dev, int mode)
352 gpio_set_value(GPIO_NR_PALMLD_IR_DISABLE, mode & IR_OFF);
353 pxa2xx_transceiver_mode(dev, mode);
356 static struct pxaficp_platform_data palmld_ficp_platform_data = {
357 .startup = palmld_irda_startup,
358 .shutdown = palmld_irda_shutdown,
359 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
360 .transceiver_mode = palmld_irda_transceiver_mode,
363 /******************************************************************************
365 ******************************************************************************/
366 struct gpio_led gpio_leds[] = {
368 .name = "palmld:green:led",
369 .default_trigger = "none",
370 .gpio = GPIO_NR_PALMLD_LED_GREEN,
372 .name = "palmld:amber:led",
373 .default_trigger = "none",
374 .gpio = GPIO_NR_PALMLD_LED_AMBER,
378 static struct gpio_led_platform_data gpio_led_info = {
380 .num_leds = ARRAY_SIZE(gpio_leds),
383 static struct platform_device palmld_leds = {
387 .platform_data = &gpio_led_info,
391 /******************************************************************************
393 ******************************************************************************/
394 static int power_supply_init(struct device *dev)
398 ret = gpio_request(GPIO_NR_PALMLD_POWER_DETECT, "CABLE_STATE_AC");
401 ret = gpio_direction_input(GPIO_NR_PALMLD_POWER_DETECT);
405 ret = gpio_request(GPIO_NR_PALMLD_USB_DETECT_N, "CABLE_STATE_USB");
408 ret = gpio_direction_input(GPIO_NR_PALMLD_USB_DETECT_N);
415 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N);
417 gpio_free(GPIO_NR_PALMLD_POWER_DETECT);
422 static int palmld_is_ac_online(void)
424 return gpio_get_value(GPIO_NR_PALMLD_POWER_DETECT);
427 static int palmld_is_usb_online(void)
429 return !gpio_get_value(GPIO_NR_PALMLD_USB_DETECT_N);
432 static void power_supply_exit(struct device *dev)
434 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N);
435 gpio_free(GPIO_NR_PALMLD_POWER_DETECT);
438 static char *palmld_supplicants[] = {
442 static struct pda_power_pdata power_supply_info = {
443 .init = power_supply_init,
444 .is_ac_online = palmld_is_ac_online,
445 .is_usb_online = palmld_is_usb_online,
446 .exit = power_supply_exit,
447 .supplied_to = palmld_supplicants,
448 .num_supplicants = ARRAY_SIZE(palmld_supplicants),
451 static struct platform_device power_supply = {
455 .platform_data = &power_supply_info,
459 /******************************************************************************
461 ******************************************************************************/
462 static struct wm97xx_batt_info wm97xx_batt_pdata = {
463 .batt_aux = WM97XX_AUX_ID3,
464 .temp_aux = WM97XX_AUX_ID2,
466 .max_voltage = PALMLD_BAT_MAX_VOLTAGE,
467 .min_voltage = PALMLD_BAT_MIN_VOLTAGE,
472 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
473 .batt_name = "main-batt",
476 /******************************************************************************
478 ******************************************************************************/
479 static struct palm27x_asoc_info palm27x_asoc_pdata = {
480 .jack_gpio = GPIO_NR_PALMLD_EARPHONE_DETECT,
483 /******************************************************************************
485 ******************************************************************************/
486 static struct pxafb_mode_info palmld_lcd_modes[] = {
503 static struct pxafb_mach_info palmld_lcd_screen = {
504 .modes = palmld_lcd_modes,
505 .num_modes = ARRAY_SIZE(palmld_lcd_modes),
506 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
509 /******************************************************************************
511 ******************************************************************************/
512 static struct platform_device *devices[] __initdata = {
513 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
521 static struct map_desc palmld_io_desc[] __initdata = {
523 .virtual = PALMLD_IDE_VIRT,
524 .pfn = __phys_to_pfn(PALMLD_IDE_PHYS),
525 .length = PALMLD_IDE_SIZE,
529 .virtual = PALMLD_USB_VIRT,
530 .pfn = __phys_to_pfn(PALMLD_USB_PHYS),
531 .length = PALMLD_USB_SIZE,
536 static void __init palmld_map_io(void)
539 iotable_init(palmld_io_desc, ARRAY_SIZE(palmld_io_desc));
542 static void __init palmld_init(void)
544 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmld_pin_config));
546 set_pxa_fb_info(&palmld_lcd_screen);
547 pxa_set_mci_info(&palmld_mci_platform_data);
548 pxa_set_ac97_info(NULL);
549 pxa_set_ficp_info(&palmld_ficp_platform_data);
550 pxa_set_keypad_info(&palmld_keypad_platform_data);
551 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
552 palm27x_asoc_set_pdata(&palm27x_asoc_pdata);
554 platform_add_devices(devices, ARRAY_SIZE(devices));
557 MACHINE_START(PALMLD, "Palm LifeDrive")
558 .phys_io = PALMLD_PHYS_IO_START,
559 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
560 .boot_params = 0xa0000100,
561 .map_io = palmld_map_io,
562 .init_irq = pxa27x_init_irq,
564 .init_machine = palmld_init