2 * Hardware definitions for Palm Tungsten|E2
5 * Carlos Eduardo Medaglia Dyonisio <cadu@nerdfeliz.com>
7 * Rewrite for mainline:
8 * Marek Vasut <marek.vasut@gmail.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * (find more info at www.hackndev.com)
18 #include <linux/platform_device.h>
19 #include <linux/delay.h>
20 #include <linux/irq.h>
21 #include <linux/gpio_keys.h>
22 #include <linux/input.h>
23 #include <linux/pda_power.h>
24 #include <linux/pwm_backlight.h>
25 #include <linux/gpio.h>
26 #include <linux/wm97xx_batt.h>
27 #include <linux/power_supply.h>
28 #include <linux/usb/gpio_vbus.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
34 #include <mach/audio.h>
35 #include <mach/palmte2.h>
37 #include <mach/pxafb.h>
38 #include <mach/mfp-pxa25x.h>
39 #include <mach/irda.h>
41 #include <mach/palmasoc.h>
46 /******************************************************************************
48 ******************************************************************************/
49 static unsigned long palmte2_pin_config[] __initdata = {
53 GPIO10_GPIO, /* SD detect */
54 GPIO55_GPIO, /* SD power */
55 GPIO51_GPIO, /* SD r/o switch */
59 GPIO29_AC97_SDATA_IN_0,
60 GPIO30_AC97_SDATA_OUT,
67 GPIO15_GPIO, /* usb detect */
68 GPIO53_GPIO, /* usb power */
71 GPIO48_GPIO, /* ir disable */
98 GPIO5_GPIO, /* notes */
99 GPIO7_GPIO, /* tasks */
100 GPIO11_GPIO, /* calendar */
101 GPIO13_GPIO, /* contacts */
102 GPIO14_GPIO, /* center */
103 GPIO19_GPIO, /* left */
104 GPIO20_GPIO, /* right */
105 GPIO21_GPIO, /* down */
106 GPIO22_GPIO, /* up */
109 GPIO1_RST, /* reset */
110 GPIO4_GPIO, /* Hotsync button */
111 GPIO9_GPIO, /* power detect */
112 GPIO15_GPIO, /* earphone detect */
113 GPIO37_GPIO, /* LCD power */
114 GPIO56_GPIO, /* Backlight power */
117 /******************************************************************************
118 * SD/MMC card controller
119 ******************************************************************************/
120 static int palmte2_mci_init(struct device *dev,
121 irq_handler_t palmte2_detect_int, void *data)
125 /* Setup an interrupt for detecting card insert/remove events */
126 err = gpio_request(GPIO_NR_PALMTE2_SD_DETECT_N, "SD IRQ");
129 err = gpio_direction_input(GPIO_NR_PALMTE2_SD_DETECT_N);
132 err = request_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N),
133 palmte2_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
134 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
135 "SD/MMC card detect", data);
137 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
142 err = gpio_request(GPIO_NR_PALMTE2_SD_POWER, "SD_POWER");
145 err = gpio_direction_output(GPIO_NR_PALMTE2_SD_POWER, 0);
149 err = gpio_request(GPIO_NR_PALMTE2_SD_READONLY, "SD_READONLY");
152 err = gpio_direction_input(GPIO_NR_PALMTE2_SD_READONLY);
156 printk(KERN_DEBUG "%s: irq registered\n", __func__);
161 gpio_free(GPIO_NR_PALMTE2_SD_READONLY);
163 gpio_free(GPIO_NR_PALMTE2_SD_POWER);
165 free_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N), data);
167 gpio_free(GPIO_NR_PALMTE2_SD_DETECT_N);
172 static void palmte2_mci_exit(struct device *dev, void *data)
174 gpio_free(GPIO_NR_PALMTE2_SD_READONLY);
175 gpio_free(GPIO_NR_PALMTE2_SD_POWER);
176 free_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N), data);
177 gpio_free(GPIO_NR_PALMTE2_SD_DETECT_N);
180 static void palmte2_mci_power(struct device *dev, unsigned int vdd)
182 struct pxamci_platform_data *p_d = dev->platform_data;
183 gpio_set_value(GPIO_NR_PALMTE2_SD_POWER, p_d->ocr_mask & (1 << vdd));
186 static int palmte2_mci_get_ro(struct device *dev)
188 return gpio_get_value(GPIO_NR_PALMTE2_SD_READONLY);
191 static struct pxamci_platform_data palmte2_mci_platform_data = {
192 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
193 .setpower = palmte2_mci_power,
194 .get_ro = palmte2_mci_get_ro,
195 .init = palmte2_mci_init,
196 .exit = palmte2_mci_exit,
199 /******************************************************************************
201 ******************************************************************************/
202 static struct gpio_keys_button palmte2_pxa_buttons[] = {
203 {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
204 {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
205 {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
206 {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
207 {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
208 {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
209 {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
210 {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
211 {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
214 static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
215 .buttons = palmte2_pxa_buttons,
216 .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
219 static struct platform_device palmte2_pxa_keys = {
223 .platform_data = &palmte2_pxa_keys_data,
227 /******************************************************************************
229 ******************************************************************************/
230 static int palmte2_backlight_init(struct device *dev)
234 ret = gpio_request(GPIO_NR_PALMTE2_BL_POWER, "BL POWER");
237 ret = gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER, 0);
240 ret = gpio_request(GPIO_NR_PALMTE2_LCD_POWER, "LCD POWER");
243 ret = gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER, 0);
249 gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
251 gpio_free(GPIO_NR_PALMTE2_BL_POWER);
256 static int palmte2_backlight_notify(int brightness)
258 gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
259 gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
263 static void palmte2_backlight_exit(struct device *dev)
265 gpio_free(GPIO_NR_PALMTE2_BL_POWER);
266 gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
269 static struct platform_pwm_backlight_data palmte2_backlight_data = {
271 .max_brightness = PALMTE2_MAX_INTENSITY,
272 .dft_brightness = PALMTE2_MAX_INTENSITY,
273 .pwm_period_ns = PALMTE2_PERIOD_NS,
274 .init = palmte2_backlight_init,
275 .notify = palmte2_backlight_notify,
276 .exit = palmte2_backlight_exit,
279 static struct platform_device palmte2_backlight = {
280 .name = "pwm-backlight",
282 .parent = &pxa25x_device_pwm0.dev,
283 .platform_data = &palmte2_backlight_data,
287 /******************************************************************************
289 ******************************************************************************/
290 static int palmte2_irda_startup(struct device *dev)
293 err = gpio_request(GPIO_NR_PALMTE2_IR_DISABLE, "IR DISABLE");
296 err = gpio_direction_output(GPIO_NR_PALMTE2_IR_DISABLE, 1);
298 gpio_free(GPIO_NR_PALMTE2_IR_DISABLE);
303 static void palmte2_irda_shutdown(struct device *dev)
305 gpio_free(GPIO_NR_PALMTE2_IR_DISABLE);
308 static void palmte2_irda_transceiver_mode(struct device *dev, int mode)
310 gpio_set_value(GPIO_NR_PALMTE2_IR_DISABLE, mode & IR_OFF);
311 pxa2xx_transceiver_mode(dev, mode);
314 static struct pxaficp_platform_data palmte2_ficp_platform_data = {
315 .startup = palmte2_irda_startup,
316 .shutdown = palmte2_irda_shutdown,
317 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
318 .transceiver_mode = palmte2_irda_transceiver_mode,
321 /******************************************************************************
323 ******************************************************************************/
324 static struct gpio_vbus_mach_info palmte2_udc_info = {
325 .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
326 .gpio_vbus_inverted = 1,
327 .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
330 static struct platform_device palmte2_gpio_vbus = {
334 .platform_data = &palmte2_udc_info,
338 /******************************************************************************
340 ******************************************************************************/
341 static int power_supply_init(struct device *dev)
345 ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
348 ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
355 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
360 static int palmte2_is_ac_online(void)
362 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
365 static void power_supply_exit(struct device *dev)
367 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
370 static char *palmte2_supplicants[] = {
374 static struct pda_power_pdata power_supply_info = {
375 .init = power_supply_init,
376 .is_ac_online = palmte2_is_ac_online,
377 .exit = power_supply_exit,
378 .supplied_to = palmte2_supplicants,
379 .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
382 static struct platform_device power_supply = {
386 .platform_data = &power_supply_info,
390 /******************************************************************************
392 ******************************************************************************/
393 static struct wm97xx_batt_info wm97xx_batt_pdata = {
394 .batt_aux = WM97XX_AUX_ID3,
395 .temp_aux = WM97XX_AUX_ID2,
397 .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
398 .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
403 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
404 .batt_name = "main-batt",
407 /******************************************************************************
409 ******************************************************************************/
410 static struct palm27x_asoc_info palmte2_asoc_pdata = {
411 .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
414 static struct platform_device palmte2_asoc = {
415 .name = "palm27x-asoc",
418 .platform_data = &palmte2_asoc_pdata,
422 /******************************************************************************
424 ******************************************************************************/
425 static struct pxafb_mode_info palmte2_lcd_modes[] = {
442 static struct pxafb_mach_info palmte2_lcd_screen = {
443 .modes = palmte2_lcd_modes,
444 .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
445 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
448 /******************************************************************************
450 ******************************************************************************/
451 static struct platform_device *devices[] __initdata = {
452 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
461 /* setup udc GPIOs initial state */
462 static void __init palmte2_udc_init(void)
464 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
465 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
466 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
470 static void __init palmte2_init(void)
472 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
474 set_pxa_fb_info(&palmte2_lcd_screen);
475 pxa_set_mci_info(&palmte2_mci_platform_data);
477 pxa_set_ac97_info(NULL);
478 pxa_set_ficp_info(&palmte2_ficp_platform_data);
479 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
481 platform_add_devices(devices, ARRAY_SIZE(devices));
484 MACHINE_START(PALMTE2, "Palm Tungsten|E2")
485 .phys_io = 0x40000000,
486 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
487 .boot_params = 0xa0000100,
488 .map_io = pxa_map_io,
489 .init_irq = pxa25x_init_irq,
491 .init_machine = palmte2_init