[ARM] pxa/balloon3: PCMCIA Support
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-pxa / balloon3.c
blob91ad56d6e92974f17089b614055f3c5eafcb64b3
1 /*
2 * linux/arch/arm/mach-pxa/balloon3.c
4 * Support for Balloonboard.org Balloon3 board.
6 * Author: Nick Bane, Wookey, Jonathan McDowell
7 * Created: June, 2006
8 * Copyright: Toby Churchill Ltd
9 * Derived from mainstone.c, by Nico Pitre
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.
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>
25 #include <linux/ucb1400.h>
26 #include <linux/mtd/mtd.h>
27 #include <linux/mtd/partitions.h>
28 #include <linux/types.h>
30 #include <asm/setup.h>
31 #include <asm/mach-types.h>
32 #include <asm/irq.h>
33 #include <asm/sizes.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37 #include <asm/mach/irq.h>
38 #include <asm/mach/flash.h>
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>
50 #include <plat/i2c.h>
52 #include "generic.h"
53 #include "devices.h"
55 /******************************************************************************
56 * Pin configuration
57 ******************************************************************************/
58 static 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,
65 /* Reset, configured as GPIO wakeup source */
66 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
68 /* LEDs */
69 GPIO9_GPIO, /* NAND activity LED */
70 GPIO10_GPIO, /* Heartbeat LED */
72 /* AC97 */
73 GPIO28_AC97_BITCLK,
74 GPIO29_AC97_SDATA_IN_0,
75 GPIO30_AC97_SDATA_OUT,
76 GPIO31_AC97_SYNC,
77 GPIO113_AC97_nRESET,
78 GPIO95_GPIO,
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,
88 /* USB Host */
89 GPIO88_USBH1_PWR,
90 GPIO89_USBH1_PEN,
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,
105 /******************************************************************************
106 * Compatibility: Parameter parsing
107 ******************************************************************************/
108 static unsigned long balloon3_irq_enabled;
110 static unsigned long balloon3_features_present =
111 (1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) |
112 (1 << BALLOON3_FEATURE_AUDIO) |
113 (1 << BALLOON3_FEATURE_TOPPOLY);
115 int balloon3_has(enum balloon3_features feature)
117 return (balloon3_features_present & (1 << feature)) ? 1 : 0;
119 EXPORT_SYMBOL_GPL(balloon3_has);
121 int __init parse_balloon3_features(char *arg)
123 if (!arg)
124 return 0;
126 return strict_strtoul(arg, 0, &balloon3_features_present);
128 early_param("balloon3_features", parse_balloon3_features);
130 /******************************************************************************
131 * NOR Flash
132 ******************************************************************************/
133 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
134 static struct mtd_partition balloon3_nor_partitions[] = {
136 .name = "Flash",
137 .offset = 0x00000000,
138 .size = MTDPART_SIZ_FULL,
142 static struct physmap_flash_data balloon3_flash_data[] = {
144 .width = 2, /* bankwidth in bytes */
145 .parts = balloon3_nor_partitions,
146 .nr_parts = ARRAY_SIZE(balloon3_nor_partitions)
150 static struct resource balloon3_flash_resource = {
151 .start = PXA_CS0_PHYS,
152 .end = PXA_CS0_PHYS + SZ_64M - 1,
153 .flags = IORESOURCE_MEM,
156 static 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,
165 static void __init balloon3_nor_init(void)
167 platform_device_register(&balloon3_flash);
169 #else
170 static inline void balloon3_nor_init(void) {}
171 #endif
173 /******************************************************************************
174 * Audio and Touchscreen
175 ******************************************************************************/
176 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
177 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
178 static struct ucb1400_pdata vpac270_ucb1400_pdata = {
179 .irq = IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ),
183 static struct platform_device balloon3_ucb1400_device = {
184 .name = "ucb1400_core",
185 .id = -1,
186 .dev = {
187 .platform_data = &vpac270_ucb1400_pdata,
191 static void __init balloon3_ts_init(void)
193 if (!balloon3_has(BALLOON3_FEATURE_AUDIO))
194 return;
196 pxa_set_ac97_info(NULL);
197 platform_device_register(&balloon3_ucb1400_device);
199 #else
200 static inline void balloon3_ts_init(void) {}
201 #endif
203 /******************************************************************************
204 * Framebuffer
205 ******************************************************************************/
206 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
207 static struct pxafb_mode_info balloon3_lcd_modes[] = {
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,
223 static 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,
229 static void balloon3_backlight_power(int on)
231 gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
234 static void __init balloon3_lcd_init(void)
236 int ret;
238 if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY))
239 return;
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;
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;
253 balloon3_lcd_screen.pxafb_backlight_power = balloon3_backlight_power;
254 set_pxa_fb_info(&balloon3_lcd_screen);
255 return;
257 err2:
258 gpio_free(BALLOON3_GPIO_RUN_BACKLIGHT);
259 err:
260 return;
262 #else
263 static inline void balloon3_lcd_init(void) {}
264 #endif
266 /******************************************************************************
267 * SD/MMC card controller
268 ******************************************************************************/
269 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
270 static 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,
278 static void __init balloon3_mmc_init(void)
280 pxa_set_mci_info(&balloon3_mci_platform_data);
282 #else
283 static inline void balloon3_mmc_init(void) {}
284 #endif
286 /******************************************************************************
287 * USB Gadget
288 ******************************************************************************/
289 #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
290 static void balloon3_udc_command(int cmd)
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;
298 static int balloon3_udc_is_connected(void)
300 return 1;
303 static 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,
309 static void __init balloon3_udc_init(void)
311 pxa_set_udc_info(&balloon3_udc_info);
312 platform_device_register(&balloon3_gpio_vbus);
314 #else
315 static inline void balloon3_udc_init(void) {}
316 #endif
318 /******************************************************************************
319 * IrDA
320 ******************************************************************************/
321 #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
322 static struct pxaficp_platform_data balloon3_ficp_platform_data = {
323 .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF,
326 static void __init balloon3_irda_init(void)
328 pxa_set_ficp_info(&balloon3_ficp_platform_data);
330 #else
331 static inline void balloon3_irda_init(void) {}
332 #endif
334 /******************************************************************************
335 * USB Host
336 ******************************************************************************/
337 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
338 static struct pxaohci_platform_data balloon3_ohci_info = {
339 .port_mode = PMM_PERPORT_MODE,
340 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
343 static void __init balloon3_uhc_init(void)
345 if (!balloon3_has(BALLOON3_FEATURE_OHCI))
346 return;
347 pxa_set_ohci_info(&balloon3_ohci_info);
349 #else
350 static inline void balloon3_uhc_init(void) {}
351 #endif
353 /******************************************************************************
354 * LEDs
355 ******************************************************************************/
356 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
357 struct gpio_led balloon3_gpio_leds[] = {
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,
371 static struct gpio_led_platform_data balloon3_gpio_led_info = {
372 .leds = balloon3_gpio_leds,
373 .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
376 static struct platform_device balloon3_leds = {
377 .name = "leds-gpio",
378 .id = -1,
379 .dev = {
380 .platform_data = &balloon3_gpio_led_info,
384 static void __init balloon3_leds_init(void)
386 platform_device_register(&balloon3_leds);
388 #else
389 static inline void balloon3_leds_init(void) {}
390 #endif
392 /******************************************************************************
393 * FPGA IRQ
394 ******************************************************************************/
395 static void balloon3_mask_irq(unsigned int irq)
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);
402 static void balloon3_unmask_irq(unsigned int irq)
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);
409 static struct irq_chip balloon3_irq_chip = {
410 .name = "FPGA",
411 .ack = balloon3_mask_irq,
412 .mask = balloon3_mask_irq,
413 .unmask = balloon3_unmask_irq,
416 static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc)
418 unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
419 balloon3_irq_enabled;
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;
429 pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
430 balloon3_irq_enabled;
431 } while (pending);
434 static void __init balloon3_init_irq(void)
436 int irq;
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);
446 set_irq_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler);
447 set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING);
449 pr_debug("%s: chained handler installed - irq %d automatically "
450 "enabled\n", __func__, BALLOON3_AUX_NIRQ);
453 /******************************************************************************
454 * Machine init
455 ******************************************************************************/
456 static void __init balloon3_init(void)
458 ARB_CNTRL = ARB_CORE_PARK | 0x234;
460 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
462 pxa_set_ffuart_info(NULL);
463 pxa_set_btuart_info(NULL);
464 pxa_set_stuart_info(NULL);
466 pxa_set_i2c_info(NULL);
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();
478 static 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,
487 static void __init balloon3_map_io(void)
489 pxa_map_io();
490 iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc));
493 MACHINE_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,
502 MACHINE_END