blob: 91ad56d6e92974f17089b614055f3c5eafcb64b3 [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,
Marek Vasuta9c06292010-07-27 21:48:10 +020091
92 /* PC Card */
93 GPIO48_nPOE,
94 GPIO49_nPWE,
95 GPIO50_nPIOR,
96 GPIO51_nPIOW,
97 GPIO85_nPCE_1,
98 GPIO54_nPCE_2,
99 GPIO79_PSKTSEL,
100 GPIO55_nPREG,
101 GPIO56_nPWAIT,
102 GPIO57_nIOIS16,
Marek Vasutb0240bf2010-07-26 23:24:44 +0200103};
104
Marek Vasutb0240bf2010-07-26 23:24:44 +0200105/******************************************************************************
106 * Compatibility: Parameter parsing
107 ******************************************************************************/
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100108static unsigned long balloon3_irq_enabled;
109
110static unsigned long balloon3_features_present =
111 (1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) |
112 (1 << BALLOON3_FEATURE_AUDIO) |
113 (1 << BALLOON3_FEATURE_TOPPOLY);
114
115int balloon3_has(enum balloon3_features feature)
116{
117 return (balloon3_features_present & (1 << feature)) ? 1 : 0;
118}
119EXPORT_SYMBOL_GPL(balloon3_has);
120
121int __init parse_balloon3_features(char *arg)
122{
123 if (!arg)
124 return 0;
125
126 return strict_strtoul(arg, 0, &balloon3_features_present);
127}
128early_param("balloon3_features", parse_balloon3_features);
129
Marek Vasutb0240bf2010-07-26 23:24:44 +0200130/******************************************************************************
Marek Vasut12a24492010-07-27 01:37:44 +0200131 * NOR Flash
132 ******************************************************************************/
133#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
134static struct mtd_partition balloon3_nor_partitions[] = {
135 {
136 .name = "Flash",
137 .offset = 0x00000000,
138 .size = MTDPART_SIZ_FULL,
139 }
140};
141
142static struct physmap_flash_data balloon3_flash_data[] = {
143 {
144 .width = 2, /* bankwidth in bytes */
145 .parts = balloon3_nor_partitions,
146 .nr_parts = ARRAY_SIZE(balloon3_nor_partitions)
147 }
148};
149
150static struct resource balloon3_flash_resource = {
151 .start = PXA_CS0_PHYS,
152 .end = PXA_CS0_PHYS + SZ_64M - 1,
153 .flags = IORESOURCE_MEM,
154};
155
156static struct platform_device balloon3_flash = {
157 .name = "physmap-flash",
158 .id = 0,
159 .resource = &balloon3_flash_resource,
160 .num_resources = 1,
161 .dev = {
162 .platform_data = balloon3_flash_data,
163 },
164};
165static void __init balloon3_nor_init(void)
166{
167 platform_device_register(&balloon3_flash);
168}
169#else
170static inline void balloon3_nor_init(void) {}
171#endif
172
173/******************************************************************************
174 * Audio and Touchscreen
175 ******************************************************************************/
176#if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
177 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
178static struct ucb1400_pdata vpac270_ucb1400_pdata = {
179 .irq = IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ),
180};
181
182
183static struct platform_device balloon3_ucb1400_device = {
184 .name = "ucb1400_core",
185 .id = -1,
186 .dev = {
187 .platform_data = &vpac270_ucb1400_pdata,
188 },
189};
190
191static void __init balloon3_ts_init(void)
192{
193 if (!balloon3_has(BALLOON3_FEATURE_AUDIO))
194 return;
195
196 pxa_set_ac97_info(NULL);
197 platform_device_register(&balloon3_ucb1400_device);
198}
199#else
200static inline void balloon3_ts_init(void) {}
201#endif
202
203/******************************************************************************
204 * Framebuffer
205 ******************************************************************************/
206#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
207static struct pxafb_mode_info balloon3_lcd_modes[] = {
208 {
209 .pixclock = 38000,
210 .xres = 480,
211 .yres = 640,
212 .bpp = 16,
213 .hsync_len = 8,
214 .left_margin = 8,
215 .right_margin = 8,
216 .vsync_len = 2,
217 .upper_margin = 4,
218 .lower_margin = 5,
219 .sync = 0,
220 },
221};
222
223static struct pxafb_mach_info balloon3_lcd_screen = {
224 .modes = balloon3_lcd_modes,
225 .num_modes = ARRAY_SIZE(balloon3_lcd_modes),
226 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
227};
228
229static void balloon3_backlight_power(int on)
230{
231 gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
232}
233
234static void __init balloon3_lcd_init(void)
235{
236 int ret;
237
238 if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY))
239 return;
240
241 ret = gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT, "BKL-ON");
242 if (ret) {
243 pr_err("Requesting BKL-ON GPIO failed!\n");
244 goto err;
245 }
246
247 ret = gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT, 1);
248 if (ret) {
249 pr_err("Setting BKL-ON GPIO direction failed!\n");
250 goto err2;
251 }
252
253 balloon3_lcd_screen.pxafb_backlight_power = balloon3_backlight_power;
254 set_pxa_fb_info(&balloon3_lcd_screen);
255 return;
256
257err2:
258 gpio_free(BALLOON3_GPIO_RUN_BACKLIGHT);
259err:
260 return;
261}
262#else
263static inline void balloon3_lcd_init(void) {}
264#endif
265
266/******************************************************************************
267 * SD/MMC card controller
268 ******************************************************************************/
269#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
270static struct pxamci_platform_data balloon3_mci_platform_data = {
271 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
272 .gpio_card_detect = -1,
273 .gpio_card_ro = -1,
274 .gpio_power = -1,
275 .detect_delay_ms = 200,
276};
277
278static void __init balloon3_mmc_init(void)
279{
280 pxa_set_mci_info(&balloon3_mci_platform_data);
281}
282#else
283static inline void balloon3_mmc_init(void) {}
284#endif
285
286/******************************************************************************
287 * USB Gadget
288 ******************************************************************************/
289#if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
290static void balloon3_udc_command(int cmd)
291{
292 if (cmd == PXA2XX_UDC_CMD_CONNECT)
293 UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE;
294 else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
295 UP2OCR &= ~UP2OCR_DPPUE;
296}
297
298static int balloon3_udc_is_connected(void)
299{
300 return 1;
301}
302
303static struct pxa2xx_udc_mach_info balloon3_udc_info __initdata = {
304 .udc_command = balloon3_udc_command,
305 .udc_is_connected = balloon3_udc_is_connected,
306 .gpio_pullup = -1,
307};
308
309static void __init balloon3_udc_init(void)
310{
311 pxa_set_udc_info(&balloon3_udc_info);
312 platform_device_register(&balloon3_gpio_vbus);
313}
314#else
315static inline void balloon3_udc_init(void) {}
316#endif
317
318/******************************************************************************
319 * IrDA
320 ******************************************************************************/
321#if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
322static struct pxaficp_platform_data balloon3_ficp_platform_data = {
323 .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF,
324};
325
326static void __init balloon3_irda_init(void)
327{
328 pxa_set_ficp_info(&balloon3_ficp_platform_data);
329}
330#else
331static inline void balloon3_irda_init(void) {}
332#endif
333
334/******************************************************************************
335 * USB Host
336 ******************************************************************************/
337#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
338static struct pxaohci_platform_data balloon3_ohci_info = {
339 .port_mode = PMM_PERPORT_MODE,
340 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
341};
342
343static void __init balloon3_uhc_init(void)
344{
345 if (!balloon3_has(BALLOON3_FEATURE_OHCI))
346 return;
347 pxa_set_ohci_info(&balloon3_ohci_info);
348}
349#else
350static inline void balloon3_uhc_init(void) {}
351#endif
352
353/******************************************************************************
354 * LEDs
355 ******************************************************************************/
356#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
357struct gpio_led balloon3_gpio_leds[] = {
358 {
359 .name = "balloon3:green:idle",
360 .default_trigger = "heartbeat",
361 .gpio = BALLOON3_GPIO_LED_IDLE,
362 .active_low = 1,
363 }, {
364 .name = "balloon3:green:nand",
365 .default_trigger = "nand-disk",
366 .gpio = BALLOON3_GPIO_LED_NAND,
367 .active_low = 1,
368 },
369};
370
371static struct gpio_led_platform_data balloon3_gpio_led_info = {
372 .leds = balloon3_gpio_leds,
373 .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
374};
375
376static struct platform_device balloon3_leds = {
377 .name = "leds-gpio",
378 .id = -1,
379 .dev = {
380 .platform_data = &balloon3_gpio_led_info,
381 }
382};
383
384static void __init balloon3_leds_init(void)
385{
386 platform_device_register(&balloon3_leds);
387}
388#else
389static inline void balloon3_leds_init(void) {}
390#endif
391
392/******************************************************************************
Marek Vasutb0240bf2010-07-26 23:24:44 +0200393 * FPGA IRQ
394 ******************************************************************************/
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100395static void balloon3_mask_irq(unsigned int irq)
396{
397 int balloon3_irq = (irq - BALLOON3_IRQ(0));
398 balloon3_irq_enabled &= ~(1 << balloon3_irq);
399 __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
400}
401
402static void balloon3_unmask_irq(unsigned int irq)
403{
404 int balloon3_irq = (irq - BALLOON3_IRQ(0));
405 balloon3_irq_enabled |= (1 << balloon3_irq);
406 __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
407}
408
409static struct irq_chip balloon3_irq_chip = {
410 .name = "FPGA",
411 .ack = balloon3_mask_irq,
412 .mask = balloon3_mask_irq,
413 .unmask = balloon3_unmask_irq,
414};
415
416static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc)
417{
418 unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
419 balloon3_irq_enabled;
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100420 do {
421 /* clear useless edge notification */
422 if (desc->chip->ack)
423 desc->chip->ack(BALLOON3_AUX_NIRQ);
424 while (pending) {
425 irq = BALLOON3_IRQ(0) + __ffs(pending);
426 generic_handle_irq(irq);
427 pending &= pending - 1;
428 }
429 pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
430 balloon3_irq_enabled;
431 } while (pending);
432}
433
434static void __init balloon3_init_irq(void)
435{
436 int irq;
437
438 pxa27x_init_irq();
439 /* setup extra Balloon3 irqs */
440 for (irq = BALLOON3_IRQ(0); irq <= BALLOON3_IRQ(7); irq++) {
441 set_irq_chip(irq, &balloon3_irq_chip);
442 set_irq_handler(irq, handle_level_irq);
443 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
444 }
445
446 set_irq_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler);
447 set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING);
448
449 pr_debug("%s: chained handler installed - irq %d automatically "
450 "enabled\n", __func__, BALLOON3_AUX_NIRQ);
451}
452
Marek Vasutb0240bf2010-07-26 23:24:44 +0200453/******************************************************************************
454 * Machine init
455 ******************************************************************************/
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100456static void __init balloon3_init(void)
457{
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100458 ARB_CNTRL = ARB_CORE_PARK | 0x234;
459
Marek Vasut12a24492010-07-27 01:37:44 +0200460 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
461
Russell Kingcc155c62009-11-09 13:34:08 +0800462 pxa_set_ffuart_info(NULL);
463 pxa_set_btuart_info(NULL);
464 pxa_set_stuart_info(NULL);
465
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100466 pxa_set_i2c_info(NULL);
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100467
Marek Vasut12a24492010-07-27 01:37:44 +0200468 balloon3_irda_init();
469 balloon3_lcd_init();
470 balloon3_leds_init();
471 balloon3_mmc_init();
472 balloon3_nor_init();
473 balloon3_ts_init();
474 balloon3_udc_init();
475 balloon3_uhc_init();
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100476}
477
478static struct map_desc balloon3_io_desc[] __initdata = {
479 { /* CPLD/FPGA */
480 .virtual = BALLOON3_FPGA_VIRT,
481 .pfn = __phys_to_pfn(BALLOON3_FPGA_PHYS),
482 .length = BALLOON3_FPGA_LENGTH,
483 .type = MT_DEVICE,
484 },
485};
486
487static void __init balloon3_map_io(void)
488{
489 pxa_map_io();
490 iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc));
491}
492
493MACHINE_START(BALLOON3, "Balloon3")
494 /* Maintainer: Nick Bane. */
495 .phys_io = 0x40000000,
496 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
497 .map_io = balloon3_map_io,
498 .init_irq = balloon3_init_irq,
499 .timer = &pxa_timer,
500 .init_machine = balloon3_init,
501 .boot_params = PHYS_OFFSET + 0x100,
502MACHINE_END