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/ide.h>
26 #include <linux/i2c.h>
28 #include <media/soc_camera.h>
31 #include <asm/arch/i2c.h>
32 #include <asm/arch/camera.h>
33 #include <asm/mach/map.h>
34 #include <asm/arch/pxa-regs.h>
35 #include <asm/arch/pxa2xx-gpio.h>
36 #include <asm/arch/mmc.h>
37 #include <asm/arch/ohci.h>
38 #include <asm/arch/pcm990_baseboard.h>
41 * The PCM-990 development baseboard uses PCM-027's hardeware in the
44 * - LCD support is in use
45 * - GPIO16 is output for back light on/off with PWM
46 * - GPIO58 ... GPIO73 are outputs for display data
47 * - GPIO74 is output output for LCDFCLK
48 * - GPIO75 is output for LCDLCLK
49 * - GPIO76 is output for LCDPCLK
50 * - GPIO77 is output for LCDBIAS
51 * - MMC support is in use
52 * - GPIO32 is output for MMCCLK
58 * - IDE/CF card is in use
59 * - GPIO48 is output /POE
60 * - GPIO49 is output /PWE
61 * - GPIO50 is output /PIOR
62 * - GPIO51 is output /PIOW
63 * - GPIO54 is output /PCE2
64 * - GPIO55 is output /PREG
65 * - GPIO56 is input /PWAIT
66 * - GPIO57 is output /PIOS16
67 * - GPIO79 is output PSKTSEL
68 * - GPIO85 is output /PCE1
70 * - GPIO34 is input FFRXD
71 * - GPIO35 is input FFCTS
72 * - GPIO36 is input FFDCD
73 * - GPIO37 is input FFDSR
74 * - GPIO38 is input FFRI
75 * - GPIO39 is output FFTXD
76 * - GPIO40 is output FFDTR
77 * - GPIO41 is output FFRTS
79 * - GPIO42 is input BTRXD
80 * - GPIO43 is output BTTXD
81 * - GPIO44 is input BTCTS
82 * - GPIO45 is output BTRTS
84 * - GPIO46 is input STDRXD
85 * - GPIO47 is output STDTXD
87 * - GPIO28 is input AC97CLK
88 * - GPIO29 is input AC97DatIn
89 * - GPIO30 is output AC97DatO
90 * - GPIO31 is output AC97SYNC
91 * - GPIO113 is output AC97_RESET
93 * - GPIO23 is output SSPSCLK
94 * - GPIO24 is output chip select to Max7301
95 * - GPIO25 is output SSPTXD
96 * - GPIO26 is input SSPRXD
97 * - GPIO27 is input for Max7301 IRQ
98 * - GPIO53 is input SSPSYSCLK
100 * - GPIO81 is output SSPTXD3
101 * - GPIO82 is input SSPRXD3
102 * - GPIO83 is output SSPSFRM
103 * - GPIO84 is output SSPCLK3
105 * Otherwise claimed GPIOs:
106 * GPIO1 -> IRQ from user switch
107 * GPIO9 -> IRQ from power management
108 * GPIO10 -> IRQ from WML9712 AC97 controller
109 * GPIO11 -> IRQ from IDE controller
110 * GPIO12 -> IRQ from CF controller
111 * GPIO13 -> IRQ from CF controller
112 * GPIO14 -> GPIO free
113 * GPIO15 -> /CS1 selects baseboard's Control CPLD (U7, 16 bit wide data path)
114 * GPIO19 -> GPIO free
116 * GPIO21 -> /CS3 PC card socket select
117 * GPIO33 -> /CS5 network controller select
118 * GPIO78 -> /CS2 (16 bit wide data path)
119 * GPIO80 -> /CS4 (16 bit wide data path)
120 * GPIO86 -> GPIO free
121 * GPIO87 -> GPIO free
122 * GPIO90 -> LED0 on CPU module
123 * GPIO91 -> LED1 on CPI module
128 static unsigned long pcm990_irq_enabled;
130 static void pcm990_mask_ack_irq(unsigned int irq)
132 int pcm990_irq = (irq - PCM027_IRQ(0));
133 PCM990_INTMSKENA = (pcm990_irq_enabled &= ~(1 << pcm990_irq));
136 static void pcm990_unmask_irq(unsigned int irq)
138 int pcm990_irq = (irq - PCM027_IRQ(0));
139 /* the irq can be acknowledged only if deasserted, so it's done here */
140 PCM990_INTSETCLR |= 1 << pcm990_irq;
141 PCM990_INTMSKENA = (pcm990_irq_enabled |= (1 << pcm990_irq));
144 static struct irq_chip pcm990_irq_chip = {
145 .mask_ack = pcm990_mask_ack_irq,
146 .unmask = pcm990_unmask_irq,
149 static void pcm990_irq_handler(unsigned int irq, struct irq_desc *desc)
151 unsigned long pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
154 GEDR(PCM990_CTRL_INT_IRQ_GPIO) =
155 GPIO_bit(PCM990_CTRL_INT_IRQ_GPIO);
156 if (likely(pending)) {
157 irq = PCM027_IRQ(0) + __ffs(pending);
158 desc = irq_desc + irq;
159 desc_handle_irq(irq, desc);
161 pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
165 static void __init pcm990_init_irq(void)
169 /* setup extra PCM990 irqs */
170 for (irq = PCM027_IRQ(0); irq <= PCM027_IRQ(3); irq++) {
171 set_irq_chip(irq, &pcm990_irq_chip);
172 set_irq_handler(irq, handle_level_irq);
173 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
176 PCM990_INTMSKENA = 0x00; /* disable all Interrupts */
177 PCM990_INTSETCLR = 0xFF;
179 set_irq_chained_handler(PCM990_CTRL_INT_IRQ, pcm990_irq_handler);
180 set_irq_type(PCM990_CTRL_INT_IRQ, PCM990_CTRL_INT_IRQ_EDGE);
183 static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int,
189 * enable GPIO for PXA27x MMC controller
191 pxa_gpio_mode(GPIO32_MMCCLK_MD);
192 pxa_gpio_mode(GPIO112_MMCCMD_MD);
193 pxa_gpio_mode(GPIO92_MMCDAT0_MD);
194 pxa_gpio_mode(GPIO109_MMCDAT1_MD);
195 pxa_gpio_mode(GPIO110_MMCDAT2_MD);
196 pxa_gpio_mode(GPIO111_MMCDAT3_MD);
198 err = request_irq(PCM027_MMCDET_IRQ, mci_detect_int, IRQF_DISABLED,
199 "MMC card detect", data);
201 printk(KERN_ERR "pcm990_mci_init: MMC/SD: can't request MMC "
202 "card detect IRQ\n");
207 static void pcm990_mci_setpower(struct device *dev, unsigned int vdd)
209 struct pxamci_platform_data *p_d = dev->platform_data;
211 if ((1 << vdd) & p_d->ocr_mask)
212 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) =
215 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) =
216 ~PCM990_CTRL_MMC2PWR;
219 static void pcm990_mci_exit(struct device *dev, void *data)
221 free_irq(PCM027_MMCDET_IRQ, data);
224 #define MSECS_PER_JIFFY (1000/HZ)
226 static struct pxamci_platform_data pcm990_mci_platform_data = {
227 .detect_delay = 250 / MSECS_PER_JIFFY,
228 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
229 .init = pcm990_mci_init,
230 .setpower = pcm990_mci_setpower,
231 .exit = pcm990_mci_exit,
235 * init OHCI hardware to work with
237 * Note: Only USB port 1 (host only) is connected
239 * GPIO88 (USBHPWR#1): overcurrent in, overcurrent when low
240 * GPIO89 (USBHPEN#1): power-on out, on when low
242 static int pcm990_ohci_init(struct device *dev)
244 pxa_gpio_mode(PCM990_USB_OVERCURRENT);
245 pxa_gpio_mode(PCM990_USB_PWR_EN);
247 * disable USB port 2 and 3
248 * power sense is active low
250 UHCHR = ((UHCHR) | UHCHR_PCPL | UHCHR_PSPL | UHCHR_SSEP2 |
251 UHCHR_SSEP3) & ~(UHCHR_SSEP1 | UHCHR_SSE);
253 * wait 10ms after Power on
254 * overcurrent per port
255 * power switch per port
257 UHCRHDA = (5<<24) | (1<<11) | (1<<8); /* FIXME: Required? */
262 static struct pxaohci_platform_data pcm990_ohci_platform_data = {
263 .port_mode = PMM_PERPORT_MODE,
264 .init = pcm990_ohci_init,
269 * PXA27x Camera specific stuff
271 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
272 static int pcm990_pxacamera_init(struct device *dev)
274 pxa_gpio_mode(GPIO98_CIF_DD_0_MD);
275 pxa_gpio_mode(GPIO105_CIF_DD_1_MD);
276 pxa_gpio_mode(GPIO104_CIF_DD_2_MD);
277 pxa_gpio_mode(GPIO103_CIF_DD_3_MD);
278 pxa_gpio_mode(GPIO95_CIF_DD_4_MD);
279 pxa_gpio_mode(GPIO94_CIF_DD_5_MD);
280 pxa_gpio_mode(GPIO93_CIF_DD_6_MD);
281 pxa_gpio_mode(GPIO108_CIF_DD_7_MD);
282 pxa_gpio_mode(GPIO107_CIF_DD_8_MD);
283 pxa_gpio_mode(GPIO106_CIF_DD_9_MD);
284 pxa_gpio_mode(GPIO42_CIF_MCLK_MD);
285 pxa_gpio_mode(GPIO45_CIF_PCLK_MD);
286 pxa_gpio_mode(GPIO43_CIF_FV_MD);
287 pxa_gpio_mode(GPIO44_CIF_LV_MD);
293 * CICR4: PCLK_EN: Pixel clock is supplied by the sensor
294 * MCLK_EN: Master clock is generated by PXA
295 * PCP: Data sampled on the falling edge of pixel clock
297 struct pxacamera_platform_data pcm990_pxacamera_platform_data = {
298 .init = pcm990_pxacamera_init,
299 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | PXA_CAMERA_DATAWIDTH_10 |
300 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN/* | PXA_CAMERA_PCP*/,
304 #include <linux/i2c/pca953x.h>
306 static struct pca953x_platform_data pca9536_data = {
307 .gpio_base = NR_BUILTIN_GPIO + 1,
310 static struct soc_camera_link iclink[] = {
312 .bus_id = 0, /* Must match with the camera ID above */
313 .gpio = NR_BUILTIN_GPIO + 1,
315 .bus_id = 0, /* Must match with the camera ID above */
319 /* Board I2C devices. */
320 static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
322 /* Must initialize before the camera(s) */
323 I2C_BOARD_INFO("pca9536", 0x41),
324 .platform_data = &pca9536_data,
326 I2C_BOARD_INFO("mt9v022", 0x48),
327 .platform_data = &iclink[0], /* With extender */
329 I2C_BOARD_INFO("mt9m001", 0x5d),
330 .platform_data = &iclink[0], /* With extender */
333 #endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
337 * Note: The connected AC97 mixer also reports interrupts at PCM990_AC97_IRQ
339 static struct resource pxa27x_ac97_resources[] = {
342 .end = 0x40500000 + 0xfff,
343 .flags = IORESOURCE_MEM,
348 .flags = IORESOURCE_IRQ,
352 static u64 pxa_ac97_dmamask = 0xffffffffUL;
354 static struct platform_device pxa27x_device_ac97 = {
355 .name = "pxa2xx-ac97",
358 .dma_mask = &pxa_ac97_dmamask,
359 .coherent_dma_mask = 0xffffffff,
361 .num_resources = ARRAY_SIZE(pxa27x_ac97_resources),
362 .resource = pxa27x_ac97_resources,
366 * enable generic access to the base board control CPLDs U6 and U7
368 static struct map_desc pcm990_io_desc[] __initdata = {
370 .virtual = PCM990_CTRL_BASE,
371 .pfn = __phys_to_pfn(PCM990_CTRL_PHYS),
372 .length = PCM990_CTRL_SIZE,
373 .type = MT_DEVICE /* CPLD */
375 .virtual = PCM990_CF_PLD_BASE,
376 .pfn = __phys_to_pfn(PCM990_CF_PLD_PHYS),
377 .length = PCM990_CF_PLD_SIZE,
378 .type = MT_DEVICE /* CPLD */
383 * system init for baseboard usage. Will be called by pcm027 init.
385 * Add platform devices present on this baseboard and init
386 * them from CPU side as far as required to use them later on
388 void __init pcm990_baseboard_init(void)
390 /* register CPLD access */
391 iotable_init(pcm990_io_desc, ARRAY_SIZE(pcm990_io_desc));
393 /* register CPLD's IRQ controller */
396 platform_device_register(&pxa27x_device_ac97);
399 pxa_set_mci_info(&pcm990_mci_platform_data);
402 pxa_set_ohci_info(&pcm990_ohci_platform_data);
404 pxa_set_i2c_info(NULL);
406 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
407 pxa_set_camera_info(&pcm990_pxacamera_platform_data);
409 i2c_register_board_info(0, pcm990_i2c_devices,
410 ARRAY_SIZE(pcm990_i2c_devices));
413 printk(KERN_INFO"PCM-990 Evaluation baseboard initialized\n");