blob: b71c96f614f935317bfeb5d5b74b39a616aa64bd [file] [log] [blame]
Robert Schwebel2e927b72008-01-08 08:52:04 +01001/*
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 King2f8163b2011-07-26 10:53:52 +010022#include <linux/gpio.h>
Robert Schwebel2e927b72008-01-08 08:52:04 +010023#include <linux/irq.h>
24#include <linux/platform_device.h>
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +020025#include <linux/i2c.h>
Sebastian Andrzej Siewiorb4593962011-02-23 12:38:16 +010026#include <linux/i2c/pxa-i2c.h>
Thierry Reding542789d2015-10-05 10:49:52 +020027#include <linux/pwm.h>
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010028#include <linux/pwm_backlight.h>
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +020029
Anatolij Gustschinb6f50b42012-09-27 19:05:27 -030030#include <media/mt9v022.h>
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +020031#include <media/soc_camera.h>
32
Arnd Bergmann293b2da2012-08-24 15:16:48 +020033#include <linux/platform_data/camera-pxa.h>
Robert Schwebel2e927b72008-01-08 08:52:04 +010034#include <asm/mach/map.h>
Eric Miao51c62982009-01-02 23:17:22 +080035#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010036#include <mach/audio.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020037#include <linux/platform_data/mmc-pxamci.h>
38#include <linux/platform_data/usb-ohci-pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010039#include <mach/pcm990_baseboard.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020040#include <linux/platform_data/video-pxafb.h>
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010041
42#include "devices.h"
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +010043#include "generic.h"
44
45static unsigned long pcm990_pin_config[] __initdata = {
46 /* MMC */
47 GPIO32_MMC_CLK,
48 GPIO112_MMC_CMD,
49 GPIO92_MMC_DAT_0,
50 GPIO109_MMC_DAT_1,
51 GPIO110_MMC_DAT_2,
52 GPIO111_MMC_DAT_3,
53 /* USB */
54 GPIO88_USBH1_PWR,
55 GPIO89_USBH1_PEN,
56 /* PWM0 */
57 GPIO16_PWM0_OUT,
Eric Miao6f584cf2008-11-28 16:00:24 +080058
59 /* I2C */
60 GPIO117_I2C_SCL,
61 GPIO118_I2C_SDA,
Eric Miaoc11b6a42010-01-04 17:00:13 +080062
63 /* AC97 */
64 GPIO28_AC97_BITCLK,
65 GPIO29_AC97_SDATA_IN_0,
66 GPIO30_AC97_SDATA_OUT,
67 GPIO31_AC97_SYNC,
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +010068};
Robert Schwebel2e927b72008-01-08 08:52:04 +010069
Sascha Hauerb2983222012-04-12 11:45:08 +020070static void __iomem *pcm990_cpld_base;
71
72static u8 pcm990_cpld_readb(unsigned int reg)
73{
74 return readb(pcm990_cpld_base + reg);
75}
76
77static void pcm990_cpld_writeb(u8 value, unsigned int reg)
78{
79 writeb(value, pcm990_cpld_base + reg);
80}
81
Robert Schwebel2e927b72008-01-08 08:52:04 +010082/*
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010083 * pcm990_lcd_power - control power supply to the LCD
84 * @on: 0 = switch off, 1 = switch on
85 *
86 * Called by the pxafb driver
87 */
88#ifndef CONFIG_PCM990_DISPLAY_NONE
89static void pcm990_lcd_power(int on, struct fb_var_screeninfo *var)
90{
91 if (on) {
92 /* enable LCD-Latches
93 * power on LCD
94 */
Sascha Hauerb2983222012-04-12 11:45:08 +020095 pcm990_cpld_writeb(PCM990_CTRL_LCDPWR + PCM990_CTRL_LCDON,
96 PCM990_CTRL_REG3);
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010097 } else {
98 /* disable LCD-Latches
99 * power off LCD
100 */
Sascha Hauerb2983222012-04-12 11:45:08 +0200101 pcm990_cpld_writeb(0, PCM990_CTRL_REG3);
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100102 }
103}
104#endif
105
106#if defined(CONFIG_PCM990_DISPLAY_SHARP)
107static struct pxafb_mode_info fb_info_sharp_lq084v1dg21 = {
108 .pixclock = 28000,
109 .xres = 640,
110 .yres = 480,
111 .bpp = 16,
112 .hsync_len = 20,
113 .left_margin = 103,
114 .right_margin = 47,
115 .vsync_len = 6,
116 .upper_margin = 28,
117 .lower_margin = 5,
118 .sync = 0,
119 .cmap_greyscale = 0,
120};
121
122static struct pxafb_mach_info pcm990_fbinfo __initdata = {
123 .modes = &fb_info_sharp_lq084v1dg21,
124 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800125 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100126 .pxafb_lcd_power = pcm990_lcd_power,
127};
128#elif defined(CONFIG_PCM990_DISPLAY_NEC)
129struct pxafb_mode_info fb_info_nec_nl6448bc20_18d = {
130 .pixclock = 39720,
131 .xres = 640,
132 .yres = 480,
133 .bpp = 16,
134 .hsync_len = 32,
135 .left_margin = 16,
136 .right_margin = 48,
137 .vsync_len = 2,
138 .upper_margin = 12,
139 .lower_margin = 17,
140 .sync = 0,
141 .cmap_greyscale = 0,
142};
143
144static struct pxafb_mach_info pcm990_fbinfo __initdata = {
145 .modes = &fb_info_nec_nl6448bc20_18d,
146 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800147 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100148 .pxafb_lcd_power = pcm990_lcd_power,
149};
150#endif
151
Thierry Reding542789d2015-10-05 10:49:52 +0200152static struct pwm_lookup pcm990_pwm_lookup[] = {
153 PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL, 78770,
154 PWM_POLARITY_NORMAL),
155};
156
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100157static struct platform_pwm_backlight_data pcm990_backlight_data = {
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100158 .max_brightness = 1023,
159 .dft_brightness = 1023,
Thierry Redingdb011202013-08-30 12:15:24 +0200160 .enable_gpio = -1,
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100161};
162
163static struct platform_device pcm990_backlight_device = {
164 .name = "pwm-backlight",
165 .dev = {
166 .parent = &pxa27x_device_pwm0.dev,
167 .platform_data = &pcm990_backlight_data,
168 },
169};
170
171/*
172 * The PCM-990 development baseboard uses PCM-027's hardware in the
Robert Schwebel2e927b72008-01-08 08:52:04 +0100173 * following way:
174 *
175 * - LCD support is in use
176 * - GPIO16 is output for back light on/off with PWM
177 * - GPIO58 ... GPIO73 are outputs for display data
178 * - GPIO74 is output output for LCDFCLK
179 * - GPIO75 is output for LCDLCLK
180 * - GPIO76 is output for LCDPCLK
181 * - GPIO77 is output for LCDBIAS
182 * - MMC support is in use
183 * - GPIO32 is output for MMCCLK
184 * - GPIO92 is MMDAT0
185 * - GPIO109 is MMDAT1
186 * - GPIO110 is MMCS0
187 * - GPIO111 is MMCS1
188 * - GPIO112 is MMCMD
189 * - IDE/CF card is in use
190 * - GPIO48 is output /POE
191 * - GPIO49 is output /PWE
192 * - GPIO50 is output /PIOR
193 * - GPIO51 is output /PIOW
194 * - GPIO54 is output /PCE2
195 * - GPIO55 is output /PREG
196 * - GPIO56 is input /PWAIT
197 * - GPIO57 is output /PIOS16
198 * - GPIO79 is output PSKTSEL
199 * - GPIO85 is output /PCE1
200 * - FFUART is in use
201 * - GPIO34 is input FFRXD
202 * - GPIO35 is input FFCTS
203 * - GPIO36 is input FFDCD
204 * - GPIO37 is input FFDSR
205 * - GPIO38 is input FFRI
206 * - GPIO39 is output FFTXD
207 * - GPIO40 is output FFDTR
208 * - GPIO41 is output FFRTS
209 * - BTUART is in use
210 * - GPIO42 is input BTRXD
211 * - GPIO43 is output BTTXD
212 * - GPIO44 is input BTCTS
213 * - GPIO45 is output BTRTS
214 * - IRUART is in use
215 * - GPIO46 is input STDRXD
216 * - GPIO47 is output STDTXD
217 * - AC97 is in use*)
218 * - GPIO28 is input AC97CLK
219 * - GPIO29 is input AC97DatIn
220 * - GPIO30 is output AC97DatO
221 * - GPIO31 is output AC97SYNC
222 * - GPIO113 is output AC97_RESET
223 * - SSP is in use
224 * - GPIO23 is output SSPSCLK
225 * - GPIO24 is output chip select to Max7301
226 * - GPIO25 is output SSPTXD
227 * - GPIO26 is input SSPRXD
228 * - GPIO27 is input for Max7301 IRQ
229 * - GPIO53 is input SSPSYSCLK
230 * - SSP3 is in use
231 * - GPIO81 is output SSPTXD3
232 * - GPIO82 is input SSPRXD3
233 * - GPIO83 is output SSPSFRM
234 * - GPIO84 is output SSPCLK3
235 *
236 * Otherwise claimed GPIOs:
237 * GPIO1 -> IRQ from user switch
238 * GPIO9 -> IRQ from power management
239 * GPIO10 -> IRQ from WML9712 AC97 controller
240 * GPIO11 -> IRQ from IDE controller
241 * GPIO12 -> IRQ from CF controller
242 * GPIO13 -> IRQ from CF controller
243 * GPIO14 -> GPIO free
244 * GPIO15 -> /CS1 selects baseboard's Control CPLD (U7, 16 bit wide data path)
245 * GPIO19 -> GPIO free
246 * GPIO20 -> /SDCS2
247 * GPIO21 -> /CS3 PC card socket select
248 * GPIO33 -> /CS5 network controller select
249 * GPIO78 -> /CS2 (16 bit wide data path)
250 * GPIO80 -> /CS4 (16 bit wide data path)
251 * GPIO86 -> GPIO free
252 * GPIO87 -> GPIO free
253 * GPIO90 -> LED0 on CPU module
254 * GPIO91 -> LED1 on CPI module
255 * GPIO117 -> SCL
256 * GPIO118 -> SDA
257 */
258
259static unsigned long pcm990_irq_enabled;
260
Lennert Buytenheka3f4c922010-11-29 11:18:26 +0100261static void pcm990_mask_ack_irq(struct irq_data *d)
Robert Schwebel2e927b72008-01-08 08:52:04 +0100262{
Lennert Buytenheka3f4c922010-11-29 11:18:26 +0100263 int pcm990_irq = (d->irq - PCM027_IRQ(0));
Sascha Hauerb2983222012-04-12 11:45:08 +0200264
265 pcm990_irq_enabled &= ~(1 << pcm990_irq);
266
267 pcm990_cpld_writeb(pcm990_irq_enabled, PCM990_CTRL_INTMSKENA);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100268}
269
Lennert Buytenheka3f4c922010-11-29 11:18:26 +0100270static void pcm990_unmask_irq(struct irq_data *d)
Robert Schwebel2e927b72008-01-08 08:52:04 +0100271{
Lennert Buytenheka3f4c922010-11-29 11:18:26 +0100272 int pcm990_irq = (d->irq - PCM027_IRQ(0));
Sascha Hauerb2983222012-04-12 11:45:08 +0200273 u8 val;
274
Robert Schwebel2e927b72008-01-08 08:52:04 +0100275 /* the irq can be acknowledged only if deasserted, so it's done here */
Sascha Hauerb2983222012-04-12 11:45:08 +0200276
277 pcm990_irq_enabled |= (1 << pcm990_irq);
278
279 val = pcm990_cpld_readb(PCM990_CTRL_INTSETCLR);
280 val |= 1 << pcm990_irq;
281 pcm990_cpld_writeb(val, PCM990_CTRL_INTSETCLR);
282
283 pcm990_cpld_writeb(pcm990_irq_enabled, PCM990_CTRL_INTMSKENA);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100284}
285
286static struct irq_chip pcm990_irq_chip = {
Lennert Buytenheka3f4c922010-11-29 11:18:26 +0100287 .irq_mask_ack = pcm990_mask_ack_irq,
288 .irq_unmask = pcm990_unmask_irq,
Robert Schwebel2e927b72008-01-08 08:52:04 +0100289};
290
Thomas Gleixnerbd0b9ac2015-09-14 10:42:37 +0200291static void pcm990_irq_handler(struct irq_desc *desc)
Robert Schwebel2e927b72008-01-08 08:52:04 +0100292{
Thomas Gleixner6947d042015-07-13 10:17:54 +0200293 unsigned int irq;
Sascha Hauerb2983222012-04-12 11:45:08 +0200294 unsigned long pending;
295
296 pending = ~pcm990_cpld_readb(PCM990_CTRL_INTSETCLR);
297 pending &= pcm990_irq_enabled;
Robert Schwebel2e927b72008-01-08 08:52:04 +0100298
299 do {
Lennert Buytenheka3f4c922010-11-29 11:18:26 +0100300 /* clear our parent IRQ */
301 desc->irq_data.chip->irq_ack(&desc->irq_data);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100302 if (likely(pending)) {
303 irq = PCM027_IRQ(0) + __ffs(pending);
Dmitry Baryshkovd8aa0252008-10-09 13:36:24 +0100304 generic_handle_irq(irq);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100305 }
Sascha Hauerb2983222012-04-12 11:45:08 +0200306 pending = ~pcm990_cpld_readb(PCM990_CTRL_INTSETCLR);
307 pending &= pcm990_irq_enabled;
Robert Schwebel2e927b72008-01-08 08:52:04 +0100308 } while (pending);
309}
310
311static void __init pcm990_init_irq(void)
312{
313 int irq;
314
315 /* setup extra PCM990 irqs */
316 for (irq = PCM027_IRQ(0); irq <= PCM027_IRQ(3); irq++) {
Thomas Gleixnerf38c02f2011-03-24 13:35:09 +0100317 irq_set_chip_and_handler(irq, &pcm990_irq_chip,
318 handle_level_irq);
Rob Herringe8d36d52015-07-27 15:55:13 -0500319 irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100320 }
321
Sascha Hauerb2983222012-04-12 11:45:08 +0200322 /* disable all Interrupts */
323 pcm990_cpld_writeb(0x0, PCM990_CTRL_INTMSKENA);
324 pcm990_cpld_writeb(0xff, PCM990_CTRL_INTSETCLR);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100325
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100326 irq_set_chained_handler(PCM990_CTRL_INT_IRQ, pcm990_irq_handler);
327 irq_set_irq_type(PCM990_CTRL_INT_IRQ, PCM990_CTRL_INT_IRQ_EDGE);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100328}
329
330static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int,
331 void *data)
332{
333 int err;
334
Michael Opdenackered7936f2013-12-09 11:22:22 +0100335 err = request_irq(PCM027_MMCDET_IRQ, mci_detect_int, 0,
Robert Schwebel2e927b72008-01-08 08:52:04 +0100336 "MMC card detect", data);
337 if (err)
338 printk(KERN_ERR "pcm990_mci_init: MMC/SD: can't request MMC "
339 "card detect IRQ\n");
340
341 return err;
342}
343
Arnd Bergmanna829abf2013-07-05 17:51:20 +0200344static int pcm990_mci_setpower(struct device *dev, unsigned int vdd)
Robert Schwebel2e927b72008-01-08 08:52:04 +0100345{
346 struct pxamci_platform_data *p_d = dev->platform_data;
Sascha Hauerb2983222012-04-12 11:45:08 +0200347 u8 val;
348
349 val = pcm990_cpld_readb(PCM990_CTRL_REG5);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100350
351 if ((1 << vdd) & p_d->ocr_mask)
Sascha Hauerb2983222012-04-12 11:45:08 +0200352 val |= PCM990_CTRL_MMC2PWR;
Robert Schwebel2e927b72008-01-08 08:52:04 +0100353 else
Sascha Hauerb2983222012-04-12 11:45:08 +0200354 val &= ~PCM990_CTRL_MMC2PWR;
355
356 pcm990_cpld_writeb(PCM990_CTRL_MMC2PWR, PCM990_CTRL_REG5);
Arnd Bergmanna829abf2013-07-05 17:51:20 +0200357 return 0;
Robert Schwebel2e927b72008-01-08 08:52:04 +0100358}
359
360static void pcm990_mci_exit(struct device *dev, void *data)
361{
362 free_irq(PCM027_MMCDET_IRQ, data);
363}
364
365#define MSECS_PER_JIFFY (1000/HZ)
366
367static struct pxamci_platform_data pcm990_mci_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800368 .detect_delay_ms = 250,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200369 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
370 .init = pcm990_mci_init,
371 .setpower = pcm990_mci_setpower,
372 .exit = pcm990_mci_exit,
373 .gpio_card_detect = -1,
374 .gpio_card_ro = -1,
375 .gpio_power = -1,
Robert Schwebel2e927b72008-01-08 08:52:04 +0100376};
377
Robert Schwebel2e927b72008-01-08 08:52:04 +0100378static struct pxaohci_platform_data pcm990_ohci_platform_data = {
379 .port_mode = PMM_PERPORT_MODE,
Eric Miao097b5332008-09-27 15:49:57 +0800380 .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
381 .power_on_delay = 10,
Robert Schwebel2e927b72008-01-08 08:52:04 +0100382};
383
384/*
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200385 * PXA27x Camera specific stuff
386 */
387#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100388static unsigned long pcm990_camera_pin_config[] = {
389 /* CIF */
390 GPIO98_CIF_DD_0,
391 GPIO105_CIF_DD_1,
392 GPIO104_CIF_DD_2,
393 GPIO103_CIF_DD_3,
394 GPIO95_CIF_DD_4,
395 GPIO94_CIF_DD_5,
396 GPIO93_CIF_DD_6,
397 GPIO108_CIF_DD_7,
398 GPIO107_CIF_DD_8,
399 GPIO106_CIF_DD_9,
400 GPIO42_CIF_MCLK,
401 GPIO45_CIF_PCLK,
402 GPIO43_CIF_FV,
403 GPIO44_CIF_LV,
404};
405
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200406/*
407 * CICR4: PCLK_EN: Pixel clock is supplied by the sensor
408 * MCLK_EN: Master clock is generated by PXA
409 * PCP: Data sampled on the falling edge of pixel clock
410 */
411struct pxacamera_platform_data pcm990_pxacamera_platform_data = {
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200412 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | PXA_CAMERA_DATAWIDTH_10 |
413 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN/* | PXA_CAMERA_PCP*/,
414 .mclk_10khz = 1000,
415};
416
Vivien Didelot58774572013-08-29 15:24:14 -0400417#include <linux/platform_data/pca953x.h>
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200418
419static struct pca953x_platform_data pca9536_data = {
Haojian Zhuang1a8d5fa2011-11-08 14:15:59 +0800420 .gpio_base = PXA_NR_BUILTIN_GPIO,
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200421};
422
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300423static int gpio_bus_switch = -EINVAL;
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300424
425static int pcm990_camera_set_bus_param(struct soc_camera_link *link,
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300426 unsigned long flags)
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300427{
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300428 if (gpio_bus_switch < 0) {
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300429 if (flags == SOCAM_DATAWIDTH_10)
430 return 0;
431 else
432 return -EINVAL;
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200433 }
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300434
435 if (flags & SOCAM_DATAWIDTH_8)
Guennadi Liakhovetskifae00282011-07-27 11:11:41 -0300436 gpio_set_value_cansleep(gpio_bus_switch, 1);
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300437 else
Guennadi Liakhovetskifae00282011-07-27 11:11:41 -0300438 gpio_set_value_cansleep(gpio_bus_switch, 0);
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300439
440 return 0;
441}
442
443static unsigned long pcm990_camera_query_bus_param(struct soc_camera_link *link)
444{
445 int ret;
446
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300447 if (gpio_bus_switch < 0) {
Haojian Zhuang1a8d5fa2011-11-08 14:15:59 +0800448 ret = gpio_request(PXA_NR_BUILTIN_GPIO, "camera");
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300449 if (!ret) {
Haojian Zhuang1a8d5fa2011-11-08 14:15:59 +0800450 gpio_bus_switch = PXA_NR_BUILTIN_GPIO;
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300451 gpio_direction_output(gpio_bus_switch, 0);
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300452 }
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300453 }
454
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300455 if (gpio_bus_switch >= 0)
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300456 return SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_10;
457 else
458 return SOCAM_DATAWIDTH_10;
459}
460
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300461static void pcm990_camera_free_bus(struct soc_camera_link *link)
462{
463 if (gpio_bus_switch < 0)
464 return;
465
466 gpio_free(gpio_bus_switch);
467 gpio_bus_switch = -EINVAL;
468}
469
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200470/* Board I2C devices. */
471static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
472 {
473 /* Must initialize before the camera(s) */
Jean Delvare3760f732008-04-29 23:11:40 +0200474 I2C_BOARD_INFO("pca9536", 0x41),
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200475 .platform_data = &pca9536_data,
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200476 },
477};
478
Anatolij Gustschinb6f50b42012-09-27 19:05:27 -0300479static struct mt9v022_platform_data mt9v022_pdata = {
480 .y_skip_top = 1,
481};
482
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200483static struct i2c_board_info pcm990_camera_i2c[] = {
484 {
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200485 I2C_BOARD_INFO("mt9v022", 0x48),
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200486 }, {
487 I2C_BOARD_INFO("mt9m001", 0x5d),
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200488 },
489};
490
491static struct soc_camera_link iclink[] = {
492 {
493 .bus_id = 0, /* Must match with the camera ID */
494 .board_info = &pcm990_camera_i2c[0],
Anatolij Gustschinb6f50b42012-09-27 19:05:27 -0300495 .priv = &mt9v022_pdata,
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200496 .i2c_adapter_id = 0,
497 .query_bus_param = pcm990_camera_query_bus_param,
498 .set_bus_param = pcm990_camera_set_bus_param,
499 .free_bus = pcm990_camera_free_bus,
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200500 }, {
501 .bus_id = 0, /* Must match with the camera ID */
502 .board_info = &pcm990_camera_i2c[1],
503 .i2c_adapter_id = 0,
504 .query_bus_param = pcm990_camera_query_bus_param,
505 .set_bus_param = pcm990_camera_set_bus_param,
506 .free_bus = pcm990_camera_free_bus,
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200507 },
508};
509
510static struct platform_device pcm990_camera[] = {
511 {
512 .name = "soc-camera-pdrv",
513 .id = 0,
514 .dev = {
515 .platform_data = &iclink[0],
516 },
517 }, {
518 .name = "soc-camera-pdrv",
519 .id = 1,
520 .dev = {
521 .platform_data = &iclink[1],
522 },
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200523 },
524};
525#endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
526
527/*
Robert Schwebel2e927b72008-01-08 08:52:04 +0100528 * system init for baseboard usage. Will be called by pcm027 init.
529 *
530 * Add platform devices present on this baseboard and init
531 * them from CPU side as far as required to use them later on
532 */
533void __init pcm990_baseboard_init(void)
534{
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100535 pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_pin_config));
536
Sascha Hauerb2983222012-04-12 11:45:08 +0200537 pcm990_cpld_base = ioremap(PCM990_CTRL_PHYS, PCM990_CTRL_SIZE);
538 if (!pcm990_cpld_base) {
539 pr_err("pcm990: failed to ioremap cpld\n");
540 return;
541 }
Robert Schwebel2e927b72008-01-08 08:52:04 +0100542
543 /* register CPLD's IRQ controller */
544 pcm990_init_irq();
545
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100546#ifndef CONFIG_PCM990_DISPLAY_NONE
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800547 pxa_set_fb_info(NULL, &pcm990_fbinfo);
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100548#endif
Thierry Reding542789d2015-10-05 10:49:52 +0200549 pwm_add_table(pcm990_pwm_lookup, ARRAY_SIZE(pcm990_pwm_lookup));
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100550 platform_device_register(&pcm990_backlight_device);
551
Robert Schwebel2e927b72008-01-08 08:52:04 +0100552 /* MMC */
553 pxa_set_mci_info(&pcm990_mci_platform_data);
554
555 /* USB host */
556 pxa_set_ohci_info(&pcm990_ohci_platform_data);
557
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200558 pxa_set_i2c_info(NULL);
Mark Brown9f19d632008-06-10 12:30:05 +0100559 pxa_set_ac97_info(NULL);
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200560
561#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
Antonio Ospite0e851902009-11-27 21:31:36 +0100562 pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_camera_pin_config));
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200563 pxa_set_camera_info(&pcm990_pxacamera_platform_data);
564
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100565 i2c_register_board_info(0, ARRAY_AND_SIZE(pcm990_i2c_devices));
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200566
567 platform_device_register(&pcm990_camera[0]);
568 platform_device_register(&pcm990_camera[1]);
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200569#endif
570
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100571 printk(KERN_INFO "PCM-990 Evaluation baseboard initialized\n");
Robert Schwebel2e927b72008-01-08 08:52:04 +0100572}