2 * Hardware definitions for PalmTX
4 * Author: Marek Vasut <marek.vasut@gmail.com>
7 * Alex Osborne <ato@meshy.org>
8 * Cristiano P. <cristianop@users.sourceforge.net>
9 * Jan Herman <2hp@seznam.cz>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * (find more info at www.hackndev.com)
20 #include <linux/platform_device.h>
21 #include <linux/delay.h>
22 #include <linux/irq.h>
23 #include <linux/gpio_keys.h>
24 #include <linux/input.h>
25 #include <linux/pda_power.h>
26 #include <linux/pwm_backlight.h>
27 #include <linux/gpio.h>
28 #include <linux/wm97xx_batt.h>
29 #include <linux/power_supply.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
35 #include <mach/audio.h>
36 #include <mach/palmtx.h>
38 #include <mach/pxafb.h>
39 #include <mach/pxa-regs.h>
40 #include <mach/mfp-pxa27x.h>
41 #include <mach/irda.h>
42 #include <mach/pxa27x_keypad.h>
48 /******************************************************************************
50 ******************************************************************************/
51 static unsigned long palmtx_pin_config[] __initdata = {
59 GPIO14_GPIO, /* SD detect */
60 GPIO114_GPIO, /* SD power */
61 GPIO115_GPIO, /* SD r/o switch */
65 GPIO29_AC97_SDATA_IN_0,
66 GPIO30_AC97_SDATA_OUT,
70 GPIO40_GPIO, /* ir disable */
78 GPIO13_GPIO, /* usb detect */
79 GPIO95_GPIO, /* usb power */
92 GPIO94_GPIO, /* wifi power 1 */
93 GPIO108_GPIO, /* wifi power 2 */
94 GPIO116_GPIO, /* wifi ready */
128 GPIO10_GPIO, /* hotsync button */
129 GPIO12_GPIO, /* power detect */
130 GPIO107_GPIO, /* earphone detect */
133 /******************************************************************************
134 * SD/MMC card controller
135 ******************************************************************************/
136 static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int,
141 /* Setup an interrupt for detecting card insert/remove events */
142 err = gpio_request(GPIO_NR_PALMTX_SD_DETECT_N, "SD IRQ");
145 err = gpio_direction_input(GPIO_NR_PALMTX_SD_DETECT_N);
148 err = request_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N),
149 palmtx_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
150 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
151 "SD/MMC card detect", data);
153 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
158 err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER");
161 err = gpio_direction_output(GPIO_NR_PALMTX_SD_POWER, 0);
165 err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY");
168 err = gpio_direction_input(GPIO_NR_PALMTX_SD_READONLY);
172 printk(KERN_DEBUG "%s: irq registered\n", __func__);
177 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
179 gpio_free(GPIO_NR_PALMTX_SD_POWER);
181 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
183 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
188 static void palmtx_mci_exit(struct device *dev, void *data)
190 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
191 gpio_free(GPIO_NR_PALMTX_SD_POWER);
192 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
193 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
196 static void palmtx_mci_power(struct device *dev, unsigned int vdd)
198 struct pxamci_platform_data *p_d = dev->platform_data;
199 gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd));
202 static int palmtx_mci_get_ro(struct device *dev)
204 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY);
207 static struct pxamci_platform_data palmtx_mci_platform_data = {
208 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
209 .setpower = palmtx_mci_power,
210 .get_ro = palmtx_mci_get_ro,
211 .init = palmtx_mci_init,
212 .exit = palmtx_mci_exit,
215 /******************************************************************************
217 ******************************************************************************/
218 static unsigned int palmtx_matrix_keys[] = {
219 KEY(0, 0, KEY_POWER),
221 KEY(0, 2, KEY_ENTER),
230 KEY(3, 0, KEY_RIGHT),
234 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
235 .matrix_key_rows = 4,
236 .matrix_key_cols = 3,
237 .matrix_key_map = palmtx_matrix_keys,
238 .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
240 .debounce_interval = 30,
243 /******************************************************************************
245 ******************************************************************************/
246 static struct gpio_keys_button palmtx_pxa_buttons[] = {
247 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
250 static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
251 .buttons = palmtx_pxa_buttons,
252 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
255 static struct platform_device palmtx_pxa_keys = {
259 .platform_data = &palmtx_pxa_keys_data,
263 /******************************************************************************
265 ******************************************************************************/
266 static int palmtx_backlight_init(struct device *dev)
270 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
273 ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
276 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
279 ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
285 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
287 gpio_free(GPIO_NR_PALMTX_BL_POWER);
292 static int palmtx_backlight_notify(int brightness)
294 gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
295 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
299 static void palmtx_backlight_exit(struct device *dev)
301 gpio_free(GPIO_NR_PALMTX_BL_POWER);
302 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
305 static struct platform_pwm_backlight_data palmtx_backlight_data = {
307 .max_brightness = PALMTX_MAX_INTENSITY,
308 .dft_brightness = PALMTX_MAX_INTENSITY,
309 .pwm_period_ns = PALMTX_PERIOD_NS,
310 .init = palmtx_backlight_init,
311 .notify = palmtx_backlight_notify,
312 .exit = palmtx_backlight_exit,
315 static struct platform_device palmtx_backlight = {
316 .name = "pwm-backlight",
318 .parent = &pxa27x_device_pwm0.dev,
319 .platform_data = &palmtx_backlight_data,
323 /******************************************************************************
325 ******************************************************************************/
326 static int palmtx_irda_startup(struct device *dev)
329 err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
332 err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
334 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
339 static void palmtx_irda_shutdown(struct device *dev)
341 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
344 static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
346 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
347 pxa2xx_transceiver_mode(dev, mode);
350 static struct pxaficp_platform_data palmtx_ficp_platform_data = {
351 .startup = palmtx_irda_startup,
352 .shutdown = palmtx_irda_shutdown,
353 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
354 .transceiver_mode = palmtx_irda_transceiver_mode,
357 /******************************************************************************
359 ******************************************************************************/
360 static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = {
361 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
362 .gpio_vbus_inverted = 1,
363 .gpio_pullup = GPIO_NR_PALMTX_USB_POWER,
364 .gpio_pullup_inverted = 0,
367 /******************************************************************************
369 ******************************************************************************/
370 static int power_supply_init(struct device *dev)
374 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
377 ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
384 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
389 static int palmtx_is_ac_online(void)
391 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
394 static void power_supply_exit(struct device *dev)
396 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
399 static char *palmtx_supplicants[] = {
403 static struct pda_power_pdata power_supply_info = {
404 .init = power_supply_init,
405 .is_ac_online = palmtx_is_ac_online,
406 .exit = power_supply_exit,
407 .supplied_to = palmtx_supplicants,
408 .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
411 static struct platform_device power_supply = {
415 .platform_data = &power_supply_info,
419 /******************************************************************************
421 ******************************************************************************/
422 static struct wm97xx_batt_info wm97xx_batt_pdata = {
423 .batt_aux = WM97XX_AUX_ID3,
424 .temp_aux = WM97XX_AUX_ID2,
426 .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
427 .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
432 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
433 .batt_name = "main-batt",
436 /******************************************************************************
438 ******************************************************************************/
439 static struct pxafb_mode_info palmtx_lcd_modes[] = {
456 static struct pxafb_mach_info palmtx_lcd_screen = {
457 .modes = palmtx_lcd_modes,
458 .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
459 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
462 /******************************************************************************
464 ******************************************************************************/
465 static struct platform_device *devices[] __initdata = {
466 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
473 static struct map_desc palmtx_io_desc[] __initdata = {
475 .virtual = PALMTX_PCMCIA_VIRT,
476 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
477 .length = PALMTX_PCMCIA_SIZE,
482 static void __init palmtx_map_io(void)
485 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
488 /* setup udc GPIOs initial state */
489 static void __init palmtx_udc_init(void)
491 if (!gpio_request(GPIO_NR_PALMTX_USB_POWER, "UDC Vbus")) {
492 gpio_direction_output(GPIO_NR_PALMTX_USB_POWER, 1);
493 gpio_free(GPIO_NR_PALMTX_USB_POWER);
498 static void __init palmtx_init(void)
500 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
502 set_pxa_fb_info(&palmtx_lcd_screen);
503 pxa_set_mci_info(&palmtx_mci_platform_data);
505 pxa_set_udc_info(&palmtx_udc_info);
506 pxa_set_ac97_info(NULL);
507 pxa_set_ficp_info(&palmtx_ficp_platform_data);
508 pxa_set_keypad_info(&palmtx_keypad_platform_data);
509 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
511 platform_add_devices(devices, ARRAY_SIZE(devices));
514 MACHINE_START(PALMTX, "Palm T|X")
515 .phys_io = PALMTX_PHYS_IO_START,
516 .io_pg_offst = io_p2v(0x40000000),
517 .boot_params = 0xa0000100,
518 .map_io = palmtx_map_io,
519 .init_irq = pxa27x_init_irq,
521 .init_machine = palmtx_init