2 * arch/arm/mach-pxa/pcm990-baseboard.c
3 * Support for the Phytec phyCORE-PXA270 Development Platform (PCM-990).
6 * http://www.phytec.com/products/rdk/ARM-XScale/phyCORE-XScale-PXA270.html
7 * for additional hardware info
10 * Created: April 05, 2005
11 * Copyright: Phytec Messtechnik GmbH
12 * e-Mail: armlinux@phytec.de
14 * based on Intel Mainstone Board
16 * Copyright 2007 Juergen Beisert @ Pengutronix (j.beisert@pengutronix.de)
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.
22 #include <linux/gpio.h>
23 #include <linux/irq.h>
24 #include <linux/platform_device.h>
25 #include <linux/i2c.h>
26 #include <linux/i2c/pxa-i2c.h>
27 #include <linux/pwm_backlight.h>
29 #include <media/mt9v022.h>
30 #include <media/soc_camera.h>
32 #include <linux/platform_data/camera-pxa.h>
33 #include <asm/mach/map.h>
34 #include <mach/pxa27x.h>
35 #include <mach/audio.h>
36 #include <linux/platform_data/mmc-pxamci.h>
37 #include <linux/platform_data/usb-ohci-pxa27x.h>
38 #include <mach/pcm990_baseboard.h>
39 #include <linux/platform_data/video-pxafb.h>
44 static unsigned long pcm990_pin_config[] __initdata = {
64 GPIO29_AC97_SDATA_IN_0,
65 GPIO30_AC97_SDATA_OUT,
69 static void __iomem *pcm990_cpld_base;
71 static u8 pcm990_cpld_readb(unsigned int reg)
73 return readb(pcm990_cpld_base + reg);
76 static void pcm990_cpld_writeb(u8 value, unsigned int reg)
78 writeb(value, pcm990_cpld_base + reg);
82 * pcm990_lcd_power - control power supply to the LCD
83 * @on: 0 = switch off, 1 = switch on
85 * Called by the pxafb driver
87 #ifndef CONFIG_PCM990_DISPLAY_NONE
88 static void pcm990_lcd_power(int on, struct fb_var_screeninfo *var)
94 pcm990_cpld_writeb(PCM990_CTRL_LCDPWR + PCM990_CTRL_LCDON,
97 /* disable LCD-Latches
100 pcm990_cpld_writeb(0, PCM990_CTRL_REG3);
105 #if defined(CONFIG_PCM990_DISPLAY_SHARP)
106 static struct pxafb_mode_info fb_info_sharp_lq084v1dg21 = {
121 static struct pxafb_mach_info pcm990_fbinfo __initdata = {
122 .modes = &fb_info_sharp_lq084v1dg21,
124 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
125 .pxafb_lcd_power = pcm990_lcd_power,
127 #elif defined(CONFIG_PCM990_DISPLAY_NEC)
128 struct pxafb_mode_info fb_info_nec_nl6448bc20_18d = {
143 static struct pxafb_mach_info pcm990_fbinfo __initdata = {
144 .modes = &fb_info_nec_nl6448bc20_18d,
146 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
147 .pxafb_lcd_power = pcm990_lcd_power,
151 static struct platform_pwm_backlight_data pcm990_backlight_data = {
153 .max_brightness = 1023,
154 .dft_brightness = 1023,
155 .pwm_period_ns = 78770,
158 static struct platform_device pcm990_backlight_device = {
159 .name = "pwm-backlight",
161 .parent = &pxa27x_device_pwm0.dev,
162 .platform_data = &pcm990_backlight_data,
167 * The PCM-990 development baseboard uses PCM-027's hardware in the
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
180 * - GPIO109 is MMDAT1
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
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
205 * - GPIO42 is input BTRXD
206 * - GPIO43 is output BTTXD
207 * - GPIO44 is input BTCTS
208 * - GPIO45 is output BTRTS
210 * - GPIO46 is input STDRXD
211 * - GPIO47 is output STDTXD
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
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
226 * - GPIO81 is output SSPTXD3
227 * - GPIO82 is input SSPRXD3
228 * - GPIO83 is output SSPSFRM
229 * - GPIO84 is output SSPCLK3
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
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
254 static unsigned long pcm990_irq_enabled;
256 static void pcm990_mask_ack_irq(struct irq_data *d)
258 int pcm990_irq = (d->irq - PCM027_IRQ(0));
260 pcm990_irq_enabled &= ~(1 << pcm990_irq);
262 pcm990_cpld_writeb(pcm990_irq_enabled, PCM990_CTRL_INTMSKENA);
265 static void pcm990_unmask_irq(struct irq_data *d)
267 int pcm990_irq = (d->irq - PCM027_IRQ(0));
270 /* the irq can be acknowledged only if deasserted, so it's done here */
272 pcm990_irq_enabled |= (1 << pcm990_irq);
274 val = pcm990_cpld_readb(PCM990_CTRL_INTSETCLR);
275 val |= 1 << pcm990_irq;
276 pcm990_cpld_writeb(val, PCM990_CTRL_INTSETCLR);
278 pcm990_cpld_writeb(pcm990_irq_enabled, PCM990_CTRL_INTMSKENA);
281 static struct irq_chip pcm990_irq_chip = {
282 .irq_mask_ack = pcm990_mask_ack_irq,
283 .irq_unmask = pcm990_unmask_irq,
286 static void pcm990_irq_handler(unsigned int irq, struct irq_desc *desc)
288 unsigned long pending;
290 pending = ~pcm990_cpld_readb(PCM990_CTRL_INTSETCLR);
291 pending &= pcm990_irq_enabled;
294 /* clear our parent IRQ */
295 desc->irq_data.chip->irq_ack(&desc->irq_data);
296 if (likely(pending)) {
297 irq = PCM027_IRQ(0) + __ffs(pending);
298 generic_handle_irq(irq);
300 pending = ~pcm990_cpld_readb(PCM990_CTRL_INTSETCLR);
301 pending &= pcm990_irq_enabled;
305 static void __init pcm990_init_irq(void)
309 /* setup extra PCM990 irqs */
310 for (irq = PCM027_IRQ(0); irq <= PCM027_IRQ(3); irq++) {
311 irq_set_chip_and_handler(irq, &pcm990_irq_chip,
313 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
316 /* disable all Interrupts */
317 pcm990_cpld_writeb(0x0, PCM990_CTRL_INTMSKENA);
318 pcm990_cpld_writeb(0xff, PCM990_CTRL_INTSETCLR);
320 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);
324 static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int,
329 err = request_irq(PCM027_MMCDET_IRQ, mci_detect_int, IRQF_DISABLED,
330 "MMC card detect", data);
332 printk(KERN_ERR "pcm990_mci_init: MMC/SD: can't request MMC "
333 "card detect IRQ\n");
338 static int pcm990_mci_setpower(struct device *dev, unsigned int vdd)
340 struct pxamci_platform_data *p_d = dev->platform_data;
343 val = pcm990_cpld_readb(PCM990_CTRL_REG5);
345 if ((1 << vdd) & p_d->ocr_mask)
346 val |= PCM990_CTRL_MMC2PWR;
348 val &= ~PCM990_CTRL_MMC2PWR;
350 pcm990_cpld_writeb(PCM990_CTRL_MMC2PWR, PCM990_CTRL_REG5);
354 static void pcm990_mci_exit(struct device *dev, void *data)
356 free_irq(PCM027_MMCDET_IRQ, data);
359 #define MSECS_PER_JIFFY (1000/HZ)
361 static struct pxamci_platform_data pcm990_mci_platform_data = {
362 .detect_delay_ms = 250,
363 .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,
372 static struct pxaohci_platform_data pcm990_ohci_platform_data = {
373 .port_mode = PMM_PERPORT_MODE,
374 .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
375 .power_on_delay = 10,
379 * PXA27x Camera specific stuff
381 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
382 static unsigned long pcm990_camera_pin_config[] = {
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
405 struct pxacamera_platform_data pcm990_pxacamera_platform_data = {
406 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | PXA_CAMERA_DATAWIDTH_10 |
407 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN/* | PXA_CAMERA_PCP*/,
411 #include <linux/platform_data/pca953x.h>
413 static struct pca953x_platform_data pca9536_data = {
414 .gpio_base = PXA_NR_BUILTIN_GPIO,
417 static int gpio_bus_switch = -EINVAL;
419 static int pcm990_camera_set_bus_param(struct soc_camera_link *link,
422 if (gpio_bus_switch < 0) {
423 if (flags == SOCAM_DATAWIDTH_10)
429 if (flags & SOCAM_DATAWIDTH_8)
430 gpio_set_value_cansleep(gpio_bus_switch, 1);
432 gpio_set_value_cansleep(gpio_bus_switch, 0);
437 static unsigned long pcm990_camera_query_bus_param(struct soc_camera_link *link)
441 if (gpio_bus_switch < 0) {
442 ret = gpio_request(PXA_NR_BUILTIN_GPIO, "camera");
444 gpio_bus_switch = PXA_NR_BUILTIN_GPIO;
445 gpio_direction_output(gpio_bus_switch, 0);
449 if (gpio_bus_switch >= 0)
450 return SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_10;
452 return SOCAM_DATAWIDTH_10;
455 static void pcm990_camera_free_bus(struct soc_camera_link *link)
457 if (gpio_bus_switch < 0)
460 gpio_free(gpio_bus_switch);
461 gpio_bus_switch = -EINVAL;
464 /* Board I2C devices. */
465 static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
467 /* Must initialize before the camera(s) */
468 I2C_BOARD_INFO("pca9536", 0x41),
469 .platform_data = &pca9536_data,
473 static struct mt9v022_platform_data mt9v022_pdata = {
477 static struct i2c_board_info pcm990_camera_i2c[] = {
479 I2C_BOARD_INFO("mt9v022", 0x48),
481 I2C_BOARD_INFO("mt9m001", 0x5d),
485 static struct soc_camera_link iclink[] = {
487 .bus_id = 0, /* Must match with the camera ID */
488 .board_info = &pcm990_camera_i2c[0],
489 .priv = &mt9v022_pdata,
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,
495 .bus_id = 0, /* Must match with the camera ID */
496 .board_info = &pcm990_camera_i2c[1],
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,
504 static struct platform_device pcm990_camera[] = {
506 .name = "soc-camera-pdrv",
509 .platform_data = &iclink[0],
512 .name = "soc-camera-pdrv",
515 .platform_data = &iclink[1],
519 #endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
522 * system init for baseboard usage. Will be called by pcm027 init.
524 * Add platform devices present on this baseboard and init
525 * them from CPU side as far as required to use them later on
527 void __init pcm990_baseboard_init(void)
529 pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_pin_config));
531 pcm990_cpld_base = ioremap(PCM990_CTRL_PHYS, PCM990_CTRL_SIZE);
532 if (!pcm990_cpld_base) {
533 pr_err("pcm990: failed to ioremap cpld\n");
537 /* register CPLD's IRQ controller */
540 #ifndef CONFIG_PCM990_DISPLAY_NONE
541 pxa_set_fb_info(NULL, &pcm990_fbinfo);
543 platform_device_register(&pcm990_backlight_device);
546 pxa_set_mci_info(&pcm990_mci_platform_data);
549 pxa_set_ohci_info(&pcm990_ohci_platform_data);
551 pxa_set_i2c_info(NULL);
552 pxa_set_ac97_info(NULL);
554 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
555 pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_camera_pin_config));
556 pxa_set_camera_info(&pcm990_pxacamera_platform_data);
558 i2c_register_board_info(0, ARRAY_AND_SIZE(pcm990_i2c_devices));
560 platform_device_register(&pcm990_camera[0]);
561 platform_device_register(&pcm990_camera[1]);
564 printk(KERN_INFO "PCM-990 Evaluation baseboard initialized\n");