Commit | Line | Data |
---|---|---|
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> |
543cd842 M |
25 | |
26 | #include <asm/mach-types.h> | |
27 | #include <asm/mach/arch.h> | |
28 | ||
29 | #include <mach/pxa27x.h> | |
30 | #include <mach/vpac270.h> | |
31 | #include <mach/mmc.h> | |
32 | #include <mach/pxafb.h> | |
3d98f881 MV |
33 | #include <mach/ohci.h> |
34 | #include <mach/pxa27x-udc.h> | |
35 | #include <mach/udc.h> | |
543cd842 M |
36 | |
37 | #include "generic.h" | |
38 | #include "devices.h" | |
39 | ||
40 | /****************************************************************************** | |
41 | * Pin configuration | |
42 | ******************************************************************************/ | |
43 | static unsigned long vpac270_pin_config[] __initdata = { | |
44 | /* MMC */ | |
45 | GPIO32_MMC_CLK, | |
46 | GPIO92_MMC_DAT_0, | |
47 | GPIO109_MMC_DAT_1, | |
48 | GPIO110_MMC_DAT_2, | |
49 | GPIO111_MMC_DAT_3, | |
50 | GPIO112_MMC_CMD, | |
51 | GPIO53_GPIO, /* SD detect */ | |
52 | GPIO52_GPIO, /* SD r/o switch */ | |
53 | ||
54 | /* GPIO KEYS */ | |
55 | GPIO1_GPIO, /* USER BTN */ | |
56 | ||
57 | /* LEDs */ | |
58 | GPIO15_GPIO, /* orange led */ | |
59 | ||
60 | /* FFUART */ | |
61 | GPIO34_FFUART_RXD, | |
62 | GPIO39_FFUART_TXD, | |
63 | GPIO27_FFUART_RTS, | |
64 | GPIO100_FFUART_CTS, | |
65 | GPIO33_FFUART_DSR, | |
66 | GPIO40_FFUART_DTR, | |
67 | GPIO10_FFUART_DCD, | |
68 | GPIO38_FFUART_RI, | |
69 | ||
70 | /* LCD */ | |
71 | GPIO58_LCD_LDD_0, | |
72 | GPIO59_LCD_LDD_1, | |
73 | GPIO60_LCD_LDD_2, | |
74 | GPIO61_LCD_LDD_3, | |
75 | GPIO62_LCD_LDD_4, | |
76 | GPIO63_LCD_LDD_5, | |
77 | GPIO64_LCD_LDD_6, | |
78 | GPIO65_LCD_LDD_7, | |
79 | GPIO66_LCD_LDD_8, | |
80 | GPIO67_LCD_LDD_9, | |
81 | GPIO68_LCD_LDD_10, | |
82 | GPIO69_LCD_LDD_11, | |
83 | GPIO70_LCD_LDD_12, | |
84 | GPIO71_LCD_LDD_13, | |
85 | GPIO72_LCD_LDD_14, | |
86 | GPIO73_LCD_LDD_15, | |
87 | GPIO86_LCD_LDD_16, | |
88 | GPIO87_LCD_LDD_17, | |
89 | GPIO74_LCD_FCLK, | |
90 | GPIO75_LCD_LCLK, | |
91 | GPIO76_LCD_PCLK, | |
92 | GPIO77_LCD_BIAS, | |
addff0fa MV |
93 | |
94 | /* PCMCIA */ | |
95 | GPIO48_nPOE, | |
96 | GPIO49_nPWE, | |
97 | GPIO50_nPIOR, | |
98 | GPIO51_nPIOW, | |
99 | GPIO85_nPCE_1, | |
100 | GPIO54_nPCE_2, | |
101 | GPIO55_nPREG, | |
102 | GPIO57_nIOIS16, | |
103 | GPIO56_nPWAIT, | |
104 | GPIO104_PSKTSEL, | |
105 | GPIO84_GPIO, /* PCMCIA CD */ | |
106 | GPIO35_GPIO, /* PCMCIA RDY */ | |
107 | GPIO107_GPIO, /* PCMCIA PPEN */ | |
108 | GPIO11_GPIO, /* PCMCIA RESET */ | |
109 | GPIO17_GPIO, /* CF CD */ | |
110 | GPIO12_GPIO, /* CF RDY */ | |
111 | GPIO16_GPIO, /* CF RESET */ | |
112 | ||
3d98f881 MV |
113 | /* UHC */ |
114 | GPIO88_USBH1_PWR, | |
115 | GPIO89_USBH1_PEN, | |
116 | GPIO119_USBH2_PWR, | |
117 | GPIO120_USBH2_PEN, | |
118 | ||
119 | /* UDC */ | |
120 | GPIO41_GPIO, | |
947fb57e MV |
121 | |
122 | /* Ethernet */ | |
123 | GPIO114_GPIO, /* IRQ */ | |
543cd842 M |
124 | }; |
125 | ||
126 | /****************************************************************************** | |
127 | * NOR Flash | |
128 | ******************************************************************************/ | |
129 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) | |
130 | static struct mtd_partition vpac270_partitions[] = { | |
131 | { | |
132 | .name = "Flash", | |
133 | .offset = 0x00000000, | |
134 | .size = MTDPART_SIZ_FULL, | |
135 | } | |
136 | }; | |
137 | ||
138 | static struct physmap_flash_data vpac270_flash_data[] = { | |
139 | { | |
140 | .width = 2, /* bankwidth in bytes */ | |
141 | .parts = vpac270_partitions, | |
142 | .nr_parts = ARRAY_SIZE(vpac270_partitions) | |
143 | } | |
144 | }; | |
145 | ||
146 | static struct resource vpac270_flash_resource = { | |
147 | .start = PXA_CS0_PHYS, | |
148 | .end = PXA_CS0_PHYS + SZ_64M - 1, | |
149 | .flags = IORESOURCE_MEM, | |
150 | }; | |
151 | ||
152 | static struct platform_device vpac270_flash = { | |
153 | .name = "physmap-flash", | |
154 | .id = 0, | |
155 | .resource = &vpac270_flash_resource, | |
156 | .num_resources = 1, | |
157 | .dev = { | |
158 | .platform_data = vpac270_flash_data, | |
159 | }, | |
160 | }; | |
161 | static void __init vpac270_nor_init(void) | |
162 | { | |
163 | platform_device_register(&vpac270_flash); | |
164 | } | |
165 | #else | |
166 | static inline void vpac270_nor_init(void) {} | |
167 | #endif | |
168 | ||
169 | /****************************************************************************** | |
170 | * SD/MMC card controller | |
171 | ******************************************************************************/ | |
172 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) | |
173 | static struct pxamci_platform_data vpac270_mci_platform_data = { | |
174 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, | |
175 | .gpio_card_detect = GPIO53_VPAC270_SD_DETECT_N, | |
176 | .gpio_card_ro = GPIO52_VPAC270_SD_READONLY, | |
177 | .detect_delay = 20, | |
178 | }; | |
179 | ||
180 | static void __init vpac270_mmc_init(void) | |
181 | { | |
182 | pxa_set_mci_info(&vpac270_mci_platform_data); | |
183 | } | |
184 | #else | |
185 | static inline void vpac270_mmc_init(void) {} | |
186 | #endif | |
187 | ||
188 | /****************************************************************************** | |
189 | * GPIO keys | |
190 | ******************************************************************************/ | |
191 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) | |
192 | static struct gpio_keys_button vpac270_pxa_buttons[] = { | |
193 | {KEY_POWER, GPIO1_VPAC270_USER_BTN, 0, "USER BTN"}, | |
194 | }; | |
195 | ||
196 | static struct gpio_keys_platform_data vpac270_pxa_keys_data = { | |
197 | .buttons = vpac270_pxa_buttons, | |
198 | .nbuttons = ARRAY_SIZE(vpac270_pxa_buttons), | |
199 | }; | |
200 | ||
201 | static struct platform_device vpac270_pxa_keys = { | |
202 | .name = "gpio-keys", | |
203 | .id = -1, | |
204 | .dev = { | |
205 | .platform_data = &vpac270_pxa_keys_data, | |
206 | }, | |
207 | }; | |
208 | ||
209 | static void __init vpac270_keys_init(void) | |
210 | { | |
211 | platform_device_register(&vpac270_pxa_keys); | |
212 | } | |
213 | #else | |
214 | static inline void vpac270_keys_init(void) {} | |
215 | #endif | |
216 | ||
217 | /****************************************************************************** | |
218 | * LED | |
219 | ******************************************************************************/ | |
220 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) | |
221 | struct gpio_led vpac270_gpio_leds[] = { | |
222 | { | |
223 | .name = "vpac270:orange:user", | |
224 | .default_trigger = "none", | |
225 | .gpio = GPIO15_VPAC270_LED_ORANGE, | |
226 | .active_low = 1, | |
227 | } | |
228 | }; | |
229 | ||
230 | static struct gpio_led_platform_data vpac270_gpio_led_info = { | |
231 | .leds = vpac270_gpio_leds, | |
232 | .num_leds = ARRAY_SIZE(vpac270_gpio_leds), | |
233 | }; | |
234 | ||
235 | static struct platform_device vpac270_leds = { | |
236 | .name = "leds-gpio", | |
237 | .id = -1, | |
238 | .dev = { | |
239 | .platform_data = &vpac270_gpio_led_info, | |
240 | } | |
241 | }; | |
242 | ||
243 | static void __init vpac270_leds_init(void) | |
244 | { | |
245 | platform_device_register(&vpac270_leds); | |
246 | } | |
247 | #else | |
248 | static inline void vpac270_leds_init(void) {} | |
249 | #endif | |
250 | ||
3d98f881 MV |
251 | /****************************************************************************** |
252 | * USB Host | |
253 | ******************************************************************************/ | |
254 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) | |
255 | static int vpac270_ohci_init(struct device *dev) | |
256 | { | |
257 | UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE; | |
258 | return 0; | |
259 | } | |
260 | ||
261 | static struct pxaohci_platform_data vpac270_ohci_info = { | |
262 | .port_mode = PMM_PERPORT_MODE, | |
263 | .flags = ENABLE_PORT1 | ENABLE_PORT2 | | |
264 | POWER_CONTROL_LOW | POWER_SENSE_LOW, | |
265 | .init = vpac270_ohci_init, | |
266 | }; | |
267 | ||
268 | static void __init vpac270_uhc_init(void) | |
269 | { | |
270 | pxa_set_ohci_info(&vpac270_ohci_info); | |
271 | } | |
272 | #else | |
273 | static inline void vpac270_uhc_init(void) {} | |
274 | #endif | |
275 | ||
276 | /****************************************************************************** | |
277 | * USB Gadget | |
278 | ******************************************************************************/ | |
279 | #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE) | |
280 | static struct gpio_vbus_mach_info vpac270_gpio_vbus_info = { | |
281 | .gpio_vbus = GPIO41_VPAC270_UDC_DETECT, | |
282 | .gpio_pullup = -1, | |
283 | }; | |
284 | ||
285 | static struct platform_device vpac270_gpio_vbus = { | |
286 | .name = "gpio-vbus", | |
287 | .id = -1, | |
288 | .dev = { | |
289 | .platform_data = &vpac270_gpio_vbus_info, | |
290 | }, | |
291 | }; | |
292 | ||
293 | static void vpac270_udc_command(int cmd) | |
294 | { | |
295 | if (cmd == PXA2XX_UDC_CMD_CONNECT) | |
296 | UP2OCR |= UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE; | |
297 | else if (cmd == PXA2XX_UDC_CMD_DISCONNECT) | |
298 | UP2OCR &= ~(UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE); | |
299 | } | |
300 | ||
301 | static struct pxa2xx_udc_mach_info vpac270_udc_info __initdata = { | |
302 | .udc_command = vpac270_udc_command, | |
303 | .gpio_pullup = -1, | |
304 | }; | |
305 | ||
306 | static void __init vpac270_udc_init(void) | |
307 | { | |
308 | pxa_set_udc_info(&vpac270_udc_info); | |
309 | platform_device_register(&vpac270_gpio_vbus); | |
310 | } | |
311 | #else | |
312 | static inline void vpac270_udc_init(void) {} | |
313 | #endif | |
314 | ||
947fb57e MV |
315 | /****************************************************************************** |
316 | * Ethernet | |
317 | ******************************************************************************/ | |
318 | #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) | |
319 | static struct resource vpac270_dm9000_resources[] = { | |
320 | [0] = { | |
321 | .start = PXA_CS2_PHYS + 0x300, | |
322 | .end = PXA_CS2_PHYS + 0x303, | |
323 | .flags = IORESOURCE_MEM, | |
324 | }, | |
325 | [1] = { | |
326 | .start = PXA_CS2_PHYS + 0x304, | |
327 | .end = PXA_CS2_PHYS + 0x343, | |
328 | .flags = IORESOURCE_MEM, | |
329 | }, | |
330 | [2] = { | |
331 | .start = IRQ_GPIO(GPIO114_VPAC270_ETH_IRQ), | |
332 | .end = IRQ_GPIO(GPIO114_VPAC270_ETH_IRQ), | |
333 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, | |
334 | }, | |
335 | }; | |
336 | ||
337 | static struct dm9000_plat_data vpac270_dm9000_platdata = { | |
338 | .flags = DM9000_PLATF_32BITONLY, | |
339 | }; | |
340 | ||
341 | static struct platform_device vpac270_dm9000_device = { | |
342 | .name = "dm9000", | |
343 | .id = -1, | |
344 | .num_resources = ARRAY_SIZE(vpac270_dm9000_resources), | |
345 | .resource = vpac270_dm9000_resources, | |
346 | .dev = { | |
347 | .platform_data = &vpac270_dm9000_platdata, | |
348 | } | |
349 | }; | |
350 | ||
351 | static void __init vpac270_eth_init(void) | |
352 | { | |
353 | platform_device_register(&vpac270_dm9000_device); | |
354 | } | |
355 | #else | |
356 | static inline void vpac270_eth_init(void) {} | |
357 | #endif | |
358 | ||
543cd842 M |
359 | /****************************************************************************** |
360 | * Framebuffer | |
361 | ******************************************************************************/ | |
362 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) | |
363 | static struct pxafb_mode_info vpac270_lcd_modes[] = { | |
364 | { | |
365 | .pixclock = 57692, | |
366 | .xres = 640, | |
367 | .yres = 480, | |
368 | .bpp = 32, | |
369 | .depth = 18, | |
370 | ||
371 | .left_margin = 144, | |
372 | .right_margin = 32, | |
373 | .upper_margin = 13, | |
374 | .lower_margin = 30, | |
375 | ||
376 | .hsync_len = 32, | |
377 | .vsync_len = 2, | |
378 | ||
379 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, | |
380 | }, | |
381 | }; | |
382 | ||
383 | static struct pxafb_mach_info vpac270_lcd_screen = { | |
384 | .modes = vpac270_lcd_modes, | |
385 | .num_modes = ARRAY_SIZE(vpac270_lcd_modes), | |
386 | .lcd_conn = LCD_COLOR_TFT_18BPP, | |
387 | }; | |
388 | ||
389 | static void vpac270_lcd_power(int on, struct fb_var_screeninfo *info) | |
390 | { | |
391 | gpio_set_value(GPIO81_VPAC270_BKL_ON, on); | |
392 | } | |
393 | ||
394 | static void __init vpac270_lcd_init(void) | |
395 | { | |
396 | int ret; | |
397 | ||
398 | ret = gpio_request(GPIO81_VPAC270_BKL_ON, "BKL-ON"); | |
399 | if (ret) { | |
400 | pr_err("Requesting BKL-ON GPIO failed!\n"); | |
401 | goto err; | |
402 | } | |
403 | ||
404 | ret = gpio_direction_output(GPIO81_VPAC270_BKL_ON, 1); | |
405 | if (ret) { | |
406 | pr_err("Setting BKL-ON GPIO direction failed!\n"); | |
407 | goto err2; | |
408 | } | |
409 | ||
410 | vpac270_lcd_screen.pxafb_lcd_power = vpac270_lcd_power; | |
411 | set_pxa_fb_info(&vpac270_lcd_screen); | |
412 | return; | |
413 | ||
414 | err2: | |
415 | gpio_free(GPIO81_VPAC270_BKL_ON); | |
416 | err: | |
417 | return; | |
418 | } | |
419 | #else | |
420 | static inline void vpac270_lcd_init(void) {} | |
421 | #endif | |
422 | ||
423 | /****************************************************************************** | |
424 | * Machine init | |
425 | ******************************************************************************/ | |
426 | static void __init vpac270_init(void) | |
427 | { | |
428 | pxa2xx_mfp_config(ARRAY_AND_SIZE(vpac270_pin_config)); | |
429 | ||
430 | pxa_set_ffuart_info(NULL); | |
431 | pxa_set_btuart_info(NULL); | |
432 | pxa_set_stuart_info(NULL); | |
433 | ||
434 | vpac270_lcd_init(); | |
435 | vpac270_mmc_init(); | |
436 | vpac270_nor_init(); | |
437 | vpac270_leds_init(); | |
438 | vpac270_keys_init(); | |
3d98f881 MV |
439 | vpac270_uhc_init(); |
440 | vpac270_udc_init(); | |
947fb57e | 441 | vpac270_eth_init(); |
543cd842 M |
442 | } |
443 | ||
444 | MACHINE_START(VPAC270, "Voipac PXA270") | |
445 | .phys_io = 0x40000000, | |
446 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
447 | .boot_params = 0xa0000100, | |
448 | .map_io = pxa_map_io, | |
449 | .init_irq = pxa27x_init_irq, | |
450 | .timer = &pxa_timer, | |
451 | .init_machine = vpac270_init | |
452 | MACHINE_END |