Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-pxa/pcm990-baseboard.c |
| 3 | * Support for the Phytec phyCORE-PXA270 Development Platform (PCM-990). |
| 4 | * |
| 5 | * Refer |
| 6 | * http://www.phytec.com/products/rdk/ARM-XScale/phyCORE-XScale-PXA270.html |
| 7 | * for additional hardware info |
| 8 | * |
| 9 | * Author: Juergen Kilb |
| 10 | * Created: April 05, 2005 |
| 11 | * Copyright: Phytec Messtechnik GmbH |
| 12 | * e-Mail: armlinux@phytec.de |
| 13 | * |
| 14 | * based on Intel Mainstone Board |
| 15 | * |
| 16 | * Copyright 2007 Juergen Beisert @ Pengutronix (j.beisert@pengutronix.de) |
| 17 | * |
| 18 | * This program is free software; you can redistribute it and/or modify |
| 19 | * it under the terms of the GNU General Public License version 2 as |
| 20 | * published by the Free Software Foundation. |
| 21 | */ |
| 22 | |
| 23 | #include <linux/irq.h> |
| 24 | #include <linux/platform_device.h> |
| 25 | #include <linux/ide.h> |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame^] | 26 | #include <linux/i2c.h> |
| 27 | |
| 28 | #include <media/soc_camera.h> |
| 29 | |
| 30 | #include <asm/gpio.h> |
| 31 | #include <asm/arch/i2c.h> |
| 32 | #include <asm/arch/camera.h> |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 33 | #include <asm/mach/map.h> |
| 34 | #include <asm/arch/pxa-regs.h> |
eric miao | a683b14 | 2008-03-03 09:44:25 +0800 | [diff] [blame] | 35 | #include <asm/arch/pxa2xx-gpio.h> |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 36 | #include <asm/arch/mmc.h> |
| 37 | #include <asm/arch/ohci.h> |
| 38 | #include <asm/arch/pcm990_baseboard.h> |
| 39 | |
| 40 | /* |
| 41 | * The PCM-990 development baseboard uses PCM-027's hardeware in the |
| 42 | * following way: |
| 43 | * |
| 44 | * - LCD support is in use |
| 45 | * - GPIO16 is output for back light on/off with PWM |
| 46 | * - GPIO58 ... GPIO73 are outputs for display data |
| 47 | * - GPIO74 is output output for LCDFCLK |
| 48 | * - GPIO75 is output for LCDLCLK |
| 49 | * - GPIO76 is output for LCDPCLK |
| 50 | * - GPIO77 is output for LCDBIAS |
| 51 | * - MMC support is in use |
| 52 | * - GPIO32 is output for MMCCLK |
| 53 | * - GPIO92 is MMDAT0 |
| 54 | * - GPIO109 is MMDAT1 |
| 55 | * - GPIO110 is MMCS0 |
| 56 | * - GPIO111 is MMCS1 |
| 57 | * - GPIO112 is MMCMD |
| 58 | * - IDE/CF card is in use |
| 59 | * - GPIO48 is output /POE |
| 60 | * - GPIO49 is output /PWE |
| 61 | * - GPIO50 is output /PIOR |
| 62 | * - GPIO51 is output /PIOW |
| 63 | * - GPIO54 is output /PCE2 |
| 64 | * - GPIO55 is output /PREG |
| 65 | * - GPIO56 is input /PWAIT |
| 66 | * - GPIO57 is output /PIOS16 |
| 67 | * - GPIO79 is output PSKTSEL |
| 68 | * - GPIO85 is output /PCE1 |
| 69 | * - FFUART is in use |
| 70 | * - GPIO34 is input FFRXD |
| 71 | * - GPIO35 is input FFCTS |
| 72 | * - GPIO36 is input FFDCD |
| 73 | * - GPIO37 is input FFDSR |
| 74 | * - GPIO38 is input FFRI |
| 75 | * - GPIO39 is output FFTXD |
| 76 | * - GPIO40 is output FFDTR |
| 77 | * - GPIO41 is output FFRTS |
| 78 | * - BTUART is in use |
| 79 | * - GPIO42 is input BTRXD |
| 80 | * - GPIO43 is output BTTXD |
| 81 | * - GPIO44 is input BTCTS |
| 82 | * - GPIO45 is output BTRTS |
| 83 | * - IRUART is in use |
| 84 | * - GPIO46 is input STDRXD |
| 85 | * - GPIO47 is output STDTXD |
| 86 | * - AC97 is in use*) |
| 87 | * - GPIO28 is input AC97CLK |
| 88 | * - GPIO29 is input AC97DatIn |
| 89 | * - GPIO30 is output AC97DatO |
| 90 | * - GPIO31 is output AC97SYNC |
| 91 | * - GPIO113 is output AC97_RESET |
| 92 | * - SSP is in use |
| 93 | * - GPIO23 is output SSPSCLK |
| 94 | * - GPIO24 is output chip select to Max7301 |
| 95 | * - GPIO25 is output SSPTXD |
| 96 | * - GPIO26 is input SSPRXD |
| 97 | * - GPIO27 is input for Max7301 IRQ |
| 98 | * - GPIO53 is input SSPSYSCLK |
| 99 | * - SSP3 is in use |
| 100 | * - GPIO81 is output SSPTXD3 |
| 101 | * - GPIO82 is input SSPRXD3 |
| 102 | * - GPIO83 is output SSPSFRM |
| 103 | * - GPIO84 is output SSPCLK3 |
| 104 | * |
| 105 | * Otherwise claimed GPIOs: |
| 106 | * GPIO1 -> IRQ from user switch |
| 107 | * GPIO9 -> IRQ from power management |
| 108 | * GPIO10 -> IRQ from WML9712 AC97 controller |
| 109 | * GPIO11 -> IRQ from IDE controller |
| 110 | * GPIO12 -> IRQ from CF controller |
| 111 | * GPIO13 -> IRQ from CF controller |
| 112 | * GPIO14 -> GPIO free |
| 113 | * GPIO15 -> /CS1 selects baseboard's Control CPLD (U7, 16 bit wide data path) |
| 114 | * GPIO19 -> GPIO free |
| 115 | * GPIO20 -> /SDCS2 |
| 116 | * GPIO21 -> /CS3 PC card socket select |
| 117 | * GPIO33 -> /CS5 network controller select |
| 118 | * GPIO78 -> /CS2 (16 bit wide data path) |
| 119 | * GPIO80 -> /CS4 (16 bit wide data path) |
| 120 | * GPIO86 -> GPIO free |
| 121 | * GPIO87 -> GPIO free |
| 122 | * GPIO90 -> LED0 on CPU module |
| 123 | * GPIO91 -> LED1 on CPI module |
| 124 | * GPIO117 -> SCL |
| 125 | * GPIO118 -> SDA |
| 126 | */ |
| 127 | |
| 128 | static unsigned long pcm990_irq_enabled; |
| 129 | |
| 130 | static void pcm990_mask_ack_irq(unsigned int irq) |
| 131 | { |
| 132 | int pcm990_irq = (irq - PCM027_IRQ(0)); |
| 133 | PCM990_INTMSKENA = (pcm990_irq_enabled &= ~(1 << pcm990_irq)); |
| 134 | } |
| 135 | |
| 136 | static void pcm990_unmask_irq(unsigned int irq) |
| 137 | { |
| 138 | int pcm990_irq = (irq - PCM027_IRQ(0)); |
| 139 | /* the irq can be acknowledged only if deasserted, so it's done here */ |
| 140 | PCM990_INTSETCLR |= 1 << pcm990_irq; |
| 141 | PCM990_INTMSKENA = (pcm990_irq_enabled |= (1 << pcm990_irq)); |
| 142 | } |
| 143 | |
| 144 | static struct irq_chip pcm990_irq_chip = { |
| 145 | .mask_ack = pcm990_mask_ack_irq, |
| 146 | .unmask = pcm990_unmask_irq, |
| 147 | }; |
| 148 | |
| 149 | static void pcm990_irq_handler(unsigned int irq, struct irq_desc *desc) |
| 150 | { |
| 151 | unsigned long pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled; |
| 152 | |
| 153 | do { |
| 154 | GEDR(PCM990_CTRL_INT_IRQ_GPIO) = |
| 155 | GPIO_bit(PCM990_CTRL_INT_IRQ_GPIO); |
| 156 | if (likely(pending)) { |
| 157 | irq = PCM027_IRQ(0) + __ffs(pending); |
| 158 | desc = irq_desc + irq; |
| 159 | desc_handle_irq(irq, desc); |
| 160 | } |
| 161 | pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled; |
| 162 | } while (pending); |
| 163 | } |
| 164 | |
| 165 | static void __init pcm990_init_irq(void) |
| 166 | { |
| 167 | int irq; |
| 168 | |
| 169 | /* setup extra PCM990 irqs */ |
| 170 | for (irq = PCM027_IRQ(0); irq <= PCM027_IRQ(3); irq++) { |
| 171 | set_irq_chip(irq, &pcm990_irq_chip); |
| 172 | set_irq_handler(irq, handle_level_irq); |
| 173 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); |
| 174 | } |
| 175 | |
| 176 | PCM990_INTMSKENA = 0x00; /* disable all Interrupts */ |
| 177 | PCM990_INTSETCLR = 0xFF; |
| 178 | |
| 179 | set_irq_chained_handler(PCM990_CTRL_INT_IRQ, pcm990_irq_handler); |
| 180 | set_irq_type(PCM990_CTRL_INT_IRQ, PCM990_CTRL_INT_IRQ_EDGE); |
| 181 | } |
| 182 | |
| 183 | static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int, |
| 184 | void *data) |
| 185 | { |
| 186 | int err; |
| 187 | |
| 188 | /* |
| 189 | * enable GPIO for PXA27x MMC controller |
| 190 | */ |
| 191 | pxa_gpio_mode(GPIO32_MMCCLK_MD); |
| 192 | pxa_gpio_mode(GPIO112_MMCCMD_MD); |
| 193 | pxa_gpio_mode(GPIO92_MMCDAT0_MD); |
| 194 | pxa_gpio_mode(GPIO109_MMCDAT1_MD); |
| 195 | pxa_gpio_mode(GPIO110_MMCDAT2_MD); |
| 196 | pxa_gpio_mode(GPIO111_MMCDAT3_MD); |
| 197 | |
| 198 | err = request_irq(PCM027_MMCDET_IRQ, mci_detect_int, IRQF_DISABLED, |
| 199 | "MMC card detect", data); |
| 200 | if (err) |
| 201 | printk(KERN_ERR "pcm990_mci_init: MMC/SD: can't request MMC " |
| 202 | "card detect IRQ\n"); |
| 203 | |
| 204 | return err; |
| 205 | } |
| 206 | |
| 207 | static void pcm990_mci_setpower(struct device *dev, unsigned int vdd) |
| 208 | { |
| 209 | struct pxamci_platform_data *p_d = dev->platform_data; |
| 210 | |
| 211 | if ((1 << vdd) & p_d->ocr_mask) |
| 212 | __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) = |
| 213 | PCM990_CTRL_MMC2PWR; |
| 214 | else |
| 215 | __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) = |
| 216 | ~PCM990_CTRL_MMC2PWR; |
| 217 | } |
| 218 | |
| 219 | static void pcm990_mci_exit(struct device *dev, void *data) |
| 220 | { |
| 221 | free_irq(PCM027_MMCDET_IRQ, data); |
| 222 | } |
| 223 | |
| 224 | #define MSECS_PER_JIFFY (1000/HZ) |
| 225 | |
| 226 | static struct pxamci_platform_data pcm990_mci_platform_data = { |
| 227 | .detect_delay = 250 / MSECS_PER_JIFFY, |
| 228 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 229 | .init = pcm990_mci_init, |
| 230 | .setpower = pcm990_mci_setpower, |
| 231 | .exit = pcm990_mci_exit, |
| 232 | }; |
| 233 | |
| 234 | /* |
| 235 | * init OHCI hardware to work with |
| 236 | * |
| 237 | * Note: Only USB port 1 (host only) is connected |
| 238 | * |
| 239 | * GPIO88 (USBHPWR#1): overcurrent in, overcurrent when low |
| 240 | * GPIO89 (USBHPEN#1): power-on out, on when low |
| 241 | */ |
| 242 | static int pcm990_ohci_init(struct device *dev) |
| 243 | { |
| 244 | pxa_gpio_mode(PCM990_USB_OVERCURRENT); |
| 245 | pxa_gpio_mode(PCM990_USB_PWR_EN); |
| 246 | /* |
| 247 | * disable USB port 2 and 3 |
| 248 | * power sense is active low |
| 249 | */ |
| 250 | UHCHR = ((UHCHR) | UHCHR_PCPL | UHCHR_PSPL | UHCHR_SSEP2 | |
| 251 | UHCHR_SSEP3) & ~(UHCHR_SSEP1 | UHCHR_SSE); |
| 252 | /* |
| 253 | * wait 10ms after Power on |
| 254 | * overcurrent per port |
| 255 | * power switch per port |
| 256 | */ |
| 257 | UHCRHDA = (5<<24) | (1<<11) | (1<<8); /* FIXME: Required? */ |
| 258 | |
| 259 | return 0; |
| 260 | } |
| 261 | |
| 262 | static struct pxaohci_platform_data pcm990_ohci_platform_data = { |
| 263 | .port_mode = PMM_PERPORT_MODE, |
| 264 | .init = pcm990_ohci_init, |
| 265 | .exit = NULL, |
| 266 | }; |
| 267 | |
| 268 | /* |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame^] | 269 | * PXA27x Camera specific stuff |
| 270 | */ |
| 271 | #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE) |
| 272 | static int pcm990_pxacamera_init(struct device *dev) |
| 273 | { |
| 274 | pxa_gpio_mode(GPIO98_CIF_DD_0_MD); |
| 275 | pxa_gpio_mode(GPIO105_CIF_DD_1_MD); |
| 276 | pxa_gpio_mode(GPIO104_CIF_DD_2_MD); |
| 277 | pxa_gpio_mode(GPIO103_CIF_DD_3_MD); |
| 278 | pxa_gpio_mode(GPIO95_CIF_DD_4_MD); |
| 279 | pxa_gpio_mode(GPIO94_CIF_DD_5_MD); |
| 280 | pxa_gpio_mode(GPIO93_CIF_DD_6_MD); |
| 281 | pxa_gpio_mode(GPIO108_CIF_DD_7_MD); |
| 282 | pxa_gpio_mode(GPIO107_CIF_DD_8_MD); |
| 283 | pxa_gpio_mode(GPIO106_CIF_DD_9_MD); |
| 284 | pxa_gpio_mode(GPIO42_CIF_MCLK_MD); |
| 285 | pxa_gpio_mode(GPIO45_CIF_PCLK_MD); |
| 286 | pxa_gpio_mode(GPIO43_CIF_FV_MD); |
| 287 | pxa_gpio_mode(GPIO44_CIF_LV_MD); |
| 288 | |
| 289 | return 0; |
| 290 | } |
| 291 | |
| 292 | /* |
| 293 | * CICR4: PCLK_EN: Pixel clock is supplied by the sensor |
| 294 | * MCLK_EN: Master clock is generated by PXA |
| 295 | * PCP: Data sampled on the falling edge of pixel clock |
| 296 | */ |
| 297 | struct pxacamera_platform_data pcm990_pxacamera_platform_data = { |
| 298 | .init = pcm990_pxacamera_init, |
| 299 | .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | PXA_CAMERA_DATAWIDTH_10 | |
| 300 | PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN/* | PXA_CAMERA_PCP*/, |
| 301 | .mclk_10khz = 1000, |
| 302 | }; |
| 303 | |
| 304 | #include <linux/i2c/pca953x.h> |
| 305 | |
| 306 | static struct pca953x_platform_data pca9536_data = { |
| 307 | .gpio_base = NR_BUILTIN_GPIO + 1, |
| 308 | }; |
| 309 | |
| 310 | static struct soc_camera_link iclink[] = { |
| 311 | { |
| 312 | .bus_id = 0, /* Must match with the camera ID above */ |
| 313 | .gpio = NR_BUILTIN_GPIO + 1, |
| 314 | }, { |
| 315 | .bus_id = 0, /* Must match with the camera ID above */ |
| 316 | } |
| 317 | }; |
| 318 | |
| 319 | /* Board I2C devices. */ |
| 320 | static struct i2c_board_info __initdata pcm990_i2c_devices[] = { |
| 321 | { |
| 322 | /* Must initialize before the camera(s) */ |
| 323 | I2C_BOARD_INFO("pca953x", 0x41), |
| 324 | .type = "pca9536", |
| 325 | .platform_data = &pca9536_data, |
| 326 | }, { |
| 327 | I2C_BOARD_INFO("mt9v022", 0x48), |
| 328 | .type = "mt9v022", |
| 329 | .platform_data = &iclink[0], /* With extender */ |
| 330 | }, { |
| 331 | I2C_BOARD_INFO("mt9m001", 0x5d), |
| 332 | .type = "mt9m001", |
| 333 | .platform_data = &iclink[0], /* With extender */ |
| 334 | }, |
| 335 | }; |
| 336 | #endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */ |
| 337 | |
| 338 | /* |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 339 | * AC97 support |
| 340 | * Note: The connected AC97 mixer also reports interrupts at PCM990_AC97_IRQ |
| 341 | */ |
| 342 | static struct resource pxa27x_ac97_resources[] = { |
| 343 | [0] = { |
| 344 | .start = 0x40500000, |
| 345 | .end = 0x40500000 + 0xfff, |
| 346 | .flags = IORESOURCE_MEM, |
| 347 | }, |
| 348 | [1] = { |
| 349 | .start = IRQ_AC97, |
| 350 | .end = IRQ_AC97, |
| 351 | .flags = IORESOURCE_IRQ, |
| 352 | }, |
| 353 | }; |
| 354 | |
| 355 | static u64 pxa_ac97_dmamask = 0xffffffffUL; |
| 356 | |
| 357 | static struct platform_device pxa27x_device_ac97 = { |
| 358 | .name = "pxa2xx-ac97", |
| 359 | .id = -1, |
| 360 | .dev = { |
| 361 | .dma_mask = &pxa_ac97_dmamask, |
| 362 | .coherent_dma_mask = 0xffffffff, |
| 363 | }, |
| 364 | .num_resources = ARRAY_SIZE(pxa27x_ac97_resources), |
| 365 | .resource = pxa27x_ac97_resources, |
| 366 | }; |
| 367 | |
| 368 | /* |
| 369 | * enable generic access to the base board control CPLDs U6 and U7 |
| 370 | */ |
| 371 | static struct map_desc pcm990_io_desc[] __initdata = { |
| 372 | { |
| 373 | .virtual = PCM990_CTRL_BASE, |
| 374 | .pfn = __phys_to_pfn(PCM990_CTRL_PHYS), |
| 375 | .length = PCM990_CTRL_SIZE, |
| 376 | .type = MT_DEVICE /* CPLD */ |
| 377 | }, { |
| 378 | .virtual = PCM990_CF_PLD_BASE, |
| 379 | .pfn = __phys_to_pfn(PCM990_CF_PLD_PHYS), |
| 380 | .length = PCM990_CF_PLD_SIZE, |
| 381 | .type = MT_DEVICE /* CPLD */ |
| 382 | } |
| 383 | }; |
| 384 | |
| 385 | /* |
| 386 | * system init for baseboard usage. Will be called by pcm027 init. |
| 387 | * |
| 388 | * Add platform devices present on this baseboard and init |
| 389 | * them from CPU side as far as required to use them later on |
| 390 | */ |
| 391 | void __init pcm990_baseboard_init(void) |
| 392 | { |
| 393 | /* register CPLD access */ |
| 394 | iotable_init(pcm990_io_desc, ARRAY_SIZE(pcm990_io_desc)); |
| 395 | |
| 396 | /* register CPLD's IRQ controller */ |
| 397 | pcm990_init_irq(); |
| 398 | |
| 399 | platform_device_register(&pxa27x_device_ac97); |
| 400 | |
| 401 | /* MMC */ |
| 402 | pxa_set_mci_info(&pcm990_mci_platform_data); |
| 403 | |
| 404 | /* USB host */ |
| 405 | pxa_set_ohci_info(&pcm990_ohci_platform_data); |
| 406 | |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame^] | 407 | pxa_set_i2c_info(NULL); |
| 408 | |
| 409 | #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE) |
| 410 | pxa_set_camera_info(&pcm990_pxacamera_platform_data); |
| 411 | |
| 412 | i2c_register_board_info(0, pcm990_i2c_devices, |
| 413 | ARRAY_SIZE(pcm990_i2c_devices)); |
| 414 | #endif |
| 415 | |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 416 | printk(KERN_INFO"PCM-990 Evaluation baseboard initialized\n"); |
| 417 | } |