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