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.
23 #include <linux/irq.h>
24 #include <linux/platform_device.h>
25 #include <linux/i2c.h>
26 #include <linux/pwm_backlight.h>
28 #include <media/soc_camera.h>
32 #include <mach/camera.h>
33 #include <asm/mach/map.h>
34 #include <mach/pxa-regs.h>
35 #include <mach/audio.h>
37 #include <mach/ohci.h>
38 #include <mach/pcm990_baseboard.h>
39 #include <mach/pxafb.h>
40 #include <mach/mfp-pxa27x.h>
45 static unsigned long pcm990_pin_config[] __initdata = {
61 * pcm990_lcd_power - control power supply to the LCD
62 * @on: 0 = switch off, 1 = switch on
64 * Called by the pxafb driver
66 #ifndef CONFIG_PCM990_DISPLAY_NONE
67 static void pcm990_lcd_power(int on, struct fb_var_screeninfo *var)
73 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG3) =
74 PCM990_CTRL_LCDPWR + PCM990_CTRL_LCDON;
76 /* disable LCD-Latches
79 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG3) = 0x00;
84 #if defined(CONFIG_PCM990_DISPLAY_SHARP)
85 static struct pxafb_mode_info fb_info_sharp_lq084v1dg21 = {
100 static struct pxafb_mach_info pcm990_fbinfo __initdata = {
101 .modes = &fb_info_sharp_lq084v1dg21,
105 .pxafb_lcd_power = pcm990_lcd_power,
107 #elif defined(CONFIG_PCM990_DISPLAY_NEC)
108 struct pxafb_mode_info fb_info_nec_nl6448bc20_18d = {
123 static struct pxafb_mach_info pcm990_fbinfo __initdata = {
124 .modes = &fb_info_nec_nl6448bc20_18d,
127 .lccr3 = LCCR3_PixFlEdg,
128 .pxafb_lcd_power = pcm990_lcd_power,
132 static struct platform_pwm_backlight_data pcm990_backlight_data = {
134 .max_brightness = 1023,
135 .dft_brightness = 1023,
136 .pwm_period_ns = 78770,
139 static struct platform_device pcm990_backlight_device = {
140 .name = "pwm-backlight",
142 .parent = &pxa27x_device_pwm0.dev,
143 .platform_data = &pcm990_backlight_data,
148 * The PCM-990 development baseboard uses PCM-027's hardware in the
151 * - LCD support is in use
152 * - GPIO16 is output for back light on/off with PWM
153 * - GPIO58 ... GPIO73 are outputs for display data
154 * - GPIO74 is output output for LCDFCLK
155 * - GPIO75 is output for LCDLCLK
156 * - GPIO76 is output for LCDPCLK
157 * - GPIO77 is output for LCDBIAS
158 * - MMC support is in use
159 * - GPIO32 is output for MMCCLK
161 * - GPIO109 is MMDAT1
165 * - IDE/CF card is in use
166 * - GPIO48 is output /POE
167 * - GPIO49 is output /PWE
168 * - GPIO50 is output /PIOR
169 * - GPIO51 is output /PIOW
170 * - GPIO54 is output /PCE2
171 * - GPIO55 is output /PREG
172 * - GPIO56 is input /PWAIT
173 * - GPIO57 is output /PIOS16
174 * - GPIO79 is output PSKTSEL
175 * - GPIO85 is output /PCE1
177 * - GPIO34 is input FFRXD
178 * - GPIO35 is input FFCTS
179 * - GPIO36 is input FFDCD
180 * - GPIO37 is input FFDSR
181 * - GPIO38 is input FFRI
182 * - GPIO39 is output FFTXD
183 * - GPIO40 is output FFDTR
184 * - GPIO41 is output FFRTS
186 * - GPIO42 is input BTRXD
187 * - GPIO43 is output BTTXD
188 * - GPIO44 is input BTCTS
189 * - GPIO45 is output BTRTS
191 * - GPIO46 is input STDRXD
192 * - GPIO47 is output STDTXD
194 * - GPIO28 is input AC97CLK
195 * - GPIO29 is input AC97DatIn
196 * - GPIO30 is output AC97DatO
197 * - GPIO31 is output AC97SYNC
198 * - GPIO113 is output AC97_RESET
200 * - GPIO23 is output SSPSCLK
201 * - GPIO24 is output chip select to Max7301
202 * - GPIO25 is output SSPTXD
203 * - GPIO26 is input SSPRXD
204 * - GPIO27 is input for Max7301 IRQ
205 * - GPIO53 is input SSPSYSCLK
207 * - GPIO81 is output SSPTXD3
208 * - GPIO82 is input SSPRXD3
209 * - GPIO83 is output SSPSFRM
210 * - GPIO84 is output SSPCLK3
212 * Otherwise claimed GPIOs:
213 * GPIO1 -> IRQ from user switch
214 * GPIO9 -> IRQ from power management
215 * GPIO10 -> IRQ from WML9712 AC97 controller
216 * GPIO11 -> IRQ from IDE controller
217 * GPIO12 -> IRQ from CF controller
218 * GPIO13 -> IRQ from CF controller
219 * GPIO14 -> GPIO free
220 * GPIO15 -> /CS1 selects baseboard's Control CPLD (U7, 16 bit wide data path)
221 * GPIO19 -> GPIO free
223 * GPIO21 -> /CS3 PC card socket select
224 * GPIO33 -> /CS5 network controller select
225 * GPIO78 -> /CS2 (16 bit wide data path)
226 * GPIO80 -> /CS4 (16 bit wide data path)
227 * GPIO86 -> GPIO free
228 * GPIO87 -> GPIO free
229 * GPIO90 -> LED0 on CPU module
230 * GPIO91 -> LED1 on CPI module
235 static unsigned long pcm990_irq_enabled;
237 static void pcm990_mask_ack_irq(unsigned int irq)
239 int pcm990_irq = (irq - PCM027_IRQ(0));
240 PCM990_INTMSKENA = (pcm990_irq_enabled &= ~(1 << pcm990_irq));
243 static void pcm990_unmask_irq(unsigned int irq)
245 int pcm990_irq = (irq - PCM027_IRQ(0));
246 /* the irq can be acknowledged only if deasserted, so it's done here */
247 PCM990_INTSETCLR |= 1 << pcm990_irq;
248 PCM990_INTMSKENA = (pcm990_irq_enabled |= (1 << pcm990_irq));
251 static struct irq_chip pcm990_irq_chip = {
252 .mask_ack = pcm990_mask_ack_irq,
253 .unmask = pcm990_unmask_irq,
256 static void pcm990_irq_handler(unsigned int irq, struct irq_desc *desc)
258 unsigned long pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
261 GEDR(PCM990_CTRL_INT_IRQ_GPIO) =
262 GPIO_bit(PCM990_CTRL_INT_IRQ_GPIO);
263 if (likely(pending)) {
264 irq = PCM027_IRQ(0) + __ffs(pending);
265 desc = irq_desc + irq;
266 desc_handle_irq(irq, desc);
268 pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
272 static void __init pcm990_init_irq(void)
276 /* setup extra PCM990 irqs */
277 for (irq = PCM027_IRQ(0); irq <= PCM027_IRQ(3); irq++) {
278 set_irq_chip(irq, &pcm990_irq_chip);
279 set_irq_handler(irq, handle_level_irq);
280 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
283 PCM990_INTMSKENA = 0x00; /* disable all Interrupts */
284 PCM990_INTSETCLR = 0xFF;
286 set_irq_chained_handler(PCM990_CTRL_INT_IRQ, pcm990_irq_handler);
287 set_irq_type(PCM990_CTRL_INT_IRQ, PCM990_CTRL_INT_IRQ_EDGE);
290 static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int,
295 err = request_irq(PCM027_MMCDET_IRQ, mci_detect_int, IRQF_DISABLED,
296 "MMC card detect", data);
298 printk(KERN_ERR "pcm990_mci_init: MMC/SD: can't request MMC "
299 "card detect IRQ\n");
304 static void pcm990_mci_setpower(struct device *dev, unsigned int vdd)
306 struct pxamci_platform_data *p_d = dev->platform_data;
308 if ((1 << vdd) & p_d->ocr_mask)
309 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) =
312 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) =
313 ~PCM990_CTRL_MMC2PWR;
316 static void pcm990_mci_exit(struct device *dev, void *data)
318 free_irq(PCM027_MMCDET_IRQ, data);
321 #define MSECS_PER_JIFFY (1000/HZ)
323 static struct pxamci_platform_data pcm990_mci_platform_data = {
324 .detect_delay = 250 / MSECS_PER_JIFFY,
325 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
326 .init = pcm990_mci_init,
327 .setpower = pcm990_mci_setpower,
328 .exit = pcm990_mci_exit,
332 * init OHCI hardware to work with
334 * Note: Only USB port 1 (host only) is connected
336 * GPIO88 (USBHPWR#1): overcurrent in, overcurrent when low
337 * GPIO89 (USBHPEN#1): power-on out, on when low
339 static int pcm990_ohci_init(struct device *dev)
342 * disable USB port 2 and 3
343 * power sense is active low
345 UHCHR = ((UHCHR) | UHCHR_PCPL | UHCHR_PSPL | UHCHR_SSEP2 |
346 UHCHR_SSEP3) & ~(UHCHR_SSEP1 | UHCHR_SSE);
348 * wait 10ms after Power on
349 * overcurrent per port
350 * power switch per port
352 UHCRHDA = (5<<24) | (1<<11) | (1<<8); /* FIXME: Required? */
357 static struct pxaohci_platform_data pcm990_ohci_platform_data = {
358 .port_mode = PMM_PERPORT_MODE,
359 .init = pcm990_ohci_init,
364 * PXA27x Camera specific stuff
366 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
367 static unsigned long pcm990_camera_pin_config[] = {
385 static int pcm990_pxacamera_init(struct device *dev)
387 pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_camera_pin_config));
392 * CICR4: PCLK_EN: Pixel clock is supplied by the sensor
393 * MCLK_EN: Master clock is generated by PXA
394 * PCP: Data sampled on the falling edge of pixel clock
396 struct pxacamera_platform_data pcm990_pxacamera_platform_data = {
397 .init = pcm990_pxacamera_init,
398 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | PXA_CAMERA_DATAWIDTH_10 |
399 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN/* | PXA_CAMERA_PCP*/,
403 #include <linux/i2c/pca953x.h>
405 static struct pca953x_platform_data pca9536_data = {
406 .gpio_base = NR_BUILTIN_GPIO + 1,
409 static struct soc_camera_link iclink[] = {
411 .bus_id = 0, /* Must match with the camera ID above */
412 .gpio = NR_BUILTIN_GPIO + 1,
414 .bus_id = 0, /* Must match with the camera ID above */
418 /* Board I2C devices. */
419 static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
421 /* Must initialize before the camera(s) */
422 I2C_BOARD_INFO("pca9536", 0x41),
423 .platform_data = &pca9536_data,
425 I2C_BOARD_INFO("mt9v022", 0x48),
426 .platform_data = &iclink[0], /* With extender */
428 I2C_BOARD_INFO("mt9m001", 0x5d),
429 .platform_data = &iclink[0], /* With extender */
432 #endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
435 * enable generic access to the base board control CPLDs U6 and U7
437 static struct map_desc pcm990_io_desc[] __initdata = {
439 .virtual = PCM990_CTRL_BASE,
440 .pfn = __phys_to_pfn(PCM990_CTRL_PHYS),
441 .length = PCM990_CTRL_SIZE,
442 .type = MT_DEVICE /* CPLD */
444 .virtual = PCM990_CF_PLD_BASE,
445 .pfn = __phys_to_pfn(PCM990_CF_PLD_PHYS),
446 .length = PCM990_CF_PLD_SIZE,
447 .type = MT_DEVICE /* CPLD */
452 * system init for baseboard usage. Will be called by pcm027 init.
454 * Add platform devices present on this baseboard and init
455 * them from CPU side as far as required to use them later on
457 void __init pcm990_baseboard_init(void)
459 pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_pin_config));
461 /* register CPLD access */
462 iotable_init(ARRAY_AND_SIZE(pcm990_io_desc));
464 /* register CPLD's IRQ controller */
467 #ifndef CONFIG_PCM990_DISPLAY_NONE
468 set_pxa_fb_info(&pcm990_fbinfo);
470 platform_device_register(&pcm990_backlight_device);
473 pxa_set_mci_info(&pcm990_mci_platform_data);
476 pxa_set_ohci_info(&pcm990_ohci_platform_data);
478 pxa_set_i2c_info(NULL);
479 pxa_set_ac97_info(NULL);
481 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
482 pxa_set_camera_info(&pcm990_pxacamera_platform_data);
484 i2c_register_board_info(0, ARRAY_AND_SIZE(pcm990_i2c_devices));
487 printk(KERN_INFO "PCM-990 Evaluation baseboard initialized\n");