[ARM] pxa/vpac270: Add touchscreen support
[deliverable/linux.git] / arch / arm / mach-pxa / vpac270.c
CommitLineData
543cd842
M
1/*
2 * Hardware definitions for Voipac PXA270
3 *
4 * Copyright (C) 2010
5 * Marek Vasut <marek.vasut@gmail.com>
6 *
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.
10 *
11 */
12
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>
3d98f881 20#include <linux/usb/gpio_vbus.h>
543cd842
M
21#include <linux/mtd/mtd.h>
22#include <linux/mtd/partitions.h>
23#include <linux/mtd/physmap.h>
947fb57e 24#include <linux/dm9000.h>
1a8fb70e 25#include <linux/ucb1400.h>
543cd842
M
26
27#include <asm/mach-types.h>
28#include <asm/mach/arch.h>
29
30#include <mach/pxa27x.h>
1a8fb70e 31#include <mach/audio.h>
543cd842
M
32#include <mach/vpac270.h>
33#include <mach/mmc.h>
34#include <mach/pxafb.h>
3d98f881
MV
35#include <mach/ohci.h>
36#include <mach/pxa27x-udc.h>
37#include <mach/udc.h>
543cd842
M
38
39#include "generic.h"
40#include "devices.h"
41
42/******************************************************************************
43 * Pin configuration
44 ******************************************************************************/
45static 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 */
55
56 /* GPIO KEYS */
57 GPIO1_GPIO, /* USER BTN */
58
59 /* LEDs */
60 GPIO15_GPIO, /* orange led */
61
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,
71
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,
addff0fa
MV
95
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 */
114
3d98f881
MV
115 /* UHC */
116 GPIO88_USBH1_PWR,
117 GPIO89_USBH1_PEN,
118 GPIO119_USBH2_PWR,
119 GPIO120_USBH2_PEN,
120
121 /* UDC */
122 GPIO41_GPIO,
947fb57e
MV
123
124 /* Ethernet */
125 GPIO114_GPIO, /* IRQ */
1a8fb70e
MV
126
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 */
543cd842
M
135};
136
137/******************************************************************************
138 * NOR Flash
139 ******************************************************************************/
140#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
141static struct mtd_partition vpac270_partitions[] = {
142 {
143 .name = "Flash",
144 .offset = 0x00000000,
145 .size = MTDPART_SIZ_FULL,
146 }
147};
148
149static struct physmap_flash_data vpac270_flash_data[] = {
150 {
151 .width = 2, /* bankwidth in bytes */
152 .parts = vpac270_partitions,
153 .nr_parts = ARRAY_SIZE(vpac270_partitions)
154 }
155};
156
157static struct resource vpac270_flash_resource = {
158 .start = PXA_CS0_PHYS,
159 .end = PXA_CS0_PHYS + SZ_64M - 1,
160 .flags = IORESOURCE_MEM,
161};
162
163static 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,
170 },
171};
172static void __init vpac270_nor_init(void)
173{
174 platform_device_register(&vpac270_flash);
175}
176#else
177static inline void vpac270_nor_init(void) {}
178#endif
179
180/******************************************************************************
181 * SD/MMC card controller
182 ******************************************************************************/
183#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
184static 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,
189};
190
191static void __init vpac270_mmc_init(void)
192{
193 pxa_set_mci_info(&vpac270_mci_platform_data);
194}
195#else
196static inline void vpac270_mmc_init(void) {}
197#endif
198
199/******************************************************************************
200 * GPIO keys
201 ******************************************************************************/
202#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
203static struct gpio_keys_button vpac270_pxa_buttons[] = {
204 {KEY_POWER, GPIO1_VPAC270_USER_BTN, 0, "USER BTN"},
205};
206
207static struct gpio_keys_platform_data vpac270_pxa_keys_data = {
208 .buttons = vpac270_pxa_buttons,
209 .nbuttons = ARRAY_SIZE(vpac270_pxa_buttons),
210};
211
212static struct platform_device vpac270_pxa_keys = {
213 .name = "gpio-keys",
214 .id = -1,
215 .dev = {
216 .platform_data = &vpac270_pxa_keys_data,
217 },
218};
219
220static void __init vpac270_keys_init(void)
221{
222 platform_device_register(&vpac270_pxa_keys);
223}
224#else
225static inline void vpac270_keys_init(void) {}
226#endif
227
228/******************************************************************************
229 * LED
230 ******************************************************************************/
231#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
232struct gpio_led vpac270_gpio_leds[] = {
233{
234 .name = "vpac270:orange:user",
235 .default_trigger = "none",
236 .gpio = GPIO15_VPAC270_LED_ORANGE,
237 .active_low = 1,
238}
239};
240
241static struct gpio_led_platform_data vpac270_gpio_led_info = {
242 .leds = vpac270_gpio_leds,
243 .num_leds = ARRAY_SIZE(vpac270_gpio_leds),
244};
245
246static struct platform_device vpac270_leds = {
247 .name = "leds-gpio",
248 .id = -1,
249 .dev = {
250 .platform_data = &vpac270_gpio_led_info,
251 }
252};
253
254static void __init vpac270_leds_init(void)
255{
256 platform_device_register(&vpac270_leds);
257}
258#else
259static inline void vpac270_leds_init(void) {}
260#endif
261
3d98f881
MV
262/******************************************************************************
263 * USB Host
264 ******************************************************************************/
265#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
266static int vpac270_ohci_init(struct device *dev)
267{
268 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
269 return 0;
270}
271
272static 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,
277};
278
279static void __init vpac270_uhc_init(void)
280{
281 pxa_set_ohci_info(&vpac270_ohci_info);
282}
283#else
284static inline void vpac270_uhc_init(void) {}
285#endif
286
287/******************************************************************************
288 * USB Gadget
289 ******************************************************************************/
290#if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
291static struct gpio_vbus_mach_info vpac270_gpio_vbus_info = {
292 .gpio_vbus = GPIO41_VPAC270_UDC_DETECT,
293 .gpio_pullup = -1,
294};
295
296static struct platform_device vpac270_gpio_vbus = {
297 .name = "gpio-vbus",
298 .id = -1,
299 .dev = {
300 .platform_data = &vpac270_gpio_vbus_info,
301 },
302};
303
304static void vpac270_udc_command(int cmd)
305{
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);
310}
311
312static struct pxa2xx_udc_mach_info vpac270_udc_info __initdata = {
313 .udc_command = vpac270_udc_command,
314 .gpio_pullup = -1,
315};
316
317static void __init vpac270_udc_init(void)
318{
319 pxa_set_udc_info(&vpac270_udc_info);
320 platform_device_register(&vpac270_gpio_vbus);
321}
322#else
323static inline void vpac270_udc_init(void) {}
324#endif
325
947fb57e
MV
326/******************************************************************************
327 * Ethernet
328 ******************************************************************************/
329#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
330static struct resource vpac270_dm9000_resources[] = {
331 [0] = {
332 .start = PXA_CS2_PHYS + 0x300,
333 .end = PXA_CS2_PHYS + 0x303,
334 .flags = IORESOURCE_MEM,
335 },
336 [1] = {
337 .start = PXA_CS2_PHYS + 0x304,
338 .end = PXA_CS2_PHYS + 0x343,
339 .flags = IORESOURCE_MEM,
340 },
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,
345 },
346};
347
348static struct dm9000_plat_data vpac270_dm9000_platdata = {
349 .flags = DM9000_PLATF_32BITONLY,
350};
351
352static 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,
359 }
360};
361
362static void __init vpac270_eth_init(void)
363{
364 platform_device_register(&vpac270_dm9000_device);
365}
366#else
367static inline void vpac270_eth_init(void) {}
368#endif
369
1a8fb70e
MV
370/******************************************************************************
371 * Audio and Touchscreen
372 ******************************************************************************/
373#if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
374 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
375static pxa2xx_audio_ops_t vpac270_ac97_pdata = {
376 .reset_gpio = 95,
377};
378
379static struct ucb1400_pdata vpac270_ucb1400_pdata = {
380 .irq = IRQ_GPIO(113),
381};
382
383static struct platform_device vpac270_ucb1400_device = {
384 .name = "ucb1400_core",
385 .id = -1,
386 .dev = {
387 .platform_data = &vpac270_ucb1400_pdata,
388 },
389};
390
391static void __init vpac270_ts_init(void)
392{
393 pxa_set_ac97_info(&vpac270_ac97_pdata);
394 platform_device_register(&vpac270_ucb1400_device);
395}
396#else
397static inline void vpac270_ts_init(void) {}
398#endif
399
543cd842
M
400/******************************************************************************
401 * Framebuffer
402 ******************************************************************************/
403#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
404static struct pxafb_mode_info vpac270_lcd_modes[] = {
405{
406 .pixclock = 57692,
407 .xres = 640,
408 .yres = 480,
409 .bpp = 32,
410 .depth = 18,
411
412 .left_margin = 144,
413 .right_margin = 32,
414 .upper_margin = 13,
415 .lower_margin = 30,
416
417 .hsync_len = 32,
418 .vsync_len = 2,
419
420 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
421},
422};
423
424static 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,
428};
429
430static void vpac270_lcd_power(int on, struct fb_var_screeninfo *info)
431{
432 gpio_set_value(GPIO81_VPAC270_BKL_ON, on);
433}
434
435static void __init vpac270_lcd_init(void)
436{
437 int ret;
438
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;
443 }
444
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;
449 }
450
451 vpac270_lcd_screen.pxafb_lcd_power = vpac270_lcd_power;
452 set_pxa_fb_info(&vpac270_lcd_screen);
453 return;
454
455err2:
456 gpio_free(GPIO81_VPAC270_BKL_ON);
457err:
458 return;
459}
460#else
461static inline void vpac270_lcd_init(void) {}
462#endif
463
464/******************************************************************************
465 * Machine init
466 ******************************************************************************/
467static void __init vpac270_init(void)
468{
469 pxa2xx_mfp_config(ARRAY_AND_SIZE(vpac270_pin_config));
470
471 pxa_set_ffuart_info(NULL);
472 pxa_set_btuart_info(NULL);
473 pxa_set_stuart_info(NULL);
474
475 vpac270_lcd_init();
476 vpac270_mmc_init();
477 vpac270_nor_init();
478 vpac270_leds_init();
479 vpac270_keys_init();
3d98f881
MV
480 vpac270_uhc_init();
481 vpac270_udc_init();
947fb57e 482 vpac270_eth_init();
1a8fb70e 483 vpac270_ts_init();
543cd842
M
484}
485
486MACHINE_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
494MACHINE_END
This page took 0.044956 seconds and 5 git commands to generate.