Jonathan McDowell | 2a23ec3 | 2009-07-04 14:43:56 +0100 | [diff] [blame] | 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> |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 25 | #include <linux/ucb1400.h> |
Jonathan McDowell | 2a23ec3 | 2009-07-04 14:43:56 +0100 | [diff] [blame] | 26 | #include <linux/mtd/mtd.h> |
| 27 | #include <linux/mtd/partitions.h> |
| 28 | #include <linux/types.h> |
Marek Vasut | 02a453e | 2010-07-27 23:11:03 +0200 | [diff] [blame] | 29 | #include <linux/i2c/pcf857x.h> |
Marek Vasut | e6a8ef5 | 2010-07-28 03:32:05 +0200 | [diff] [blame^] | 30 | #include <linux/mtd/nand.h> |
| 31 | #include <linux/mtd/physmap.h> |
Jonathan McDowell | 2a23ec3 | 2009-07-04 14:43:56 +0100 | [diff] [blame] | 32 | |
| 33 | #include <asm/setup.h> |
| 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/irq.h> |
| 36 | #include <asm/sizes.h> |
| 37 | |
| 38 | #include <asm/mach/arch.h> |
| 39 | #include <asm/mach/map.h> |
| 40 | #include <asm/mach/irq.h> |
| 41 | #include <asm/mach/flash.h> |
| 42 | |
| 43 | #include <mach/pxa27x.h> |
| 44 | #include <mach/balloon3.h> |
| 45 | #include <mach/audio.h> |
| 46 | #include <mach/pxafb.h> |
| 47 | #include <mach/mmc.h> |
| 48 | #include <mach/udc.h> |
| 49 | #include <mach/pxa27x-udc.h> |
| 50 | #include <mach/irda.h> |
| 51 | #include <mach/ohci.h> |
| 52 | |
| 53 | #include <plat/i2c.h> |
| 54 | |
| 55 | #include "generic.h" |
| 56 | #include "devices.h" |
| 57 | |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 58 | /****************************************************************************** |
| 59 | * Pin configuration |
| 60 | ******************************************************************************/ |
| 61 | static unsigned long balloon3_pin_config[] __initdata = { |
| 62 | /* Select BTUART 'COM1/ttyS0' as IO option for pins 42/43/44/45 */ |
| 63 | GPIO42_BTUART_RXD, |
| 64 | GPIO43_BTUART_TXD, |
| 65 | GPIO44_BTUART_CTS, |
| 66 | GPIO45_BTUART_RTS, |
| 67 | |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 68 | /* Reset, configured as GPIO wakeup source */ |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 69 | GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, |
| 70 | |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 71 | /* LEDs */ |
| 72 | GPIO9_GPIO, /* NAND activity LED */ |
| 73 | GPIO10_GPIO, /* Heartbeat LED */ |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 74 | |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 75 | /* AC97 */ |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 76 | GPIO28_AC97_BITCLK, |
| 77 | GPIO29_AC97_SDATA_IN_0, |
| 78 | GPIO30_AC97_SDATA_OUT, |
| 79 | GPIO31_AC97_SYNC, |
| 80 | GPIO113_AC97_nRESET, |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 81 | GPIO95_GPIO, |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 82 | |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 83 | /* MMC */ |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 84 | GPIO32_MMC_CLK, |
| 85 | GPIO92_MMC_DAT_0, |
| 86 | GPIO109_MMC_DAT_1, |
| 87 | GPIO110_MMC_DAT_2, |
| 88 | GPIO111_MMC_DAT_3, |
| 89 | GPIO112_MMC_CMD, |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 90 | |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 91 | /* USB Host */ |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 92 | GPIO88_USBH1_PWR, |
| 93 | GPIO89_USBH1_PEN, |
Marek Vasut | a9c0629 | 2010-07-27 21:48:10 +0200 | [diff] [blame] | 94 | |
| 95 | /* PC Card */ |
| 96 | GPIO48_nPOE, |
| 97 | GPIO49_nPWE, |
| 98 | GPIO50_nPIOR, |
| 99 | GPIO51_nPIOW, |
| 100 | GPIO85_nPCE_1, |
| 101 | GPIO54_nPCE_2, |
| 102 | GPIO79_PSKTSEL, |
| 103 | GPIO55_nPREG, |
| 104 | GPIO56_nPWAIT, |
| 105 | GPIO57_nIOIS16, |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 106 | }; |
| 107 | |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 108 | /****************************************************************************** |
| 109 | * Compatibility: Parameter parsing |
| 110 | ******************************************************************************/ |
Jonathan McDowell | 2a23ec3 | 2009-07-04 14:43:56 +0100 | [diff] [blame] | 111 | static unsigned long balloon3_irq_enabled; |
| 112 | |
| 113 | static unsigned long balloon3_features_present = |
| 114 | (1 << BALLOON3_FEATURE_OHCI) | (1 << BALLOON3_FEATURE_CF) | |
| 115 | (1 << BALLOON3_FEATURE_AUDIO) | |
| 116 | (1 << BALLOON3_FEATURE_TOPPOLY); |
| 117 | |
| 118 | int balloon3_has(enum balloon3_features feature) |
| 119 | { |
| 120 | return (balloon3_features_present & (1 << feature)) ? 1 : 0; |
| 121 | } |
| 122 | EXPORT_SYMBOL_GPL(balloon3_has); |
| 123 | |
| 124 | int __init parse_balloon3_features(char *arg) |
| 125 | { |
| 126 | if (!arg) |
| 127 | return 0; |
| 128 | |
| 129 | return strict_strtoul(arg, 0, &balloon3_features_present); |
| 130 | } |
| 131 | early_param("balloon3_features", parse_balloon3_features); |
| 132 | |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 133 | /****************************************************************************** |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 134 | * NOR Flash |
| 135 | ******************************************************************************/ |
| 136 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) |
| 137 | static struct mtd_partition balloon3_nor_partitions[] = { |
| 138 | { |
| 139 | .name = "Flash", |
| 140 | .offset = 0x00000000, |
| 141 | .size = MTDPART_SIZ_FULL, |
| 142 | } |
| 143 | }; |
| 144 | |
| 145 | static struct physmap_flash_data balloon3_flash_data[] = { |
| 146 | { |
| 147 | .width = 2, /* bankwidth in bytes */ |
| 148 | .parts = balloon3_nor_partitions, |
| 149 | .nr_parts = ARRAY_SIZE(balloon3_nor_partitions) |
| 150 | } |
| 151 | }; |
| 152 | |
| 153 | static struct resource balloon3_flash_resource = { |
| 154 | .start = PXA_CS0_PHYS, |
| 155 | .end = PXA_CS0_PHYS + SZ_64M - 1, |
| 156 | .flags = IORESOURCE_MEM, |
| 157 | }; |
| 158 | |
| 159 | static struct platform_device balloon3_flash = { |
| 160 | .name = "physmap-flash", |
| 161 | .id = 0, |
| 162 | .resource = &balloon3_flash_resource, |
| 163 | .num_resources = 1, |
| 164 | .dev = { |
| 165 | .platform_data = balloon3_flash_data, |
| 166 | }, |
| 167 | }; |
| 168 | static void __init balloon3_nor_init(void) |
| 169 | { |
| 170 | platform_device_register(&balloon3_flash); |
| 171 | } |
| 172 | #else |
| 173 | static inline void balloon3_nor_init(void) {} |
| 174 | #endif |
| 175 | |
| 176 | /****************************************************************************** |
| 177 | * Audio and Touchscreen |
| 178 | ******************************************************************************/ |
| 179 | #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \ |
| 180 | defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE) |
| 181 | static struct ucb1400_pdata vpac270_ucb1400_pdata = { |
| 182 | .irq = IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ), |
| 183 | }; |
| 184 | |
| 185 | |
| 186 | static struct platform_device balloon3_ucb1400_device = { |
| 187 | .name = "ucb1400_core", |
| 188 | .id = -1, |
| 189 | .dev = { |
| 190 | .platform_data = &vpac270_ucb1400_pdata, |
| 191 | }, |
| 192 | }; |
| 193 | |
| 194 | static void __init balloon3_ts_init(void) |
| 195 | { |
| 196 | if (!balloon3_has(BALLOON3_FEATURE_AUDIO)) |
| 197 | return; |
| 198 | |
| 199 | pxa_set_ac97_info(NULL); |
| 200 | platform_device_register(&balloon3_ucb1400_device); |
| 201 | } |
| 202 | #else |
| 203 | static inline void balloon3_ts_init(void) {} |
| 204 | #endif |
| 205 | |
| 206 | /****************************************************************************** |
| 207 | * Framebuffer |
| 208 | ******************************************************************************/ |
| 209 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
| 210 | static struct pxafb_mode_info balloon3_lcd_modes[] = { |
| 211 | { |
| 212 | .pixclock = 38000, |
| 213 | .xres = 480, |
| 214 | .yres = 640, |
| 215 | .bpp = 16, |
| 216 | .hsync_len = 8, |
| 217 | .left_margin = 8, |
| 218 | .right_margin = 8, |
| 219 | .vsync_len = 2, |
| 220 | .upper_margin = 4, |
| 221 | .lower_margin = 5, |
| 222 | .sync = 0, |
| 223 | }, |
| 224 | }; |
| 225 | |
| 226 | static struct pxafb_mach_info balloon3_lcd_screen = { |
| 227 | .modes = balloon3_lcd_modes, |
| 228 | .num_modes = ARRAY_SIZE(balloon3_lcd_modes), |
| 229 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, |
| 230 | }; |
| 231 | |
| 232 | static void balloon3_backlight_power(int on) |
| 233 | { |
| 234 | gpio_set_value(BALLOON3_GPIO_RUN_BACKLIGHT, on); |
| 235 | } |
| 236 | |
| 237 | static void __init balloon3_lcd_init(void) |
| 238 | { |
| 239 | int ret; |
| 240 | |
| 241 | if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY)) |
| 242 | return; |
| 243 | |
| 244 | ret = gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT, "BKL-ON"); |
| 245 | if (ret) { |
| 246 | pr_err("Requesting BKL-ON GPIO failed!\n"); |
| 247 | goto err; |
| 248 | } |
| 249 | |
| 250 | ret = gpio_direction_output(BALLOON3_GPIO_RUN_BACKLIGHT, 1); |
| 251 | if (ret) { |
| 252 | pr_err("Setting BKL-ON GPIO direction failed!\n"); |
| 253 | goto err2; |
| 254 | } |
| 255 | |
| 256 | balloon3_lcd_screen.pxafb_backlight_power = balloon3_backlight_power; |
| 257 | set_pxa_fb_info(&balloon3_lcd_screen); |
| 258 | return; |
| 259 | |
| 260 | err2: |
| 261 | gpio_free(BALLOON3_GPIO_RUN_BACKLIGHT); |
| 262 | err: |
| 263 | return; |
| 264 | } |
| 265 | #else |
| 266 | static inline void balloon3_lcd_init(void) {} |
| 267 | #endif |
| 268 | |
| 269 | /****************************************************************************** |
| 270 | * SD/MMC card controller |
| 271 | ******************************************************************************/ |
| 272 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) |
| 273 | static struct pxamci_platform_data balloon3_mci_platform_data = { |
| 274 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 275 | .gpio_card_detect = -1, |
| 276 | .gpio_card_ro = -1, |
| 277 | .gpio_power = -1, |
| 278 | .detect_delay_ms = 200, |
| 279 | }; |
| 280 | |
| 281 | static void __init balloon3_mmc_init(void) |
| 282 | { |
| 283 | pxa_set_mci_info(&balloon3_mci_platform_data); |
| 284 | } |
| 285 | #else |
| 286 | static inline void balloon3_mmc_init(void) {} |
| 287 | #endif |
| 288 | |
| 289 | /****************************************************************************** |
| 290 | * USB Gadget |
| 291 | ******************************************************************************/ |
| 292 | #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE) |
| 293 | static void balloon3_udc_command(int cmd) |
| 294 | { |
| 295 | if (cmd == PXA2XX_UDC_CMD_CONNECT) |
| 296 | UP2OCR |= UP2OCR_DPPUE | UP2OCR_DPPUBE; |
| 297 | else if (cmd == PXA2XX_UDC_CMD_DISCONNECT) |
| 298 | UP2OCR &= ~UP2OCR_DPPUE; |
| 299 | } |
| 300 | |
| 301 | static int balloon3_udc_is_connected(void) |
| 302 | { |
| 303 | return 1; |
| 304 | } |
| 305 | |
| 306 | static struct pxa2xx_udc_mach_info balloon3_udc_info __initdata = { |
| 307 | .udc_command = balloon3_udc_command, |
| 308 | .udc_is_connected = balloon3_udc_is_connected, |
| 309 | .gpio_pullup = -1, |
| 310 | }; |
| 311 | |
| 312 | static void __init balloon3_udc_init(void) |
| 313 | { |
| 314 | pxa_set_udc_info(&balloon3_udc_info); |
| 315 | platform_device_register(&balloon3_gpio_vbus); |
| 316 | } |
| 317 | #else |
| 318 | static inline void balloon3_udc_init(void) {} |
| 319 | #endif |
| 320 | |
| 321 | /****************************************************************************** |
| 322 | * IrDA |
| 323 | ******************************************************************************/ |
| 324 | #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE) |
| 325 | static struct pxaficp_platform_data balloon3_ficp_platform_data = { |
| 326 | .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF, |
| 327 | }; |
| 328 | |
| 329 | static void __init balloon3_irda_init(void) |
| 330 | { |
| 331 | pxa_set_ficp_info(&balloon3_ficp_platform_data); |
| 332 | } |
| 333 | #else |
| 334 | static inline void balloon3_irda_init(void) {} |
| 335 | #endif |
| 336 | |
| 337 | /****************************************************************************** |
| 338 | * USB Host |
| 339 | ******************************************************************************/ |
| 340 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
| 341 | static struct pxaohci_platform_data balloon3_ohci_info = { |
| 342 | .port_mode = PMM_PERPORT_MODE, |
| 343 | .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW, |
| 344 | }; |
| 345 | |
| 346 | static void __init balloon3_uhc_init(void) |
| 347 | { |
| 348 | if (!balloon3_has(BALLOON3_FEATURE_OHCI)) |
| 349 | return; |
| 350 | pxa_set_ohci_info(&balloon3_ohci_info); |
| 351 | } |
| 352 | #else |
| 353 | static inline void balloon3_uhc_init(void) {} |
| 354 | #endif |
| 355 | |
| 356 | /****************************************************************************** |
| 357 | * LEDs |
| 358 | ******************************************************************************/ |
| 359 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) |
| 360 | struct gpio_led balloon3_gpio_leds[] = { |
| 361 | { |
| 362 | .name = "balloon3:green:idle", |
| 363 | .default_trigger = "heartbeat", |
| 364 | .gpio = BALLOON3_GPIO_LED_IDLE, |
| 365 | .active_low = 1, |
| 366 | }, { |
| 367 | .name = "balloon3:green:nand", |
| 368 | .default_trigger = "nand-disk", |
| 369 | .gpio = BALLOON3_GPIO_LED_NAND, |
| 370 | .active_low = 1, |
| 371 | }, |
| 372 | }; |
| 373 | |
| 374 | static struct gpio_led_platform_data balloon3_gpio_led_info = { |
| 375 | .leds = balloon3_gpio_leds, |
| 376 | .num_leds = ARRAY_SIZE(balloon3_gpio_leds), |
| 377 | }; |
| 378 | |
| 379 | static struct platform_device balloon3_leds = { |
| 380 | .name = "leds-gpio", |
Marek Vasut | 02a453e | 2010-07-27 23:11:03 +0200 | [diff] [blame] | 381 | .id = 0, |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 382 | .dev = { |
| 383 | .platform_data = &balloon3_gpio_led_info, |
| 384 | } |
| 385 | }; |
| 386 | |
Marek Vasut | 02a453e | 2010-07-27 23:11:03 +0200 | [diff] [blame] | 387 | struct gpio_led balloon3_pcf_gpio_leds[] = { |
| 388 | { |
| 389 | .name = "balloon3:green:led0", |
| 390 | .gpio = BALLOON3_PCF_GPIO_LED0, |
| 391 | .active_low = 1, |
| 392 | }, { |
| 393 | .name = "balloon3:green:led1", |
| 394 | .gpio = BALLOON3_PCF_GPIO_LED1, |
| 395 | .active_low = 1, |
| 396 | }, { |
| 397 | .name = "balloon3:orange:led2", |
| 398 | .gpio = BALLOON3_PCF_GPIO_LED2, |
| 399 | .active_low = 1, |
| 400 | }, { |
| 401 | .name = "balloon3:orange:led3", |
| 402 | .gpio = BALLOON3_PCF_GPIO_LED3, |
| 403 | .active_low = 1, |
| 404 | }, { |
| 405 | .name = "balloon3:orange:led4", |
| 406 | .gpio = BALLOON3_PCF_GPIO_LED4, |
| 407 | .active_low = 1, |
| 408 | }, { |
| 409 | .name = "balloon3:orange:led5", |
| 410 | .gpio = BALLOON3_PCF_GPIO_LED5, |
| 411 | .active_low = 1, |
| 412 | }, { |
| 413 | .name = "balloon3:red:led6", |
| 414 | .gpio = BALLOON3_PCF_GPIO_LED6, |
| 415 | .active_low = 1, |
| 416 | }, { |
| 417 | .name = "balloon3:red:led7", |
| 418 | .gpio = BALLOON3_PCF_GPIO_LED7, |
| 419 | .active_low = 1, |
| 420 | }, |
| 421 | }; |
| 422 | |
| 423 | static struct gpio_led_platform_data balloon3_pcf_gpio_led_info = { |
| 424 | .leds = balloon3_pcf_gpio_leds, |
| 425 | .num_leds = ARRAY_SIZE(balloon3_pcf_gpio_leds), |
| 426 | }; |
| 427 | |
| 428 | static struct platform_device balloon3_pcf_leds = { |
| 429 | .name = "leds-gpio", |
| 430 | .id = 1, |
| 431 | .dev = { |
| 432 | .platform_data = &balloon3_pcf_gpio_led_info, |
| 433 | } |
| 434 | }; |
| 435 | |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 436 | static void __init balloon3_leds_init(void) |
| 437 | { |
| 438 | platform_device_register(&balloon3_leds); |
Marek Vasut | 02a453e | 2010-07-27 23:11:03 +0200 | [diff] [blame] | 439 | platform_device_register(&balloon3_pcf_leds); |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 440 | } |
| 441 | #else |
| 442 | static inline void balloon3_leds_init(void) {} |
| 443 | #endif |
| 444 | |
| 445 | /****************************************************************************** |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 446 | * FPGA IRQ |
| 447 | ******************************************************************************/ |
Jonathan McDowell | 2a23ec3 | 2009-07-04 14:43:56 +0100 | [diff] [blame] | 448 | static void balloon3_mask_irq(unsigned int irq) |
| 449 | { |
| 450 | int balloon3_irq = (irq - BALLOON3_IRQ(0)); |
| 451 | balloon3_irq_enabled &= ~(1 << balloon3_irq); |
| 452 | __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG); |
| 453 | } |
| 454 | |
| 455 | static void balloon3_unmask_irq(unsigned int irq) |
| 456 | { |
| 457 | int balloon3_irq = (irq - BALLOON3_IRQ(0)); |
| 458 | balloon3_irq_enabled |= (1 << balloon3_irq); |
| 459 | __raw_writel(~balloon3_irq_enabled, BALLOON3_INT_CONTROL_REG); |
| 460 | } |
| 461 | |
| 462 | static struct irq_chip balloon3_irq_chip = { |
| 463 | .name = "FPGA", |
| 464 | .ack = balloon3_mask_irq, |
| 465 | .mask = balloon3_mask_irq, |
| 466 | .unmask = balloon3_unmask_irq, |
| 467 | }; |
| 468 | |
| 469 | static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc) |
| 470 | { |
| 471 | unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) & |
| 472 | balloon3_irq_enabled; |
Jonathan McDowell | 2a23ec3 | 2009-07-04 14:43:56 +0100 | [diff] [blame] | 473 | do { |
| 474 | /* clear useless edge notification */ |
| 475 | if (desc->chip->ack) |
| 476 | desc->chip->ack(BALLOON3_AUX_NIRQ); |
| 477 | while (pending) { |
| 478 | irq = BALLOON3_IRQ(0) + __ffs(pending); |
| 479 | generic_handle_irq(irq); |
| 480 | pending &= pending - 1; |
| 481 | } |
| 482 | pending = __raw_readl(BALLOON3_INT_CONTROL_REG) & |
| 483 | balloon3_irq_enabled; |
| 484 | } while (pending); |
| 485 | } |
| 486 | |
| 487 | static void __init balloon3_init_irq(void) |
| 488 | { |
| 489 | int irq; |
| 490 | |
| 491 | pxa27x_init_irq(); |
| 492 | /* setup extra Balloon3 irqs */ |
| 493 | for (irq = BALLOON3_IRQ(0); irq <= BALLOON3_IRQ(7); irq++) { |
| 494 | set_irq_chip(irq, &balloon3_irq_chip); |
| 495 | set_irq_handler(irq, handle_level_irq); |
| 496 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); |
| 497 | } |
| 498 | |
| 499 | set_irq_chained_handler(BALLOON3_AUX_NIRQ, balloon3_irq_handler); |
| 500 | set_irq_type(BALLOON3_AUX_NIRQ, IRQ_TYPE_EDGE_FALLING); |
| 501 | |
| 502 | pr_debug("%s: chained handler installed - irq %d automatically " |
| 503 | "enabled\n", __func__, BALLOON3_AUX_NIRQ); |
| 504 | } |
| 505 | |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 506 | /****************************************************************************** |
Marek Vasut | 02a453e | 2010-07-27 23:11:03 +0200 | [diff] [blame] | 507 | * GPIO expander |
| 508 | ******************************************************************************/ |
| 509 | #if defined(CONFIG_GPIO_PCF857X) || defined(CONFIG_GPIO_PCF857X_MODULE) |
| 510 | static struct pcf857x_platform_data balloon3_pcf857x_pdata = { |
| 511 | .gpio_base = BALLOON3_PCF_GPIO_BASE, |
| 512 | .n_latch = 0, |
| 513 | .setup = NULL, |
| 514 | .teardown = NULL, |
| 515 | .context = NULL, |
| 516 | }; |
| 517 | |
| 518 | static struct i2c_board_info __initdata balloon3_i2c_devs[] = { |
| 519 | { |
| 520 | I2C_BOARD_INFO("pcf8574a", 0x38), |
| 521 | .platform_data = &balloon3_pcf857x_pdata, |
| 522 | }, |
| 523 | }; |
| 524 | |
| 525 | static void __init balloon3_i2c_init(void) |
| 526 | { |
| 527 | pxa_set_i2c_info(NULL); |
| 528 | i2c_register_board_info(0, ARRAY_AND_SIZE(balloon3_i2c_devs)); |
| 529 | } |
| 530 | #else |
| 531 | static inline void balloon3_i2c_init(void) {} |
| 532 | #endif |
| 533 | |
| 534 | /****************************************************************************** |
Marek Vasut | e6a8ef5 | 2010-07-28 03:32:05 +0200 | [diff] [blame^] | 535 | * NAND |
| 536 | ******************************************************************************/ |
| 537 | #if defined(CONFIG_MTD_NAND_PLATFORM)||defined(CONFIG_MTD_NAND_PLATFORM_MODULE) |
| 538 | static uint16_t balloon3_ctl = |
| 539 | BALLOON3_NAND_CONTROL_FLCE0 | BALLOON3_NAND_CONTROL_FLCE1 | |
| 540 | BALLOON3_NAND_CONTROL_FLCE2 | BALLOON3_NAND_CONTROL_FLCE3 | |
| 541 | BALLOON3_NAND_CONTROL_FLWP; |
| 542 | |
| 543 | static void balloon3_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl) |
| 544 | { |
| 545 | struct nand_chip *this = mtd->priv; |
| 546 | |
| 547 | if (ctrl & NAND_CTRL_CHANGE) { |
| 548 | if (ctrl & NAND_CLE) |
| 549 | balloon3_ctl |= BALLOON3_NAND_CONTROL_FLCLE; |
| 550 | else |
| 551 | balloon3_ctl &= ~BALLOON3_NAND_CONTROL_FLCLE; |
| 552 | |
| 553 | if (ctrl & NAND_ALE) |
| 554 | balloon3_ctl |= BALLOON3_NAND_CONTROL_FLALE; |
| 555 | else |
| 556 | balloon3_ctl &= ~BALLOON3_NAND_CONTROL_FLALE; |
| 557 | |
| 558 | __raw_writel(balloon3_ctl, BALLOON3_NAND_CONTROL_REG); |
| 559 | } |
| 560 | |
| 561 | if (cmd != NAND_CMD_NONE) |
| 562 | writeb(cmd, this->IO_ADDR_W); |
| 563 | } |
| 564 | |
| 565 | static void balloon3_nand_select_chip(struct mtd_info *mtd, int chip) |
| 566 | { |
| 567 | if (chip < 0 || chip > 3) |
| 568 | return; |
| 569 | |
| 570 | balloon3_ctl |= BALLOON3_NAND_CONTROL_FLCE0 | |
| 571 | BALLOON3_NAND_CONTROL_FLCE1 | |
| 572 | BALLOON3_NAND_CONTROL_FLCE2 | |
| 573 | BALLOON3_NAND_CONTROL_FLCE3; |
| 574 | |
| 575 | /* Deassert correct nCE line */ |
| 576 | balloon3_ctl &= ~(BALLOON3_NAND_CONTROL_FLCE0 << chip); |
| 577 | |
| 578 | __raw_writew(balloon3_ctl, BALLOON3_NAND_CONTROL_REG); |
| 579 | } |
| 580 | |
| 581 | static int balloon3_nand_probe(struct platform_device *pdev) |
| 582 | { |
| 583 | void __iomem *temp_map; |
| 584 | uint16_t ver; |
| 585 | int ret; |
| 586 | |
| 587 | __raw_writew(BALLOON3_NAND_CONTROL2_16BIT, BALLOON3_NAND_CONTROL2_REG); |
| 588 | |
| 589 | ver = __raw_readw(BALLOON3_FPGA_VER); |
| 590 | if (ver > 0x0201) |
| 591 | pr_warn("The FPGA code, version 0x%04x, is newer than rel-0.3. " |
| 592 | "NAND support might be broken in this version!", ver); |
| 593 | |
| 594 | /* Power up the NAND chips */ |
| 595 | ret = gpio_request(BALLOON3_GPIO_RUN_NAND, "NAND"); |
| 596 | if (ret) |
| 597 | goto err1; |
| 598 | |
| 599 | ret = gpio_direction_output(BALLOON3_GPIO_RUN_NAND, 1); |
| 600 | if (ret) |
| 601 | goto err2; |
| 602 | |
| 603 | gpio_set_value(BALLOON3_GPIO_RUN_NAND, 1); |
| 604 | |
| 605 | /* Deassert all nCE lines and write protect line */ |
| 606 | __raw_writel(balloon3_ctl, BALLOON3_NAND_CONTROL_REG); |
| 607 | return 0; |
| 608 | |
| 609 | err2: |
| 610 | gpio_free(BALLOON3_GPIO_RUN_NAND); |
| 611 | err1: |
| 612 | return ret; |
| 613 | } |
| 614 | |
| 615 | static void balloon3_nand_remove(struct platform_device *pdev) |
| 616 | { |
| 617 | /* Power down the NAND chips */ |
| 618 | gpio_set_value(BALLOON3_GPIO_RUN_NAND, 0); |
| 619 | gpio_free(BALLOON3_GPIO_RUN_NAND); |
| 620 | } |
| 621 | |
| 622 | static struct mtd_partition balloon3_partition_info[] = { |
| 623 | [0] = { |
| 624 | .name = "Boot", |
| 625 | .offset = 0, |
| 626 | .size = SZ_4M, |
| 627 | }, |
| 628 | [1] = { |
| 629 | .name = "RootFS", |
| 630 | .offset = MTDPART_OFS_APPEND, |
| 631 | .size = MTDPART_SIZ_FULL |
| 632 | }, |
| 633 | }; |
| 634 | |
| 635 | static const char *balloon3_part_probes[] = { "cmdlinepart", NULL }; |
| 636 | |
| 637 | struct platform_nand_data balloon3_nand_pdata = { |
| 638 | .chip = { |
| 639 | .nr_chips = 4, |
| 640 | .chip_offset = 0, |
| 641 | .nr_partitions = ARRAY_SIZE(balloon3_partition_info), |
| 642 | .partitions = balloon3_partition_info, |
| 643 | .chip_delay = 50, |
| 644 | .part_probe_types = balloon3_part_probes, |
| 645 | }, |
| 646 | .ctrl = { |
| 647 | .hwcontrol = 0, |
| 648 | .dev_ready = 0, |
| 649 | .select_chip = balloon3_nand_select_chip, |
| 650 | .cmd_ctrl = balloon3_nand_cmd_ctl, |
| 651 | .probe = balloon3_nand_probe, |
| 652 | .remove = balloon3_nand_remove, |
| 653 | }, |
| 654 | }; |
| 655 | |
| 656 | static struct resource balloon3_nand_resource[] = { |
| 657 | [0] = { |
| 658 | .start = BALLOON3_NAND_BASE, |
| 659 | .end = BALLOON3_NAND_BASE + 0x4, |
| 660 | .flags = IORESOURCE_MEM, |
| 661 | }, |
| 662 | }; |
| 663 | |
| 664 | static struct platform_device balloon3_nand = { |
| 665 | .name = "gen_nand", |
| 666 | .num_resources = ARRAY_SIZE(balloon3_nand_resource), |
| 667 | .resource = balloon3_nand_resource, |
| 668 | .id = -1, |
| 669 | .dev = { |
| 670 | .platform_data = &balloon3_nand_pdata, |
| 671 | } |
| 672 | }; |
| 673 | |
| 674 | static void __init balloon3_nand_init(void) |
| 675 | { |
| 676 | platform_device_register(&balloon3_nand); |
| 677 | } |
| 678 | #else |
| 679 | static inline void balloon3_nand_init(void) {} |
| 680 | #endif |
| 681 | |
| 682 | /****************************************************************************** |
Marek Vasut | b0240bf | 2010-07-26 23:24:44 +0200 | [diff] [blame] | 683 | * Machine init |
| 684 | ******************************************************************************/ |
Jonathan McDowell | 2a23ec3 | 2009-07-04 14:43:56 +0100 | [diff] [blame] | 685 | static void __init balloon3_init(void) |
| 686 | { |
Jonathan McDowell | 2a23ec3 | 2009-07-04 14:43:56 +0100 | [diff] [blame] | 687 | ARB_CNTRL = ARB_CORE_PARK | 0x234; |
| 688 | |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 689 | pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_pin_config)); |
| 690 | |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 691 | pxa_set_ffuart_info(NULL); |
| 692 | pxa_set_btuart_info(NULL); |
| 693 | pxa_set_stuart_info(NULL); |
| 694 | |
Marek Vasut | 02a453e | 2010-07-27 23:11:03 +0200 | [diff] [blame] | 695 | balloon3_i2c_init(); |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 696 | balloon3_irda_init(); |
| 697 | balloon3_lcd_init(); |
| 698 | balloon3_leds_init(); |
| 699 | balloon3_mmc_init(); |
Marek Vasut | e6a8ef5 | 2010-07-28 03:32:05 +0200 | [diff] [blame^] | 700 | balloon3_nand_init(); |
Marek Vasut | 12a2449 | 2010-07-27 01:37:44 +0200 | [diff] [blame] | 701 | balloon3_nor_init(); |
| 702 | balloon3_ts_init(); |
| 703 | balloon3_udc_init(); |
| 704 | balloon3_uhc_init(); |
Jonathan McDowell | 2a23ec3 | 2009-07-04 14:43:56 +0100 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | static struct map_desc balloon3_io_desc[] __initdata = { |
| 708 | { /* CPLD/FPGA */ |
| 709 | .virtual = BALLOON3_FPGA_VIRT, |
| 710 | .pfn = __phys_to_pfn(BALLOON3_FPGA_PHYS), |
| 711 | .length = BALLOON3_FPGA_LENGTH, |
| 712 | .type = MT_DEVICE, |
| 713 | }, |
| 714 | }; |
| 715 | |
| 716 | static void __init balloon3_map_io(void) |
| 717 | { |
| 718 | pxa_map_io(); |
| 719 | iotable_init(balloon3_io_desc, ARRAY_SIZE(balloon3_io_desc)); |
| 720 | } |
| 721 | |
| 722 | MACHINE_START(BALLOON3, "Balloon3") |
| 723 | /* Maintainer: Nick Bane. */ |
| 724 | .phys_io = 0x40000000, |
| 725 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 726 | .map_io = balloon3_map_io, |
| 727 | .init_irq = balloon3_init_irq, |
| 728 | .timer = &pxa_timer, |
| 729 | .init_machine = balloon3_init, |
| 730 | .boot_params = PHYS_OFFSET + 0x100, |
| 731 | MACHINE_END |