2 * linux/arch/arm/mach-pxa/balloon3.c
4 * Support for Balloonboard.org Balloon3 board.
6 * Author: Nick Bane, Wookey, Jonathan McDowell
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>
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>
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>
46 #include <mach/pxa27x-udc.h>
47 #include <mach/irda.h>
48 #include <mach/ohci.h>
55 /******************************************************************************
57 ******************************************************************************/
58 static unsigned long balloon3_pin_config
[] __initdata
= {
59 /* Select BTUART 'COM1/ttyS0' as IO option for pins 42/43/44/45 */
65 /* Reset, configured as GPIO wakeup source */
66 GPIO1_GPIO
| WAKEUP_ON_EDGE_BOTH
,
69 GPIO9_GPIO
, /* NAND activity LED */
70 GPIO10_GPIO
, /* Heartbeat LED */
74 GPIO29_AC97_SDATA_IN_0
,
75 GPIO30_AC97_SDATA_OUT
,
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
)
126 return strict_strtoul(arg
, 0, &balloon3_features_present
);
128 early_param("balloon3_features", parse_balloon3_features
);
130 /******************************************************************************
132 ******************************************************************************/
133 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
134 static struct mtd_partition balloon3_nor_partitions
[] = {
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",
159 .resource
= &balloon3_flash_resource
,
162 .platform_data
= balloon3_flash_data
,
165 static void __init
balloon3_nor_init(void)
167 platform_device_register(&balloon3_flash
);
170 static inline void balloon3_nor_init(void) {}
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",
187 .platform_data
= &vpac270_ucb1400_pdata
,
191 static void __init
balloon3_ts_init(void)
193 if (!balloon3_has(BALLOON3_FEATURE_AUDIO
))
196 pxa_set_ac97_info(NULL
);
197 platform_device_register(&balloon3_ucb1400_device
);
200 static inline void balloon3_ts_init(void) {}
203 /******************************************************************************
205 ******************************************************************************/
206 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
207 static struct pxafb_mode_info balloon3_lcd_modes
[] = {
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)
238 if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY
))
241 ret
= gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT
, "BKL-ON");
243 pr_err("Requesting BKL-ON GPIO failed!\n");
247 ret
= gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT
, 1);
249 pr_err("Setting BKL-ON GPIO direction failed!\n");
253 balloon3_lcd_screen
.pxafb_backlight_power
= balloon3_backlight_power
;
254 set_pxa_fb_info(&balloon3_lcd_screen
);
258 gpio_free(BALLOON3_GPIO_RUN_BACKLIGHT
);
263 static inline void balloon3_lcd_init(void) {}
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,
275 .detect_delay_ms
= 200,
278 static void __init
balloon3_mmc_init(void)
280 pxa_set_mci_info(&balloon3_mci_platform_data
);
283 static inline void balloon3_mmc_init(void) {}
286 /******************************************************************************
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)
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
,
309 static void __init
balloon3_udc_init(void)
311 pxa_set_udc_info(&balloon3_udc_info
);
312 platform_device_register(&balloon3_gpio_vbus
);
315 static inline void balloon3_udc_init(void) {}
318 /******************************************************************************
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
);
331 static inline void balloon3_irda_init(void) {}
334 /******************************************************************************
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
))
347 pxa_set_ohci_info(&balloon3_ohci_info
);
350 static inline void balloon3_uhc_init(void) {}
353 /******************************************************************************
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
,
364 .name
= "balloon3:green:nand",
365 .default_trigger
= "nand-disk",
366 .gpio
= BALLOON3_GPIO_LED_NAND
,
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
= {
380 .platform_data
= &balloon3_gpio_led_info
,
384 static void __init
balloon3_leds_init(void)
386 platform_device_register(&balloon3_leds
);
389 static inline void balloon3_leds_init(void) {}
392 /******************************************************************************
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
= {
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
;
421 /* clear useless edge notification */
423 desc
->chip
->ack(BALLOON3_AUX_NIRQ
);
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
;
434 static void __init
balloon3_init_irq(void)
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 /******************************************************************************
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();
470 balloon3_leds_init();
478 static struct map_desc balloon3_io_desc
[] __initdata
= {
480 .virtual = BALLOON3_FPGA_VIRT
,
481 .pfn
= __phys_to_pfn(BALLOON3_FPGA_PHYS
),
482 .length
= BALLOON3_FPGA_LENGTH
,
487 static void __init
balloon3_map_io(void)
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
,
500 .init_machine
= balloon3_init
,
501 .boot_params
= PHYS_OFFSET
+ 0x100,