]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/arm/mach-pxa/balloon3.c
[ARM] pxa/balloon3: PCMCIA Support
[net-next-2.6.git] / arch / arm / mach-pxa / balloon3.c
CommitLineData
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>
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
b0240bf4
MV
55/******************************************************************************
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,
2a23ec36 64
12a2449c 65 /* Reset, configured as GPIO wakeup source */
b0240bf4 66 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
2a23ec36 67
12a2449c
MV
68 /* LEDs */
69 GPIO9_GPIO, /* NAND activity LED */
70 GPIO10_GPIO, /* Heartbeat LED */
2a23ec36 71
12a2449c 72 /* AC97 */
c11b6a42
EM
73 GPIO28_AC97_BITCLK,
74 GPIO29_AC97_SDATA_IN_0,
75 GPIO30_AC97_SDATA_OUT,
76 GPIO31_AC97_SYNC,
77 GPIO113_AC97_nRESET,
12a2449c
MV
78 GPIO95_GPIO,
79
80 /* MMC */
81 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,
87
88 /* USB Host */
89 GPIO88_USBH1_PWR,
90 GPIO89_USBH1_PEN,
a9c0629c
MV
91
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,
c11b6a42
EM
103};
104
b0240bf4 105/******************************************************************************
12a2449c 106 * Compatibility: Parameter parsing
b0240bf4 107 ******************************************************************************/
12a2449c 108static unsigned long balloon3_irq_enabled;
b0240bf4 109
12a2449c
MV
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)
2a23ec36 116{
12a2449c
MV
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);
2a23ec36 127}
12a2449c 128early_param("balloon3_features", parse_balloon3_features);
2a23ec36 129
12a2449c
MV
130/******************************************************************************
131 * 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)
2a23ec36
JM
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
12a2449c 223static struct pxafb_mach_info balloon3_lcd_screen = {
2a23ec36
JM
224 .modes = balloon3_lcd_modes,
225 .num_modes = ARRAY_SIZE(balloon3_lcd_modes),
226 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
2a23ec36
JM
227};
228
12a2449c
MV
229static void balloon3_backlight_power(int on)
230{
231 gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
232}
2a23ec36 233
12a2449c 234static void __init balloon3_lcd_init(void)
2a23ec36 235{
12a2449c
MV
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;
2a23ec36 251 }
12a2449c
MV
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;
2a23ec36 261}
12a2449c
MV
262#else
263static inline void balloon3_lcd_init(void) {}
264#endif
2a23ec36 265
12a2449c
MV
266/******************************************************************************
267 * SD/MMC card controller
268 ******************************************************************************/
269#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
2a23ec36 270static struct pxamci_platform_data balloon3_mci_platform_data = {
12a2449c
MV
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,
2a23ec36
JM
276};
277
12a2449c
MV
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
b0240bf4
MV
286/******************************************************************************
287 * USB Gadget
288 ******************************************************************************/
12a2449c
MV
289#if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
290static void balloon3_udc_command(int cmd)
2a23ec36 291{
12a2449c
MV
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;
2a23ec36
JM
296}
297
12a2449c 298static int balloon3_udc_is_connected(void)
2a23ec36 299{
12a2449c 300 return 1;
2a23ec36
JM
301}
302
12a2449c
MV
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,
2a23ec36
JM
307};
308
12a2449c
MV
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
b0240bf4
MV
318/******************************************************************************
319 * IrDA
320 ******************************************************************************/
12a2449c 321#if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
2a23ec36 322static struct pxaficp_platform_data balloon3_ficp_platform_data = {
12a2449c 323 .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF,
2a23ec36
JM
324};
325
12a2449c
MV
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
b0240bf4
MV
334/******************************************************************************
335 * USB Host
336 ******************************************************************************/
12a2449c
MV
337#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
338static struct pxaohci_platform_data balloon3_ohci_info = {
2a23ec36
JM
339 .port_mode = PMM_PERPORT_MODE,
340 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
341};
342
12a2449c
MV
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
b0240bf4 353/******************************************************************************
12a2449c 354 * LEDs
b0240bf4 355 ******************************************************************************/
12a2449c
MV
356#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
357struct gpio_led balloon3_gpio_leds[] = {
2a23ec36
JM
358 {
359 .name = "balloon3:green:idle",
360 .default_trigger = "heartbeat",
361 .gpio = BALLOON3_GPIO_LED_IDLE,
362 .active_low = 1,
12a2449c 363 }, {
2a23ec36
JM
364 .name = "balloon3:green:nand",
365 .default_trigger = "nand-disk",
366 .gpio = BALLOON3_GPIO_LED_NAND,
367 .active_low = 1,
368 },
369};
370
12a2449c 371static struct gpio_led_platform_data balloon3_gpio_led_info = {
2a23ec36
JM
372 .leds = balloon3_gpio_leds,
373 .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
374};
375
12a2449c 376static struct platform_device balloon3_leds = {
2a23ec36
JM
377 .name = "leds-gpio",
378 .id = -1,
379 .dev = {
12a2449c
MV
380 .platform_data = &balloon3_gpio_led_info,
381 }
2a23ec36
JM
382};
383
12a2449c 384static void __init balloon3_leds_init(void)
b0240bf4 385{
12a2449c 386 platform_device_register(&balloon3_leds);
b0240bf4 387}
12a2449c
MV
388#else
389static inline void balloon3_leds_init(void) {}
390#endif
b0240bf4
MV
391
392/******************************************************************************
393 * FPGA IRQ
394 ******************************************************************************/
395static 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;
b0240bf4
MV
420 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
453/******************************************************************************
454 * Machine init
455 ******************************************************************************/
2a23ec36
JM
456static void __init balloon3_init(void)
457{
2a23ec36
JM
458 ARB_CNTRL = ARB_CORE_PARK | 0x234;
459
12a2449c
MV
460 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
461
cc155c6f
RK
462 pxa_set_ffuart_info(NULL);
463 pxa_set_btuart_info(NULL);
464 pxa_set_stuart_info(NULL);
465
2a23ec36 466 pxa_set_i2c_info(NULL);
2a23ec36 467
12a2449c
MV
468 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();
2a23ec36
JM
476}
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