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>
30 #include <linux/usb/gpio_vbus.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
36 #include <mach/pxa27x.h>
37 #include <mach/audio.h>
38 #include <mach/palmtx.h>
40 #include <mach/pxafb.h>
41 #include <mach/irda.h>
42 #include <mach/pxa27x_keypad.h>
44 #include <mach/palmasoc.h>
49 /******************************************************************************
51 ******************************************************************************/
52 static unsigned long palmtx_pin_config
[] __initdata
= {
60 GPIO14_GPIO
, /* SD detect */
61 GPIO114_GPIO
, /* SD power */
62 GPIO115_GPIO
, /* SD r/o switch */
66 GPIO29_AC97_SDATA_IN_0
,
67 GPIO30_AC97_SDATA_OUT
,
73 GPIO40_GPIO
, /* ir disable */
81 GPIO13_GPIO
, /* usb detect */
82 GPIO93_GPIO
, /* usb power */
95 GPIO94_GPIO
, /* wifi power 1 */
96 GPIO108_GPIO
, /* wifi power 2 */
97 GPIO116_GPIO
, /* wifi ready */
100 GPIO100_KP_MKIN_0
| WAKEUP_ON_LEVEL_HIGH
,
101 GPIO101_KP_MKIN_1
| WAKEUP_ON_LEVEL_HIGH
,
102 GPIO102_KP_MKIN_2
| WAKEUP_ON_LEVEL_HIGH
,
103 GPIO97_KP_MKIN_3
| WAKEUP_ON_LEVEL_HIGH
,
135 GPIO10_GPIO
, /* hotsync button */
136 GPIO12_GPIO
, /* power detect */
137 GPIO107_GPIO
, /* earphone detect */
140 /******************************************************************************
141 * SD/MMC card controller
142 ******************************************************************************/
143 static int palmtx_mci_init(struct device
*dev
, irq_handler_t palmtx_detect_int
,
148 /* Setup an interrupt for detecting card insert/remove events */
149 err
= gpio_request(GPIO_NR_PALMTX_SD_DETECT_N
, "SD IRQ");
152 err
= gpio_direction_input(GPIO_NR_PALMTX_SD_DETECT_N
);
155 err
= request_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N
),
156 palmtx_detect_int
, IRQF_DISABLED
| IRQF_SAMPLE_RANDOM
|
157 IRQF_TRIGGER_FALLING
| IRQF_TRIGGER_RISING
,
158 "SD/MMC card detect", data
);
160 printk(KERN_ERR
"%s: cannot request SD/MMC card detect IRQ\n",
165 err
= gpio_request(GPIO_NR_PALMTX_SD_POWER
, "SD_POWER");
168 err
= gpio_direction_output(GPIO_NR_PALMTX_SD_POWER
, 0);
172 err
= gpio_request(GPIO_NR_PALMTX_SD_READONLY
, "SD_READONLY");
175 err
= gpio_direction_input(GPIO_NR_PALMTX_SD_READONLY
);
179 printk(KERN_DEBUG
"%s: irq registered\n", __func__
);
184 gpio_free(GPIO_NR_PALMTX_SD_READONLY
);
186 gpio_free(GPIO_NR_PALMTX_SD_POWER
);
188 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N
), data
);
190 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N
);
195 static void palmtx_mci_exit(struct device
*dev
, void *data
)
197 gpio_free(GPIO_NR_PALMTX_SD_READONLY
);
198 gpio_free(GPIO_NR_PALMTX_SD_POWER
);
199 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N
), data
);
200 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N
);
203 static void palmtx_mci_power(struct device
*dev
, unsigned int vdd
)
205 struct pxamci_platform_data
*p_d
= dev
->platform_data
;
206 gpio_set_value(GPIO_NR_PALMTX_SD_POWER
, p_d
->ocr_mask
& (1 << vdd
));
209 static int palmtx_mci_get_ro(struct device
*dev
)
211 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY
);
214 static struct pxamci_platform_data palmtx_mci_platform_data
= {
215 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
216 .setpower
= palmtx_mci_power
,
217 .get_ro
= palmtx_mci_get_ro
,
218 .init
= palmtx_mci_init
,
219 .exit
= palmtx_mci_exit
,
222 /******************************************************************************
224 ******************************************************************************/
225 static unsigned int palmtx_matrix_keys
[] = {
226 KEY(0, 0, KEY_POWER
),
228 KEY(0, 2, KEY_ENTER
),
237 KEY(3, 0, KEY_RIGHT
),
241 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data
= {
242 .matrix_key_rows
= 4,
243 .matrix_key_cols
= 3,
244 .matrix_key_map
= palmtx_matrix_keys
,
245 .matrix_key_map_size
= ARRAY_SIZE(palmtx_matrix_keys
),
247 .debounce_interval
= 30,
250 /******************************************************************************
252 ******************************************************************************/
253 static struct gpio_keys_button palmtx_pxa_buttons
[] = {
254 {KEY_F8
, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N
, 1, "HotSync Button" },
257 static struct gpio_keys_platform_data palmtx_pxa_keys_data
= {
258 .buttons
= palmtx_pxa_buttons
,
259 .nbuttons
= ARRAY_SIZE(palmtx_pxa_buttons
),
262 static struct platform_device palmtx_pxa_keys
= {
266 .platform_data
= &palmtx_pxa_keys_data
,
270 /******************************************************************************
272 ******************************************************************************/
273 static int palmtx_backlight_init(struct device
*dev
)
277 ret
= gpio_request(GPIO_NR_PALMTX_BL_POWER
, "BL POWER");
280 ret
= gpio_direction_output(GPIO_NR_PALMTX_BL_POWER
, 0);
283 ret
= gpio_request(GPIO_NR_PALMTX_LCD_POWER
, "LCD POWER");
286 ret
= gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER
, 0);
292 gpio_free(GPIO_NR_PALMTX_LCD_POWER
);
294 gpio_free(GPIO_NR_PALMTX_BL_POWER
);
299 static int palmtx_backlight_notify(int brightness
)
301 gpio_set_value(GPIO_NR_PALMTX_BL_POWER
, brightness
);
302 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER
, brightness
);
306 static void palmtx_backlight_exit(struct device
*dev
)
308 gpio_free(GPIO_NR_PALMTX_BL_POWER
);
309 gpio_free(GPIO_NR_PALMTX_LCD_POWER
);
312 static struct platform_pwm_backlight_data palmtx_backlight_data
= {
314 .max_brightness
= PALMTX_MAX_INTENSITY
,
315 .dft_brightness
= PALMTX_MAX_INTENSITY
,
316 .pwm_period_ns
= PALMTX_PERIOD_NS
,
317 .init
= palmtx_backlight_init
,
318 .notify
= palmtx_backlight_notify
,
319 .exit
= palmtx_backlight_exit
,
322 static struct platform_device palmtx_backlight
= {
323 .name
= "pwm-backlight",
325 .parent
= &pxa27x_device_pwm0
.dev
,
326 .platform_data
= &palmtx_backlight_data
,
330 /******************************************************************************
332 ******************************************************************************/
333 static int palmtx_irda_startup(struct device
*dev
)
336 err
= gpio_request(GPIO_NR_PALMTX_IR_DISABLE
, "IR DISABLE");
339 err
= gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE
, 1);
341 gpio_free(GPIO_NR_PALMTX_IR_DISABLE
);
346 static void palmtx_irda_shutdown(struct device
*dev
)
348 gpio_free(GPIO_NR_PALMTX_IR_DISABLE
);
351 static void palmtx_irda_transceiver_mode(struct device
*dev
, int mode
)
353 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE
, mode
& IR_OFF
);
354 pxa2xx_transceiver_mode(dev
, mode
);
357 static struct pxaficp_platform_data palmtx_ficp_platform_data
= {
358 .startup
= palmtx_irda_startup
,
359 .shutdown
= palmtx_irda_shutdown
,
360 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
361 .transceiver_mode
= palmtx_irda_transceiver_mode
,
364 /******************************************************************************
366 ******************************************************************************/
367 static struct gpio_vbus_mach_info palmtx_udc_info
= {
368 .gpio_vbus
= GPIO_NR_PALMTX_USB_DETECT_N
,
369 .gpio_vbus_inverted
= 1,
370 .gpio_pullup
= GPIO_NR_PALMTX_USB_PULLUP
,
373 static struct platform_device palmtx_gpio_vbus
= {
377 .platform_data
= &palmtx_udc_info
,
381 /******************************************************************************
383 ******************************************************************************/
384 static int power_supply_init(struct device
*dev
)
388 ret
= gpio_request(GPIO_NR_PALMTX_POWER_DETECT
, "CABLE_STATE_AC");
391 ret
= gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT
);
398 gpio_free(GPIO_NR_PALMTX_POWER_DETECT
);
403 static int palmtx_is_ac_online(void)
405 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT
);
408 static void power_supply_exit(struct device
*dev
)
410 gpio_free(GPIO_NR_PALMTX_POWER_DETECT
);
413 static char *palmtx_supplicants
[] = {
417 static struct pda_power_pdata power_supply_info
= {
418 .init
= power_supply_init
,
419 .is_ac_online
= palmtx_is_ac_online
,
420 .exit
= power_supply_exit
,
421 .supplied_to
= palmtx_supplicants
,
422 .num_supplicants
= ARRAY_SIZE(palmtx_supplicants
),
425 static struct platform_device power_supply
= {
429 .platform_data
= &power_supply_info
,
433 /******************************************************************************
435 ******************************************************************************/
436 static struct wm97xx_batt_info wm97xx_batt_pdata
= {
437 .batt_aux
= WM97XX_AUX_ID3
,
438 .temp_aux
= WM97XX_AUX_ID2
,
440 .max_voltage
= PALMTX_BAT_MAX_VOLTAGE
,
441 .min_voltage
= PALMTX_BAT_MIN_VOLTAGE
,
446 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LIPO
,
447 .batt_name
= "main-batt",
450 /******************************************************************************
452 ******************************************************************************/
453 static struct palm27x_asoc_info palmtx_asoc_pdata
= {
454 .jack_gpio
= GPIO_NR_PALMTX_EARPHONE_DETECT
,
457 static pxa2xx_audio_ops_t palmtx_ac97_pdata
= {
461 static struct platform_device palmtx_asoc
= {
462 .name
= "palm27x-asoc",
465 .platform_data
= &palmtx_asoc_pdata
,
469 /******************************************************************************
471 ******************************************************************************/
472 static struct pxafb_mode_info palmtx_lcd_modes
[] = {
489 static struct pxafb_mach_info palmtx_lcd_screen
= {
490 .modes
= palmtx_lcd_modes
,
491 .num_modes
= ARRAY_SIZE(palmtx_lcd_modes
),
492 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
495 /******************************************************************************
496 * Power management - standby
497 ******************************************************************************/
498 static void __init
palmtx_pm_init(void)
500 static u32 resume
[] = {
501 0xe3a00101, /* mov r0, #0x40000000 */
502 0xe380060f, /* orr r0, r0, #0x00f00000 */
503 0xe590f008, /* ldr pc, [r0, #0x08] */
506 /* copy the bootloader */
507 memcpy(phys_to_virt(PALMTX_STR_BASE
), resume
, sizeof(resume
));
510 /******************************************************************************
512 ******************************************************************************/
513 static struct platform_device
*devices
[] __initdata
= {
514 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
523 static struct map_desc palmtx_io_desc
[] __initdata
= {
525 .virtual = PALMTX_PCMCIA_VIRT
,
526 .pfn
= __phys_to_pfn(PALMTX_PCMCIA_PHYS
),
527 .length
= PALMTX_PCMCIA_SIZE
,
532 static void __init
palmtx_map_io(void)
535 iotable_init(palmtx_io_desc
, ARRAY_SIZE(palmtx_io_desc
));
538 /* setup udc GPIOs initial state */
539 static void __init
palmtx_udc_init(void)
541 if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP
, "UDC Vbus")) {
542 gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP
, 1);
543 gpio_free(GPIO_NR_PALMTX_USB_PULLUP
);
548 static void __init
palmtx_init(void)
550 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config
));
553 set_pxa_fb_info(&palmtx_lcd_screen
);
554 pxa_set_mci_info(&palmtx_mci_platform_data
);
556 pxa_set_ac97_info(&palmtx_ac97_pdata
);
557 pxa_set_ficp_info(&palmtx_ficp_platform_data
);
558 pxa_set_keypad_info(&palmtx_keypad_platform_data
);
559 wm97xx_bat_set_pdata(&wm97xx_batt_pdata
);
561 platform_add_devices(devices
, ARRAY_SIZE(devices
));
564 MACHINE_START(PALMTX
, "Palm T|X")
565 .phys_io
= PALMTX_PHYS_IO_START
,
566 .io_pg_offst
= io_p2v(0x40000000),
567 .boot_params
= 0xa0000100,
568 .map_io
= palmtx_map_io
,
569 .init_irq
= pxa27x_init_irq
,
571 .init_machine
= palmtx_init