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/mtd/mtd.h>
26 #include <linux/mtd/partitions.h>
27 #include <linux/types.h>
29 #include <asm/setup.h>
30 #include <asm/mach-types.h>
32 #include <asm/sizes.h>
34 #include <asm/mach/arch.h>
35 #include <asm/mach/map.h>
36 #include <asm/mach/irq.h>
37 #include <asm/mach/flash.h>
39 #include <mach/pxa27x.h>
40 #include <mach/balloon3.h>
41 #include <mach/audio.h>
42 #include <mach/pxafb.h>
45 #include <mach/pxa27x-udc.h>
46 #include <mach/irda.h>
47 #include <mach/ohci.h>
54 /******************************************************************************
56 ******************************************************************************/
57 static unsigned long balloon3_pin_config[] __initdata = {
58 /* Select BTUART 'COM1/ttyS0' as IO option for pins 42/43/44/45 */
65 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
67 /* NAND & IDLE LED GPIOs */
72 /******************************************************************************
73 * Audio and Touchscreen
74 ******************************************************************************/
75 static unsigned long balloon3_ac97_pin_config[] = {
77 GPIO29_AC97_SDATA_IN_0,
78 GPIO30_AC97_SDATA_OUT,
83 /******************************************************************************
85 ******************************************************************************/
87 static void balloon3_backlight_power(int on)
89 pr_debug("%s: power is %s\n", __func__, on ? "on" : "off");
90 gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
93 static struct pxafb_mode_info balloon3_lcd_modes[] = {
109 static struct pxafb_mach_info balloon3_pxafb_info = {
110 .modes = balloon3_lcd_modes,
111 .num_modes = ARRAY_SIZE(balloon3_lcd_modes),
112 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
113 .pxafb_backlight_power = balloon3_backlight_power,
116 /******************************************************************************
117 * SD/MMC card controller
118 ******************************************************************************/
119 static unsigned long balloon3_mmc_pin_config[] = {
128 static void balloon3_mci_setpower(struct device *dev, unsigned int vdd)
130 struct pxamci_platform_data *p_d = dev->platform_data;
132 if ((1 << vdd) & p_d->ocr_mask) {
133 pr_debug("%s: on\n", __func__);
134 /* FIXME something to prod here? */
136 pr_debug("%s: off\n", __func__);
137 /* FIXME something to prod here? */
141 static struct pxamci_platform_data balloon3_mci_platform_data = {
142 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
143 .setpower = balloon3_mci_setpower,
146 /******************************************************************************
148 ******************************************************************************/
149 static int balloon3_udc_is_connected(void)
151 pr_debug("%s: udc connected\n", __func__);
155 static void balloon3_udc_command(int cmd)
158 case PXA2XX_UDC_CMD_CONNECT:
159 UP2OCR |= (UP2OCR_DPPUE + UP2OCR_DPPUBE);
160 pr_debug("%s: connect\n", __func__);
162 case PXA2XX_UDC_CMD_DISCONNECT:
163 UP2OCR &= ~UP2OCR_DPPUE;
164 pr_debug("%s: disconnect\n", __func__);
169 static struct pxa2xx_udc_mach_info balloon3_udc_info = {
170 .udc_is_connected = balloon3_udc_is_connected,
171 .udc_command = balloon3_udc_command,
174 /******************************************************************************
176 ******************************************************************************/
177 static struct pxaficp_platform_data balloon3_ficp_platform_data = {
178 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
181 /******************************************************************************
183 ******************************************************************************/
184 static unsigned long balloon3_ohci_pin_config[] = {
189 static struct pxaohci_platform_data balloon3_ohci_platform_data = {
190 .port_mode = PMM_PERPORT_MODE,
191 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
194 /******************************************************************************
196 ******************************************************************************/
197 static struct gpio_led balloon3_gpio_leds[] = {
199 .name = "balloon3:green:idle",
200 .default_trigger = "heartbeat",
201 .gpio = BALLOON3_GPIO_LED_IDLE,
205 .name = "balloon3:green:nand",
206 .default_trigger = "nand-disk",
207 .gpio = BALLOON3_GPIO_LED_NAND,
212 static struct gpio_led_platform_data balloon3_gpio_leds_platform_data = {
213 .leds = balloon3_gpio_leds,
214 .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
217 static struct platform_device balloon3led_device = {
221 .platform_data = &balloon3_gpio_leds_platform_data,
225 /******************************************************************************
226 * Compatibility: Parameter parsing
227 ******************************************************************************/
228 static unsigned long balloon3_irq_enabled;
230 static unsigned long balloon3_features_present =
231 (1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) |
232 (1 << BALLOON3_FEATURE_AUDIO) |
233 (1 << BALLOON3_FEATURE_TOPPOLY);
235 int balloon3_has(enum balloon3_features feature)
237 return (balloon3_features_present & (1 << feature)) ? 1 : 0;
239 EXPORT_SYMBOL_GPL(balloon3_has);
241 int __init parse_balloon3_features(char *arg)
246 return strict_strtoul(arg, 0, &balloon3_features_present);
248 early_param("balloon3_features", parse_balloon3_features);
250 /******************************************************************************
252 ******************************************************************************/
253 static void balloon3_mask_irq(unsigned int irq)
255 int balloon3_irq = (irq - BALLOON3_IRQ(0));
256 balloon3_irq_enabled &= ~(1 << balloon3_irq);
257 __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
260 static void balloon3_unmask_irq(unsigned int irq)
262 int balloon3_irq = (irq - BALLOON3_IRQ(0));
263 balloon3_irq_enabled |= (1 << balloon3_irq);
264 __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG);
267 static struct irq_chip balloon3_irq_chip = {
269 .ack = balloon3_mask_irq,
270 .mask = balloon3_mask_irq,
271 .unmask = balloon3_unmask_irq,
274 static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc)
276 unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
277 balloon3_irq_enabled;
280 /* clear useless edge notification */
282 desc->chip->ack(BALLOON3_AUX_NIRQ);
284 irq = BALLOON3_IRQ(0) + __ffs(pending);
285 generic_handle_irq(irq);
286 pending &= pending - 1;
288 pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
289 balloon3_irq_enabled;
293 static void __init balloon3_init_irq(void)
298 /* setup extra Balloon3 irqs */
299 for (irq = BALLOON3_IRQ(0); irq <= BALLOON3_IRQ(7); irq++) {
300 set_irq_chip(irq, &balloon3_irq_chip);
301 set_irq_handler(irq, handle_level_irq);
302 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
305 set_irq_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler);
306 set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING);
308 pr_debug("%s: chained handler installed - irq %d automatically "
309 "enabled\n", __func__, BALLOON3_AUX_NIRQ);
312 /******************************************************************************
314 ******************************************************************************/
315 static void __init balloon3_init(void)
317 pr_info("Initialising Balloon3\n");
319 /* system bus arbiter setting
321 * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
323 ARB_CNTRL = ARB_CORE_PARK | 0x234;
325 pxa_set_ffuart_info(NULL);
326 pxa_set_btuart_info(NULL);
327 pxa_set_stuart_info(NULL);
329 pxa_set_i2c_info(NULL);
330 if (balloon3_has(BALLOON3_FEATURE_AUDIO)) {
331 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_ac97_pin_config));
332 pxa_set_ac97_info(NULL);
335 if (balloon3_has(BALLOON3_FEATURE_TOPPOLY)) {
336 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_lcd_pin_config));
337 gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT,
338 "LCD Backlight Power");
339 gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT, 1);
340 set_pxa_fb_info(&balloon3_pxafb_info);
343 if (balloon3_has(BALLOON3_FEATURE_MMC)) {
344 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_mmc_pin_config));
345 pxa_set_mci_info(&balloon3_mci_platform_data);
347 pxa_set_ficp_info(&balloon3_ficp_platform_data);
348 if (balloon3_has(BALLOON3_FEATURE_OHCI)) {
349 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_ohci_pin_config));
350 pxa_set_ohci_info(&balloon3_ohci_platform_data);
352 pxa_set_udc_info(&balloon3_udc_info);
354 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
356 platform_device_register(&balloon3led_device);
359 static struct map_desc balloon3_io_desc[] __initdata = {
361 .virtual = BALLOON3_FPGA_VIRT,
362 .pfn = __phys_to_pfn(BALLOON3_FPGA_PHYS),
363 .length = BALLOON3_FPGA_LENGTH,
368 static void __init balloon3_map_io(void)
371 iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc));
374 MACHINE_START(BALLOON3, "Balloon3")
375 /* Maintainer: Nick Bane. */
376 .phys_io = 0x40000000,
377 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
378 .map_io = balloon3_map_io,
379 .init_irq = balloon3_init_irq,
381 .init_machine = balloon3_init,
382 .boot_params = PHYS_OFFSET + 0x100,