blob: 3133ba82c50807ec105a57f1dfe4b7d06a887c31 [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>
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010027#include <linux/pwm_backlight.h>
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +020028
Anatolij Gustschinb6f50b42012-09-27 19:05:27 -030029#include <media/mt9v022.h>
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +020030#include <media/soc_camera.h>
31
Arnd Bergmann293b2da2012-08-24 15:16:48 +020032#include <linux/platform_data/camera-pxa.h>
Robert Schwebel2e927b72008-01-08 08:52:04 +010033#include <asm/mach/map.h>
Eric Miao51c62982009-01-02 23:17:22 +080034#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010035#include <mach/audio.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020036#include <linux/platform_data/mmc-pxamci.h>
37#include <linux/platform_data/usb-ohci-pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010038#include <mach/pcm990_baseboard.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020039#include <linux/platform_data/video-pxafb.h>
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010040
41#include "devices.h"
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +010042#include "generic.h"
43
44static 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 Miao6f584cf2008-11-28 16:00:24 +080057
58 /* I2C */
59 GPIO117_I2C_SCL,
60 GPIO118_I2C_SDA,
Eric Miaoc11b6a42010-01-04 17:00:13 +080061
62 /* AC97 */
63 GPIO28_AC97_BITCLK,
64 GPIO29_AC97_SDATA_IN_0,
65 GPIO30_AC97_SDATA_OUT,
66 GPIO31_AC97_SYNC,
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +010067};
Robert Schwebel2e927b72008-01-08 08:52:04 +010068
Sascha Hauerb2983222012-04-12 11:45:08 +020069static void __iomem *pcm990_cpld_base;
70
71static u8 pcm990_cpld_readb(unsigned int reg)
72{
73 return readb(pcm990_cpld_base + reg);
74}
75
76static void pcm990_cpld_writeb(u8 value, unsigned int reg)
77{
78 writeb(value, pcm990_cpld_base + reg);
79}
80
Robert Schwebel2e927b72008-01-08 08:52:04 +010081/*
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010082 * pcm990_lcd_power - control power supply to the LCD
83 * @on: 0 = switch off, 1 = switch on
84 *
85 * Called by the pxafb driver
86 */
87#ifndef CONFIG_PCM990_DISPLAY_NONE
88static void pcm990_lcd_power(int on, struct fb_var_screeninfo *var)
89{
90 if (on) {
91 /* enable LCD-Latches
92 * power on LCD
93 */
Sascha Hauerb2983222012-04-12 11:45:08 +020094 pcm990_cpld_writeb(PCM990_CTRL_LCDPWR + PCM990_CTRL_LCDON,
95 PCM990_CTRL_REG3);
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010096 } else {
97 /* disable LCD-Latches
98 * power off LCD
99 */
Sascha Hauerb2983222012-04-12 11:45:08 +0200100 pcm990_cpld_writeb(0, PCM990_CTRL_REG3);
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100101 }
102}
103#endif
104
105#if defined(CONFIG_PCM990_DISPLAY_SHARP)
106static struct pxafb_mode_info fb_info_sharp_lq084v1dg21 = {
107 .pixclock = 28000,
108 .xres = 640,
109 .yres = 480,
110 .bpp = 16,
111 .hsync_len = 20,
112 .left_margin = 103,
113 .right_margin = 47,
114 .vsync_len = 6,
115 .upper_margin = 28,
116 .lower_margin = 5,
117 .sync = 0,
118 .cmap_greyscale = 0,
119};
120
121static struct pxafb_mach_info pcm990_fbinfo __initdata = {
122 .modes = &fb_info_sharp_lq084v1dg21,
123 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800124 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100125 .pxafb_lcd_power = pcm990_lcd_power,
126};
127#elif defined(CONFIG_PCM990_DISPLAY_NEC)
128struct pxafb_mode_info fb_info_nec_nl6448bc20_18d = {
129 .pixclock = 39720,
130 .xres = 640,
131 .yres = 480,
132 .bpp = 16,
133 .hsync_len = 32,
134 .left_margin = 16,
135 .right_margin = 48,
136 .vsync_len = 2,
137 .upper_margin = 12,
138 .lower_margin = 17,
139 .sync = 0,
140 .cmap_greyscale = 0,
141};
142
143static struct pxafb_mach_info pcm990_fbinfo __initdata = {
144 .modes = &fb_info_nec_nl6448bc20_18d,
145 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800146 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100147 .pxafb_lcd_power = pcm990_lcd_power,
148};
149#endif
150
151static struct platform_pwm_backlight_data pcm990_backlight_data = {
152 .pwm_id = 0,
153 .max_brightness = 1023,
154 .dft_brightness = 1023,
155 .pwm_period_ns = 78770,
156};
157
158static struct platform_device pcm990_backlight_device = {
159 .name = "pwm-backlight",
160 .dev = {
161 .parent = &pxa27x_device_pwm0.dev,
162 .platform_data = &pcm990_backlight_data,
163 },
164};
165
166/*
167 * The PCM-990 development baseboard uses PCM-027's hardware in the
Robert Schwebel2e927b72008-01-08 08:52:04 +0100168 * following way:
169 *
170 * - LCD support is in use
171 * - GPIO16 is output for back light on/off with PWM
172 * - GPIO58 ... GPIO73 are outputs for display data
173 * - GPIO74 is output output for LCDFCLK
174 * - GPIO75 is output for LCDLCLK
175 * - GPIO76 is output for LCDPCLK
176 * - GPIO77 is output for LCDBIAS
177 * - MMC support is in use
178 * - GPIO32 is output for MMCCLK
179 * - GPIO92 is MMDAT0
180 * - GPIO109 is MMDAT1
181 * - GPIO110 is MMCS0
182 * - GPIO111 is MMCS1
183 * - GPIO112 is MMCMD
184 * - IDE/CF card is in use
185 * - GPIO48 is output /POE
186 * - GPIO49 is output /PWE
187 * - GPIO50 is output /PIOR
188 * - GPIO51 is output /PIOW
189 * - GPIO54 is output /PCE2
190 * - GPIO55 is output /PREG
191 * - GPIO56 is input /PWAIT
192 * - GPIO57 is output /PIOS16
193 * - GPIO79 is output PSKTSEL
194 * - GPIO85 is output /PCE1
195 * - FFUART is in use
196 * - GPIO34 is input FFRXD
197 * - GPIO35 is input FFCTS
198 * - GPIO36 is input FFDCD
199 * - GPIO37 is input FFDSR
200 * - GPIO38 is input FFRI
201 * - GPIO39 is output FFTXD
202 * - GPIO40 is output FFDTR
203 * - GPIO41 is output FFRTS
204 * - BTUART is in use
205 * - GPIO42 is input BTRXD
206 * - GPIO43 is output BTTXD
207 * - GPIO44 is input BTCTS
208 * - GPIO45 is output BTRTS
209 * - IRUART is in use
210 * - GPIO46 is input STDRXD
211 * - GPIO47 is output STDTXD
212 * - AC97 is in use*)
213 * - GPIO28 is input AC97CLK
214 * - GPIO29 is input AC97DatIn
215 * - GPIO30 is output AC97DatO
216 * - GPIO31 is output AC97SYNC
217 * - GPIO113 is output AC97_RESET
218 * - SSP is in use
219 * - GPIO23 is output SSPSCLK
220 * - GPIO24 is output chip select to Max7301
221 * - GPIO25 is output SSPTXD
222 * - GPIO26 is input SSPRXD
223 * - GPIO27 is input for Max7301 IRQ
224 * - GPIO53 is input SSPSYSCLK
225 * - SSP3 is in use
226 * - GPIO81 is output SSPTXD3
227 * - GPIO82 is input SSPRXD3
228 * - GPIO83 is output SSPSFRM
229 * - GPIO84 is output SSPCLK3
230 *
231 * Otherwise claimed GPIOs:
232 * GPIO1 -> IRQ from user switch
233 * GPIO9 -> IRQ from power management
234 * GPIO10 -> IRQ from WML9712 AC97 controller
235 * GPIO11 -> IRQ from IDE controller
236 * GPIO12 -> IRQ from CF controller
237 * GPIO13 -> IRQ from CF controller
238 * GPIO14 -> GPIO free
239 * GPIO15 -> /CS1 selects baseboard's Control CPLD (U7, 16 bit wide data path)
240 * GPIO19 -> GPIO free
241 * GPIO20 -> /SDCS2
242 * GPIO21 -> /CS3 PC card socket select
243 * GPIO33 -> /CS5 network controller select
244 * GPIO78 -> /CS2 (16 bit wide data path)
245 * GPIO80 -> /CS4 (16 bit wide data path)
246 * GPIO86 -> GPIO free
247 * GPIO87 -> GPIO free
248 * GPIO90 -> LED0 on CPU module
249 * GPIO91 -> LED1 on CPI module
250 * GPIO117 -> SCL
251 * GPIO118 -> SDA
252 */
253
254static unsigned long pcm990_irq_enabled;
255
Lennert Buytenheka3f4c922010-11-29 11:18:26 +0100256static void pcm990_mask_ack_irq(struct irq_data *d)
Robert Schwebel2e927b72008-01-08 08:52:04 +0100257{
Lennert Buytenheka3f4c922010-11-29 11:18:26 +0100258 int pcm990_irq = (d->irq - PCM027_IRQ(0));
Sascha Hauerb2983222012-04-12 11:45:08 +0200259
260 pcm990_irq_enabled &= ~(1 << pcm990_irq);
261
262 pcm990_cpld_writeb(pcm990_irq_enabled, PCM990_CTRL_INTMSKENA);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100263}
264
Lennert Buytenheka3f4c922010-11-29 11:18:26 +0100265static void pcm990_unmask_irq(struct irq_data *d)
Robert Schwebel2e927b72008-01-08 08:52:04 +0100266{
Lennert Buytenheka3f4c922010-11-29 11:18:26 +0100267 int pcm990_irq = (d->irq - PCM027_IRQ(0));
Sascha Hauerb2983222012-04-12 11:45:08 +0200268 u8 val;
269
Robert Schwebel2e927b72008-01-08 08:52:04 +0100270 /* the irq can be acknowledged only if deasserted, so it's done here */
Sascha Hauerb2983222012-04-12 11:45:08 +0200271
272 pcm990_irq_enabled |= (1 << pcm990_irq);
273
274 val = pcm990_cpld_readb(PCM990_CTRL_INTSETCLR);
275 val |= 1 << pcm990_irq;
276 pcm990_cpld_writeb(val, PCM990_CTRL_INTSETCLR);
277
278 pcm990_cpld_writeb(pcm990_irq_enabled, PCM990_CTRL_INTMSKENA);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100279}
280
281static struct irq_chip pcm990_irq_chip = {
Lennert Buytenheka3f4c922010-11-29 11:18:26 +0100282 .irq_mask_ack = pcm990_mask_ack_irq,
283 .irq_unmask = pcm990_unmask_irq,
Robert Schwebel2e927b72008-01-08 08:52:04 +0100284};
285
286static void pcm990_irq_handler(unsigned int irq, struct irq_desc *desc)
287{
Sascha Hauerb2983222012-04-12 11:45:08 +0200288 unsigned long pending;
289
290 pending = ~pcm990_cpld_readb(PCM990_CTRL_INTSETCLR);
291 pending &= pcm990_irq_enabled;
Robert Schwebel2e927b72008-01-08 08:52:04 +0100292
293 do {
Lennert Buytenheka3f4c922010-11-29 11:18:26 +0100294 /* clear our parent IRQ */
295 desc->irq_data.chip->irq_ack(&desc->irq_data);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100296 if (likely(pending)) {
297 irq = PCM027_IRQ(0) + __ffs(pending);
Dmitry Baryshkovd8aa0252008-10-09 13:36:24 +0100298 generic_handle_irq(irq);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100299 }
Sascha Hauerb2983222012-04-12 11:45:08 +0200300 pending = ~pcm990_cpld_readb(PCM990_CTRL_INTSETCLR);
301 pending &= pcm990_irq_enabled;
Robert Schwebel2e927b72008-01-08 08:52:04 +0100302 } while (pending);
303}
304
305static void __init pcm990_init_irq(void)
306{
307 int irq;
308
309 /* setup extra PCM990 irqs */
310 for (irq = PCM027_IRQ(0); irq <= PCM027_IRQ(3); irq++) {
Thomas Gleixnerf38c02f2011-03-24 13:35:09 +0100311 irq_set_chip_and_handler(irq, &pcm990_irq_chip,
312 handle_level_irq);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100313 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
314 }
315
Sascha Hauerb2983222012-04-12 11:45:08 +0200316 /* disable all Interrupts */
317 pcm990_cpld_writeb(0x0, PCM990_CTRL_INTMSKENA);
318 pcm990_cpld_writeb(0xff, PCM990_CTRL_INTSETCLR);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100319
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100320 irq_set_chained_handler(PCM990_CTRL_INT_IRQ, pcm990_irq_handler);
321 irq_set_irq_type(PCM990_CTRL_INT_IRQ, PCM990_CTRL_INT_IRQ_EDGE);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100322}
323
324static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int,
325 void *data)
326{
327 int err;
328
Robert Schwebel2e927b72008-01-08 08:52:04 +0100329 err = request_irq(PCM027_MMCDET_IRQ, mci_detect_int, IRQF_DISABLED,
330 "MMC card detect", data);
331 if (err)
332 printk(KERN_ERR "pcm990_mci_init: MMC/SD: can't request MMC "
333 "card detect IRQ\n");
334
335 return err;
336}
337
Arnd Bergmanna829abf2013-07-05 17:51:20 +0200338static int pcm990_mci_setpower(struct device *dev, unsigned int vdd)
Robert Schwebel2e927b72008-01-08 08:52:04 +0100339{
340 struct pxamci_platform_data *p_d = dev->platform_data;
Sascha Hauerb2983222012-04-12 11:45:08 +0200341 u8 val;
342
343 val = pcm990_cpld_readb(PCM990_CTRL_REG5);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100344
345 if ((1 << vdd) & p_d->ocr_mask)
Sascha Hauerb2983222012-04-12 11:45:08 +0200346 val |= PCM990_CTRL_MMC2PWR;
Robert Schwebel2e927b72008-01-08 08:52:04 +0100347 else
Sascha Hauerb2983222012-04-12 11:45:08 +0200348 val &= ~PCM990_CTRL_MMC2PWR;
349
350 pcm990_cpld_writeb(PCM990_CTRL_MMC2PWR, PCM990_CTRL_REG5);
Arnd Bergmanna829abf2013-07-05 17:51:20 +0200351 return 0;
Robert Schwebel2e927b72008-01-08 08:52:04 +0100352}
353
354static void pcm990_mci_exit(struct device *dev, void *data)
355{
356 free_irq(PCM027_MMCDET_IRQ, data);
357}
358
359#define MSECS_PER_JIFFY (1000/HZ)
360
361static struct pxamci_platform_data pcm990_mci_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800362 .detect_delay_ms = 250,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200363 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
364 .init = pcm990_mci_init,
365 .setpower = pcm990_mci_setpower,
366 .exit = pcm990_mci_exit,
367 .gpio_card_detect = -1,
368 .gpio_card_ro = -1,
369 .gpio_power = -1,
Robert Schwebel2e927b72008-01-08 08:52:04 +0100370};
371
Robert Schwebel2e927b72008-01-08 08:52:04 +0100372static struct pxaohci_platform_data pcm990_ohci_platform_data = {
373 .port_mode = PMM_PERPORT_MODE,
Eric Miao097b5332008-09-27 15:49:57 +0800374 .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
375 .power_on_delay = 10,
Robert Schwebel2e927b72008-01-08 08:52:04 +0100376};
377
378/*
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200379 * PXA27x Camera specific stuff
380 */
381#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100382static unsigned long pcm990_camera_pin_config[] = {
383 /* CIF */
384 GPIO98_CIF_DD_0,
385 GPIO105_CIF_DD_1,
386 GPIO104_CIF_DD_2,
387 GPIO103_CIF_DD_3,
388 GPIO95_CIF_DD_4,
389 GPIO94_CIF_DD_5,
390 GPIO93_CIF_DD_6,
391 GPIO108_CIF_DD_7,
392 GPIO107_CIF_DD_8,
393 GPIO106_CIF_DD_9,
394 GPIO42_CIF_MCLK,
395 GPIO45_CIF_PCLK,
396 GPIO43_CIF_FV,
397 GPIO44_CIF_LV,
398};
399
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200400/*
401 * CICR4: PCLK_EN: Pixel clock is supplied by the sensor
402 * MCLK_EN: Master clock is generated by PXA
403 * PCP: Data sampled on the falling edge of pixel clock
404 */
405struct pxacamera_platform_data pcm990_pxacamera_platform_data = {
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200406 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | PXA_CAMERA_DATAWIDTH_10 |
407 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN/* | PXA_CAMERA_PCP*/,
408 .mclk_10khz = 1000,
409};
410
Vivien Didelot58774572013-08-29 15:24:14 -0400411#include <linux/platform_data/pca953x.h>
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200412
413static struct pca953x_platform_data pca9536_data = {
Haojian Zhuang1a8d5fa2011-11-08 14:15:59 +0800414 .gpio_base = PXA_NR_BUILTIN_GPIO,
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200415};
416
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300417static int gpio_bus_switch = -EINVAL;
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300418
419static int pcm990_camera_set_bus_param(struct soc_camera_link *link,
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300420 unsigned long flags)
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300421{
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300422 if (gpio_bus_switch < 0) {
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300423 if (flags == SOCAM_DATAWIDTH_10)
424 return 0;
425 else
426 return -EINVAL;
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200427 }
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300428
429 if (flags & SOCAM_DATAWIDTH_8)
Guennadi Liakhovetskifae00282011-07-27 11:11:41 -0300430 gpio_set_value_cansleep(gpio_bus_switch, 1);
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300431 else
Guennadi Liakhovetskifae00282011-07-27 11:11:41 -0300432 gpio_set_value_cansleep(gpio_bus_switch, 0);
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300433
434 return 0;
435}
436
437static unsigned long pcm990_camera_query_bus_param(struct soc_camera_link *link)
438{
439 int ret;
440
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300441 if (gpio_bus_switch < 0) {
Haojian Zhuang1a8d5fa2011-11-08 14:15:59 +0800442 ret = gpio_request(PXA_NR_BUILTIN_GPIO, "camera");
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300443 if (!ret) {
Haojian Zhuang1a8d5fa2011-11-08 14:15:59 +0800444 gpio_bus_switch = PXA_NR_BUILTIN_GPIO;
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300445 gpio_direction_output(gpio_bus_switch, 0);
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300446 }
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300447 }
448
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300449 if (gpio_bus_switch >= 0)
Sascha Hauerd75b1dcc2009-03-13 06:08:20 -0300450 return SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_10;
451 else
452 return SOCAM_DATAWIDTH_10;
453}
454
Guennadi Liakhovetski594bb462009-04-24 12:53:51 -0300455static void pcm990_camera_free_bus(struct soc_camera_link *link)
456{
457 if (gpio_bus_switch < 0)
458 return;
459
460 gpio_free(gpio_bus_switch);
461 gpio_bus_switch = -EINVAL;
462}
463
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200464/* Board I2C devices. */
465static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
466 {
467 /* Must initialize before the camera(s) */
Jean Delvare3760f732008-04-29 23:11:40 +0200468 I2C_BOARD_INFO("pca9536", 0x41),
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200469 .platform_data = &pca9536_data,
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200470 },
471};
472
Anatolij Gustschinb6f50b42012-09-27 19:05:27 -0300473static struct mt9v022_platform_data mt9v022_pdata = {
474 .y_skip_top = 1,
475};
476
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200477static struct i2c_board_info pcm990_camera_i2c[] = {
478 {
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200479 I2C_BOARD_INFO("mt9v022", 0x48),
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200480 }, {
481 I2C_BOARD_INFO("mt9m001", 0x5d),
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200482 },
483};
484
485static struct soc_camera_link iclink[] = {
486 {
487 .bus_id = 0, /* Must match with the camera ID */
488 .board_info = &pcm990_camera_i2c[0],
Anatolij Gustschinb6f50b42012-09-27 19:05:27 -0300489 .priv = &mt9v022_pdata,
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200490 .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 Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200494 }, {
495 .bus_id = 0, /* Must match with the camera ID */
496 .board_info = &pcm990_camera_i2c[1],
497 .i2c_adapter_id = 0,
498 .query_bus_param = pcm990_camera_query_bus_param,
499 .set_bus_param = pcm990_camera_set_bus_param,
500 .free_bus = pcm990_camera_free_bus,
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200501 },
502};
503
504static struct platform_device pcm990_camera[] = {
505 {
506 .name = "soc-camera-pdrv",
507 .id = 0,
508 .dev = {
509 .platform_data = &iclink[0],
510 },
511 }, {
512 .name = "soc-camera-pdrv",
513 .id = 1,
514 .dev = {
515 .platform_data = &iclink[1],
516 },
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200517 },
518};
519#endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
520
521/*
Robert Schwebel2e927b72008-01-08 08:52:04 +0100522 * system init for baseboard usage. Will be called by pcm027 init.
523 *
524 * Add platform devices present on this baseboard and init
525 * them from CPU side as far as required to use them later on
526 */
527void __init pcm990_baseboard_init(void)
528{
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100529 pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_pin_config));
530
Sascha Hauerb2983222012-04-12 11:45:08 +0200531 pcm990_cpld_base = ioremap(PCM990_CTRL_PHYS, PCM990_CTRL_SIZE);
532 if (!pcm990_cpld_base) {
533 pr_err("pcm990: failed to ioremap cpld\n");
534 return;
535 }
Robert Schwebel2e927b72008-01-08 08:52:04 +0100536
537 /* register CPLD's IRQ controller */
538 pcm990_init_irq();
539
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100540#ifndef CONFIG_PCM990_DISPLAY_NONE
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800541 pxa_set_fb_info(NULL, &pcm990_fbinfo);
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100542#endif
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100543 platform_device_register(&pcm990_backlight_device);
544
Robert Schwebel2e927b72008-01-08 08:52:04 +0100545 /* MMC */
546 pxa_set_mci_info(&pcm990_mci_platform_data);
547
548 /* USB host */
549 pxa_set_ohci_info(&pcm990_ohci_platform_data);
550
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200551 pxa_set_i2c_info(NULL);
Mark Brown9f19d632008-06-10 12:30:05 +0100552 pxa_set_ac97_info(NULL);
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200553
554#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
Antonio Ospite0e851902009-11-27 21:31:36 +0100555 pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_camera_pin_config));
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200556 pxa_set_camera_info(&pcm990_pxacamera_platform_data);
557
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100558 i2c_register_board_info(0, ARRAY_AND_SIZE(pcm990_i2c_devices));
Guennadi Liakhovetski4a3d3ab2009-05-13 11:33:43 +0200559
560 platform_device_register(&pcm990_camera[0]);
561 platform_device_register(&pcm990_camera[1]);
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200562#endif
563
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100564 printk(KERN_INFO "PCM-990 Evaluation baseboard initialized\n");
Robert Schwebel2e927b72008-01-08 08:52:04 +0100565}