2 * linux/arch/arm/mach-pxa/palmtc.c
4 * Support for the Palm Tungsten|C
6 * Author: Marek Vasut <marek.vasut@gmail.com>
9 * Petr Blaha <p3t3@centrum.cz>
10 * Chetan S. Kumar <shivakumar.chetan@gmail.com>
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.
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/irq.h>
20 #include <linux/input.h>
21 #include <linux/pwm_backlight.h>
22 #include <linux/gpio.h>
23 #include <linux/input/matrix_keypad.h>
24 #include <linux/ucb1400.h>
25 #include <linux/power_supply.h>
26 #include <linux/gpio_keys.h>
27 #include <linux/mtd/physmap.h>
28 #include <linux/usb/gpio_vbus.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
34 #include <mach/pxa25x.h>
35 #include <mach/audio.h>
36 #include <mach/palmtc.h>
38 #include <mach/pxafb.h>
39 #include <mach/irda.h>
45 /******************************************************************************
47 ******************************************************************************/
48 static unsigned long palmtc_pin_config
[] __initdata
= {
52 GPIO12_GPIO
, /* detect */
53 GPIO32_GPIO
, /* power */
54 GPIO54_GPIO
, /* r/o switch */
70 GPIO29_AC97_SDATA_IN_0
,
71 GPIO30_AC97_SDATA_OUT
,
75 GPIO45_GPIO
, /* ir disable */
83 GPIO4_GPIO
, /* detect */
84 GPIO36_GPIO
, /* pullup */
90 GPIO0_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* in 0 */
91 GPIO9_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* in 1 */
92 GPIO10_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* in 2 */
93 GPIO11_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* in 3 */
94 GPIO18_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 0 */
95 GPIO19_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 1 */
96 GPIO20_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 2 */
97 GPIO21_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 3 */
98 GPIO22_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 4 */
99 GPIO23_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 5 */
100 GPIO24_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 6 */
101 GPIO25_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 7 */
102 GPIO26_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 8 */
103 GPIO27_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 9 */
104 GPIO79_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 10 */
105 GPIO80_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 11 */
108 GPIO7_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* hotsync button on cradle */
111 GPIO1_RST
, /* reset */
112 GPIO2_GPIO
, /* earphone detect */
113 GPIO16_GPIO
, /* backlight switch */
116 /******************************************************************************
117 * SD/MMC card controller
118 ******************************************************************************/
119 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
120 static struct pxamci_platform_data palmtc_mci_platform_data
= {
121 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
122 .gpio_power
= GPIO_NR_PALMTC_SD_POWER
,
123 .gpio_card_ro
= GPIO_NR_PALMTC_SD_READONLY
,
124 .gpio_card_detect
= GPIO_NR_PALMTC_SD_DETECT_N
,
125 .detect_delay_ms
= 200,
128 static void __init
palmtc_mmc_init(void)
130 pxa_set_mci_info(&palmtc_mci_platform_data
);
133 static inline void palmtc_mmc_init(void) {}
136 /******************************************************************************
138 ******************************************************************************/
139 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
140 static struct gpio_keys_button palmtc_pxa_buttons
[] = {
141 {KEY_F8
, GPIO_NR_PALMTC_HOTSYNC_BUTTON
, 1, "HotSync Button", EV_KEY
, 1},
144 static struct gpio_keys_platform_data palmtc_pxa_keys_data
= {
145 .buttons
= palmtc_pxa_buttons
,
146 .nbuttons
= ARRAY_SIZE(palmtc_pxa_buttons
),
149 static struct platform_device palmtc_pxa_keys
= {
153 .platform_data
= &palmtc_pxa_keys_data
,
157 static void __init
palmtc_keys_init(void)
159 platform_device_register(&palmtc_pxa_keys
);
162 static inline void palmtc_keys_init(void) {}
165 /******************************************************************************
167 ******************************************************************************/
168 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
169 static int palmtc_backlight_init(struct device
*dev
)
173 ret
= gpio_request(GPIO_NR_PALMTC_BL_POWER
, "BL POWER");
176 ret
= gpio_direction_output(GPIO_NR_PALMTC_BL_POWER
, 1);
183 gpio_free(GPIO_NR_PALMTC_BL_POWER
);
188 static int palmtc_backlight_notify(struct device
*dev
, int brightness
)
190 /* backlight is on when GPIO16 AF0 is high */
191 gpio_set_value(GPIO_NR_PALMTC_BL_POWER
, brightness
);
195 static void palmtc_backlight_exit(struct device
*dev
)
197 gpio_free(GPIO_NR_PALMTC_BL_POWER
);
200 static struct platform_pwm_backlight_data palmtc_backlight_data
= {
202 .max_brightness
= PALMTC_MAX_INTENSITY
,
203 .dft_brightness
= PALMTC_MAX_INTENSITY
,
204 .pwm_period_ns
= PALMTC_PERIOD_NS
,
205 .init
= palmtc_backlight_init
,
206 .notify
= palmtc_backlight_notify
,
207 .exit
= palmtc_backlight_exit
,
210 static struct platform_device palmtc_backlight
= {
211 .name
= "pwm-backlight",
213 .parent
= &pxa25x_device_pwm1
.dev
,
214 .platform_data
= &palmtc_backlight_data
,
218 static void __init
palmtc_pwm_init(void)
220 platform_device_register(&palmtc_backlight
);
223 static inline void palmtc_pwm_init(void) {}
226 /******************************************************************************
228 ******************************************************************************/
229 #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
230 static struct pxaficp_platform_data palmtc_ficp_platform_data
= {
231 .gpio_pwdown
= GPIO_NR_PALMTC_IR_DISABLE
,
232 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
235 static void __init
palmtc_irda_init(void)
237 pxa_set_ficp_info(&palmtc_ficp_platform_data
);
240 static inline void palmtc_irda_init(void) {}
243 /******************************************************************************
245 ******************************************************************************/
246 #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE)
247 static const uint32_t palmtc_matrix_keys
[] = {
250 KEY(0, 2, KEY_POWER
),
254 KEY(0, 6, KEY_LEFTSHIFT
),
267 KEY(1, 7, KEY_SPACE
),
271 KEY(1, 11, KEY_LEFT
),
274 KEY(2, 1, KEY_LEFTCTRL
),
283 KEY(2, 11, KEY_RIGHT
),
286 KEY(3, 1, KEY_ENTER
),
290 KEY(3, 6, KEY_LEFTALT
),
291 KEY(3, 7, KEY_ENTER
),
292 KEY(3, 8, KEY_BACKSPACE
),
298 const struct matrix_keymap_data palmtc_keymap_data
= {
299 .keymap
= palmtc_matrix_keys
,
300 .keymap_size
= ARRAY_SIZE(palmtc_matrix_keys
),
303 static const unsigned int palmtc_keypad_row_gpios
[] = {
307 static const unsigned int palmtc_keypad_col_gpios
[] = {
308 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 79, 80
311 static struct matrix_keypad_platform_data palmtc_keypad_platform_data
= {
312 .keymap_data
= &palmtc_keymap_data
,
313 .row_gpios
= palmtc_keypad_row_gpios
,
314 .num_row_gpios
= ARRAY_SIZE(palmtc_keypad_row_gpios
),
315 .col_gpios
= palmtc_keypad_col_gpios
,
316 .num_col_gpios
= ARRAY_SIZE(palmtc_keypad_col_gpios
),
320 .col_scan_delay_us
= 5,
323 static struct platform_device palmtc_keyboard
= {
324 .name
= "matrix-keypad",
327 .platform_data
= &palmtc_keypad_platform_data
,
330 static void __init
palmtc_mkp_init(void)
332 platform_device_register(&palmtc_keyboard
);
335 static inline void palmtc_mkp_init(void) {}
338 /******************************************************************************
340 ******************************************************************************/
341 #if defined(CONFIG_USB_PXA25X)||defined(CONFIG_USB_PXA25X_MODULE)
342 static struct gpio_vbus_mach_info palmtc_udc_info
= {
343 .gpio_vbus
= GPIO_NR_PALMTC_USB_DETECT_N
,
344 .gpio_vbus_inverted
= 1,
345 .gpio_pullup
= GPIO_NR_PALMTC_USB_POWER
,
348 static struct platform_device palmtc_gpio_vbus
= {
352 .platform_data
= &palmtc_udc_info
,
356 static void __init
palmtc_udc_init(void)
358 platform_device_register(&palmtc_gpio_vbus
);
361 static inline void palmtc_udc_init(void) {}
364 /******************************************************************************
365 * Touchscreen / Battery / GPIO-extender
366 ******************************************************************************/
367 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
368 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
369 static struct platform_device palmtc_ucb1400_device
= {
370 .name
= "ucb1400_core",
374 static void __init
palmtc_ts_init(void)
376 pxa_set_ac97_info(NULL
);
377 platform_device_register(&palmtc_ucb1400_device
);
380 static inline void palmtc_ts_init(void) {}
383 /******************************************************************************
385 ******************************************************************************/
386 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
387 struct gpio_led palmtc_gpio_leds
[] = {
389 .name
= "palmtc:green:user",
390 .default_trigger
= "none",
391 .gpio
= GPIO_NR_PALMTC_LED_POWER
,
394 .name
= "palmtc:vibra:vibra",
395 .default_trigger
= "none",
396 .gpio
= GPIO_NR_PALMTC_VIBRA_POWER
,
402 static struct gpio_led_platform_data palmtc_gpio_led_info
= {
403 .leds
= palmtc_gpio_leds
,
404 .num_leds
= ARRAY_SIZE(palmtc_gpio_leds
),
407 static struct platform_device palmtc_leds
= {
411 .platform_data
= &palmtc_gpio_led_info
,
415 static void __init
palmtc_leds_init(void)
417 platform_device_register(&palmtc_leds
);
420 static inline void palmtc_leds_init(void) {}
423 /******************************************************************************
425 ******************************************************************************/
426 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
427 static struct resource palmtc_flash_resource
= {
428 .start
= PXA_CS0_PHYS
,
429 .end
= PXA_CS0_PHYS
+ SZ_16M
- 1,
430 .flags
= IORESOURCE_MEM
,
433 static struct mtd_partition palmtc_flash_parts
[] = {
435 .name
= "U-Boot Bootloader",
440 .name
= "Linux Kernel",
445 .name
= "Filesystem",
450 .name
= "U-Boot Environment",
452 .size
= MTDPART_SIZ_FULL
,
456 static struct physmap_flash_data palmtc_flash_data
= {
458 .parts
= palmtc_flash_parts
,
459 .nr_parts
= ARRAY_SIZE(palmtc_flash_parts
),
462 static struct platform_device palmtc_flash
= {
463 .name
= "physmap-flash",
465 .resource
= &palmtc_flash_resource
,
468 .platform_data
= &palmtc_flash_data
,
472 static void __init
palmtc_nor_init(void)
474 platform_device_register(&palmtc_flash
);
477 static inline void palmtc_nor_init(void) {}
480 /******************************************************************************
482 ******************************************************************************/
483 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
484 static struct pxafb_mode_info palmtc_lcd_modes
[] = {
501 static struct pxafb_mach_info palmtc_lcd_screen
= {
502 .modes
= palmtc_lcd_modes
,
503 .num_modes
= ARRAY_SIZE(palmtc_lcd_modes
),
504 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
507 static void __init
palmtc_lcd_init(void)
509 pxa_set_fb_info(NULL
, &palmtc_lcd_screen
);
512 static inline void palmtc_lcd_init(void) {}
515 /******************************************************************************
517 ******************************************************************************/
518 static void __init
palmtc_init(void)
520 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtc_pin_config
));
522 pxa_set_ffuart_info(NULL
);
523 pxa_set_btuart_info(NULL
);
524 pxa_set_stuart_info(NULL
);
525 pxa_set_hwuart_info(NULL
);
539 MACHINE_START(PALMTC
, "Palm Tungsten|C")
540 .atag_offset
= 0x100,
541 .map_io
= pxa25x_map_io
,
542 .init_irq
= pxa25x_init_irq
,
543 .handle_irq
= pxa25x_handle_irq
,
545 .init_machine
= palmtc_init
,
546 .restart
= pxa_restart
,