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/soc_camera.h>
31 #include <mach/camera.h>
32 #include <asm/mach/map.h>
33 #include <mach/pxa27x.h>
34 #include <mach/audio.h>
36 #include <mach/ohci.h>
37 #include <mach/pcm990_baseboard.h>
38 #include <mach/pxafb.h>
43 static unsigned long pcm990_pin_config
[] __initdata
= {
63 GPIO29_AC97_SDATA_IN_0
,
64 GPIO30_AC97_SDATA_OUT
,
69 * pcm990_lcd_power - control power supply to the LCD
70 * @on: 0 = switch off, 1 = switch on
72 * Called by the pxafb driver
74 #ifndef CONFIG_PCM990_DISPLAY_NONE
75 static void pcm990_lcd_power(int on
, struct fb_var_screeninfo
*var
)
81 __PCM990_CTRL_REG(PCM990_CTRL_PHYS
+ PCM990_CTRL_REG3
) =
82 PCM990_CTRL_LCDPWR
+ PCM990_CTRL_LCDON
;
84 /* disable LCD-Latches
87 __PCM990_CTRL_REG(PCM990_CTRL_PHYS
+ PCM990_CTRL_REG3
) = 0x00;
92 #if defined(CONFIG_PCM990_DISPLAY_SHARP)
93 static struct pxafb_mode_info fb_info_sharp_lq084v1dg21
= {
108 static struct pxafb_mach_info pcm990_fbinfo __initdata
= {
109 .modes
= &fb_info_sharp_lq084v1dg21
,
111 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
112 .pxafb_lcd_power
= pcm990_lcd_power
,
114 #elif defined(CONFIG_PCM990_DISPLAY_NEC)
115 struct pxafb_mode_info fb_info_nec_nl6448bc20_18d
= {
130 static struct pxafb_mach_info pcm990_fbinfo __initdata
= {
131 .modes
= &fb_info_nec_nl6448bc20_18d
,
133 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
134 .pxafb_lcd_power
= pcm990_lcd_power
,
138 static struct platform_pwm_backlight_data pcm990_backlight_data
= {
140 .max_brightness
= 1023,
141 .dft_brightness
= 1023,
142 .pwm_period_ns
= 78770,
145 static struct platform_device pcm990_backlight_device
= {
146 .name
= "pwm-backlight",
148 .parent
= &pxa27x_device_pwm0
.dev
,
149 .platform_data
= &pcm990_backlight_data
,
154 * The PCM-990 development baseboard uses PCM-027's hardware in the
157 * - LCD support is in use
158 * - GPIO16 is output for back light on/off with PWM
159 * - GPIO58 ... GPIO73 are outputs for display data
160 * - GPIO74 is output output for LCDFCLK
161 * - GPIO75 is output for LCDLCLK
162 * - GPIO76 is output for LCDPCLK
163 * - GPIO77 is output for LCDBIAS
164 * - MMC support is in use
165 * - GPIO32 is output for MMCCLK
167 * - GPIO109 is MMDAT1
171 * - IDE/CF card is in use
172 * - GPIO48 is output /POE
173 * - GPIO49 is output /PWE
174 * - GPIO50 is output /PIOR
175 * - GPIO51 is output /PIOW
176 * - GPIO54 is output /PCE2
177 * - GPIO55 is output /PREG
178 * - GPIO56 is input /PWAIT
179 * - GPIO57 is output /PIOS16
180 * - GPIO79 is output PSKTSEL
181 * - GPIO85 is output /PCE1
183 * - GPIO34 is input FFRXD
184 * - GPIO35 is input FFCTS
185 * - GPIO36 is input FFDCD
186 * - GPIO37 is input FFDSR
187 * - GPIO38 is input FFRI
188 * - GPIO39 is output FFTXD
189 * - GPIO40 is output FFDTR
190 * - GPIO41 is output FFRTS
192 * - GPIO42 is input BTRXD
193 * - GPIO43 is output BTTXD
194 * - GPIO44 is input BTCTS
195 * - GPIO45 is output BTRTS
197 * - GPIO46 is input STDRXD
198 * - GPIO47 is output STDTXD
200 * - GPIO28 is input AC97CLK
201 * - GPIO29 is input AC97DatIn
202 * - GPIO30 is output AC97DatO
203 * - GPIO31 is output AC97SYNC
204 * - GPIO113 is output AC97_RESET
206 * - GPIO23 is output SSPSCLK
207 * - GPIO24 is output chip select to Max7301
208 * - GPIO25 is output SSPTXD
209 * - GPIO26 is input SSPRXD
210 * - GPIO27 is input for Max7301 IRQ
211 * - GPIO53 is input SSPSYSCLK
213 * - GPIO81 is output SSPTXD3
214 * - GPIO82 is input SSPRXD3
215 * - GPIO83 is output SSPSFRM
216 * - GPIO84 is output SSPCLK3
218 * Otherwise claimed GPIOs:
219 * GPIO1 -> IRQ from user switch
220 * GPIO9 -> IRQ from power management
221 * GPIO10 -> IRQ from WML9712 AC97 controller
222 * GPIO11 -> IRQ from IDE controller
223 * GPIO12 -> IRQ from CF controller
224 * GPIO13 -> IRQ from CF controller
225 * GPIO14 -> GPIO free
226 * GPIO15 -> /CS1 selects baseboard's Control CPLD (U7, 16 bit wide data path)
227 * GPIO19 -> GPIO free
229 * GPIO21 -> /CS3 PC card socket select
230 * GPIO33 -> /CS5 network controller select
231 * GPIO78 -> /CS2 (16 bit wide data path)
232 * GPIO80 -> /CS4 (16 bit wide data path)
233 * GPIO86 -> GPIO free
234 * GPIO87 -> GPIO free
235 * GPIO90 -> LED0 on CPU module
236 * GPIO91 -> LED1 on CPI module
241 static unsigned long pcm990_irq_enabled
;
243 static void pcm990_mask_ack_irq(struct irq_data
*d
)
245 int pcm990_irq
= (d
->irq
- PCM027_IRQ(0));
246 PCM990_INTMSKENA
= (pcm990_irq_enabled
&= ~(1 << pcm990_irq
));
249 static void pcm990_unmask_irq(struct irq_data
*d
)
251 int pcm990_irq
= (d
->irq
- PCM027_IRQ(0));
252 /* the irq can be acknowledged only if deasserted, so it's done here */
253 PCM990_INTSETCLR
|= 1 << pcm990_irq
;
254 PCM990_INTMSKENA
= (pcm990_irq_enabled
|= (1 << pcm990_irq
));
257 static struct irq_chip pcm990_irq_chip
= {
258 .irq_mask_ack
= pcm990_mask_ack_irq
,
259 .irq_unmask
= pcm990_unmask_irq
,
262 static void pcm990_irq_handler(unsigned int irq
, struct irq_desc
*desc
)
264 unsigned long pending
= (~PCM990_INTSETCLR
) & pcm990_irq_enabled
;
267 /* clear our parent IRQ */
268 desc
->irq_data
.chip
->irq_ack(&desc
->irq_data
);
269 if (likely(pending
)) {
270 irq
= PCM027_IRQ(0) + __ffs(pending
);
271 generic_handle_irq(irq
);
273 pending
= (~PCM990_INTSETCLR
) & pcm990_irq_enabled
;
277 static void __init
pcm990_init_irq(void)
281 /* setup extra PCM990 irqs */
282 for (irq
= PCM027_IRQ(0); irq
<= PCM027_IRQ(3); irq
++) {
283 irq_set_chip_and_handler(irq
, &pcm990_irq_chip
,
285 set_irq_flags(irq
, IRQF_VALID
| IRQF_PROBE
);
288 PCM990_INTMSKENA
= 0x00; /* disable all Interrupts */
289 PCM990_INTSETCLR
= 0xFF;
291 irq_set_chained_handler(PCM990_CTRL_INT_IRQ
, pcm990_irq_handler
);
292 irq_set_irq_type(PCM990_CTRL_INT_IRQ
, PCM990_CTRL_INT_IRQ_EDGE
);
295 static int pcm990_mci_init(struct device
*dev
, irq_handler_t mci_detect_int
,
300 err
= request_irq(PCM027_MMCDET_IRQ
, mci_detect_int
, IRQF_DISABLED
,
301 "MMC card detect", data
);
303 printk(KERN_ERR
"pcm990_mci_init: MMC/SD: can't request MMC "
304 "card detect IRQ\n");
309 static void pcm990_mci_setpower(struct device
*dev
, unsigned int vdd
)
311 struct pxamci_platform_data
*p_d
= dev
->platform_data
;
313 if ((1 << vdd
) & p_d
->ocr_mask
)
314 __PCM990_CTRL_REG(PCM990_CTRL_PHYS
+ PCM990_CTRL_REG5
) =
317 __PCM990_CTRL_REG(PCM990_CTRL_PHYS
+ PCM990_CTRL_REG5
) =
318 ~PCM990_CTRL_MMC2PWR
;
321 static void pcm990_mci_exit(struct device
*dev
, void *data
)
323 free_irq(PCM027_MMCDET_IRQ
, data
);
326 #define MSECS_PER_JIFFY (1000/HZ)
328 static struct pxamci_platform_data pcm990_mci_platform_data
= {
329 .detect_delay_ms
= 250,
330 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
331 .init
= pcm990_mci_init
,
332 .setpower
= pcm990_mci_setpower
,
333 .exit
= pcm990_mci_exit
,
334 .gpio_card_detect
= -1,
339 static struct pxaohci_platform_data pcm990_ohci_platform_data
= {
340 .port_mode
= PMM_PERPORT_MODE
,
341 .flags
= ENABLE_PORT1
| POWER_CONTROL_LOW
| POWER_SENSE_LOW
,
342 .power_on_delay
= 10,
346 * PXA27x Camera specific stuff
348 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
349 static unsigned long pcm990_camera_pin_config
[] = {
368 * CICR4: PCLK_EN: Pixel clock is supplied by the sensor
369 * MCLK_EN: Master clock is generated by PXA
370 * PCP: Data sampled on the falling edge of pixel clock
372 struct pxacamera_platform_data pcm990_pxacamera_platform_data
= {
373 .flags
= PXA_CAMERA_MASTER
| PXA_CAMERA_DATAWIDTH_8
| PXA_CAMERA_DATAWIDTH_10
|
374 PXA_CAMERA_PCLK_EN
| PXA_CAMERA_MCLK_EN
/* | PXA_CAMERA_PCP*/,
378 #include <linux/i2c/pca953x.h>
380 static struct pca953x_platform_data pca9536_data
= {
381 .gpio_base
= NR_BUILTIN_GPIO
,
384 static int gpio_bus_switch
= -EINVAL
;
386 static int pcm990_camera_set_bus_param(struct soc_camera_link
*link
,
389 if (gpio_bus_switch
< 0) {
390 if (flags
== SOCAM_DATAWIDTH_10
)
396 if (flags
& SOCAM_DATAWIDTH_8
)
397 gpio_set_value(gpio_bus_switch
, 1);
399 gpio_set_value(gpio_bus_switch
, 0);
404 static unsigned long pcm990_camera_query_bus_param(struct soc_camera_link
*link
)
408 if (gpio_bus_switch
< 0) {
409 ret
= gpio_request(NR_BUILTIN_GPIO
, "camera");
411 gpio_bus_switch
= NR_BUILTIN_GPIO
;
412 gpio_direction_output(gpio_bus_switch
, 0);
416 if (gpio_bus_switch
>= 0)
417 return SOCAM_DATAWIDTH_8
| SOCAM_DATAWIDTH_10
;
419 return SOCAM_DATAWIDTH_10
;
422 static void pcm990_camera_free_bus(struct soc_camera_link
*link
)
424 if (gpio_bus_switch
< 0)
427 gpio_free(gpio_bus_switch
);
428 gpio_bus_switch
= -EINVAL
;
431 /* Board I2C devices. */
432 static struct i2c_board_info __initdata pcm990_i2c_devices
[] = {
434 /* Must initialize before the camera(s) */
435 I2C_BOARD_INFO("pca9536", 0x41),
436 .platform_data
= &pca9536_data
,
440 static struct i2c_board_info pcm990_camera_i2c
[] = {
442 I2C_BOARD_INFO("mt9v022", 0x48),
444 I2C_BOARD_INFO("mt9m001", 0x5d),
448 static struct soc_camera_link iclink
[] = {
450 .bus_id
= 0, /* Must match with the camera ID */
451 .board_info
= &pcm990_camera_i2c
[0],
453 .query_bus_param
= pcm990_camera_query_bus_param
,
454 .set_bus_param
= pcm990_camera_set_bus_param
,
455 .free_bus
= pcm990_camera_free_bus
,
457 .bus_id
= 0, /* Must match with the camera ID */
458 .board_info
= &pcm990_camera_i2c
[1],
460 .query_bus_param
= pcm990_camera_query_bus_param
,
461 .set_bus_param
= pcm990_camera_set_bus_param
,
462 .free_bus
= pcm990_camera_free_bus
,
466 static struct platform_device pcm990_camera
[] = {
468 .name
= "soc-camera-pdrv",
471 .platform_data
= &iclink
[0],
474 .name
= "soc-camera-pdrv",
477 .platform_data
= &iclink
[1],
481 #endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
484 * enable generic access to the base board control CPLDs U6 and U7
486 static struct map_desc pcm990_io_desc
[] __initdata
= {
488 .virtual = PCM990_CTRL_BASE
,
489 .pfn
= __phys_to_pfn(PCM990_CTRL_PHYS
),
490 .length
= PCM990_CTRL_SIZE
,
491 .type
= MT_DEVICE
/* CPLD */
493 .virtual = PCM990_CF_PLD_BASE
,
494 .pfn
= __phys_to_pfn(PCM990_CF_PLD_PHYS
),
495 .length
= PCM990_CF_PLD_SIZE
,
496 .type
= MT_DEVICE
/* CPLD */
501 * system init for baseboard usage. Will be called by pcm027 init.
503 * Add platform devices present on this baseboard and init
504 * them from CPU side as far as required to use them later on
506 void __init
pcm990_baseboard_init(void)
508 pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_pin_config
));
510 /* register CPLD access */
511 iotable_init(ARRAY_AND_SIZE(pcm990_io_desc
));
513 /* register CPLD's IRQ controller */
516 #ifndef CONFIG_PCM990_DISPLAY_NONE
517 pxa_set_fb_info(NULL
, &pcm990_fbinfo
);
519 platform_device_register(&pcm990_backlight_device
);
522 pxa_set_mci_info(&pcm990_mci_platform_data
);
525 pxa_set_ohci_info(&pcm990_ohci_platform_data
);
527 pxa_set_i2c_info(NULL
);
528 pxa_set_ac97_info(NULL
);
530 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
531 pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_camera_pin_config
));
532 pxa_set_camera_info(&pcm990_pxacamera_platform_data
);
534 i2c_register_board_info(0, ARRAY_AND_SIZE(pcm990_i2c_devices
));
536 platform_device_register(&pcm990_camera
[0]);
537 platform_device_register(&pcm990_camera
[1]);
540 printk(KERN_INFO
"PCM-990 Evaluation baseboard initialized\n");