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 | */ |
Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 22 | #include <linux/gpio.h> |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 23 | #include <linux/irq.h> |
| 24 | #include <linux/platform_device.h> |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 25 | #include <linux/i2c.h> |
Sebastian Andrzej Siewior | b459396 | 2011-02-23 12:38:16 +0100 | [diff] [blame] | 26 | #include <linux/i2c/pxa-i2c.h> |
Guennadi Liakhovetski | c0f7edb | 2008-06-13 11:50:44 +0100 | [diff] [blame] | 27 | #include <linux/pwm_backlight.h> |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 28 | |
| 29 | #include <media/soc_camera.h> |
| 30 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 31 | #include <mach/camera.h> |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 32 | #include <asm/mach/map.h> |
Eric Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 33 | #include <mach/pxa27x.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 34 | #include <mach/audio.h> |
| 35 | #include <mach/mmc.h> |
| 36 | #include <mach/ohci.h> |
| 37 | #include <mach/pcm990_baseboard.h> |
| 38 | #include <mach/pxafb.h> |
Guennadi Liakhovetski | c0f7edb | 2008-06-13 11:50:44 +0100 | [diff] [blame] | 39 | |
| 40 | #include "devices.h" |
Guennadi Liakhovetski | 6a566fb | 2008-06-16 08:16:46 +0100 | [diff] [blame] | 41 | #include "generic.h" |
| 42 | |
| 43 | static unsigned long pcm990_pin_config[] __initdata = { |
| 44 | /* MMC */ |
| 45 | GPIO32_MMC_CLK, |
| 46 | GPIO112_MMC_CMD, |
| 47 | GPIO92_MMC_DAT_0, |
| 48 | GPIO109_MMC_DAT_1, |
| 49 | GPIO110_MMC_DAT_2, |
| 50 | GPIO111_MMC_DAT_3, |
| 51 | /* USB */ |
| 52 | GPIO88_USBH1_PWR, |
| 53 | GPIO89_USBH1_PEN, |
| 54 | /* PWM0 */ |
| 55 | GPIO16_PWM0_OUT, |
Eric Miao | 6f584cf | 2008-11-28 16:00:24 +0800 | [diff] [blame] | 56 | |
| 57 | /* I2C */ |
| 58 | GPIO117_I2C_SCL, |
| 59 | GPIO118_I2C_SDA, |
Eric Miao | c11b6a4 | 2010-01-04 17:00:13 +0800 | [diff] [blame] | 60 | |
| 61 | /* AC97 */ |
| 62 | GPIO28_AC97_BITCLK, |
| 63 | GPIO29_AC97_SDATA_IN_0, |
| 64 | GPIO30_AC97_SDATA_OUT, |
| 65 | GPIO31_AC97_SYNC, |
Guennadi Liakhovetski | 6a566fb | 2008-06-16 08:16:46 +0100 | [diff] [blame] | 66 | }; |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 67 | |
| 68 | /* |
Guennadi Liakhovetski | c0f7edb | 2008-06-13 11:50:44 +0100 | [diff] [blame] | 69 | * pcm990_lcd_power - control power supply to the LCD |
| 70 | * @on: 0 = switch off, 1 = switch on |
| 71 | * |
| 72 | * Called by the pxafb driver |
| 73 | */ |
| 74 | #ifndef CONFIG_PCM990_DISPLAY_NONE |
| 75 | static void pcm990_lcd_power(int on, struct fb_var_screeninfo *var) |
| 76 | { |
| 77 | if (on) { |
| 78 | /* enable LCD-Latches |
| 79 | * power on LCD |
| 80 | */ |
| 81 | __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG3) = |
| 82 | PCM990_CTRL_LCDPWR + PCM990_CTRL_LCDON; |
| 83 | } else { |
| 84 | /* disable LCD-Latches |
| 85 | * power off LCD |
| 86 | */ |
| 87 | __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG3) = 0x00; |
| 88 | } |
| 89 | } |
| 90 | #endif |
| 91 | |
| 92 | #if defined(CONFIG_PCM990_DISPLAY_SHARP) |
| 93 | static struct pxafb_mode_info fb_info_sharp_lq084v1dg21 = { |
| 94 | .pixclock = 28000, |
| 95 | .xres = 640, |
| 96 | .yres = 480, |
| 97 | .bpp = 16, |
| 98 | .hsync_len = 20, |
| 99 | .left_margin = 103, |
| 100 | .right_margin = 47, |
| 101 | .vsync_len = 6, |
| 102 | .upper_margin = 28, |
| 103 | .lower_margin = 5, |
| 104 | .sync = 0, |
| 105 | .cmap_greyscale = 0, |
| 106 | }; |
| 107 | |
| 108 | static struct pxafb_mach_info pcm990_fbinfo __initdata = { |
| 109 | .modes = &fb_info_sharp_lq084v1dg21, |
| 110 | .num_modes = 1, |
Eric Miao | 9587319 | 2008-12-07 17:49:01 +0800 | [diff] [blame] | 111 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, |
Guennadi Liakhovetski | c0f7edb | 2008-06-13 11:50:44 +0100 | [diff] [blame] | 112 | .pxafb_lcd_power = pcm990_lcd_power, |
| 113 | }; |
| 114 | #elif defined(CONFIG_PCM990_DISPLAY_NEC) |
| 115 | struct pxafb_mode_info fb_info_nec_nl6448bc20_18d = { |
| 116 | .pixclock = 39720, |
| 117 | .xres = 640, |
| 118 | .yres = 480, |
| 119 | .bpp = 16, |
| 120 | .hsync_len = 32, |
| 121 | .left_margin = 16, |
| 122 | .right_margin = 48, |
| 123 | .vsync_len = 2, |
| 124 | .upper_margin = 12, |
| 125 | .lower_margin = 17, |
| 126 | .sync = 0, |
| 127 | .cmap_greyscale = 0, |
| 128 | }; |
| 129 | |
| 130 | static struct pxafb_mach_info pcm990_fbinfo __initdata = { |
| 131 | .modes = &fb_info_nec_nl6448bc20_18d, |
| 132 | .num_modes = 1, |
Eric Miao | 9587319 | 2008-12-07 17:49:01 +0800 | [diff] [blame] | 133 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, |
Guennadi Liakhovetski | c0f7edb | 2008-06-13 11:50:44 +0100 | [diff] [blame] | 134 | .pxafb_lcd_power = pcm990_lcd_power, |
| 135 | }; |
| 136 | #endif |
| 137 | |
| 138 | static struct platform_pwm_backlight_data pcm990_backlight_data = { |
| 139 | .pwm_id = 0, |
| 140 | .max_brightness = 1023, |
| 141 | .dft_brightness = 1023, |
| 142 | .pwm_period_ns = 78770, |
| 143 | }; |
| 144 | |
| 145 | static struct platform_device pcm990_backlight_device = { |
| 146 | .name = "pwm-backlight", |
| 147 | .dev = { |
| 148 | .parent = &pxa27x_device_pwm0.dev, |
| 149 | .platform_data = &pcm990_backlight_data, |
| 150 | }, |
| 151 | }; |
| 152 | |
| 153 | /* |
| 154 | * The PCM-990 development baseboard uses PCM-027's hardware in the |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 155 | * following way: |
| 156 | * |
| 157 | * - LCD support is in use |
| 158 | * - GPIO16 is output for back light on/off with PWM |
| 159 | * - GPIO58 ... GPIO73 are outputs for display data |
| 160 | * - GPIO74 is output output for LCDFCLK |
| 161 | * - GPIO75 is output for LCDLCLK |
| 162 | * - GPIO76 is output for LCDPCLK |
| 163 | * - GPIO77 is output for LCDBIAS |
| 164 | * - MMC support is in use |
| 165 | * - GPIO32 is output for MMCCLK |
| 166 | * - GPIO92 is MMDAT0 |
| 167 | * - GPIO109 is MMDAT1 |
| 168 | * - GPIO110 is MMCS0 |
| 169 | * - GPIO111 is MMCS1 |
| 170 | * - GPIO112 is MMCMD |
| 171 | * - IDE/CF card is in use |
| 172 | * - GPIO48 is output /POE |
| 173 | * - GPIO49 is output /PWE |
| 174 | * - GPIO50 is output /PIOR |
| 175 | * - GPIO51 is output /PIOW |
| 176 | * - GPIO54 is output /PCE2 |
| 177 | * - GPIO55 is output /PREG |
| 178 | * - GPIO56 is input /PWAIT |
| 179 | * - GPIO57 is output /PIOS16 |
| 180 | * - GPIO79 is output PSKTSEL |
| 181 | * - GPIO85 is output /PCE1 |
| 182 | * - FFUART is in use |
| 183 | * - GPIO34 is input FFRXD |
| 184 | * - GPIO35 is input FFCTS |
| 185 | * - GPIO36 is input FFDCD |
| 186 | * - GPIO37 is input FFDSR |
| 187 | * - GPIO38 is input FFRI |
| 188 | * - GPIO39 is output FFTXD |
| 189 | * - GPIO40 is output FFDTR |
| 190 | * - GPIO41 is output FFRTS |
| 191 | * - BTUART is in use |
| 192 | * - GPIO42 is input BTRXD |
| 193 | * - GPIO43 is output BTTXD |
| 194 | * - GPIO44 is input BTCTS |
| 195 | * - GPIO45 is output BTRTS |
| 196 | * - IRUART is in use |
| 197 | * - GPIO46 is input STDRXD |
| 198 | * - GPIO47 is output STDTXD |
| 199 | * - AC97 is in use*) |
| 200 | * - GPIO28 is input AC97CLK |
| 201 | * - GPIO29 is input AC97DatIn |
| 202 | * - GPIO30 is output AC97DatO |
| 203 | * - GPIO31 is output AC97SYNC |
| 204 | * - GPIO113 is output AC97_RESET |
| 205 | * - SSP is in use |
| 206 | * - GPIO23 is output SSPSCLK |
| 207 | * - GPIO24 is output chip select to Max7301 |
| 208 | * - GPIO25 is output SSPTXD |
| 209 | * - GPIO26 is input SSPRXD |
| 210 | * - GPIO27 is input for Max7301 IRQ |
| 211 | * - GPIO53 is input SSPSYSCLK |
| 212 | * - SSP3 is in use |
| 213 | * - GPIO81 is output SSPTXD3 |
| 214 | * - GPIO82 is input SSPRXD3 |
| 215 | * - GPIO83 is output SSPSFRM |
| 216 | * - GPIO84 is output SSPCLK3 |
| 217 | * |
| 218 | * Otherwise claimed GPIOs: |
| 219 | * GPIO1 -> IRQ from user switch |
| 220 | * GPIO9 -> IRQ from power management |
| 221 | * GPIO10 -> IRQ from WML9712 AC97 controller |
| 222 | * GPIO11 -> IRQ from IDE controller |
| 223 | * GPIO12 -> IRQ from CF controller |
| 224 | * GPIO13 -> IRQ from CF controller |
| 225 | * GPIO14 -> GPIO free |
| 226 | * GPIO15 -> /CS1 selects baseboard's Control CPLD (U7, 16 bit wide data path) |
| 227 | * GPIO19 -> GPIO free |
| 228 | * GPIO20 -> /SDCS2 |
| 229 | * GPIO21 -> /CS3 PC card socket select |
| 230 | * GPIO33 -> /CS5 network controller select |
| 231 | * GPIO78 -> /CS2 (16 bit wide data path) |
| 232 | * GPIO80 -> /CS4 (16 bit wide data path) |
| 233 | * GPIO86 -> GPIO free |
| 234 | * GPIO87 -> GPIO free |
| 235 | * GPIO90 -> LED0 on CPU module |
| 236 | * GPIO91 -> LED1 on CPI module |
| 237 | * GPIO117 -> SCL |
| 238 | * GPIO118 -> SDA |
| 239 | */ |
| 240 | |
| 241 | static unsigned long pcm990_irq_enabled; |
| 242 | |
Lennert Buytenhek | a3f4c92 | 2010-11-29 11:18:26 +0100 | [diff] [blame] | 243 | static void pcm990_mask_ack_irq(struct irq_data *d) |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 244 | { |
Lennert Buytenhek | a3f4c92 | 2010-11-29 11:18:26 +0100 | [diff] [blame] | 245 | int pcm990_irq = (d->irq - PCM027_IRQ(0)); |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 246 | PCM990_INTMSKENA = (pcm990_irq_enabled &= ~(1 << pcm990_irq)); |
| 247 | } |
| 248 | |
Lennert Buytenhek | a3f4c92 | 2010-11-29 11:18:26 +0100 | [diff] [blame] | 249 | static void pcm990_unmask_irq(struct irq_data *d) |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 250 | { |
Lennert Buytenhek | a3f4c92 | 2010-11-29 11:18:26 +0100 | [diff] [blame] | 251 | int pcm990_irq = (d->irq - PCM027_IRQ(0)); |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 252 | /* the irq can be acknowledged only if deasserted, so it's done here */ |
| 253 | PCM990_INTSETCLR |= 1 << pcm990_irq; |
| 254 | PCM990_INTMSKENA = (pcm990_irq_enabled |= (1 << pcm990_irq)); |
| 255 | } |
| 256 | |
| 257 | static struct irq_chip pcm990_irq_chip = { |
Lennert Buytenhek | a3f4c92 | 2010-11-29 11:18:26 +0100 | [diff] [blame] | 258 | .irq_mask_ack = pcm990_mask_ack_irq, |
| 259 | .irq_unmask = pcm990_unmask_irq, |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 260 | }; |
| 261 | |
| 262 | static void pcm990_irq_handler(unsigned int irq, struct irq_desc *desc) |
| 263 | { |
| 264 | unsigned long pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled; |
| 265 | |
| 266 | do { |
Lennert Buytenhek | a3f4c92 | 2010-11-29 11:18:26 +0100 | [diff] [blame] | 267 | /* clear our parent IRQ */ |
| 268 | desc->irq_data.chip->irq_ack(&desc->irq_data); |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 269 | if (likely(pending)) { |
| 270 | irq = PCM027_IRQ(0) + __ffs(pending); |
Dmitry Baryshkov | d8aa025 | 2008-10-09 13:36:24 +0100 | [diff] [blame] | 271 | generic_handle_irq(irq); |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 272 | } |
| 273 | pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled; |
| 274 | } while (pending); |
| 275 | } |
| 276 | |
| 277 | static void __init pcm990_init_irq(void) |
| 278 | { |
| 279 | int irq; |
| 280 | |
| 281 | /* setup extra PCM990 irqs */ |
| 282 | for (irq = PCM027_IRQ(0); irq <= PCM027_IRQ(3); irq++) { |
Thomas Gleixner | f38c02f | 2011-03-24 13:35:09 +0100 | [diff] [blame] | 283 | irq_set_chip_and_handler(irq, &pcm990_irq_chip, |
| 284 | handle_level_irq); |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 285 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); |
| 286 | } |
| 287 | |
| 288 | PCM990_INTMSKENA = 0x00; /* disable all Interrupts */ |
| 289 | PCM990_INTSETCLR = 0xFF; |
| 290 | |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 291 | irq_set_chained_handler(PCM990_CTRL_INT_IRQ, pcm990_irq_handler); |
| 292 | irq_set_irq_type(PCM990_CTRL_INT_IRQ, PCM990_CTRL_INT_IRQ_EDGE); |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int, |
| 296 | void *data) |
| 297 | { |
| 298 | int err; |
| 299 | |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 300 | err = request_irq(PCM027_MMCDET_IRQ, mci_detect_int, IRQF_DISABLED, |
| 301 | "MMC card detect", data); |
| 302 | if (err) |
| 303 | printk(KERN_ERR "pcm990_mci_init: MMC/SD: can't request MMC " |
| 304 | "card detect IRQ\n"); |
| 305 | |
| 306 | return err; |
| 307 | } |
| 308 | |
| 309 | static void pcm990_mci_setpower(struct device *dev, unsigned int vdd) |
| 310 | { |
| 311 | struct pxamci_platform_data *p_d = dev->platform_data; |
| 312 | |
| 313 | if ((1 << vdd) & p_d->ocr_mask) |
| 314 | __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) = |
| 315 | PCM990_CTRL_MMC2PWR; |
| 316 | else |
| 317 | __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) = |
| 318 | ~PCM990_CTRL_MMC2PWR; |
| 319 | } |
| 320 | |
| 321 | static void pcm990_mci_exit(struct device *dev, void *data) |
| 322 | { |
| 323 | free_irq(PCM027_MMCDET_IRQ, data); |
| 324 | } |
| 325 | |
| 326 | #define MSECS_PER_JIFFY (1000/HZ) |
| 327 | |
| 328 | static struct pxamci_platform_data pcm990_mci_platform_data = { |
Eric Miao | f97cab2 | 2010-04-14 07:00:42 +0800 | [diff] [blame] | 329 | .detect_delay_ms = 250, |
Robert Jarzmik | 7a64825 | 2009-07-06 22:16:42 +0200 | [diff] [blame] | 330 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 331 | .init = pcm990_mci_init, |
| 332 | .setpower = pcm990_mci_setpower, |
| 333 | .exit = pcm990_mci_exit, |
| 334 | .gpio_card_detect = -1, |
| 335 | .gpio_card_ro = -1, |
| 336 | .gpio_power = -1, |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 337 | }; |
| 338 | |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 339 | static struct pxaohci_platform_data pcm990_ohci_platform_data = { |
| 340 | .port_mode = PMM_PERPORT_MODE, |
Eric Miao | 097b533 | 2008-09-27 15:49:57 +0800 | [diff] [blame] | 341 | .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW, |
| 342 | .power_on_delay = 10, |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 343 | }; |
| 344 | |
| 345 | /* |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 346 | * PXA27x Camera specific stuff |
| 347 | */ |
| 348 | #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE) |
Guennadi Liakhovetski | 6a566fb | 2008-06-16 08:16:46 +0100 | [diff] [blame] | 349 | static unsigned long pcm990_camera_pin_config[] = { |
| 350 | /* CIF */ |
| 351 | GPIO98_CIF_DD_0, |
| 352 | GPIO105_CIF_DD_1, |
| 353 | GPIO104_CIF_DD_2, |
| 354 | GPIO103_CIF_DD_3, |
| 355 | GPIO95_CIF_DD_4, |
| 356 | GPIO94_CIF_DD_5, |
| 357 | GPIO93_CIF_DD_6, |
| 358 | GPIO108_CIF_DD_7, |
| 359 | GPIO107_CIF_DD_8, |
| 360 | GPIO106_CIF_DD_9, |
| 361 | GPIO42_CIF_MCLK, |
| 362 | GPIO45_CIF_PCLK, |
| 363 | GPIO43_CIF_FV, |
| 364 | GPIO44_CIF_LV, |
| 365 | }; |
| 366 | |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 367 | /* |
| 368 | * CICR4: PCLK_EN: Pixel clock is supplied by the sensor |
| 369 | * MCLK_EN: Master clock is generated by PXA |
| 370 | * PCP: Data sampled on the falling edge of pixel clock |
| 371 | */ |
| 372 | struct pxacamera_platform_data pcm990_pxacamera_platform_data = { |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 373 | .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | PXA_CAMERA_DATAWIDTH_10 | |
| 374 | PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN/* | PXA_CAMERA_PCP*/, |
| 375 | .mclk_10khz = 1000, |
| 376 | }; |
| 377 | |
| 378 | #include <linux/i2c/pca953x.h> |
| 379 | |
| 380 | static struct pca953x_platform_data pca9536_data = { |
Guennadi Liakhovetski | a48dc30 | 2009-04-15 13:56:08 +0200 | [diff] [blame] | 381 | .gpio_base = NR_BUILTIN_GPIO, |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 382 | }; |
| 383 | |
Guennadi Liakhovetski | 594bb46 | 2009-04-24 12:53:51 -0300 | [diff] [blame] | 384 | static int gpio_bus_switch = -EINVAL; |
Sascha Hauer | d75b1dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 385 | |
| 386 | static int pcm990_camera_set_bus_param(struct soc_camera_link *link, |
Guennadi Liakhovetski | 594bb46 | 2009-04-24 12:53:51 -0300 | [diff] [blame] | 387 | unsigned long flags) |
Sascha Hauer | d75b1dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 388 | { |
Guennadi Liakhovetski | 594bb46 | 2009-04-24 12:53:51 -0300 | [diff] [blame] | 389 | if (gpio_bus_switch < 0) { |
Sascha Hauer | d75b1dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 390 | if (flags == SOCAM_DATAWIDTH_10) |
| 391 | return 0; |
| 392 | else |
| 393 | return -EINVAL; |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 394 | } |
Sascha Hauer | d75b1dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 395 | |
| 396 | if (flags & SOCAM_DATAWIDTH_8) |
| 397 | gpio_set_value(gpio_bus_switch, 1); |
| 398 | else |
| 399 | gpio_set_value(gpio_bus_switch, 0); |
| 400 | |
| 401 | return 0; |
| 402 | } |
| 403 | |
| 404 | static unsigned long pcm990_camera_query_bus_param(struct soc_camera_link *link) |
| 405 | { |
| 406 | int ret; |
| 407 | |
Guennadi Liakhovetski | 594bb46 | 2009-04-24 12:53:51 -0300 | [diff] [blame] | 408 | if (gpio_bus_switch < 0) { |
Guennadi Liakhovetski | a48dc30 | 2009-04-15 13:56:08 +0200 | [diff] [blame] | 409 | ret = gpio_request(NR_BUILTIN_GPIO, "camera"); |
Sascha Hauer | d75b1dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 410 | if (!ret) { |
Guennadi Liakhovetski | a48dc30 | 2009-04-15 13:56:08 +0200 | [diff] [blame] | 411 | gpio_bus_switch = NR_BUILTIN_GPIO; |
Sascha Hauer | d75b1dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 412 | gpio_direction_output(gpio_bus_switch, 0); |
Guennadi Liakhovetski | 594bb46 | 2009-04-24 12:53:51 -0300 | [diff] [blame] | 413 | } |
Sascha Hauer | d75b1dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 414 | } |
| 415 | |
Guennadi Liakhovetski | 594bb46 | 2009-04-24 12:53:51 -0300 | [diff] [blame] | 416 | if (gpio_bus_switch >= 0) |
Sascha Hauer | d75b1dc | 2009-03-13 06:08:20 -0300 | [diff] [blame] | 417 | return SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_10; |
| 418 | else |
| 419 | return SOCAM_DATAWIDTH_10; |
| 420 | } |
| 421 | |
Guennadi Liakhovetski | 594bb46 | 2009-04-24 12:53:51 -0300 | [diff] [blame] | 422 | static void pcm990_camera_free_bus(struct soc_camera_link *link) |
| 423 | { |
| 424 | if (gpio_bus_switch < 0) |
| 425 | return; |
| 426 | |
| 427 | gpio_free(gpio_bus_switch); |
| 428 | gpio_bus_switch = -EINVAL; |
| 429 | } |
| 430 | |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 431 | /* Board I2C devices. */ |
| 432 | static struct i2c_board_info __initdata pcm990_i2c_devices[] = { |
| 433 | { |
| 434 | /* Must initialize before the camera(s) */ |
Jean Delvare | 3760f73 | 2008-04-29 23:11:40 +0200 | [diff] [blame] | 435 | I2C_BOARD_INFO("pca9536", 0x41), |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 436 | .platform_data = &pca9536_data, |
Guennadi Liakhovetski | 4a3d3ab | 2009-05-13 11:33:43 +0200 | [diff] [blame] | 437 | }, |
| 438 | }; |
| 439 | |
| 440 | static struct i2c_board_info pcm990_camera_i2c[] = { |
| 441 | { |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 442 | I2C_BOARD_INFO("mt9v022", 0x48), |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 443 | }, { |
| 444 | I2C_BOARD_INFO("mt9m001", 0x5d), |
Guennadi Liakhovetski | 4a3d3ab | 2009-05-13 11:33:43 +0200 | [diff] [blame] | 445 | }, |
| 446 | }; |
| 447 | |
| 448 | static struct soc_camera_link iclink[] = { |
| 449 | { |
| 450 | .bus_id = 0, /* Must match with the camera ID */ |
| 451 | .board_info = &pcm990_camera_i2c[0], |
| 452 | .i2c_adapter_id = 0, |
| 453 | .query_bus_param = pcm990_camera_query_bus_param, |
| 454 | .set_bus_param = pcm990_camera_set_bus_param, |
| 455 | .free_bus = pcm990_camera_free_bus, |
Guennadi Liakhovetski | 4a3d3ab | 2009-05-13 11:33:43 +0200 | [diff] [blame] | 456 | }, { |
| 457 | .bus_id = 0, /* Must match with the camera ID */ |
| 458 | .board_info = &pcm990_camera_i2c[1], |
| 459 | .i2c_adapter_id = 0, |
| 460 | .query_bus_param = pcm990_camera_query_bus_param, |
| 461 | .set_bus_param = pcm990_camera_set_bus_param, |
| 462 | .free_bus = pcm990_camera_free_bus, |
Guennadi Liakhovetski | 4a3d3ab | 2009-05-13 11:33:43 +0200 | [diff] [blame] | 463 | }, |
| 464 | }; |
| 465 | |
| 466 | static struct platform_device pcm990_camera[] = { |
| 467 | { |
| 468 | .name = "soc-camera-pdrv", |
| 469 | .id = 0, |
| 470 | .dev = { |
| 471 | .platform_data = &iclink[0], |
| 472 | }, |
| 473 | }, { |
| 474 | .name = "soc-camera-pdrv", |
| 475 | .id = 1, |
| 476 | .dev = { |
| 477 | .platform_data = &iclink[1], |
| 478 | }, |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 479 | }, |
| 480 | }; |
| 481 | #endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */ |
| 482 | |
| 483 | /* |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 484 | * enable generic access to the base board control CPLDs U6 and U7 |
| 485 | */ |
| 486 | static struct map_desc pcm990_io_desc[] __initdata = { |
| 487 | { |
| 488 | .virtual = PCM990_CTRL_BASE, |
| 489 | .pfn = __phys_to_pfn(PCM990_CTRL_PHYS), |
| 490 | .length = PCM990_CTRL_SIZE, |
| 491 | .type = MT_DEVICE /* CPLD */ |
| 492 | }, { |
| 493 | .virtual = PCM990_CF_PLD_BASE, |
| 494 | .pfn = __phys_to_pfn(PCM990_CF_PLD_PHYS), |
| 495 | .length = PCM990_CF_PLD_SIZE, |
| 496 | .type = MT_DEVICE /* CPLD */ |
| 497 | } |
| 498 | }; |
| 499 | |
| 500 | /* |
| 501 | * system init for baseboard usage. Will be called by pcm027 init. |
| 502 | * |
| 503 | * Add platform devices present on this baseboard and init |
| 504 | * them from CPU side as far as required to use them later on |
| 505 | */ |
| 506 | void __init pcm990_baseboard_init(void) |
| 507 | { |
Guennadi Liakhovetski | 6a566fb | 2008-06-16 08:16:46 +0100 | [diff] [blame] | 508 | pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_pin_config)); |
| 509 | |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 510 | /* register CPLD access */ |
Guennadi Liakhovetski | 6a566fb | 2008-06-16 08:16:46 +0100 | [diff] [blame] | 511 | iotable_init(ARRAY_AND_SIZE(pcm990_io_desc)); |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 512 | |
| 513 | /* register CPLD's IRQ controller */ |
| 514 | pcm990_init_irq(); |
| 515 | |
Guennadi Liakhovetski | c0f7edb | 2008-06-13 11:50:44 +0100 | [diff] [blame] | 516 | #ifndef CONFIG_PCM990_DISPLAY_NONE |
Russell King - ARM Linux | 4321e1a | 2011-02-15 15:37:30 +0800 | [diff] [blame] | 517 | pxa_set_fb_info(NULL, &pcm990_fbinfo); |
Guennadi Liakhovetski | c0f7edb | 2008-06-13 11:50:44 +0100 | [diff] [blame] | 518 | #endif |
Guennadi Liakhovetski | c0f7edb | 2008-06-13 11:50:44 +0100 | [diff] [blame] | 519 | platform_device_register(&pcm990_backlight_device); |
| 520 | |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 521 | /* MMC */ |
| 522 | pxa_set_mci_info(&pcm990_mci_platform_data); |
| 523 | |
| 524 | /* USB host */ |
| 525 | pxa_set_ohci_info(&pcm990_ohci_platform_data); |
| 526 | |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 527 | pxa_set_i2c_info(NULL); |
Mark Brown | 9f19d63 | 2008-06-10 12:30:05 +0100 | [diff] [blame] | 528 | pxa_set_ac97_info(NULL); |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 529 | |
| 530 | #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE) |
Antonio Ospite | 0e85190 | 2009-11-27 21:31:36 +0100 | [diff] [blame] | 531 | pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_camera_pin_config)); |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 532 | pxa_set_camera_info(&pcm990_pxacamera_platform_data); |
| 533 | |
Guennadi Liakhovetski | 6a566fb | 2008-06-16 08:16:46 +0100 | [diff] [blame] | 534 | i2c_register_board_info(0, ARRAY_AND_SIZE(pcm990_i2c_devices)); |
Guennadi Liakhovetski | 4a3d3ab | 2009-05-13 11:33:43 +0200 | [diff] [blame] | 535 | |
| 536 | platform_device_register(&pcm990_camera[0]); |
| 537 | platform_device_register(&pcm990_camera[1]); |
Guennadi Liakhovetski | 58762e77 | 2008-04-06 23:08:15 +0200 | [diff] [blame] | 538 | #endif |
| 539 | |
Guennadi Liakhovetski | 6a566fb | 2008-06-16 08:16:46 +0100 | [diff] [blame] | 540 | printk(KERN_INFO "PCM-990 Evaluation baseboard initialized\n"); |
Robert Schwebel | 2e927b7 | 2008-01-08 08:52:04 +0100 | [diff] [blame] | 541 | } |