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>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
33 #include <mach/audio.h>
34 #include <mach/palmtc.h>
36 #include <mach/pxafb.h>
37 #include <mach/mfp-pxa25x.h>
38 #include <mach/irda.h>
40 #include <mach/pxa2xx-regs.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 */
109 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 0 */
110 GPIO9_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 1 */
111 GPIO10_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 2 */
112 GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 3 */
113 GPIO18_GPIO | MFP_LPM_DRIVE_LOW, /* out 0 */
114 GPIO19_GPIO | MFP_LPM_DRIVE_LOW, /* out 1 */
115 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* out 2 */
116 GPIO21_GPIO | MFP_LPM_DRIVE_LOW, /* out 3 */
117 GPIO22_GPIO | MFP_LPM_DRIVE_LOW, /* out 4 */
118 GPIO23_GPIO | MFP_LPM_DRIVE_LOW, /* out 5 */
119 GPIO24_GPIO | MFP_LPM_DRIVE_LOW, /* out 6 */
120 GPIO25_GPIO | MFP_LPM_DRIVE_LOW, /* out 7 */
121 GPIO26_GPIO | MFP_LPM_DRIVE_LOW, /* out 8 */
122 GPIO27_GPIO | MFP_LPM_DRIVE_LOW, /* out 9 */
123 GPIO79_GPIO | MFP_LPM_DRIVE_LOW, /* out 10 */
124 GPIO80_GPIO | MFP_LPM_DRIVE_LOW, /* out 11 */
127 GPIO7_GPIO | WAKEUP_ON_EDGE_BOTH, /* hotsync button on cradle */
130 GPIO1_RST, /* reset */
131 GPIO2_GPIO, /* earphone detect */
132 GPIO16_GPIO, /* backlight switch */
135 /******************************************************************************
136 * SD/MMC card controller
137 ******************************************************************************/
138 static struct pxamci_platform_data palmtc_mci_platform_data = {
139 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
140 .gpio_power = GPIO_NR_PALMTC_SD_POWER,
141 .gpio_card_ro = GPIO_NR_PALMTC_SD_READONLY,
142 .gpio_card_detect = GPIO_NR_PALMTC_SD_DETECT_N,
146 /******************************************************************************
148 ******************************************************************************/
149 static struct gpio_keys_button palmtc_pxa_buttons[] = {
150 {KEY_F8, GPIO_NR_PALMTC_HOTSYNC_BUTTON, 1, "HotSync Button", EV_KEY, 1},
153 static struct gpio_keys_platform_data palmtc_pxa_keys_data = {
154 .buttons = palmtc_pxa_buttons,
155 .nbuttons = ARRAY_SIZE(palmtc_pxa_buttons),
158 static struct platform_device palmtc_pxa_keys = {
162 .platform_data = &palmtc_pxa_keys_data,
166 /******************************************************************************
168 ******************************************************************************/
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 /******************************************************************************
220 ******************************************************************************/
221 static struct pxaficp_platform_data palmtc_ficp_platform_data = {
222 .gpio_pwdown = GPIO_NR_PALMTC_IR_DISABLE,
223 .transceiver_cap = IR_SIRMODE | IR_OFF,
226 /******************************************************************************
228 ******************************************************************************/
229 static const uint32_t palmtc_matrix_keys[] = {
232 KEY(0, 2, KEY_POWER),
236 KEY(0, 6, KEY_LEFTSHIFT),
249 KEY(1, 7, KEY_SPACE),
253 KEY(1, 11, KEY_LEFT),
256 KEY(2, 1, KEY_LEFTCTRL),
265 KEY(2, 11, KEY_RIGHT),
268 KEY(3, 1, KEY_ENTER),
272 KEY(3, 6, KEY_LEFTALT),
273 KEY(3, 7, KEY_ENTER),
274 KEY(3, 8, KEY_BACKSPACE),
280 const struct matrix_keymap_data palmtc_keymap_data = {
281 .keymap = palmtc_matrix_keys,
282 .keymap_size = ARRAY_SIZE(palmtc_matrix_keys),
285 const static unsigned int palmtc_keypad_row_gpios[] = {
289 const static unsigned int palmtc_keypad_col_gpios[] = {
290 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 79, 80
293 static struct matrix_keypad_platform_data palmtc_keypad_platform_data = {
294 .keymap_data = &palmtc_keymap_data,
295 .row_gpios = palmtc_keypad_row_gpios,
296 .num_row_gpios = ARRAY_SIZE(palmtc_keypad_row_gpios),
297 .col_gpios = palmtc_keypad_col_gpios,
298 .num_col_gpios = ARRAY_SIZE(palmtc_keypad_col_gpios),
302 .col_scan_delay_us = 5,
305 static struct platform_device palmtc_keyboard = {
306 .name = "matrix-keypad",
309 .platform_data = &palmtc_keypad_platform_data,
313 /******************************************************************************
315 ******************************************************************************/
316 static struct pxa2xx_udc_mach_info palmtc_udc_info __initdata = {
317 .gpio_vbus = GPIO_NR_PALMTC_USB_DETECT_N,
318 .gpio_vbus_inverted = 1,
319 .gpio_pullup = GPIO_NR_PALMTC_USB_POWER,
322 /******************************************************************************
323 * Touchscreen / Battery / GPIO-extender
324 ******************************************************************************/
325 static struct platform_device palmtc_ucb1400_core = {
326 .name = "ucb1400_core",
330 /******************************************************************************
332 ******************************************************************************/
333 static struct resource palmtc_flash_resource = {
334 .start = PXA_CS0_PHYS,
335 .end = PXA_CS0_PHYS + SZ_16M - 1,
336 .flags = IORESOURCE_MEM,
339 static struct mtd_partition palmtc_flash_parts[] = {
341 .name = "U-Boot Bootloader",
346 .name = "Linux Kernel",
351 .name = "Filesystem",
356 .name = "U-Boot Environment",
358 .size = MTDPART_SIZ_FULL,
362 static struct physmap_flash_data palmtc_flash_data = {
364 .parts = palmtc_flash_parts,
365 .nr_parts = ARRAY_SIZE(palmtc_flash_parts),
368 static struct platform_device palmtc_flash = {
369 .name = "physmap-flash",
371 .resource = &palmtc_flash_resource,
374 .platform_data = &palmtc_flash_data,
378 /******************************************************************************
380 ******************************************************************************/
381 static struct pxafb_mode_info palmtc_lcd_modes[] = {
398 static struct pxafb_mach_info palmtc_lcd_screen = {
399 .modes = palmtc_lcd_modes,
400 .num_modes = ARRAY_SIZE(palmtc_lcd_modes),
401 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
404 /******************************************************************************
406 ******************************************************************************/
407 static struct platform_device *devices[] __initdata = {
409 &palmtc_ucb1400_core,
415 static void __init palmtc_init(void)
417 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtc_pin_config));
419 pxa_set_ffuart_info(NULL);
420 pxa_set_btuart_info(NULL);
421 pxa_set_stuart_info(NULL);
422 pxa_set_hwuart_info(NULL);
424 set_pxa_fb_info(&palmtc_lcd_screen);
425 pxa_set_mci_info(&palmtc_mci_platform_data);
426 pxa_set_udc_info(&palmtc_udc_info);
427 pxa_set_ac97_info(NULL);
428 pxa_set_ficp_info(&palmtc_ficp_platform_data);
430 platform_add_devices(devices, ARRAY_SIZE(devices));
433 MACHINE_START(PALMTC, "Palm Tungsten|C")
434 .phys_io = 0x40000000,
435 .boot_params = 0xa0000100,
436 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
437 .map_io = pxa_map_io,
438 .init_irq = pxa25x_init_irq,
440 .init_machine = palmtc_init