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/audio.h>
35 #include <mach/palmtc.h>
37 #include <mach/pxafb.h>
38 #include <mach/mfp-pxa25x.h>
39 #include <mach/irda.h>
41 #include <mach/pxa2xx-regs.h>
46 /******************************************************************************
48 ******************************************************************************/
49 static unsigned long palmtc_pin_config
[] __initdata
= {
53 GPIO12_GPIO
, /* detect */
54 GPIO32_GPIO
, /* power */
55 GPIO54_GPIO
, /* r/o switch */
71 GPIO29_AC97_SDATA_IN_0
,
72 GPIO30_AC97_SDATA_OUT
,
76 GPIO45_GPIO
, /* ir disable */
84 GPIO4_GPIO
, /* detect */
85 GPIO36_GPIO
, /* pullup */
91 GPIO0_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* in 0 */
92 GPIO9_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* in 1 */
93 GPIO10_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* in 2 */
94 GPIO11_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* in 3 */
95 GPIO18_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 0 */
96 GPIO19_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 1 */
97 GPIO20_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 2 */
98 GPIO21_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 3 */
99 GPIO22_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 4 */
100 GPIO23_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 5 */
101 GPIO24_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 6 */
102 GPIO25_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 7 */
103 GPIO26_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 8 */
104 GPIO27_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 9 */
105 GPIO79_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 10 */
106 GPIO80_GPIO
| MFP_LPM_DRIVE_LOW
, /* out 11 */
109 GPIO7_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* hotsync button on cradle */
112 GPIO1_RST
, /* reset */
113 GPIO2_GPIO
, /* earphone detect */
114 GPIO16_GPIO
, /* backlight switch */
117 /******************************************************************************
118 * SD/MMC card controller
119 ******************************************************************************/
120 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
121 static struct pxamci_platform_data palmtc_mci_platform_data
= {
122 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
123 .gpio_power
= GPIO_NR_PALMTC_SD_POWER
,
124 .gpio_card_ro
= GPIO_NR_PALMTC_SD_READONLY
,
125 .gpio_card_detect
= GPIO_NR_PALMTC_SD_DETECT_N
,
126 .detect_delay_ms
= 200,
129 static void __init
palmtc_mmc_init(void)
131 pxa_set_mci_info(&palmtc_mci_platform_data
);
134 static inline void palmtc_mmc_init(void) {}
137 /******************************************************************************
139 ******************************************************************************/
140 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
141 static struct gpio_keys_button palmtc_pxa_buttons
[] = {
142 {KEY_F8
, GPIO_NR_PALMTC_HOTSYNC_BUTTON
, 1, "HotSync Button", EV_KEY
, 1},
145 static struct gpio_keys_platform_data palmtc_pxa_keys_data
= {
146 .buttons
= palmtc_pxa_buttons
,
147 .nbuttons
= ARRAY_SIZE(palmtc_pxa_buttons
),
150 static struct platform_device palmtc_pxa_keys
= {
154 .platform_data
= &palmtc_pxa_keys_data
,
158 static void __init
palmtc_keys_init(void)
160 platform_device_register(&palmtc_pxa_keys
);
163 static inline void palmtc_keys_init(void) {}
166 /******************************************************************************
168 ******************************************************************************/
169 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
170 static int palmtc_backlight_init(struct device
*dev
)
174 ret
= gpio_request(GPIO_NR_PALMTC_BL_POWER
, "BL POWER");
177 ret
= gpio_direction_output(GPIO_NR_PALMTC_BL_POWER
, 1);
184 gpio_free(GPIO_NR_PALMTC_BL_POWER
);
189 static int palmtc_backlight_notify(struct device
*dev
, int brightness
)
191 /* backlight is on when GPIO16 AF0 is high */
192 gpio_set_value(GPIO_NR_PALMTC_BL_POWER
, brightness
);
196 static void palmtc_backlight_exit(struct device
*dev
)
198 gpio_free(GPIO_NR_PALMTC_BL_POWER
);
201 static struct platform_pwm_backlight_data palmtc_backlight_data
= {
203 .max_brightness
= PALMTC_MAX_INTENSITY
,
204 .dft_brightness
= PALMTC_MAX_INTENSITY
,
205 .pwm_period_ns
= PALMTC_PERIOD_NS
,
206 .init
= palmtc_backlight_init
,
207 .notify
= palmtc_backlight_notify
,
208 .exit
= palmtc_backlight_exit
,
211 static struct platform_device palmtc_backlight
= {
212 .name
= "pwm-backlight",
214 .parent
= &pxa25x_device_pwm1
.dev
,
215 .platform_data
= &palmtc_backlight_data
,
219 static void __init
palmtc_pwm_init(void)
221 platform_device_register(&palmtc_backlight
);
224 static inline void palmtc_pwm_init(void) {}
227 /******************************************************************************
229 ******************************************************************************/
230 #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
231 static struct pxaficp_platform_data palmtc_ficp_platform_data
= {
232 .gpio_pwdown
= GPIO_NR_PALMTC_IR_DISABLE
,
233 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
236 static void __init
palmtc_irda_init(void)
238 pxa_set_ficp_info(&palmtc_ficp_platform_data
);
241 static inline void palmtc_irda_init(void) {}
244 /******************************************************************************
246 ******************************************************************************/
247 #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE)
248 static const uint32_t palmtc_matrix_keys
[] = {
251 KEY(0, 2, KEY_POWER
),
255 KEY(0, 6, KEY_LEFTSHIFT
),
268 KEY(1, 7, KEY_SPACE
),
272 KEY(1, 11, KEY_LEFT
),
275 KEY(2, 1, KEY_LEFTCTRL
),
284 KEY(2, 11, KEY_RIGHT
),
287 KEY(3, 1, KEY_ENTER
),
291 KEY(3, 6, KEY_LEFTALT
),
292 KEY(3, 7, KEY_ENTER
),
293 KEY(3, 8, KEY_BACKSPACE
),
299 const struct matrix_keymap_data palmtc_keymap_data
= {
300 .keymap
= palmtc_matrix_keys
,
301 .keymap_size
= ARRAY_SIZE(palmtc_matrix_keys
),
304 static const unsigned int palmtc_keypad_row_gpios
[] = {
308 static const unsigned int palmtc_keypad_col_gpios
[] = {
309 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 79, 80
312 static struct matrix_keypad_platform_data palmtc_keypad_platform_data
= {
313 .keymap_data
= &palmtc_keymap_data
,
314 .row_gpios
= palmtc_keypad_row_gpios
,
315 .num_row_gpios
= ARRAY_SIZE(palmtc_keypad_row_gpios
),
316 .col_gpios
= palmtc_keypad_col_gpios
,
317 .num_col_gpios
= ARRAY_SIZE(palmtc_keypad_col_gpios
),
321 .col_scan_delay_us
= 5,
324 static struct platform_device palmtc_keyboard
= {
325 .name
= "matrix-keypad",
328 .platform_data
= &palmtc_keypad_platform_data
,
331 static void __init
palmtc_mkp_init(void)
333 platform_device_register(&palmtc_keyboard
);
336 static inline void palmtc_mkp_init(void) {}
339 /******************************************************************************
341 ******************************************************************************/
342 #if defined(CONFIG_USB_GADGET_PXA25X)||defined(CONFIG_USB_GADGET_PXA25X_MODULE)
343 static struct gpio_vbus_mach_info palmtc_udc_info
= {
344 .gpio_vbus
= GPIO_NR_PALMTC_USB_DETECT_N
,
345 .gpio_vbus_inverted
= 1,
346 .gpio_pullup
= GPIO_NR_PALMTC_USB_POWER
,
349 static struct platform_device palmtc_gpio_vbus
= {
353 .platform_data
= &palmtc_udc_info
,
357 static void __init
palmtc_udc_init(void)
359 platform_device_register(&palmtc_gpio_vbus
);
362 static inline void palmtc_udc_init(void) {}
365 /******************************************************************************
366 * Touchscreen / Battery / GPIO-extender
367 ******************************************************************************/
368 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
369 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
370 static struct platform_device palmtc_ucb1400_device
= {
371 .name
= "ucb1400_core",
375 static void __init
palmtc_ts_init(void)
377 pxa_set_ac97_info(NULL
);
378 platform_device_register(&palmtc_ucb1400_device
);
381 static inline void palmtc_ts_init(void) {}
384 /******************************************************************************
386 ******************************************************************************/
387 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
388 struct gpio_led palmtc_gpio_leds
[] = {
390 .name
= "palmtc:green:user",
391 .default_trigger
= "none",
392 .gpio
= GPIO_NR_PALMTC_LED_POWER
,
395 .name
= "palmtc:vibra:vibra",
396 .default_trigger
= "none",
397 .gpio
= GPIO_NR_PALMTC_VIBRA_POWER
,
403 static struct gpio_led_platform_data palmtc_gpio_led_info
= {
404 .leds
= palmtc_gpio_leds
,
405 .num_leds
= ARRAY_SIZE(palmtc_gpio_leds
),
408 static struct platform_device palmtc_leds
= {
412 .platform_data
= &palmtc_gpio_led_info
,
416 static void __init
palmtc_leds_init(void)
418 platform_device_register(&palmtc_leds
);
421 static inline void palmtc_leds_init(void) {}
424 /******************************************************************************
426 ******************************************************************************/
427 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
428 static struct resource palmtc_flash_resource
= {
429 .start
= PXA_CS0_PHYS
,
430 .end
= PXA_CS0_PHYS
+ SZ_16M
- 1,
431 .flags
= IORESOURCE_MEM
,
434 static struct mtd_partition palmtc_flash_parts
[] = {
436 .name
= "U-Boot Bootloader",
441 .name
= "Linux Kernel",
446 .name
= "Filesystem",
451 .name
= "U-Boot Environment",
453 .size
= MTDPART_SIZ_FULL
,
457 static struct physmap_flash_data palmtc_flash_data
= {
459 .parts
= palmtc_flash_parts
,
460 .nr_parts
= ARRAY_SIZE(palmtc_flash_parts
),
463 static struct platform_device palmtc_flash
= {
464 .name
= "physmap-flash",
466 .resource
= &palmtc_flash_resource
,
469 .platform_data
= &palmtc_flash_data
,
473 static void __init
palmtc_nor_init(void)
475 platform_device_register(&palmtc_flash
);
478 static inline void palmtc_nor_init(void) {}
481 /******************************************************************************
483 ******************************************************************************/
484 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
485 static struct pxafb_mode_info palmtc_lcd_modes
[] = {
502 static struct pxafb_mach_info palmtc_lcd_screen
= {
503 .modes
= palmtc_lcd_modes
,
504 .num_modes
= ARRAY_SIZE(palmtc_lcd_modes
),
505 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
508 static void __init
palmtc_lcd_init(void)
510 set_pxa_fb_info(&palmtc_lcd_screen
);
513 static inline void palmtc_lcd_init(void) {}
516 /******************************************************************************
518 ******************************************************************************/
519 static void __init
palmtc_init(void)
521 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtc_pin_config
));
523 pxa_set_ffuart_info(NULL
);
524 pxa_set_btuart_info(NULL
);
525 pxa_set_stuart_info(NULL
);
526 pxa_set_hwuart_info(NULL
);
540 MACHINE_START(PALMTC
, "Palm Tungsten|C")
541 .boot_params
= 0xa0000100,
542 .map_io
= pxa25x_map_io
,
543 .init_irq
= pxa25x_init_irq
,
545 .init_machine
= palmtc_init