blob: 572525c26cac6549f6a4ed9bff9355e9e8a1f20a [file] [log] [blame]
Jonathan McDowell2a23ec32009-07-04 14:43:56 +01001/*
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>
Marek Vasut12a24492010-07-27 01:37:44 +020025#include <linux/ucb1400.h>
Jonathan McDowell2a23ec32009-07-04 14:43:56 +010026#include <linux/mtd/mtd.h>
27#include <linux/mtd/partitions.h>
28#include <linux/types.h>
29
30#include <asm/setup.h>
31#include <asm/mach-types.h>
32#include <asm/irq.h>
33#include <asm/sizes.h>
34
35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
37#include <asm/mach/irq.h>
38#include <asm/mach/flash.h>
39
40#include <mach/pxa27x.h>
41#include <mach/balloon3.h>
42#include <mach/audio.h>
43#include <mach/pxafb.h>
44#include <mach/mmc.h>
45#include <mach/udc.h>
46#include <mach/pxa27x-udc.h>
47#include <mach/irda.h>
48#include <mach/ohci.h>
49
50#include <plat/i2c.h>
51
52#include "generic.h"
53#include "devices.h"
54
Marek Vasutb0240bf2010-07-26 23:24:44 +020055/******************************************************************************
56 * Pin configuration
57 ******************************************************************************/
58static unsigned long balloon3_pin_config[] __initdata = {
59 /* Select BTUART 'COM1/ttyS0' as IO option for pins 42/43/44/45 */
60 GPIO42_BTUART_RXD,
61 GPIO43_BTUART_TXD,
62 GPIO44_BTUART_CTS,
63 GPIO45_BTUART_RTS,
64
Marek Vasut12a24492010-07-27 01:37:44 +020065 /* Reset, configured as GPIO wakeup source */
Marek Vasutb0240bf2010-07-26 23:24:44 +020066 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
67
Marek Vasut12a24492010-07-27 01:37:44 +020068 /* LEDs */
69 GPIO9_GPIO, /* NAND activity LED */
70 GPIO10_GPIO, /* Heartbeat LED */
Marek Vasutb0240bf2010-07-26 23:24:44 +020071
Marek Vasut12a24492010-07-27 01:37:44 +020072 /* AC97 */
Marek Vasutb0240bf2010-07-26 23:24:44 +020073 GPIO28_AC97_BITCLK,
74 GPIO29_AC97_SDATA_IN_0,
75 GPIO30_AC97_SDATA_OUT,
76 GPIO31_AC97_SYNC,
77 GPIO113_AC97_nRESET,
Marek Vasut12a24492010-07-27 01:37:44 +020078 GPIO95_GPIO,
Marek Vasutb0240bf2010-07-26 23:24:44 +020079
Marek Vasut12a24492010-07-27 01:37:44 +020080 /* MMC */
Marek Vasutb0240bf2010-07-26 23:24:44 +020081 GPIO32_MMC_CLK,
82 GPIO92_MMC_DAT_0,
83 GPIO109_MMC_DAT_1,
84 GPIO110_MMC_DAT_2,
85 GPIO111_MMC_DAT_3,
86 GPIO112_MMC_CMD,
Marek Vasutb0240bf2010-07-26 23:24:44 +020087
Marek Vasut12a24492010-07-27 01:37:44 +020088 /* USB Host */
Marek Vasutb0240bf2010-07-26 23:24:44 +020089 GPIO88_USBH1_PWR,
90 GPIO89_USBH1_PEN,
91};
92
Marek Vasutb0240bf2010-07-26 23:24:44 +020093/******************************************************************************
94 * Compatibility: Parameter parsing
95 ******************************************************************************/
Jonathan McDowell2a23ec32009-07-04 14:43:56 +010096static unsigned long balloon3_irq_enabled;
97
98static unsigned long balloon3_features_present =
99 (1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) |
100 (1 << BALLOON3_FEATURE_AUDIO) |
101 (1 << BALLOON3_FEATURE_TOPPOLY);
102
103int balloon3_has(enum balloon3_features feature)
104{
105 return (balloon3_features_present & (1 << feature)) ? 1 : 0;
106}
107EXPORT_SYMBOL_GPL(balloon3_has);
108
109int __init parse_balloon3_features(char *arg)
110{
111 if (!arg)
112 return 0;
113
114 return strict_strtoul(arg, 0, &balloon3_features_present);
115}
116early_param("balloon3_features", parse_balloon3_features);
117
Marek Vasutb0240bf2010-07-26 23:24:44 +0200118/******************************************************************************
Marek Vasut12a24492010-07-27 01:37:44 +0200119 * NOR Flash
120 ******************************************************************************/
121#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
122static struct mtd_partition balloon3_nor_partitions[] = {
123 {
124 .name = "Flash",
125 .offset = 0x00000000,
126 .size = MTDPART_SIZ_FULL,
127 }
128};
129
130static struct physmap_flash_data balloon3_flash_data[] = {
131 {
132 .width = 2, /* bankwidth in bytes */
133 .parts = balloon3_nor_partitions,
134 .nr_parts = ARRAY_SIZE(balloon3_nor_partitions)
135 }
136};
137
138static struct resource balloon3_flash_resource = {
139 .start = PXA_CS0_PHYS,
140 .end = PXA_CS0_PHYS + SZ_64M - 1,
141 .flags = IORESOURCE_MEM,
142};
143
144static struct platform_device balloon3_flash = {
145 .name = "physmap-flash",
146 .id = 0,
147 .resource = &balloon3_flash_resource,
148 .num_resources = 1,
149 .dev = {
150 .platform_data = balloon3_flash_data,
151 },
152};
153static void __init balloon3_nor_init(void)
154{
155 platform_device_register(&balloon3_flash);
156}
157#else
158static inline void balloon3_nor_init(void) {}
159#endif
160
161/******************************************************************************
162 * Audio and Touchscreen
163 ******************************************************************************/
164#if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
165 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
166static struct ucb1400_pdata vpac270_ucb1400_pdata = {
167 .irq = IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ),
168};
169
170
171static struct platform_device balloon3_ucb1400_device = {
172 .name = "ucb1400_core",
173 .id = -1,
174 .dev = {
175 .platform_data = &vpac270_ucb1400_pdata,
176 },
177};
178
179static void __init balloon3_ts_init(void)
180{
181 if (!balloon3_has(BALLOON3_FEATURE_AUDIO))
182 return;
183
184 pxa_set_ac97_info(NULL);
185 platform_device_register(&balloon3_ucb1400_device);
186}
187#else
188static inline void balloon3_ts_init(void) {}
189#endif
190
191/******************************************************************************
192 * Framebuffer
193 ******************************************************************************/
194#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
195static struct pxafb_mode_info balloon3_lcd_modes[] = {
196 {
197 .pixclock = 38000,
198 .xres = 480,
199 .yres = 640,
200 .bpp = 16,
201 .hsync_len = 8,
202 .left_margin = 8,
203 .right_margin = 8,
204 .vsync_len = 2,
205 .upper_margin = 4,
206 .lower_margin = 5,
207 .sync = 0,
208 },
209};
210
211static struct pxafb_mach_info balloon3_lcd_screen = {
212 .modes = balloon3_lcd_modes,
213 .num_modes = ARRAY_SIZE(balloon3_lcd_modes),
214 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
215};
216
217static void balloon3_backlight_power(int on)
218{
219 gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
220}
221
222static void __init balloon3_lcd_init(void)
223{
224 int ret;
225
226 if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY))
227 return;
228
229 ret = gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT, "BKL-ON");
230 if (ret) {
231 pr_err("Requesting BKL-ON GPIO failed!\n");
232 goto err;
233 }
234
235 ret = gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT, 1);
236 if (ret) {
237 pr_err("Setting BKL-ON GPIO direction failed!\n");
238 goto err2;
239 }
240
241 balloon3_lcd_screen.pxafb_backlight_power = balloon3_backlight_power;
242 set_pxa_fb_info(&balloon3_lcd_screen);
243 return;
244
245err2:
246 gpio_free(BALLOON3_GPIO_RUN_BACKLIGHT);
247err:
248 return;
249}
250#else
251static inline void balloon3_lcd_init(void) {}
252#endif
253
254/******************************************************************************
255 * SD/MMC card controller
256 ******************************************************************************/
257#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
258static struct pxamci_platform_data balloon3_mci_platform_data = {
259 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
260 .gpio_card_detect = -1,
261 .gpio_card_ro = -1,
262 .gpio_power = -1,
263 .detect_delay_ms = 200,
264};
265
266static void __init balloon3_mmc_init(void)
267{
268 pxa_set_mci_info(&balloon3_mci_platform_data);
269}
270#else
271static inline void balloon3_mmc_init(void) {}
272#endif
273
274/******************************************************************************
275 * USB Gadget
276 ******************************************************************************/
277#if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
278static void balloon3_udc_command(int cmd)
279{
280 if (cmd == PXA2XX_UDC_CMD_CONNECT)
281 UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE;
282 else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
283 UP2OCR &= ~UP2OCR_DPPUE;
284}
285
286static int balloon3_udc_is_connected(void)
287{
288 return 1;
289}
290
291static struct pxa2xx_udc_mach_info balloon3_udc_info __initdata = {
292 .udc_command = balloon3_udc_command,
293 .udc_is_connected = balloon3_udc_is_connected,
294 .gpio_pullup = -1,
295};
296
297static void __init balloon3_udc_init(void)
298{
299 pxa_set_udc_info(&balloon3_udc_info);
300 platform_device_register(&balloon3_gpio_vbus);
301}
302#else
303static inline void balloon3_udc_init(void) {}
304#endif
305
306/******************************************************************************
307 * IrDA
308 ******************************************************************************/
309#if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
310static struct pxaficp_platform_data balloon3_ficp_platform_data = {
311 .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF,
312};
313
314static void __init balloon3_irda_init(void)
315{
316 pxa_set_ficp_info(&balloon3_ficp_platform_data);
317}
318#else
319static inline void balloon3_irda_init(void) {}
320#endif
321
322/******************************************************************************
323 * USB Host
324 ******************************************************************************/
325#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
326static struct pxaohci_platform_data balloon3_ohci_info = {
327 .port_mode = PMM_PERPORT_MODE,
328 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
329};
330
331static void __init balloon3_uhc_init(void)
332{
333 if (!balloon3_has(BALLOON3_FEATURE_OHCI))
334 return;
335 pxa_set_ohci_info(&balloon3_ohci_info);
336}
337#else
338static inline void balloon3_uhc_init(void) {}
339#endif
340
341/******************************************************************************
342 * LEDs
343 ******************************************************************************/
344#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
345struct gpio_led balloon3_gpio_leds[] = {
346 {
347 .name = "balloon3:green:idle",
348 .default_trigger = "heartbeat",
349 .gpio = BALLOON3_GPIO_LED_IDLE,
350 .active_low = 1,
351 }, {
352 .name = "balloon3:green:nand",
353 .default_trigger = "nand-disk",
354 .gpio = BALLOON3_GPIO_LED_NAND,
355 .active_low = 1,
356 },
357};
358
359static struct gpio_led_platform_data balloon3_gpio_led_info = {
360 .leds = balloon3_gpio_leds,
361 .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
362};
363
364static struct platform_device balloon3_leds = {
365 .name = "leds-gpio",
366 .id = -1,
367 .dev = {
368 .platform_data = &balloon3_gpio_led_info,
369 }
370};
371
372static void __init balloon3_leds_init(void)
373{
374 platform_device_register(&balloon3_leds);
375}
376#else
377static inline void balloon3_leds_init(void) {}
378#endif
379
380/******************************************************************************
Marek Vasutb0240bf2010-07-26 23:24:44 +0200381 * FPGA IRQ
382 ******************************************************************************/
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100383static void balloon3_mask_irq(unsigned int irq)
384{
385 int balloon3_irq = (irq - BALLOON3_IRQ(0));
386 balloon3_irq_enabled &= ~(1 << balloon3_irq);
387 __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
388}
389
390static void balloon3_unmask_irq(unsigned int irq)
391{
392 int balloon3_irq = (irq - BALLOON3_IRQ(0));
393 balloon3_irq_enabled |= (1 << balloon3_irq);
394 __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
395}
396
397static struct irq_chip balloon3_irq_chip = {
398 .name = "FPGA",
399 .ack = balloon3_mask_irq,
400 .mask = balloon3_mask_irq,
401 .unmask = balloon3_unmask_irq,
402};
403
404static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc)
405{
406 unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
407 balloon3_irq_enabled;
408
409 do {
410 /* clear useless edge notification */
411 if (desc->chip->ack)
412 desc->chip->ack(BALLOON3_AUX_NIRQ);
413 while (pending) {
414 irq = BALLOON3_IRQ(0) + __ffs(pending);
415 generic_handle_irq(irq);
416 pending &= pending - 1;
417 }
418 pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
419 balloon3_irq_enabled;
420 } while (pending);
421}
422
423static void __init balloon3_init_irq(void)
424{
425 int irq;
426
427 pxa27x_init_irq();
428 /* setup extra Balloon3 irqs */
429 for (irq = BALLOON3_IRQ(0); irq <= BALLOON3_IRQ(7); irq++) {
430 set_irq_chip(irq, &balloon3_irq_chip);
431 set_irq_handler(irq, handle_level_irq);
432 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
433 }
434
435 set_irq_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler);
436 set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING);
437
438 pr_debug("%s: chained handler installed - irq %d automatically "
439 "enabled\n", __func__, BALLOON3_AUX_NIRQ);
440}
441
Marek Vasutb0240bf2010-07-26 23:24:44 +0200442/******************************************************************************
443 * Machine init
444 ******************************************************************************/
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100445static void __init balloon3_init(void)
446{
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100447 ARB_CNTRL = ARB_CORE_PARK | 0x234;
448
Marek Vasut12a24492010-07-27 01:37:44 +0200449 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
450
Russell Kingcc155c62009-11-09 13:34:08 +0800451 pxa_set_ffuart_info(NULL);
452 pxa_set_btuart_info(NULL);
453 pxa_set_stuart_info(NULL);
454
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100455 pxa_set_i2c_info(NULL);
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100456
Marek Vasut12a24492010-07-27 01:37:44 +0200457 balloon3_irda_init();
458 balloon3_lcd_init();
459 balloon3_leds_init();
460 balloon3_mmc_init();
461 balloon3_nor_init();
462 balloon3_ts_init();
463 balloon3_udc_init();
464 balloon3_uhc_init();
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100465}
466
467static struct map_desc balloon3_io_desc[] __initdata = {
468 { /* CPLD/FPGA */
469 .virtual = BALLOON3_FPGA_VIRT,
470 .pfn = __phys_to_pfn(BALLOON3_FPGA_PHYS),
471 .length = BALLOON3_FPGA_LENGTH,
472 .type = MT_DEVICE,
473 },
474};
475
476static void __init balloon3_map_io(void)
477{
478 pxa_map_io();
479 iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc));
480}
481
482MACHINE_START(BALLOON3, "Balloon3")
483 /* Maintainer: Nick Bane. */
484 .phys_io = 0x40000000,
485 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
486 .map_io = balloon3_map_io,
487 .init_irq = balloon3_init_irq,
488 .timer = &pxa_timer,
489 .init_machine = balloon3_init,
490 .boot_params = PHYS_OFFSET + 0x100,
491MACHINE_END