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/pxa27x.h>
36 #include <mach/audio.h>
37 #include <mach/palmtx.h>
39 #include <mach/pxafb.h>
40 #include <mach/irda.h>
41 #include <mach/pxa27x_keypad.h>
43 #include <mach/palmasoc.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,
72 GPIO40_GPIO, /* ir disable */
80 GPIO13_GPIO, /* usb detect */
81 GPIO93_GPIO, /* usb power */
94 GPIO94_GPIO, /* wifi power 1 */
95 GPIO108_GPIO, /* wifi power 2 */
96 GPIO116_GPIO, /* wifi ready */
99 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
100 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
101 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
102 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
130 GPIO10_GPIO, /* hotsync button */
131 GPIO12_GPIO, /* power detect */
132 GPIO107_GPIO, /* earphone detect */
135 /******************************************************************************
136 * SD/MMC card controller
137 ******************************************************************************/
138 static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int,
143 /* Setup an interrupt for detecting card insert/remove events */
144 err = gpio_request(GPIO_NR_PALMTX_SD_DETECT_N, "SD IRQ");
147 err = gpio_direction_input(GPIO_NR_PALMTX_SD_DETECT_N);
150 err = request_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N),
151 palmtx_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
152 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
153 "SD/MMC card detect", data);
155 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
160 err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER");
163 err = gpio_direction_output(GPIO_NR_PALMTX_SD_POWER, 0);
167 err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY");
170 err = gpio_direction_input(GPIO_NR_PALMTX_SD_READONLY);
174 printk(KERN_DEBUG "%s: irq registered\n", __func__);
179 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
181 gpio_free(GPIO_NR_PALMTX_SD_POWER);
183 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
185 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
190 static void palmtx_mci_exit(struct device *dev, void *data)
192 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
193 gpio_free(GPIO_NR_PALMTX_SD_POWER);
194 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
195 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
198 static void palmtx_mci_power(struct device *dev, unsigned int vdd)
200 struct pxamci_platform_data *p_d = dev->platform_data;
201 gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd));
204 static int palmtx_mci_get_ro(struct device *dev)
206 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY);
209 static struct pxamci_platform_data palmtx_mci_platform_data = {
210 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
211 .setpower = palmtx_mci_power,
212 .get_ro = palmtx_mci_get_ro,
213 .init = palmtx_mci_init,
214 .exit = palmtx_mci_exit,
217 /******************************************************************************
219 ******************************************************************************/
220 static unsigned int palmtx_matrix_keys[] = {
221 KEY(0, 0, KEY_POWER),
223 KEY(0, 2, KEY_ENTER),
232 KEY(3, 0, KEY_RIGHT),
236 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
237 .matrix_key_rows = 4,
238 .matrix_key_cols = 3,
239 .matrix_key_map = palmtx_matrix_keys,
240 .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
242 .debounce_interval = 30,
245 /******************************************************************************
247 ******************************************************************************/
248 static struct gpio_keys_button palmtx_pxa_buttons[] = {
249 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
252 static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
253 .buttons = palmtx_pxa_buttons,
254 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
257 static struct platform_device palmtx_pxa_keys = {
261 .platform_data = &palmtx_pxa_keys_data,
265 /******************************************************************************
267 ******************************************************************************/
268 static int palmtx_backlight_init(struct device *dev)
272 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
275 ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
278 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
281 ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
287 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
289 gpio_free(GPIO_NR_PALMTX_BL_POWER);
294 static int palmtx_backlight_notify(int brightness)
296 gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
297 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
301 static void palmtx_backlight_exit(struct device *dev)
303 gpio_free(GPIO_NR_PALMTX_BL_POWER);
304 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
307 static struct platform_pwm_backlight_data palmtx_backlight_data = {
309 .max_brightness = PALMTX_MAX_INTENSITY,
310 .dft_brightness = PALMTX_MAX_INTENSITY,
311 .pwm_period_ns = PALMTX_PERIOD_NS,
312 .init = palmtx_backlight_init,
313 .notify = palmtx_backlight_notify,
314 .exit = palmtx_backlight_exit,
317 static struct platform_device palmtx_backlight = {
318 .name = "pwm-backlight",
320 .parent = &pxa27x_device_pwm0.dev,
321 .platform_data = &palmtx_backlight_data,
325 /******************************************************************************
327 ******************************************************************************/
328 static int palmtx_irda_startup(struct device *dev)
331 err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
334 err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
336 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
341 static void palmtx_irda_shutdown(struct device *dev)
343 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
346 static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
348 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
349 pxa2xx_transceiver_mode(dev, mode);
352 static struct pxaficp_platform_data palmtx_ficp_platform_data = {
353 .startup = palmtx_irda_startup,
354 .shutdown = palmtx_irda_shutdown,
355 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
356 .transceiver_mode = palmtx_irda_transceiver_mode,
359 /******************************************************************************
361 ******************************************************************************/
362 static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = {
363 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
364 .gpio_vbus_inverted = 1,
365 .gpio_pullup = GPIO_NR_PALMTX_USB_PULLUP,
366 .gpio_pullup_inverted = 0,
369 /******************************************************************************
371 ******************************************************************************/
372 static int power_supply_init(struct device *dev)
376 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
379 ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
386 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
391 static int palmtx_is_ac_online(void)
393 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
396 static void power_supply_exit(struct device *dev)
398 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
401 static char *palmtx_supplicants[] = {
405 static struct pda_power_pdata power_supply_info = {
406 .init = power_supply_init,
407 .is_ac_online = palmtx_is_ac_online,
408 .exit = power_supply_exit,
409 .supplied_to = palmtx_supplicants,
410 .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
413 static struct platform_device power_supply = {
417 .platform_data = &power_supply_info,
421 /******************************************************************************
423 ******************************************************************************/
424 static struct wm97xx_batt_info wm97xx_batt_pdata = {
425 .batt_aux = WM97XX_AUX_ID3,
426 .temp_aux = WM97XX_AUX_ID2,
428 .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
429 .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
434 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
435 .batt_name = "main-batt",
438 /******************************************************************************
440 ******************************************************************************/
441 static struct palm27x_asoc_info palmtx_asoc_pdata = {
442 .jack_gpio = GPIO_NR_PALMTX_EARPHONE_DETECT,
445 static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
449 static struct platform_device palmtx_asoc = {
450 .name = "palm27x-asoc",
453 .platform_data = &palmtx_asoc_pdata,
457 /******************************************************************************
459 ******************************************************************************/
460 static struct pxafb_mode_info palmtx_lcd_modes[] = {
477 static struct pxafb_mach_info palmtx_lcd_screen = {
478 .modes = palmtx_lcd_modes,
479 .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
480 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
483 /******************************************************************************
484 * Power management - standby
485 ******************************************************************************/
487 static u32 *addr __initdata;
488 static u32 resume[3] __initdata = {
489 0xe3a00101, /* mov r0, #0x40000000 */
490 0xe380060f, /* orr r0, r0, #0x00f00000 */
491 0xe590f008, /* ldr pc, [r0, #0x08] */
494 static int __init palmtx_pm_init(void)
498 /* this is where the bootloader jumps */
499 addr = phys_to_virt(PALMTX_STR_BASE);
501 for (i = 0; i < 3; i++)
507 device_initcall(palmtx_pm_init);
510 /******************************************************************************
512 ******************************************************************************/
513 static struct platform_device *devices[] __initdata = {
514 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
522 static struct map_desc palmtx_io_desc[] __initdata = {
524 .virtual = PALMTX_PCMCIA_VIRT,
525 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
526 .length = PALMTX_PCMCIA_SIZE,
531 static void __init palmtx_map_io(void)
534 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
537 /* setup udc GPIOs initial state */
538 static void __init palmtx_udc_init(void)
540 if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP, "UDC Vbus")) {
541 gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP, 1);
542 gpio_free(GPIO_NR_PALMTX_USB_PULLUP);
547 static void __init palmtx_init(void)
549 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
551 set_pxa_fb_info(&palmtx_lcd_screen);
552 pxa_set_mci_info(&palmtx_mci_platform_data);
554 pxa_set_ac97_info(&palmtx_ac97_pdata);
555 pxa_set_udc_info(&palmtx_udc_info);
556 pxa_set_ficp_info(&palmtx_ficp_platform_data);
557 pxa_set_keypad_info(&palmtx_keypad_platform_data);
558 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
560 platform_add_devices(devices, ARRAY_SIZE(devices));
563 MACHINE_START(PALMTX, "Palm T|X")
564 .phys_io = PALMTX_PHYS_IO_START,
565 .io_pg_offst = io_p2v(0x40000000),
566 .boot_params = 0xa0000100,
567 .map_io = palmtx_map_io,
568 .init_irq = pxa27x_init_irq,
570 .init_machine = palmtx_init