[ARM] pxa/vpac270: Add touchscreen support
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-pxa / vpac270.c
blobfa428ca54902846ac67f29ab2b0a0e5242f2e3cb
1 /*
2 * Hardware definitions for Voipac PXA270
4 * Copyright (C) 2010
5 * Marek Vasut <marek.vasut@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
13 #include <linux/platform_device.h>
14 #include <linux/delay.h>
15 #include <linux/irq.h>
16 #include <linux/gpio_keys.h>
17 #include <linux/input.h>
18 #include <linux/gpio.h>
19 #include <linux/sysdev.h>
20 #include <linux/usb/gpio_vbus.h>
21 #include <linux/mtd/mtd.h>
22 #include <linux/mtd/partitions.h>
23 #include <linux/mtd/physmap.h>
24 #include <linux/dm9000.h>
25 #include <linux/ucb1400.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
30 #include <mach/pxa27x.h>
31 #include <mach/audio.h>
32 #include <mach/vpac270.h>
33 #include <mach/mmc.h>
34 #include <mach/pxafb.h>
35 #include <mach/ohci.h>
36 #include <mach/pxa27x-udc.h>
37 #include <mach/udc.h>
39 #include "generic.h"
40 #include "devices.h"
42 /******************************************************************************
43 * Pin configuration
44 ******************************************************************************/
45 static unsigned long vpac270_pin_config[] __initdata = {
46 /* MMC */
47 GPIO32_MMC_CLK,
48 GPIO92_MMC_DAT_0,
49 GPIO109_MMC_DAT_1,
50 GPIO110_MMC_DAT_2,
51 GPIO111_MMC_DAT_3,
52 GPIO112_MMC_CMD,
53 GPIO53_GPIO, /* SD detect */
54 GPIO52_GPIO, /* SD r/o switch */
56 /* GPIO KEYS */
57 GPIO1_GPIO, /* USER BTN */
59 /* LEDs */
60 GPIO15_GPIO, /* orange led */
62 /* FFUART */
63 GPIO34_FFUART_RXD,
64 GPIO39_FFUART_TXD,
65 GPIO27_FFUART_RTS,
66 GPIO100_FFUART_CTS,
67 GPIO33_FFUART_DSR,
68 GPIO40_FFUART_DTR,
69 GPIO10_FFUART_DCD,
70 GPIO38_FFUART_RI,
72 /* LCD */
73 GPIO58_LCD_LDD_0,
74 GPIO59_LCD_LDD_1,
75 GPIO60_LCD_LDD_2,
76 GPIO61_LCD_LDD_3,
77 GPIO62_LCD_LDD_4,
78 GPIO63_LCD_LDD_5,
79 GPIO64_LCD_LDD_6,
80 GPIO65_LCD_LDD_7,
81 GPIO66_LCD_LDD_8,
82 GPIO67_LCD_LDD_9,
83 GPIO68_LCD_LDD_10,
84 GPIO69_LCD_LDD_11,
85 GPIO70_LCD_LDD_12,
86 GPIO71_LCD_LDD_13,
87 GPIO72_LCD_LDD_14,
88 GPIO73_LCD_LDD_15,
89 GPIO86_LCD_LDD_16,
90 GPIO87_LCD_LDD_17,
91 GPIO74_LCD_FCLK,
92 GPIO75_LCD_LCLK,
93 GPIO76_LCD_PCLK,
94 GPIO77_LCD_BIAS,
96 /* PCMCIA */
97 GPIO48_nPOE,
98 GPIO49_nPWE,
99 GPIO50_nPIOR,
100 GPIO51_nPIOW,
101 GPIO85_nPCE_1,
102 GPIO54_nPCE_2,
103 GPIO55_nPREG,
104 GPIO57_nIOIS16,
105 GPIO56_nPWAIT,
106 GPIO104_PSKTSEL,
107 GPIO84_GPIO, /* PCMCIA CD */
108 GPIO35_GPIO, /* PCMCIA RDY */
109 GPIO107_GPIO, /* PCMCIA PPEN */
110 GPIO11_GPIO, /* PCMCIA RESET */
111 GPIO17_GPIO, /* CF CD */
112 GPIO12_GPIO, /* CF RDY */
113 GPIO16_GPIO, /* CF RESET */
115 /* UHC */
116 GPIO88_USBH1_PWR,
117 GPIO89_USBH1_PEN,
118 GPIO119_USBH2_PWR,
119 GPIO120_USBH2_PEN,
121 /* UDC */
122 GPIO41_GPIO,
124 /* Ethernet */
125 GPIO114_GPIO, /* IRQ */
127 /* AC97 */
128 GPIO28_AC97_BITCLK,
129 GPIO29_AC97_SDATA_IN_0,
130 GPIO30_AC97_SDATA_OUT,
131 GPIO31_AC97_SYNC,
132 GPIO95_AC97_nRESET,
133 GPIO98_AC97_SYSCLK,
134 GPIO113_GPIO, /* TS IRQ */
137 /******************************************************************************
138 * NOR Flash
139 ******************************************************************************/
140 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
141 static struct mtd_partition vpac270_partitions[] = {
143 .name = "Flash",
144 .offset = 0x00000000,
145 .size = MTDPART_SIZ_FULL,
149 static struct physmap_flash_data vpac270_flash_data[] = {
151 .width = 2, /* bankwidth in bytes */
152 .parts = vpac270_partitions,
153 .nr_parts = ARRAY_SIZE(vpac270_partitions)
157 static struct resource vpac270_flash_resource = {
158 .start = PXA_CS0_PHYS,
159 .end = PXA_CS0_PHYS + SZ_64M - 1,
160 .flags = IORESOURCE_MEM,
163 static struct platform_device vpac270_flash = {
164 .name = "physmap-flash",
165 .id = 0,
166 .resource = &vpac270_flash_resource,
167 .num_resources = 1,
168 .dev = {
169 .platform_data = vpac270_flash_data,
172 static void __init vpac270_nor_init(void)
174 platform_device_register(&vpac270_flash);
176 #else
177 static inline void vpac270_nor_init(void) {}
178 #endif
180 /******************************************************************************
181 * SD/MMC card controller
182 ******************************************************************************/
183 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
184 static struct pxamci_platform_data vpac270_mci_platform_data = {
185 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
186 .gpio_card_detect = GPIO53_VPAC270_SD_DETECT_N,
187 .gpio_card_ro = GPIO52_VPAC270_SD_READONLY,
188 .detect_delay = 20,
191 static void __init vpac270_mmc_init(void)
193 pxa_set_mci_info(&vpac270_mci_platform_data);
195 #else
196 static inline void vpac270_mmc_init(void) {}
197 #endif
199 /******************************************************************************
200 * GPIO keys
201 ******************************************************************************/
202 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
203 static struct gpio_keys_button vpac270_pxa_buttons[] = {
204 {KEY_POWER, GPIO1_VPAC270_USER_BTN, 0, "USER BTN"},
207 static struct gpio_keys_platform_data vpac270_pxa_keys_data = {
208 .buttons = vpac270_pxa_buttons,
209 .nbuttons = ARRAY_SIZE(vpac270_pxa_buttons),
212 static struct platform_device vpac270_pxa_keys = {
213 .name = "gpio-keys",
214 .id = -1,
215 .dev = {
216 .platform_data = &vpac270_pxa_keys_data,
220 static void __init vpac270_keys_init(void)
222 platform_device_register(&vpac270_pxa_keys);
224 #else
225 static inline void vpac270_keys_init(void) {}
226 #endif
228 /******************************************************************************
229 * LED
230 ******************************************************************************/
231 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
232 struct gpio_led vpac270_gpio_leds[] = {
234 .name = "vpac270:orange:user",
235 .default_trigger = "none",
236 .gpio = GPIO15_VPAC270_LED_ORANGE,
237 .active_low = 1,
241 static struct gpio_led_platform_data vpac270_gpio_led_info = {
242 .leds = vpac270_gpio_leds,
243 .num_leds = ARRAY_SIZE(vpac270_gpio_leds),
246 static struct platform_device vpac270_leds = {
247 .name = "leds-gpio",
248 .id = -1,
249 .dev = {
250 .platform_data = &vpac270_gpio_led_info,
254 static void __init vpac270_leds_init(void)
256 platform_device_register(&vpac270_leds);
258 #else
259 static inline void vpac270_leds_init(void) {}
260 #endif
262 /******************************************************************************
263 * USB Host
264 ******************************************************************************/
265 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
266 static int vpac270_ohci_init(struct device *dev)
268 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
269 return 0;
272 static struct pxaohci_platform_data vpac270_ohci_info = {
273 .port_mode = PMM_PERPORT_MODE,
274 .flags = ENABLE_PORT1 | ENABLE_PORT2 |
275 POWER_CONTROL_LOW | POWER_SENSE_LOW,
276 .init = vpac270_ohci_init,
279 static void __init vpac270_uhc_init(void)
281 pxa_set_ohci_info(&vpac270_ohci_info);
283 #else
284 static inline void vpac270_uhc_init(void) {}
285 #endif
287 /******************************************************************************
288 * USB Gadget
289 ******************************************************************************/
290 #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
291 static struct gpio_vbus_mach_info vpac270_gpio_vbus_info = {
292 .gpio_vbus = GPIO41_VPAC270_UDC_DETECT,
293 .gpio_pullup = -1,
296 static struct platform_device vpac270_gpio_vbus = {
297 .name = "gpio-vbus",
298 .id = -1,
299 .dev = {
300 .platform_data = &vpac270_gpio_vbus_info,
304 static void vpac270_udc_command(int cmd)
306 if (cmd == PXA2XX_UDC_CMD_CONNECT)
307 UP2OCR |= UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE;
308 else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
309 UP2OCR &= ~(UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE);
312 static struct pxa2xx_udc_mach_info vpac270_udc_info __initdata = {
313 .udc_command = vpac270_udc_command,
314 .gpio_pullup = -1,
317 static void __init vpac270_udc_init(void)
319 pxa_set_udc_info(&vpac270_udc_info);
320 platform_device_register(&vpac270_gpio_vbus);
322 #else
323 static inline void vpac270_udc_init(void) {}
324 #endif
326 /******************************************************************************
327 * Ethernet
328 ******************************************************************************/
329 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
330 static struct resource vpac270_dm9000_resources[] = {
331 [0] = {
332 .start = PXA_CS2_PHYS + 0x300,
333 .end = PXA_CS2_PHYS + 0x303,
334 .flags = IORESOURCE_MEM,
336 [1] = {
337 .start = PXA_CS2_PHYS + 0x304,
338 .end = PXA_CS2_PHYS + 0x343,
339 .flags = IORESOURCE_MEM,
341 [2] = {
342 .start = IRQ_GPIO(GPIO114_VPAC270_ETH_IRQ),
343 .end = IRQ_GPIO(GPIO114_VPAC270_ETH_IRQ),
344 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
348 static struct dm9000_plat_data vpac270_dm9000_platdata = {
349 .flags = DM9000_PLATF_32BITONLY,
352 static struct platform_device vpac270_dm9000_device = {
353 .name = "dm9000",
354 .id = -1,
355 .num_resources = ARRAY_SIZE(vpac270_dm9000_resources),
356 .resource = vpac270_dm9000_resources,
357 .dev = {
358 .platform_data = &vpac270_dm9000_platdata,
362 static void __init vpac270_eth_init(void)
364 platform_device_register(&vpac270_dm9000_device);
366 #else
367 static inline void vpac270_eth_init(void) {}
368 #endif
370 /******************************************************************************
371 * Audio and Touchscreen
372 ******************************************************************************/
373 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
374 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
375 static pxa2xx_audio_ops_t vpac270_ac97_pdata = {
376 .reset_gpio = 95,
379 static struct ucb1400_pdata vpac270_ucb1400_pdata = {
380 .irq = IRQ_GPIO(113),
383 static struct platform_device vpac270_ucb1400_device = {
384 .name = "ucb1400_core",
385 .id = -1,
386 .dev = {
387 .platform_data = &vpac270_ucb1400_pdata,
391 static void __init vpac270_ts_init(void)
393 pxa_set_ac97_info(&vpac270_ac97_pdata);
394 platform_device_register(&vpac270_ucb1400_device);
396 #else
397 static inline void vpac270_ts_init(void) {}
398 #endif
400 /******************************************************************************
401 * Framebuffer
402 ******************************************************************************/
403 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
404 static struct pxafb_mode_info vpac270_lcd_modes[] = {
406 .pixclock = 57692,
407 .xres = 640,
408 .yres = 480,
409 .bpp = 32,
410 .depth = 18,
412 .left_margin = 144,
413 .right_margin = 32,
414 .upper_margin = 13,
415 .lower_margin = 30,
417 .hsync_len = 32,
418 .vsync_len = 2,
420 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
424 static struct pxafb_mach_info vpac270_lcd_screen = {
425 .modes = vpac270_lcd_modes,
426 .num_modes = ARRAY_SIZE(vpac270_lcd_modes),
427 .lcd_conn = LCD_COLOR_TFT_18BPP,
430 static void vpac270_lcd_power(int on, struct fb_var_screeninfo *info)
432 gpio_set_value(GPIO81_VPAC270_BKL_ON, on);
435 static void __init vpac270_lcd_init(void)
437 int ret;
439 ret = gpio_request(GPIO81_VPAC270_BKL_ON, "BKL-ON");
440 if (ret) {
441 pr_err("Requesting BKL-ON GPIO failed!\n");
442 goto err;
445 ret = gpio_direction_output(GPIO81_VPAC270_BKL_ON, 1);
446 if (ret) {
447 pr_err("Setting BKL-ON GPIO direction failed!\n");
448 goto err2;
451 vpac270_lcd_screen.pxafb_lcd_power = vpac270_lcd_power;
452 set_pxa_fb_info(&vpac270_lcd_screen);
453 return;
455 err2:
456 gpio_free(GPIO81_VPAC270_BKL_ON);
457 err:
458 return;
460 #else
461 static inline void vpac270_lcd_init(void) {}
462 #endif
464 /******************************************************************************
465 * Machine init
466 ******************************************************************************/
467 static void __init vpac270_init(void)
469 pxa2xx_mfp_config(ARRAY_AND_SIZE(vpac270_pin_config));
471 pxa_set_ffuart_info(NULL);
472 pxa_set_btuart_info(NULL);
473 pxa_set_stuart_info(NULL);
475 vpac270_lcd_init();
476 vpac270_mmc_init();
477 vpac270_nor_init();
478 vpac270_leds_init();
479 vpac270_keys_init();
480 vpac270_uhc_init();
481 vpac270_udc_init();
482 vpac270_eth_init();
483 vpac270_ts_init();
486 MACHINE_START(VPAC270, "Voipac PXA270")
487 .phys_io = 0x40000000,
488 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
489 .boot_params = 0xa0000100,
490 .map_io = pxa_map_io,
491 .init_irq = pxa27x_init_irq,
492 .timer = &pxa_timer,
493 .init_machine = vpac270_init
494 MACHINE_END