blob: 8adb87a036740ff991422344b3c513adbf9bef16 [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>
25#include <linux/mtd/mtd.h>
26#include <linux/mtd/partitions.h>
27#include <linux/types.h>
28
29#include <asm/setup.h>
30#include <asm/mach-types.h>
31#include <asm/irq.h>
32#include <asm/sizes.h>
33
34#include <asm/mach/arch.h>
35#include <asm/mach/map.h>
36#include <asm/mach/irq.h>
37#include <asm/mach/flash.h>
38
39#include <mach/pxa27x.h>
40#include <mach/balloon3.h>
41#include <mach/audio.h>
42#include <mach/pxafb.h>
43#include <mach/mmc.h>
44#include <mach/udc.h>
45#include <mach/pxa27x-udc.h>
46#include <mach/irda.h>
47#include <mach/ohci.h>
48
49#include <plat/i2c.h>
50
51#include "generic.h"
52#include "devices.h"
53
Marek Vasutb0240bf2010-07-26 23:24:44 +020054/******************************************************************************
55 * Pin configuration
56 ******************************************************************************/
57static unsigned long balloon3_pin_config[] __initdata = {
58 /* Select BTUART 'COM1/ttyS0' as IO option for pins 42/43/44/45 */
59 GPIO42_BTUART_RXD,
60 GPIO43_BTUART_TXD,
61 GPIO44_BTUART_CTS,
62 GPIO45_BTUART_RTS,
63
64 /* Wakeup GPIO */
65 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
66
67 /* NAND & IDLE LED GPIOs */
68 GPIO9_GPIO,
69 GPIO10_GPIO,
70};
71
72/******************************************************************************
73 * Audio and Touchscreen
74 ******************************************************************************/
75static unsigned long balloon3_ac97_pin_config[] = {
76 GPIO28_AC97_BITCLK,
77 GPIO29_AC97_SDATA_IN_0,
78 GPIO30_AC97_SDATA_OUT,
79 GPIO31_AC97_SYNC,
80 GPIO113_AC97_nRESET,
81};
82
83/******************************************************************************
84 * Framebuffer
85 ******************************************************************************/
86
87static void balloon3_backlight_power(int on)
88{
89 pr_debug("%s: power is %s\n", __func__, on ? "on" : "off");
90 gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on);
91}
92
93static struct pxafb_mode_info balloon3_lcd_modes[] = {
94 {
95 .pixclock = 38000,
96 .xres = 480,
97 .yres = 640,
98 .bpp = 16,
99 .hsync_len = 8,
100 .left_margin = 8,
101 .right_margin = 8,
102 .vsync_len = 2,
103 .upper_margin = 4,
104 .lower_margin = 5,
105 .sync = 0,
106 },
107};
108
109static 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,
114};
115
116/******************************************************************************
117 * SD/MMC card controller
118 ******************************************************************************/
119static unsigned long balloon3_mmc_pin_config[] = {
120 GPIO32_MMC_CLK,
121 GPIO92_MMC_DAT_0,
122 GPIO109_MMC_DAT_1,
123 GPIO110_MMC_DAT_2,
124 GPIO111_MMC_DAT_3,
125 GPIO112_MMC_CMD,
126};
127
128static void balloon3_mci_setpower(struct device *dev, unsigned int vdd)
129{
130 struct pxamci_platform_data *p_d = dev->platform_data;
131
132 if ((1 << vdd) & p_d->ocr_mask) {
133 pr_debug("%s: on\n", __func__);
134 /* FIXME something to prod here? */
135 } else {
136 pr_debug("%s: off\n", __func__);
137 /* FIXME something to prod here? */
138 }
139}
140
141static struct pxamci_platform_data balloon3_mci_platform_data = {
142 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
143 .setpower = balloon3_mci_setpower,
144};
145
146/******************************************************************************
147 * USB Gadget
148 ******************************************************************************/
149static int balloon3_udc_is_connected(void)
150{
151 pr_debug("%s: udc connected\n", __func__);
152 return 1;
153}
154
155static void balloon3_udc_command(int cmd)
156{
157 switch (cmd) {
158 case PXA2XX_UDC_CMD_CONNECT:
159 UP2OCR |= (UP2OCR_DPPUE + UP2OCR_DPPUBE);
160 pr_debug("%s: connect\n", __func__);
161 break;
162 case PXA2XX_UDC_CMD_DISCONNECT:
163 UP2OCR &= ~UP2OCR_DPPUE;
164 pr_debug("%s: disconnect\n", __func__);
165 break;
166 }
167}
168
169static struct pxa2xx_udc_mach_info balloon3_udc_info = {
170 .udc_is_connected = balloon3_udc_is_connected,
171 .udc_command = balloon3_udc_command,
172};
173
174/******************************************************************************
175 * IrDA
176 ******************************************************************************/
177static struct pxaficp_platform_data balloon3_ficp_platform_data = {
178 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
179};
180
181/******************************************************************************
182 * USB Host
183 ******************************************************************************/
184static unsigned long balloon3_ohci_pin_config[] = {
185 GPIO88_USBH1_PWR,
186 GPIO89_USBH1_PEN,
187};
188
189static 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,
192};
193
194/******************************************************************************
195 * LED
196 ******************************************************************************/
197static struct gpio_led balloon3_gpio_leds[] = {
198 {
199 .name = "balloon3:green:idle",
200 .default_trigger = "heartbeat",
201 .gpio = BALLOON3_GPIO_LED_IDLE,
202 .active_low = 1,
203 },
204 {
205 .name = "balloon3:green:nand",
206 .default_trigger = "nand-disk",
207 .gpio = BALLOON3_GPIO_LED_NAND,
208 .active_low = 1,
209 },
210};
211
212static struct gpio_led_platform_data balloon3_gpio_leds_platform_data = {
213 .leds = balloon3_gpio_leds,
214 .num_leds = ARRAY_SIZE(balloon3_gpio_leds),
215};
216
217static struct platform_device balloon3led_device = {
218 .name = "leds-gpio",
219 .id = -1,
220 .dev = {
221 .platform_data = &balloon3_gpio_leds_platform_data,
222 },
223};
224
225/******************************************************************************
226 * Compatibility: Parameter parsing
227 ******************************************************************************/
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100228static unsigned long balloon3_irq_enabled;
229
230static unsigned long balloon3_features_present =
231 (1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) |
232 (1 << BALLOON3_FEATURE_AUDIO) |
233 (1 << BALLOON3_FEATURE_TOPPOLY);
234
235int balloon3_has(enum balloon3_features feature)
236{
237 return (balloon3_features_present & (1 << feature)) ? 1 : 0;
238}
239EXPORT_SYMBOL_GPL(balloon3_has);
240
241int __init parse_balloon3_features(char *arg)
242{
243 if (!arg)
244 return 0;
245
246 return strict_strtoul(arg, 0, &balloon3_features_present);
247}
248early_param("balloon3_features", parse_balloon3_features);
249
Marek Vasutb0240bf2010-07-26 23:24:44 +0200250/******************************************************************************
251 * FPGA IRQ
252 ******************************************************************************/
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100253static void balloon3_mask_irq(unsigned int irq)
254{
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);
258}
259
260static void balloon3_unmask_irq(unsigned int irq)
261{
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);
265}
266
267static struct irq_chip balloon3_irq_chip = {
268 .name = "FPGA",
269 .ack = balloon3_mask_irq,
270 .mask = balloon3_mask_irq,
271 .unmask = balloon3_unmask_irq,
272};
273
274static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc)
275{
276 unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
277 balloon3_irq_enabled;
278
279 do {
280 /* clear useless edge notification */
281 if (desc->chip->ack)
282 desc->chip->ack(BALLOON3_AUX_NIRQ);
283 while (pending) {
284 irq = BALLOON3_IRQ(0) + __ffs(pending);
285 generic_handle_irq(irq);
286 pending &= pending - 1;
287 }
288 pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
289 balloon3_irq_enabled;
290 } while (pending);
291}
292
293static void __init balloon3_init_irq(void)
294{
295 int irq;
296
297 pxa27x_init_irq();
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);
303 }
304
305 set_irq_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler);
306 set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING);
307
308 pr_debug("%s: chained handler installed - irq %d automatically "
309 "enabled\n", __func__, BALLOON3_AUX_NIRQ);
310}
311
Marek Vasutb0240bf2010-07-26 23:24:44 +0200312/******************************************************************************
313 * Machine init
314 ******************************************************************************/
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100315static void __init balloon3_init(void)
316{
317 pr_info("Initialising Balloon3\n");
318
319 /* system bus arbiter setting
320 * - Core_Park
321 * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
322 */
323 ARB_CNTRL = ARB_CORE_PARK | 0x234;
324
Russell Kingcc155c62009-11-09 13:34:08 +0800325 pxa_set_ffuart_info(NULL);
326 pxa_set_btuart_info(NULL);
327 pxa_set_stuart_info(NULL);
328
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100329 pxa_set_i2c_info(NULL);
Eric Miaoc11b6a42010-01-04 17:00:13 +0800330 if (balloon3_has(BALLOON3_FEATURE_AUDIO)) {
331 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_ac97_pin_config));
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100332 pxa_set_ac97_info(NULL);
Eric Miaoc11b6a42010-01-04 17:00:13 +0800333 }
Jonathan McDowell2a23ec32009-07-04 14:43:56 +0100334
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);
341 }
342
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);
346 }
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);
351 }
352 pxa_set_udc_info(&balloon3_udc_info);
353
354 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config));
355
356 platform_device_register(&balloon3led_device);
357}
358
359static struct map_desc balloon3_io_desc[] __initdata = {
360 { /* CPLD/FPGA */
361 .virtual = BALLOON3_FPGA_VIRT,
362 .pfn = __phys_to_pfn(BALLOON3_FPGA_PHYS),
363 .length = BALLOON3_FPGA_LENGTH,
364 .type = MT_DEVICE,
365 },
366};
367
368static void __init balloon3_map_io(void)
369{
370 pxa_map_io();
371 iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc));
372}
373
374MACHINE_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,
380 .timer = &pxa_timer,
381 .init_machine = balloon3_init,
382 .boot_params = PHYS_OFFSET + 0x100,
383MACHINE_END