Commit | Line | Data |
---|---|---|
2a23ec36 JM |
1 | /* |
2 | * linux/arch/arm/mach-pxa/balloon3.c | |
3 | * | |
4 | * Support for Balloonboard.org Balloon3 board. | |
5 | * | |
6 | * Author: Nick Bane, Wookey, Jonathan McDowell | |
7 | * Created: June, 2006 | |
8 | * Copyright: Toby Churchill Ltd | |
9 | * Derived from mainstone.c, by Nico Pitre | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License version 2 as | |
13 | * published by the Free Software Foundation. | |
14 | */ | |
15 | ||
16 | #include <linux/init.h> | |
17 | #include <linux/platform_device.h> | |
18 | #include <linux/sysdev.h> | |
19 | #include <linux/interrupt.h> | |
20 | #include <linux/sched.h> | |
21 | #include <linux/bitops.h> | |
22 | #include <linux/fb.h> | |
23 | #include <linux/gpio.h> | |
24 | #include <linux/ioport.h> | |
12a2449c | 25 | #include <linux/ucb1400.h> |
2a23ec36 JM |
26 | #include <linux/mtd/mtd.h> |
27 | #include <linux/mtd/partitions.h> | |
28 | #include <linux/types.h> | |
02a453e4 | 29 | #include <linux/i2c/pcf857x.h> |
e6a8ef54 MV |
30 | #include <linux/mtd/nand.h> |
31 | #include <linux/mtd/physmap.h> | |
3a27f6e0 | 32 | #include <linux/regulator/max1586.h> |
2a23ec36 JM |
33 | |
34 | #include <asm/setup.h> | |
35 | #include <asm/mach-types.h> | |
36 | #include <asm/irq.h> | |
37 | #include <asm/sizes.h> | |
38 | ||
39 | #include <asm/mach/arch.h> | |
40 | #include <asm/mach/map.h> | |
41 | #include <asm/mach/irq.h> | |
42 | #include <asm/mach/flash.h> | |
43 | ||
44 | #include <mach/pxa27x.h> | |
45 | #include <mach/balloon3.h> | |
46 | #include <mach/audio.h> | |
47 | #include <mach/pxafb.h> | |
48 | #include <mach/mmc.h> | |
49 | #include <mach/udc.h> | |
50 | #include <mach/pxa27x-udc.h> | |
51 | #include <mach/irda.h> | |
52 | #include <mach/ohci.h> | |
53 | ||
54 | #include <plat/i2c.h> | |
55 | ||
56 | #include "generic.h" | |
57 | #include "devices.h" | |
58 | ||
b0240bf4 MV |
59 | /****************************************************************************** |
60 | * Pin configuration | |
61 | ******************************************************************************/ | |
62 | static unsigned long balloon3_pin_config[] __initdata = { | |
63 | /* Select BTUART 'COM1/ttyS0' as IO option for pins 42/43/44/45 */ | |
64 | GPIO42_BTUART_RXD, | |
65 | GPIO43_BTUART_TXD, | |
66 | GPIO44_BTUART_CTS, | |
67 | GPIO45_BTUART_RTS, | |
2a23ec36 | 68 | |
12a2449c | 69 | /* Reset, configured as GPIO wakeup source */ |
b0240bf4 | 70 | GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, |
c11b6a42 EM |
71 | }; |
72 | ||
b0240bf4 | 73 | /****************************************************************************** |
12a2449c | 74 | * Compatibility: Parameter parsing |
b0240bf4 | 75 | ******************************************************************************/ |
12a2449c | 76 | static unsigned long balloon3_irq_enabled; |
b0240bf4 | 77 | |
12a2449c MV |
78 | static unsigned long balloon3_features_present = |
79 | (1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) | | |
80 | (1 << BALLOON3_FEATURE_AUDIO) | | |
81 | (1 << BALLOON3_FEATURE_TOPPOLY); | |
82 | ||
83 | int balloon3_has(enum balloon3_features feature) | |
2a23ec36 | 84 | { |
12a2449c MV |
85 | return (balloon3_features_present & (1 << feature)) ? 1 : 0; |
86 | } | |
87 | EXPORT_SYMBOL_GPL(balloon3_has); | |
88 | ||
89 | int __init parse_balloon3_features(char *arg) | |
90 | { | |
91 | if (!arg) | |
92 | return 0; | |
93 | ||
94 | return strict_strtoul(arg, 0, &balloon3_features_present); | |
2a23ec36 | 95 | } |
12a2449c | 96 | early_param("balloon3_features", parse_balloon3_features); |
2a23ec36 | 97 | |
b476ef05 MV |
98 | /****************************************************************************** |
99 | * Compact Flash slot | |
100 | ******************************************************************************/ | |
101 | #if defined(CONFIG_PCMCIA_PXA2XX) || defined(CONFIG_PCMCIA_PXA2XX_MODULE) | |
102 | static unsigned long balloon3_cf_pin_config[] __initdata = { | |
103 | GPIO48_nPOE, | |
104 | GPIO49_nPWE, | |
105 | GPIO50_nPIOR, | |
106 | GPIO51_nPIOW, | |
107 | GPIO85_nPCE_1, | |
108 | GPIO54_nPCE_2, | |
109 | GPIO79_PSKTSEL, | |
110 | GPIO55_nPREG, | |
111 | GPIO56_nPWAIT, | |
112 | GPIO57_nIOIS16, | |
113 | }; | |
114 | ||
115 | static void __init balloon3_cf_init(void) | |
116 | { | |
117 | if (!balloon3_has(BALLOON3_FEATURE_CF)) | |
118 | return; | |
119 | ||
120 | pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_cf_pin_config)); | |
121 | } | |
122 | #else | |
123 | static inline void balloon3_cf_init(void) {} | |
124 | #endif | |
125 | ||
12a2449c MV |
126 | /****************************************************************************** |
127 | * NOR Flash | |
128 | ******************************************************************************/ | |
129 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) | |
130 | static struct mtd_partition balloon3_nor_partitions[] = { | |
131 | { | |
132 | .name = "Flash", | |
133 | .offset = 0x00000000, | |
134 | .size = MTDPART_SIZ_FULL, | |
135 | } | |
136 | }; | |
137 | ||
138 | static struct physmap_flash_data balloon3_flash_data[] = { | |
139 | { | |
140 | .width = 2, /* bankwidth in bytes */ | |
141 | .parts = balloon3_nor_partitions, | |
142 | .nr_parts = ARRAY_SIZE(balloon3_nor_partitions) | |
143 | } | |
144 | }; | |
145 | ||
146 | static struct resource balloon3_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 balloon3_flash = { | |
153 | .name = "physmap-flash", | |
154 | .id = 0, | |
155 | .resource = &balloon3_flash_resource, | |
156 | .num_resources = 1, | |
157 | .dev = { | |
158 | .platform_data = balloon3_flash_data, | |
159 | }, | |
160 | }; | |
161 | static void __init balloon3_nor_init(void) | |
162 | { | |
163 | platform_device_register(&balloon3_flash); | |
164 | } | |
165 | #else | |
166 | static inline void balloon3_nor_init(void) {} | |
167 | #endif | |
168 | ||
169 | /****************************************************************************** | |
170 | * Audio and Touchscreen | |
171 | ******************************************************************************/ | |
172 | #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \ | |
173 | defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE) | |
b476ef05 MV |
174 | static unsigned long balloon3_ac97_pin_config[] __initdata = { |
175 | GPIO28_AC97_BITCLK, | |
176 | GPIO29_AC97_SDATA_IN_0, | |
177 | GPIO30_AC97_SDATA_OUT, | |
178 | GPIO31_AC97_SYNC, | |
179 | GPIO113_AC97_nRESET, | |
180 | GPIO95_GPIO, | |
181 | }; | |
182 | ||
12a2449c MV |
183 | static struct ucb1400_pdata vpac270_ucb1400_pdata = { |
184 | .irq = IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ), | |
185 | }; | |
186 | ||
187 | ||
188 | static struct platform_device balloon3_ucb1400_device = { | |
189 | .name = "ucb1400_core", | |
190 | .id = -1, | |
191 | .dev = { | |
192 | .platform_data = &vpac270_ucb1400_pdata, | |
193 | }, | |
194 | }; | |
195 | ||
196 | static void __init balloon3_ts_init(void) | |
197 | { | |
198 | if (!balloon3_has(BALLOON3_FEATURE_AUDIO)) | |
199 | return; | |
200 | ||
b476ef05 | 201 | pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_ac97_pin_config)); |
12a2449c MV |
202 | pxa_set_ac97_info(NULL); |
203 | platform_device_register(&balloon3_ucb1400_device); | |
204 | } | |
205 | #else | |
206 | static inline void balloon3_ts_init(void) {} | |
207 | #endif | |
208 | ||
209 | /****************************************************************************** | |
210 | * Framebuffer | |
211 | ******************************************************************************/ | |
212 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) | |
b476ef05 MV |
213 | static unsigned long balloon3_lcd_pin_config[] __initdata = { |
214 | GPIOxx_LCD_TFT_16BPP, | |
215 | GPIO99_GPIO, | |
216 | }; | |
217 | ||
2a23ec36 JM |
218 | static struct pxafb_mode_info balloon3_lcd_modes[] = { |
219 | { | |
220 | .pixclock = 38000, | |
221 | .xres = 480, | |
222 | .yres = 640, | |
223 | .bpp = 16, | |
224 | .hsync_len = 8, | |
225 | .left_margin = 8, | |
226 | .right_margin = 8, | |
227 | .vsync_len = 2, | |
228 | .upper_margin = 4, | |
229 | .lower_margin = 5, | |
230 | .sync = 0, | |
231 | }, | |
232 | }; | |
233 | ||
12a2449c | 234 | static struct pxafb_mach_info balloon3_lcd_screen = { |
2a23ec36 JM |
235 | .modes = balloon3_lcd_modes, |
236 | .num_modes = ARRAY_SIZE(balloon3_lcd_modes), | |
237 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, | |
2a23ec36 JM |
238 | }; |
239 | ||
12a2449c MV |
240 | static void balloon3_backlight_power(int on) |
241 | { | |
242 | gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on); | |
243 | } | |
2a23ec36 | 244 | |
12a2449c | 245 | static void __init balloon3_lcd_init(void) |
2a23ec36 | 246 | { |
12a2449c MV |
247 | int ret; |
248 | ||
249 | if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY)) | |
250 | return; | |
251 | ||
b476ef05 MV |
252 | pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_lcd_pin_config)); |
253 | ||
12a2449c MV |
254 | ret = gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT, "BKL-ON"); |
255 | if (ret) { | |
256 | pr_err("Requesting BKL-ON GPIO failed!\n"); | |
257 | goto err; | |
258 | } | |
259 | ||
260 | ret = gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT, 1); | |
261 | if (ret) { | |
262 | pr_err("Setting BKL-ON GPIO direction failed!\n"); | |
263 | goto err2; | |
2a23ec36 | 264 | } |
12a2449c MV |
265 | |
266 | balloon3_lcd_screen.pxafb_backlight_power = balloon3_backlight_power; | |
267 | set_pxa_fb_info(&balloon3_lcd_screen); | |
268 | return; | |
269 | ||
270 | err2: | |
271 | gpio_free(BALLOON3_GPIO_RUN_BACKLIGHT); | |
272 | err: | |
273 | return; | |
2a23ec36 | 274 | } |
12a2449c MV |
275 | #else |
276 | static inline void balloon3_lcd_init(void) {} | |
277 | #endif | |
2a23ec36 | 278 | |
12a2449c MV |
279 | /****************************************************************************** |
280 | * SD/MMC card controller | |
281 | ******************************************************************************/ | |
282 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) | |
b476ef05 MV |
283 | static unsigned long balloon3_mmc_pin_config[] __initdata = { |
284 | GPIO32_MMC_CLK, | |
285 | GPIO92_MMC_DAT_0, | |
286 | GPIO109_MMC_DAT_1, | |
287 | GPIO110_MMC_DAT_2, | |
288 | GPIO111_MMC_DAT_3, | |
289 | GPIO112_MMC_CMD, | |
290 | }; | |
291 | ||
2a23ec36 | 292 | static struct pxamci_platform_data balloon3_mci_platform_data = { |
12a2449c MV |
293 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
294 | .gpio_card_detect = -1, | |
295 | .gpio_card_ro = -1, | |
296 | .gpio_power = -1, | |
297 | .detect_delay_ms = 200, | |
2a23ec36 JM |
298 | }; |
299 | ||
12a2449c MV |
300 | static void __init balloon3_mmc_init(void) |
301 | { | |
b476ef05 | 302 | pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_mmc_pin_config)); |
12a2449c MV |
303 | pxa_set_mci_info(&balloon3_mci_platform_data); |
304 | } | |
305 | #else | |
306 | static inline void balloon3_mmc_init(void) {} | |
307 | #endif | |
308 | ||
b0240bf4 MV |
309 | /****************************************************************************** |
310 | * USB Gadget | |
311 | ******************************************************************************/ | |
12a2449c MV |
312 | #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE) |
313 | static void balloon3_udc_command(int cmd) | |
2a23ec36 | 314 | { |
12a2449c MV |
315 | if (cmd == PXA2XX_UDC_CMD_CONNECT) |
316 | UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE; | |
317 | else if (cmd == PXA2XX_UDC_CMD_DISCONNECT) | |
318 | UP2OCR &= ~UP2OCR_DPPUE; | |
2a23ec36 JM |
319 | } |
320 | ||
12a2449c | 321 | static int balloon3_udc_is_connected(void) |
2a23ec36 | 322 | { |
12a2449c | 323 | return 1; |
2a23ec36 JM |
324 | } |
325 | ||
12a2449c MV |
326 | static struct pxa2xx_udc_mach_info balloon3_udc_info __initdata = { |
327 | .udc_command = balloon3_udc_command, | |
328 | .udc_is_connected = balloon3_udc_is_connected, | |
329 | .gpio_pullup = -1, | |
2a23ec36 JM |
330 | }; |
331 | ||
12a2449c MV |
332 | static void __init balloon3_udc_init(void) |
333 | { | |
334 | pxa_set_udc_info(&balloon3_udc_info); | |
335 | platform_device_register(&balloon3_gpio_vbus); | |
336 | } | |
337 | #else | |
338 | static inline void balloon3_udc_init(void) {} | |
339 | #endif | |
340 | ||
b0240bf4 MV |
341 | /****************************************************************************** |
342 | * IrDA | |
343 | ******************************************************************************/ | |
12a2449c | 344 | #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE) |
2a23ec36 | 345 | static struct pxaficp_platform_data balloon3_ficp_platform_data = { |
12a2449c | 346 | .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF, |
2a23ec36 JM |
347 | }; |
348 | ||
12a2449c MV |
349 | static void __init balloon3_irda_init(void) |
350 | { | |
351 | pxa_set_ficp_info(&balloon3_ficp_platform_data); | |
352 | } | |
353 | #else | |
354 | static inline void balloon3_irda_init(void) {} | |
355 | #endif | |
356 | ||
b0240bf4 MV |
357 | /****************************************************************************** |
358 | * USB Host | |
359 | ******************************************************************************/ | |
12a2449c | 360 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
b476ef05 MV |
361 | static unsigned long balloon3_uhc_pin_config[] __initdata = { |
362 | GPIO88_USBH1_PWR, | |
363 | GPIO89_USBH1_PEN, | |
364 | }; | |
365 | ||
12a2449c | 366 | static struct pxaohci_platform_data balloon3_ohci_info = { |
2a23ec36 JM |
367 | .port_mode = PMM_PERPORT_MODE, |
368 | .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW, | |
369 | }; | |
370 | ||
12a2449c MV |
371 | static void __init balloon3_uhc_init(void) |
372 | { | |
373 | if (!balloon3_has(BALLOON3_FEATURE_OHCI)) | |
374 | return; | |
b476ef05 | 375 | pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_uhc_pin_config)); |
12a2449c MV |
376 | pxa_set_ohci_info(&balloon3_ohci_info); |
377 | } | |
378 | #else | |
379 | static inline void balloon3_uhc_init(void) {} | |
380 | #endif | |
381 | ||
b0240bf4 | 382 | /****************************************************************************** |
12a2449c | 383 | * LEDs |
b0240bf4 | 384 | ******************************************************************************/ |
12a2449c | 385 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) |
b476ef05 MV |
386 | static unsigned long balloon3_led_pin_config[] __initdata = { |
387 | GPIO9_GPIO, /* NAND activity LED */ | |
388 | GPIO10_GPIO, /* Heartbeat LED */ | |
389 | }; | |
390 | ||
12a2449c | 391 | struct gpio_led balloon3_gpio_leds[] = { |
2a23ec36 JM |
392 | { |
393 | .name = "balloon3:green:idle", | |
394 | .default_trigger = "heartbeat", | |
395 | .gpio = BALLOON3_GPIO_LED_IDLE, | |
396 | .active_low = 1, | |
12a2449c | 397 | }, { |
2a23ec36 JM |
398 | .name = "balloon3:green:nand", |
399 | .default_trigger = "nand-disk", | |
400 | .gpio = BALLOON3_GPIO_LED_NAND, | |
401 | .active_low = 1, | |
402 | }, | |
403 | }; | |
404 | ||
12a2449c | 405 | static struct gpio_led_platform_data balloon3_gpio_led_info = { |
2a23ec36 JM |
406 | .leds = balloon3_gpio_leds, |
407 | .num_leds = ARRAY_SIZE(balloon3_gpio_leds), | |
408 | }; | |
409 | ||
12a2449c | 410 | static struct platform_device balloon3_leds = { |
2a23ec36 | 411 | .name = "leds-gpio", |
02a453e4 | 412 | .id = 0, |
2a23ec36 | 413 | .dev = { |
12a2449c MV |
414 | .platform_data = &balloon3_gpio_led_info, |
415 | } | |
2a23ec36 JM |
416 | }; |
417 | ||
02a453e4 MV |
418 | struct gpio_led balloon3_pcf_gpio_leds[] = { |
419 | { | |
420 | .name = "balloon3:green:led0", | |
421 | .gpio = BALLOON3_PCF_GPIO_LED0, | |
422 | .active_low = 1, | |
423 | }, { | |
424 | .name = "balloon3:green:led1", | |
425 | .gpio = BALLOON3_PCF_GPIO_LED1, | |
426 | .active_low = 1, | |
427 | }, { | |
428 | .name = "balloon3:orange:led2", | |
429 | .gpio = BALLOON3_PCF_GPIO_LED2, | |
430 | .active_low = 1, | |
431 | }, { | |
432 | .name = "balloon3:orange:led3", | |
433 | .gpio = BALLOON3_PCF_GPIO_LED3, | |
434 | .active_low = 1, | |
435 | }, { | |
436 | .name = "balloon3:orange:led4", | |
437 | .gpio = BALLOON3_PCF_GPIO_LED4, | |
438 | .active_low = 1, | |
439 | }, { | |
440 | .name = "balloon3:orange:led5", | |
441 | .gpio = BALLOON3_PCF_GPIO_LED5, | |
442 | .active_low = 1, | |
443 | }, { | |
444 | .name = "balloon3:red:led6", | |
445 | .gpio = BALLOON3_PCF_GPIO_LED6, | |
446 | .active_low = 1, | |
447 | }, { | |
448 | .name = "balloon3:red:led7", | |
449 | .gpio = BALLOON3_PCF_GPIO_LED7, | |
450 | .active_low = 1, | |
451 | }, | |
452 | }; | |
453 | ||
454 | static struct gpio_led_platform_data balloon3_pcf_gpio_led_info = { | |
455 | .leds = balloon3_pcf_gpio_leds, | |
456 | .num_leds = ARRAY_SIZE(balloon3_pcf_gpio_leds), | |
457 | }; | |
458 | ||
459 | static struct platform_device balloon3_pcf_leds = { | |
460 | .name = "leds-gpio", | |
461 | .id = 1, | |
462 | .dev = { | |
463 | .platform_data = &balloon3_pcf_gpio_led_info, | |
464 | } | |
465 | }; | |
466 | ||
12a2449c | 467 | static void __init balloon3_leds_init(void) |
b0240bf4 | 468 | { |
b476ef05 | 469 | pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_led_pin_config)); |
12a2449c | 470 | platform_device_register(&balloon3_leds); |
02a453e4 | 471 | platform_device_register(&balloon3_pcf_leds); |
b0240bf4 | 472 | } |
12a2449c MV |
473 | #else |
474 | static inline void balloon3_leds_init(void) {} | |
475 | #endif | |
b0240bf4 MV |
476 | |
477 | /****************************************************************************** | |
478 | * FPGA IRQ | |
479 | ******************************************************************************/ | |
a3f4c927 | 480 | static void balloon3_mask_irq(struct irq_data *d) |
b0240bf4 | 481 | { |
a3f4c927 | 482 | int balloon3_irq = (d->irq - BALLOON3_IRQ(0)); |
b0240bf4 MV |
483 | balloon3_irq_enabled &= ~(1 << balloon3_irq); |
484 | __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG); | |
485 | } | |
486 | ||
a3f4c927 | 487 | static void balloon3_unmask_irq(struct irq_data *d) |
b0240bf4 | 488 | { |
a3f4c927 | 489 | int balloon3_irq = (d->irq - BALLOON3_IRQ(0)); |
b0240bf4 MV |
490 | balloon3_irq_enabled |= (1 << balloon3_irq); |
491 | __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG); | |
492 | } | |
493 | ||
494 | static struct irq_chip balloon3_irq_chip = { | |
495 | .name = "FPGA", | |
a3f4c927 LB |
496 | .irq_ack = balloon3_mask_irq, |
497 | .irq_mask = balloon3_mask_irq, | |
498 | .irq_unmask = balloon3_unmask_irq, | |
b0240bf4 MV |
499 | }; |
500 | ||
501 | static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc) | |
502 | { | |
503 | unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) & | |
504 | balloon3_irq_enabled; | |
b0240bf4 MV |
505 | do { |
506 | /* clear useless edge notification */ | |
a3f4c927 LB |
507 | if (desc->irq_data.chip->irq_ack) { |
508 | struct irq_data *d; | |
509 | ||
510 | d = irq_get_irq_data(BALLOON3_AUX_NIRQ); | |
511 | desc->irq_data.chip->irq_ack(d); | |
512 | } | |
513 | ||
b0240bf4 MV |
514 | while (pending) { |
515 | irq = BALLOON3_IRQ(0) + __ffs(pending); | |
516 | generic_handle_irq(irq); | |
517 | pending &= pending - 1; | |
518 | } | |
519 | pending = __raw_readl(BALLOON3_INT_CONTROL_REG) & | |
520 | balloon3_irq_enabled; | |
521 | } while (pending); | |
522 | } | |
523 | ||
524 | static void __init balloon3_init_irq(void) | |
525 | { | |
526 | int irq; | |
527 | ||
528 | pxa27x_init_irq(); | |
529 | /* setup extra Balloon3 irqs */ | |
530 | for (irq = BALLOON3_IRQ(0); irq <= BALLOON3_IRQ(7); irq++) { | |
531 | set_irq_chip(irq, &balloon3_irq_chip); | |
532 | set_irq_handler(irq, handle_level_irq); | |
533 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); | |
534 | } | |
535 | ||
536 | set_irq_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler); | |
537 | set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING); | |
538 | ||
539 | pr_debug("%s: chained handler installed - irq %d automatically " | |
540 | "enabled\n", __func__, BALLOON3_AUX_NIRQ); | |
541 | } | |
542 | ||
02a453e4 MV |
543 | /****************************************************************************** |
544 | * GPIO expander | |
545 | ******************************************************************************/ | |
546 | #if defined(CONFIG_GPIO_PCF857X) || defined(CONFIG_GPIO_PCF857X_MODULE) | |
547 | static struct pcf857x_platform_data balloon3_pcf857x_pdata = { | |
548 | .gpio_base = BALLOON3_PCF_GPIO_BASE, | |
549 | .n_latch = 0, | |
550 | .setup = NULL, | |
551 | .teardown = NULL, | |
552 | .context = NULL, | |
553 | }; | |
554 | ||
555 | static struct i2c_board_info __initdata balloon3_i2c_devs[] = { | |
556 | { | |
557 | I2C_BOARD_INFO("pcf8574a", 0x38), | |
558 | .platform_data = &balloon3_pcf857x_pdata, | |
559 | }, | |
560 | }; | |
561 | ||
562 | static void __init balloon3_i2c_init(void) | |
563 | { | |
564 | pxa_set_i2c_info(NULL); | |
565 | i2c_register_board_info(0, ARRAY_AND_SIZE(balloon3_i2c_devs)); | |
566 | } | |
567 | #else | |
568 | static inline void balloon3_i2c_init(void) {} | |
569 | #endif | |
570 | ||
e6a8ef54 MV |
571 | /****************************************************************************** |
572 | * NAND | |
573 | ******************************************************************************/ | |
574 | #if defined(CONFIG_MTD_NAND_PLATFORM)||defined(CONFIG_MTD_NAND_PLATFORM_MODULE) | |
e6a8ef54 MV |
575 | static void balloon3_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl) |
576 | { | |
577 | struct nand_chip *this = mtd->priv; | |
1b9169d8 | 578 | uint8_t balloon3_ctl_set = 0, balloon3_ctl_clr = 0; |
e6a8ef54 MV |
579 | |
580 | if (ctrl & NAND_CTRL_CHANGE) { | |
581 | if (ctrl & NAND_CLE) | |
1b9169d8 | 582 | balloon3_ctl_set |= BALLOON3_NAND_CONTROL_FLCLE; |
e6a8ef54 | 583 | else |
1b9169d8 | 584 | balloon3_ctl_clr |= BALLOON3_NAND_CONTROL_FLCLE; |
e6a8ef54 MV |
585 | |
586 | if (ctrl & NAND_ALE) | |
1b9169d8 | 587 | balloon3_ctl_set |= BALLOON3_NAND_CONTROL_FLALE; |
e6a8ef54 | 588 | else |
1b9169d8 MV |
589 | balloon3_ctl_clr |= BALLOON3_NAND_CONTROL_FLALE; |
590 | ||
591 | if (balloon3_ctl_clr) | |
592 | __raw_writel(balloon3_ctl_clr, | |
593 | BALLOON3_NAND_CONTROL_REG); | |
594 | if (balloon3_ctl_set) | |
595 | __raw_writel(balloon3_ctl_set, | |
596 | BALLOON3_NAND_CONTROL_REG | | |
597 | BALLOON3_FPGA_SETnCLR); | |
e6a8ef54 MV |
598 | } |
599 | ||
600 | if (cmd != NAND_CMD_NONE) | |
601 | writeb(cmd, this->IO_ADDR_W); | |
602 | } | |
603 | ||
604 | static void balloon3_nand_select_chip(struct mtd_info *mtd, int chip) | |
605 | { | |
606 | if (chip < 0 || chip > 3) | |
607 | return; | |
608 | ||
1b9169d8 MV |
609 | /* Assert all nCE lines */ |
610 | __raw_writew( | |
611 | BALLOON3_NAND_CONTROL_FLCE0 | BALLOON3_NAND_CONTROL_FLCE1 | | |
612 | BALLOON3_NAND_CONTROL_FLCE2 | BALLOON3_NAND_CONTROL_FLCE3, | |
613 | BALLOON3_NAND_CONTROL_REG | BALLOON3_FPGA_SETnCLR); | |
e6a8ef54 MV |
614 | |
615 | /* Deassert correct nCE line */ | |
1b9169d8 MV |
616 | __raw_writew(BALLOON3_NAND_CONTROL_FLCE0 << chip, |
617 | BALLOON3_NAND_CONTROL_REG); | |
e6a8ef54 MV |
618 | } |
619 | ||
59bdd133 MV |
620 | static int balloon3_nand_dev_ready(struct mtd_info *mtd) |
621 | { | |
622 | return __raw_readl(BALLOON3_NAND_STAT_REG) & BALLOON3_NAND_STAT_RNB; | |
623 | } | |
624 | ||
e6a8ef54 MV |
625 | static int balloon3_nand_probe(struct platform_device *pdev) |
626 | { | |
e6a8ef54 MV |
627 | uint16_t ver; |
628 | int ret; | |
629 | ||
1b9169d8 MV |
630 | __raw_writew(BALLOON3_NAND_CONTROL2_16BIT, |
631 | BALLOON3_NAND_CONTROL2_REG | BALLOON3_FPGA_SETnCLR); | |
e6a8ef54 MV |
632 | |
633 | ver = __raw_readw(BALLOON3_FPGA_VER); | |
1b9169d8 MV |
634 | if (ver < 0x4f08) |
635 | pr_warn("The FPGA code, version 0x%04x, is too old. " | |
e6a8ef54 MV |
636 | "NAND support might be broken in this version!", ver); |
637 | ||
638 | /* Power up the NAND chips */ | |
639 | ret = gpio_request(BALLOON3_GPIO_RUN_NAND, "NAND"); | |
640 | if (ret) | |
641 | goto err1; | |
642 | ||
643 | ret = gpio_direction_output(BALLOON3_GPIO_RUN_NAND, 1); | |
644 | if (ret) | |
645 | goto err2; | |
646 | ||
647 | gpio_set_value(BALLOON3_GPIO_RUN_NAND, 1); | |
648 | ||
649 | /* Deassert all nCE lines and write protect line */ | |
1b9169d8 MV |
650 | __raw_writel( |
651 | BALLOON3_NAND_CONTROL_FLCE0 | BALLOON3_NAND_CONTROL_FLCE1 | | |
652 | BALLOON3_NAND_CONTROL_FLCE2 | BALLOON3_NAND_CONTROL_FLCE3 | | |
653 | BALLOON3_NAND_CONTROL_FLWP, | |
654 | BALLOON3_NAND_CONTROL_REG | BALLOON3_FPGA_SETnCLR); | |
e6a8ef54 MV |
655 | return 0; |
656 | ||
657 | err2: | |
658 | gpio_free(BALLOON3_GPIO_RUN_NAND); | |
659 | err1: | |
660 | return ret; | |
661 | } | |
662 | ||
663 | static void balloon3_nand_remove(struct platform_device *pdev) | |
664 | { | |
665 | /* Power down the NAND chips */ | |
666 | gpio_set_value(BALLOON3_GPIO_RUN_NAND, 0); | |
667 | gpio_free(BALLOON3_GPIO_RUN_NAND); | |
668 | } | |
669 | ||
670 | static struct mtd_partition balloon3_partition_info[] = { | |
671 | [0] = { | |
672 | .name = "Boot", | |
673 | .offset = 0, | |
674 | .size = SZ_4M, | |
675 | }, | |
676 | [1] = { | |
677 | .name = "RootFS", | |
678 | .offset = MTDPART_OFS_APPEND, | |
679 | .size = MTDPART_SIZ_FULL | |
680 | }, | |
681 | }; | |
682 | ||
683 | static const char *balloon3_part_probes[] = { "cmdlinepart", NULL }; | |
684 | ||
685 | struct platform_nand_data balloon3_nand_pdata = { | |
686 | .chip = { | |
687 | .nr_chips = 4, | |
688 | .chip_offset = 0, | |
689 | .nr_partitions = ARRAY_SIZE(balloon3_partition_info), | |
690 | .partitions = balloon3_partition_info, | |
691 | .chip_delay = 50, | |
692 | .part_probe_types = balloon3_part_probes, | |
693 | }, | |
694 | .ctrl = { | |
695 | .hwcontrol = 0, | |
59bdd133 | 696 | .dev_ready = balloon3_nand_dev_ready, |
e6a8ef54 MV |
697 | .select_chip = balloon3_nand_select_chip, |
698 | .cmd_ctrl = balloon3_nand_cmd_ctl, | |
699 | .probe = balloon3_nand_probe, | |
700 | .remove = balloon3_nand_remove, | |
701 | }, | |
702 | }; | |
703 | ||
704 | static struct resource balloon3_nand_resource[] = { | |
705 | [0] = { | |
706 | .start = BALLOON3_NAND_BASE, | |
707 | .end = BALLOON3_NAND_BASE + 0x4, | |
708 | .flags = IORESOURCE_MEM, | |
709 | }, | |
710 | }; | |
711 | ||
712 | static struct platform_device balloon3_nand = { | |
713 | .name = "gen_nand", | |
714 | .num_resources = ARRAY_SIZE(balloon3_nand_resource), | |
715 | .resource = balloon3_nand_resource, | |
716 | .id = -1, | |
717 | .dev = { | |
718 | .platform_data = &balloon3_nand_pdata, | |
719 | } | |
720 | }; | |
721 | ||
722 | static void __init balloon3_nand_init(void) | |
723 | { | |
724 | platform_device_register(&balloon3_nand); | |
725 | } | |
726 | #else | |
727 | static inline void balloon3_nand_init(void) {} | |
728 | #endif | |
729 | ||
3a27f6e0 MV |
730 | /****************************************************************************** |
731 | * Core power regulator | |
732 | ******************************************************************************/ | |
733 | #if defined(CONFIG_REGULATOR_MAX1586) || \ | |
734 | defined(CONFIG_REGULATOR_MAX1586_MODULE) | |
735 | static struct regulator_consumer_supply balloon3_max1587a_consumers[] = { | |
736 | { | |
737 | .supply = "vcc_core", | |
738 | } | |
739 | }; | |
740 | ||
741 | static struct regulator_init_data balloon3_max1587a_v3_info = { | |
742 | .constraints = { | |
743 | .name = "vcc_core range", | |
744 | .min_uV = 900000, | |
745 | .max_uV = 1705000, | |
746 | .always_on = 1, | |
747 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, | |
748 | }, | |
749 | .consumer_supplies = balloon3_max1587a_consumers, | |
750 | .num_consumer_supplies = ARRAY_SIZE(balloon3_max1587a_consumers), | |
751 | }; | |
752 | ||
753 | static struct max1586_subdev_data balloon3_max1587a_subdevs[] = { | |
754 | { | |
755 | .name = "vcc_core", | |
756 | .id = MAX1586_V3, | |
757 | .platform_data = &balloon3_max1587a_v3_info, | |
758 | } | |
759 | }; | |
760 | ||
761 | static struct max1586_platform_data balloon3_max1587a_info = { | |
762 | .subdevs = balloon3_max1587a_subdevs, | |
763 | .num_subdevs = ARRAY_SIZE(balloon3_max1587a_subdevs), | |
764 | .v3_gain = MAX1586_GAIN_R24_3k32, /* 730..1550 mV */ | |
765 | }; | |
766 | ||
767 | static struct i2c_board_info __initdata balloon3_pi2c_board_info[] = { | |
768 | { | |
769 | I2C_BOARD_INFO("max1586", 0x14), | |
770 | .platform_data = &balloon3_max1587a_info, | |
771 | }, | |
772 | }; | |
773 | ||
774 | static void __init balloon3_pmic_init(void) | |
775 | { | |
776 | pxa27x_set_i2c_power_info(NULL); | |
777 | i2c_register_board_info(1, ARRAY_AND_SIZE(balloon3_pi2c_board_info)); | |
778 | } | |
779 | #else | |
780 | static inline void balloon3_pmic_init(void) {} | |
781 | #endif | |
782 | ||
b0240bf4 MV |
783 | /****************************************************************************** |
784 | * Machine init | |
785 | ******************************************************************************/ | |
2a23ec36 JM |
786 | static void __init balloon3_init(void) |
787 | { | |
2a23ec36 JM |
788 | ARB_CNTRL = ARB_CORE_PARK | 0x234; |
789 | ||
12a2449c MV |
790 | pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config)); |
791 | ||
cc155c6f RK |
792 | pxa_set_ffuart_info(NULL); |
793 | pxa_set_btuart_info(NULL); | |
794 | pxa_set_stuart_info(NULL); | |
795 | ||
02a453e4 | 796 | balloon3_i2c_init(); |
12a2449c MV |
797 | balloon3_irda_init(); |
798 | balloon3_lcd_init(); | |
799 | balloon3_leds_init(); | |
800 | balloon3_mmc_init(); | |
e6a8ef54 | 801 | balloon3_nand_init(); |
12a2449c | 802 | balloon3_nor_init(); |
3a27f6e0 | 803 | balloon3_pmic_init(); |
12a2449c MV |
804 | balloon3_ts_init(); |
805 | balloon3_udc_init(); | |
806 | balloon3_uhc_init(); | |
b476ef05 | 807 | balloon3_cf_init(); |
2a23ec36 JM |
808 | } |
809 | ||
810 | static struct map_desc balloon3_io_desc[] __initdata = { | |
811 | { /* CPLD/FPGA */ | |
812 | .virtual = BALLOON3_FPGA_VIRT, | |
813 | .pfn = __phys_to_pfn(BALLOON3_FPGA_PHYS), | |
814 | .length = BALLOON3_FPGA_LENGTH, | |
815 | .type = MT_DEVICE, | |
816 | }, | |
817 | }; | |
818 | ||
819 | static void __init balloon3_map_io(void) | |
820 | { | |
851982c1 | 821 | pxa27x_map_io(); |
2a23ec36 JM |
822 | iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc)); |
823 | } | |
824 | ||
825 | MACHINE_START(BALLOON3, "Balloon3") | |
826 | /* Maintainer: Nick Bane. */ | |
2a23ec36 | 827 | .map_io = balloon3_map_io, |
6ac6b817 | 828 | .nr_irqs = BALLOON3_NR_IRQS, |
2a23ec36 JM |
829 | .init_irq = balloon3_init_irq, |
830 | .timer = &pxa_timer, | |
831 | .init_machine = balloon3_init, | |
832 | .boot_params = PHYS_OFFSET + 0x100, | |
833 | MACHINE_END |