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
,
71 GPIO40_GPIO
, /* ir disable */
79 GPIO13_GPIO
, /* usb detect */
80 GPIO93_GPIO
, /* usb power */
93 GPIO94_GPIO
, /* wifi power 1 */
94 GPIO108_GPIO
, /* wifi power 2 */
95 GPIO116_GPIO
, /* wifi ready */
98 GPIO100_KP_MKIN_0
| WAKEUP_ON_LEVEL_HIGH
,
99 GPIO101_KP_MKIN_1
| WAKEUP_ON_LEVEL_HIGH
,
100 GPIO102_KP_MKIN_2
| WAKEUP_ON_LEVEL_HIGH
,
101 GPIO97_KP_MKIN_3
| WAKEUP_ON_LEVEL_HIGH
,
129 GPIO10_GPIO
, /* hotsync button */
130 GPIO12_GPIO
, /* power detect */
131 GPIO107_GPIO
, /* earphone detect */
134 /******************************************************************************
135 * SD/MMC card controller
136 ******************************************************************************/
137 static int palmtx_mci_init(struct device
*dev
, irq_handler_t palmtx_detect_int
,
142 /* Setup an interrupt for detecting card insert/remove events */
143 err
= gpio_request(GPIO_NR_PALMTX_SD_DETECT_N
, "SD IRQ");
146 err
= gpio_direction_input(GPIO_NR_PALMTX_SD_DETECT_N
);
149 err
= request_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N
),
150 palmtx_detect_int
, IRQF_DISABLED
| IRQF_SAMPLE_RANDOM
|
151 IRQF_TRIGGER_FALLING
| IRQF_TRIGGER_RISING
,
152 "SD/MMC card detect", data
);
154 printk(KERN_ERR
"%s: cannot request SD/MMC card detect IRQ\n",
159 err
= gpio_request(GPIO_NR_PALMTX_SD_POWER
, "SD_POWER");
162 err
= gpio_direction_output(GPIO_NR_PALMTX_SD_POWER
, 0);
166 err
= gpio_request(GPIO_NR_PALMTX_SD_READONLY
, "SD_READONLY");
169 err
= gpio_direction_input(GPIO_NR_PALMTX_SD_READONLY
);
173 printk(KERN_DEBUG
"%s: irq registered\n", __func__
);
178 gpio_free(GPIO_NR_PALMTX_SD_READONLY
);
180 gpio_free(GPIO_NR_PALMTX_SD_POWER
);
182 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N
), data
);
184 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N
);
189 static void palmtx_mci_exit(struct device
*dev
, void *data
)
191 gpio_free(GPIO_NR_PALMTX_SD_READONLY
);
192 gpio_free(GPIO_NR_PALMTX_SD_POWER
);
193 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N
), data
);
194 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N
);
197 static void palmtx_mci_power(struct device
*dev
, unsigned int vdd
)
199 struct pxamci_platform_data
*p_d
= dev
->platform_data
;
200 gpio_set_value(GPIO_NR_PALMTX_SD_POWER
, p_d
->ocr_mask
& (1 << vdd
));
203 static int palmtx_mci_get_ro(struct device
*dev
)
205 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY
);
208 static struct pxamci_platform_data palmtx_mci_platform_data
= {
209 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
210 .setpower
= palmtx_mci_power
,
211 .get_ro
= palmtx_mci_get_ro
,
212 .init
= palmtx_mci_init
,
213 .exit
= palmtx_mci_exit
,
216 /******************************************************************************
218 ******************************************************************************/
219 static unsigned int palmtx_matrix_keys
[] = {
220 KEY(0, 0, KEY_POWER
),
222 KEY(0, 2, KEY_ENTER
),
231 KEY(3, 0, KEY_RIGHT
),
235 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data
= {
236 .matrix_key_rows
= 4,
237 .matrix_key_cols
= 3,
238 .matrix_key_map
= palmtx_matrix_keys
,
239 .matrix_key_map_size
= ARRAY_SIZE(palmtx_matrix_keys
),
241 .debounce_interval
= 30,
244 /******************************************************************************
246 ******************************************************************************/
247 static struct gpio_keys_button palmtx_pxa_buttons
[] = {
248 {KEY_F8
, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N
, 1, "HotSync Button" },
251 static struct gpio_keys_platform_data palmtx_pxa_keys_data
= {
252 .buttons
= palmtx_pxa_buttons
,
253 .nbuttons
= ARRAY_SIZE(palmtx_pxa_buttons
),
256 static struct platform_device palmtx_pxa_keys
= {
260 .platform_data
= &palmtx_pxa_keys_data
,
264 /******************************************************************************
266 ******************************************************************************/
267 static int palmtx_backlight_init(struct device
*dev
)
271 ret
= gpio_request(GPIO_NR_PALMTX_BL_POWER
, "BL POWER");
274 ret
= gpio_direction_output(GPIO_NR_PALMTX_BL_POWER
, 0);
277 ret
= gpio_request(GPIO_NR_PALMTX_LCD_POWER
, "LCD POWER");
280 ret
= gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER
, 0);
286 gpio_free(GPIO_NR_PALMTX_LCD_POWER
);
288 gpio_free(GPIO_NR_PALMTX_BL_POWER
);
293 static int palmtx_backlight_notify(int brightness
)
295 gpio_set_value(GPIO_NR_PALMTX_BL_POWER
, brightness
);
296 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER
, brightness
);
300 static void palmtx_backlight_exit(struct device
*dev
)
302 gpio_free(GPIO_NR_PALMTX_BL_POWER
);
303 gpio_free(GPIO_NR_PALMTX_LCD_POWER
);
306 static struct platform_pwm_backlight_data palmtx_backlight_data
= {
308 .max_brightness
= PALMTX_MAX_INTENSITY
,
309 .dft_brightness
= PALMTX_MAX_INTENSITY
,
310 .pwm_period_ns
= PALMTX_PERIOD_NS
,
311 .init
= palmtx_backlight_init
,
312 .notify
= palmtx_backlight_notify
,
313 .exit
= palmtx_backlight_exit
,
316 static struct platform_device palmtx_backlight
= {
317 .name
= "pwm-backlight",
319 .parent
= &pxa27x_device_pwm0
.dev
,
320 .platform_data
= &palmtx_backlight_data
,
324 /******************************************************************************
326 ******************************************************************************/
327 static int palmtx_irda_startup(struct device
*dev
)
330 err
= gpio_request(GPIO_NR_PALMTX_IR_DISABLE
, "IR DISABLE");
333 err
= gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE
, 1);
335 gpio_free(GPIO_NR_PALMTX_IR_DISABLE
);
340 static void palmtx_irda_shutdown(struct device
*dev
)
342 gpio_free(GPIO_NR_PALMTX_IR_DISABLE
);
345 static void palmtx_irda_transceiver_mode(struct device
*dev
, int mode
)
347 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE
, mode
& IR_OFF
);
348 pxa2xx_transceiver_mode(dev
, mode
);
351 static struct pxaficp_platform_data palmtx_ficp_platform_data
= {
352 .startup
= palmtx_irda_startup
,
353 .shutdown
= palmtx_irda_shutdown
,
354 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
355 .transceiver_mode
= palmtx_irda_transceiver_mode
,
358 /******************************************************************************
360 ******************************************************************************/
361 static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata
= {
362 .gpio_vbus
= GPIO_NR_PALMTX_USB_DETECT_N
,
363 .gpio_vbus_inverted
= 1,
364 .gpio_pullup
= GPIO_NR_PALMTX_USB_PULLUP
,
365 .gpio_pullup_inverted
= 0,
368 /******************************************************************************
370 ******************************************************************************/
371 static int power_supply_init(struct device
*dev
)
375 ret
= gpio_request(GPIO_NR_PALMTX_POWER_DETECT
, "CABLE_STATE_AC");
378 ret
= gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT
);
385 gpio_free(GPIO_NR_PALMTX_POWER_DETECT
);
390 static int palmtx_is_ac_online(void)
392 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT
);
395 static void power_supply_exit(struct device
*dev
)
397 gpio_free(GPIO_NR_PALMTX_POWER_DETECT
);
400 static char *palmtx_supplicants
[] = {
404 static struct pda_power_pdata power_supply_info
= {
405 .init
= power_supply_init
,
406 .is_ac_online
= palmtx_is_ac_online
,
407 .exit
= power_supply_exit
,
408 .supplied_to
= palmtx_supplicants
,
409 .num_supplicants
= ARRAY_SIZE(palmtx_supplicants
),
412 static struct platform_device power_supply
= {
416 .platform_data
= &power_supply_info
,
420 /******************************************************************************
422 ******************************************************************************/
423 static struct wm97xx_batt_info wm97xx_batt_pdata
= {
424 .batt_aux
= WM97XX_AUX_ID3
,
425 .temp_aux
= WM97XX_AUX_ID2
,
427 .max_voltage
= PALMTX_BAT_MAX_VOLTAGE
,
428 .min_voltage
= PALMTX_BAT_MIN_VOLTAGE
,
433 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LIPO
,
434 .batt_name
= "main-batt",
437 /******************************************************************************
439 ******************************************************************************/
440 static struct palm27x_asoc_info palmtx_asoc_pdata
= {
441 .jack_gpio
= GPIO_NR_PALMTX_EARPHONE_DETECT
,
444 static pxa2xx_audio_ops_t palmtx_ac97_pdata
= {
448 static struct platform_device palmtx_asoc
= {
449 .name
= "palm27x-asoc",
452 .platform_data
= &palmtx_asoc_pdata
,
456 /******************************************************************************
458 ******************************************************************************/
459 static struct pxafb_mode_info palmtx_lcd_modes
[] = {
476 static struct pxafb_mach_info palmtx_lcd_screen
= {
477 .modes
= palmtx_lcd_modes
,
478 .num_modes
= ARRAY_SIZE(palmtx_lcd_modes
),
479 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
482 /******************************************************************************
483 * Power management - standby
484 ******************************************************************************/
486 static u32
*addr __initdata
;
487 static u32 resume
[3] __initdata
= {
488 0xe3a00101, /* mov r0, #0x40000000 */
489 0xe380060f, /* orr r0, r0, #0x00f00000 */
490 0xe590f008, /* ldr pc, [r0, #0x08] */
493 static int __init
palmtx_pm_init(void)
497 /* this is where the bootloader jumps */
498 addr
= phys_to_virt(PALMTX_STR_BASE
);
500 for (i
= 0; i
< 3; i
++)
506 device_initcall(palmtx_pm_init
);
509 /******************************************************************************
511 ******************************************************************************/
512 static struct platform_device
*devices
[] __initdata
= {
513 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
521 static struct map_desc palmtx_io_desc
[] __initdata
= {
523 .virtual = PALMTX_PCMCIA_VIRT
,
524 .pfn
= __phys_to_pfn(PALMTX_PCMCIA_PHYS
),
525 .length
= PALMTX_PCMCIA_SIZE
,
530 static void __init
palmtx_map_io(void)
533 iotable_init(palmtx_io_desc
, ARRAY_SIZE(palmtx_io_desc
));
536 /* setup udc GPIOs initial state */
537 static void __init
palmtx_udc_init(void)
539 if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP
, "UDC Vbus")) {
540 gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP
, 1);
541 gpio_free(GPIO_NR_PALMTX_USB_PULLUP
);
546 static void __init
palmtx_init(void)
548 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config
));
550 set_pxa_fb_info(&palmtx_lcd_screen
);
551 pxa_set_mci_info(&palmtx_mci_platform_data
);
553 pxa_set_ac97_info(&palmtx_ac97_pdata
);
554 pxa_set_udc_info(&palmtx_udc_info
);
555 pxa_set_ficp_info(&palmtx_ficp_platform_data
);
556 pxa_set_keypad_info(&palmtx_keypad_platform_data
);
557 wm97xx_bat_set_pdata(&wm97xx_batt_pdata
);
559 platform_add_devices(devices
, ARRAY_SIZE(devices
));
562 MACHINE_START(PALMTX
, "Palm T|X")
563 .phys_io
= PALMTX_PHYS_IO_START
,
564 .io_pg_offst
= io_p2v(0x40000000),
565 .boot_params
= 0xa0000100,
566 .map_io
= palmtx_map_io
,
567 .init_irq
= pxa27x_init_irq
,
569 .init_machine
= palmtx_init