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