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>
47 /******************************************************************************
49 ******************************************************************************/
50 static unsigned long palmtx_pin_config[] __initdata = {
58 GPIO14_GPIO, /* SD detect */
59 GPIO114_GPIO, /* SD power */
60 GPIO115_GPIO, /* SD r/o switch */
64 GPIO29_AC97_SDATA_IN_0,
65 GPIO30_AC97_SDATA_OUT,
69 GPIO40_GPIO, /* ir disable */
77 GPIO13_GPIO, /* usb detect */
78 GPIO95_GPIO, /* usb power */
91 GPIO94_GPIO, /* wifi power 1 */
92 GPIO108_GPIO, /* wifi power 2 */
93 GPIO116_GPIO, /* wifi ready */
96 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
97 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
98 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
99 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
127 GPIO10_GPIO, /* hotsync button */
128 GPIO12_GPIO, /* power detect */
129 GPIO107_GPIO, /* earphone detect */
132 /******************************************************************************
133 * SD/MMC card controller
134 ******************************************************************************/
135 static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int,
140 /* Setup an interrupt for detecting card insert/remove events */
141 err = gpio_request(GPIO_NR_PALMTX_SD_DETECT_N, "SD IRQ");
144 err = gpio_direction_input(GPIO_NR_PALMTX_SD_DETECT_N);
147 err = request_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N),
148 palmtx_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
149 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
150 "SD/MMC card detect", data);
152 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
157 err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER");
160 err = gpio_direction_output(GPIO_NR_PALMTX_SD_POWER, 0);
164 err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY");
167 err = gpio_direction_input(GPIO_NR_PALMTX_SD_READONLY);
171 printk(KERN_DEBUG "%s: irq registered\n", __func__);
176 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
178 gpio_free(GPIO_NR_PALMTX_SD_POWER);
180 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
182 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
187 static void palmtx_mci_exit(struct device *dev, void *data)
189 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
190 gpio_free(GPIO_NR_PALMTX_SD_POWER);
191 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
192 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
195 static void palmtx_mci_power(struct device *dev, unsigned int vdd)
197 struct pxamci_platform_data *p_d = dev->platform_data;
198 gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd));
201 static int palmtx_mci_get_ro(struct device *dev)
203 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY);
206 static struct pxamci_platform_data palmtx_mci_platform_data = {
207 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
208 .setpower = palmtx_mci_power,
209 .get_ro = palmtx_mci_get_ro,
210 .init = palmtx_mci_init,
211 .exit = palmtx_mci_exit,
214 /******************************************************************************
216 ******************************************************************************/
217 static unsigned int palmtx_matrix_keys[] = {
218 KEY(0, 0, KEY_POWER),
220 KEY(0, 2, KEY_ENTER),
229 KEY(3, 0, KEY_RIGHT),
233 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
234 .matrix_key_rows = 4,
235 .matrix_key_cols = 3,
236 .matrix_key_map = palmtx_matrix_keys,
237 .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
239 .debounce_interval = 30,
242 /******************************************************************************
244 ******************************************************************************/
245 static struct gpio_keys_button palmtx_pxa_buttons[] = {
246 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
249 static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
250 .buttons = palmtx_pxa_buttons,
251 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
254 static struct platform_device palmtx_pxa_keys = {
258 .platform_data = &palmtx_pxa_keys_data,
262 /******************************************************************************
264 ******************************************************************************/
265 static int palmtx_backlight_init(struct device *dev)
269 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
272 ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
275 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
278 ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
284 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
286 gpio_free(GPIO_NR_PALMTX_BL_POWER);
291 static int palmtx_backlight_notify(int brightness)
293 gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
294 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
298 static void palmtx_backlight_exit(struct device *dev)
300 gpio_free(GPIO_NR_PALMTX_BL_POWER);
301 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
304 static struct platform_pwm_backlight_data palmtx_backlight_data = {
306 .max_brightness = PALMTX_MAX_INTENSITY,
307 .dft_brightness = PALMTX_MAX_INTENSITY,
308 .pwm_period_ns = PALMTX_PERIOD_NS,
309 .init = palmtx_backlight_init,
310 .notify = palmtx_backlight_notify,
311 .exit = palmtx_backlight_exit,
314 static struct platform_device palmtx_backlight = {
315 .name = "pwm-backlight",
317 .parent = &pxa27x_device_pwm0.dev,
318 .platform_data = &palmtx_backlight_data,
322 /******************************************************************************
324 ******************************************************************************/
325 static int palmtx_irda_startup(struct device *dev)
328 err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
331 err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
333 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
338 static void palmtx_irda_shutdown(struct device *dev)
340 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
343 static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
345 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
346 pxa2xx_transceiver_mode(dev, mode);
349 static struct pxaficp_platform_data palmtx_ficp_platform_data = {
350 .startup = palmtx_irda_startup,
351 .shutdown = palmtx_irda_shutdown,
352 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
353 .transceiver_mode = palmtx_irda_transceiver_mode,
356 /******************************************************************************
358 ******************************************************************************/
359 static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = {
360 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
361 .gpio_vbus_inverted = 1,
362 .gpio_pullup = GPIO_NR_PALMTX_USB_POWER,
363 .gpio_pullup_inverted = 0,
366 /******************************************************************************
368 ******************************************************************************/
369 static int power_supply_init(struct device *dev)
373 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
376 ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
383 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
388 static int palmtx_is_ac_online(void)
390 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
393 static void power_supply_exit(struct device *dev)
395 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
398 static char *palmtx_supplicants[] = {
402 static struct pda_power_pdata power_supply_info = {
403 .init = power_supply_init,
404 .is_ac_online = palmtx_is_ac_online,
405 .exit = power_supply_exit,
406 .supplied_to = palmtx_supplicants,
407 .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
410 static struct platform_device power_supply = {
414 .platform_data = &power_supply_info,
418 /******************************************************************************
420 ******************************************************************************/
421 static struct wm97xx_batt_info wm97xx_batt_pdata = {
422 .batt_aux = WM97XX_AUX_ID3,
423 .temp_aux = WM97XX_AUX_ID2,
425 .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
426 .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
431 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
432 .batt_name = "main-batt",
435 /******************************************************************************
437 ******************************************************************************/
438 static struct pxafb_mode_info palmtx_lcd_modes[] = {
455 static struct pxafb_mach_info palmtx_lcd_screen = {
456 .modes = palmtx_lcd_modes,
457 .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
458 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
461 /******************************************************************************
462 * Power management - standby
463 ******************************************************************************/
465 static u32 *addr __initdata;
466 static u32 resume[3] __initdata = {
467 0xe3a00101, /* mov r0, #0x40000000 */
468 0xe380060f, /* orr r0, r0, #0x00f00000 */
469 0xe590f008, /* ldr pc, [r0, #0x08] */
472 static int __init palmtx_pm_init(void)
476 /* this is where the bootloader jumps */
477 addr = phys_to_virt(PALMTX_STR_BASE);
479 for (i = 0; i < 3; i++)
485 device_initcall(palmtx_pm_init);
488 /******************************************************************************
490 ******************************************************************************/
491 static struct platform_device *devices[] __initdata = {
492 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
499 static struct map_desc palmtx_io_desc[] __initdata = {
501 .virtual = PALMTX_PCMCIA_VIRT,
502 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
503 .length = PALMTX_PCMCIA_SIZE,
508 static void __init palmtx_map_io(void)
511 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
514 /* setup udc GPIOs initial state */
515 static void __init palmtx_udc_init(void)
517 if (!gpio_request(GPIO_NR_PALMTX_USB_POWER, "UDC Vbus")) {
518 gpio_direction_output(GPIO_NR_PALMTX_USB_POWER, 1);
519 gpio_free(GPIO_NR_PALMTX_USB_POWER);
524 static void __init palmtx_init(void)
526 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
528 set_pxa_fb_info(&palmtx_lcd_screen);
529 pxa_set_mci_info(&palmtx_mci_platform_data);
531 pxa_set_udc_info(&palmtx_udc_info);
532 pxa_set_ac97_info(NULL);
533 pxa_set_ficp_info(&palmtx_ficp_platform_data);
534 pxa_set_keypad_info(&palmtx_keypad_platform_data);
535 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
537 platform_add_devices(devices, ARRAY_SIZE(devices));
540 MACHINE_START(PALMTX, "Palm T|X")
541 .phys_io = PALMTX_PHYS_IO_START,
542 .io_pg_offst = io_p2v(0x40000000),
543 .boot_params = 0xa0000100,
544 .map_io = palmtx_map_io,
545 .init_irq = pxa27x_init_irq,
547 .init_machine = palmtx_init