blob: 2564e16e4e2f266751ae8447baee385cc16efefc [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 */
22
23#include <linux/irq.h>
24#include <linux/platform_device.h>
25#include <linux/ide.h>
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +020026#include <linux/i2c.h>
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010027#include <linux/pwm_backlight.h>
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +020028
29#include <media/soc_camera.h>
30
31#include <asm/gpio.h>
32#include <asm/arch/i2c.h>
33#include <asm/arch/camera.h>
Robert Schwebel2e927b72008-01-08 08:52:04 +010034#include <asm/mach/map.h>
35#include <asm/arch/pxa-regs.h>
eric miaoa683b142008-03-03 09:44:25 +080036#include <asm/arch/pxa2xx-gpio.h>
Robert Schwebel2e927b72008-01-08 08:52:04 +010037#include <asm/arch/mmc.h>
38#include <asm/arch/ohci.h>
39#include <asm/arch/pcm990_baseboard.h>
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010040#include <asm/arch/pxafb.h>
41
42#include "devices.h"
Robert Schwebel2e927b72008-01-08 08:52:04 +010043
44/*
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010045 * pcm990_lcd_power - control power supply to the LCD
46 * @on: 0 = switch off, 1 = switch on
47 *
48 * Called by the pxafb driver
49 */
50#ifndef CONFIG_PCM990_DISPLAY_NONE
51static void pcm990_lcd_power(int on, struct fb_var_screeninfo *var)
52{
53 if (on) {
54 /* enable LCD-Latches
55 * power on LCD
56 */
57 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG3) =
58 PCM990_CTRL_LCDPWR + PCM990_CTRL_LCDON;
59 } else {
60 /* disable LCD-Latches
61 * power off LCD
62 */
63 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG3) = 0x00;
64 }
65}
66#endif
67
68#if defined(CONFIG_PCM990_DISPLAY_SHARP)
69static struct pxafb_mode_info fb_info_sharp_lq084v1dg21 = {
70 .pixclock = 28000,
71 .xres = 640,
72 .yres = 480,
73 .bpp = 16,
74 .hsync_len = 20,
75 .left_margin = 103,
76 .right_margin = 47,
77 .vsync_len = 6,
78 .upper_margin = 28,
79 .lower_margin = 5,
80 .sync = 0,
81 .cmap_greyscale = 0,
82};
83
84static struct pxafb_mach_info pcm990_fbinfo __initdata = {
85 .modes = &fb_info_sharp_lq084v1dg21,
86 .num_modes = 1,
87 .lccr0 = LCCR0_PAS,
88 .lccr3 = LCCR3_PCP,
89 .pxafb_lcd_power = pcm990_lcd_power,
90};
91#elif defined(CONFIG_PCM990_DISPLAY_NEC)
92struct pxafb_mode_info fb_info_nec_nl6448bc20_18d = {
93 .pixclock = 39720,
94 .xres = 640,
95 .yres = 480,
96 .bpp = 16,
97 .hsync_len = 32,
98 .left_margin = 16,
99 .right_margin = 48,
100 .vsync_len = 2,
101 .upper_margin = 12,
102 .lower_margin = 17,
103 .sync = 0,
104 .cmap_greyscale = 0,
105};
106
107static struct pxafb_mach_info pcm990_fbinfo __initdata = {
108 .modes = &fb_info_nec_nl6448bc20_18d,
109 .num_modes = 1,
110 .lccr0 = LCCR0_Act,
111 .lccr3 = LCCR3_PixFlEdg,
112 .pxafb_lcd_power = pcm990_lcd_power,
113};
114#endif
115
116static struct platform_pwm_backlight_data pcm990_backlight_data = {
117 .pwm_id = 0,
118 .max_brightness = 1023,
119 .dft_brightness = 1023,
120 .pwm_period_ns = 78770,
121};
122
123static struct platform_device pcm990_backlight_device = {
124 .name = "pwm-backlight",
125 .dev = {
126 .parent = &pxa27x_device_pwm0.dev,
127 .platform_data = &pcm990_backlight_data,
128 },
129};
130
131/*
132 * The PCM-990 development baseboard uses PCM-027's hardware in the
Robert Schwebel2e927b72008-01-08 08:52:04 +0100133 * following way:
134 *
135 * - LCD support is in use
136 * - GPIO16 is output for back light on/off with PWM
137 * - GPIO58 ... GPIO73 are outputs for display data
138 * - GPIO74 is output output for LCDFCLK
139 * - GPIO75 is output for LCDLCLK
140 * - GPIO76 is output for LCDPCLK
141 * - GPIO77 is output for LCDBIAS
142 * - MMC support is in use
143 * - GPIO32 is output for MMCCLK
144 * - GPIO92 is MMDAT0
145 * - GPIO109 is MMDAT1
146 * - GPIO110 is MMCS0
147 * - GPIO111 is MMCS1
148 * - GPIO112 is MMCMD
149 * - IDE/CF card is in use
150 * - GPIO48 is output /POE
151 * - GPIO49 is output /PWE
152 * - GPIO50 is output /PIOR
153 * - GPIO51 is output /PIOW
154 * - GPIO54 is output /PCE2
155 * - GPIO55 is output /PREG
156 * - GPIO56 is input /PWAIT
157 * - GPIO57 is output /PIOS16
158 * - GPIO79 is output PSKTSEL
159 * - GPIO85 is output /PCE1
160 * - FFUART is in use
161 * - GPIO34 is input FFRXD
162 * - GPIO35 is input FFCTS
163 * - GPIO36 is input FFDCD
164 * - GPIO37 is input FFDSR
165 * - GPIO38 is input FFRI
166 * - GPIO39 is output FFTXD
167 * - GPIO40 is output FFDTR
168 * - GPIO41 is output FFRTS
169 * - BTUART is in use
170 * - GPIO42 is input BTRXD
171 * - GPIO43 is output BTTXD
172 * - GPIO44 is input BTCTS
173 * - GPIO45 is output BTRTS
174 * - IRUART is in use
175 * - GPIO46 is input STDRXD
176 * - GPIO47 is output STDTXD
177 * - AC97 is in use*)
178 * - GPIO28 is input AC97CLK
179 * - GPIO29 is input AC97DatIn
180 * - GPIO30 is output AC97DatO
181 * - GPIO31 is output AC97SYNC
182 * - GPIO113 is output AC97_RESET
183 * - SSP is in use
184 * - GPIO23 is output SSPSCLK
185 * - GPIO24 is output chip select to Max7301
186 * - GPIO25 is output SSPTXD
187 * - GPIO26 is input SSPRXD
188 * - GPIO27 is input for Max7301 IRQ
189 * - GPIO53 is input SSPSYSCLK
190 * - SSP3 is in use
191 * - GPIO81 is output SSPTXD3
192 * - GPIO82 is input SSPRXD3
193 * - GPIO83 is output SSPSFRM
194 * - GPIO84 is output SSPCLK3
195 *
196 * Otherwise claimed GPIOs:
197 * GPIO1 -> IRQ from user switch
198 * GPIO9 -> IRQ from power management
199 * GPIO10 -> IRQ from WML9712 AC97 controller
200 * GPIO11 -> IRQ from IDE controller
201 * GPIO12 -> IRQ from CF controller
202 * GPIO13 -> IRQ from CF controller
203 * GPIO14 -> GPIO free
204 * GPIO15 -> /CS1 selects baseboard's Control CPLD (U7, 16 bit wide data path)
205 * GPIO19 -> GPIO free
206 * GPIO20 -> /SDCS2
207 * GPIO21 -> /CS3 PC card socket select
208 * GPIO33 -> /CS5 network controller select
209 * GPIO78 -> /CS2 (16 bit wide data path)
210 * GPIO80 -> /CS4 (16 bit wide data path)
211 * GPIO86 -> GPIO free
212 * GPIO87 -> GPIO free
213 * GPIO90 -> LED0 on CPU module
214 * GPIO91 -> LED1 on CPI module
215 * GPIO117 -> SCL
216 * GPIO118 -> SDA
217 */
218
219static unsigned long pcm990_irq_enabled;
220
221static void pcm990_mask_ack_irq(unsigned int irq)
222{
223 int pcm990_irq = (irq - PCM027_IRQ(0));
224 PCM990_INTMSKENA = (pcm990_irq_enabled &= ~(1 << pcm990_irq));
225}
226
227static void pcm990_unmask_irq(unsigned int irq)
228{
229 int pcm990_irq = (irq - PCM027_IRQ(0));
230 /* the irq can be acknowledged only if deasserted, so it's done here */
231 PCM990_INTSETCLR |= 1 << pcm990_irq;
232 PCM990_INTMSKENA = (pcm990_irq_enabled |= (1 << pcm990_irq));
233}
234
235static struct irq_chip pcm990_irq_chip = {
236 .mask_ack = pcm990_mask_ack_irq,
237 .unmask = pcm990_unmask_irq,
238};
239
240static void pcm990_irq_handler(unsigned int irq, struct irq_desc *desc)
241{
242 unsigned long pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
243
244 do {
245 GEDR(PCM990_CTRL_INT_IRQ_GPIO) =
246 GPIO_bit(PCM990_CTRL_INT_IRQ_GPIO);
247 if (likely(pending)) {
248 irq = PCM027_IRQ(0) + __ffs(pending);
249 desc = irq_desc + irq;
250 desc_handle_irq(irq, desc);
251 }
252 pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
253 } while (pending);
254}
255
256static void __init pcm990_init_irq(void)
257{
258 int irq;
259
260 /* setup extra PCM990 irqs */
261 for (irq = PCM027_IRQ(0); irq <= PCM027_IRQ(3); irq++) {
262 set_irq_chip(irq, &pcm990_irq_chip);
263 set_irq_handler(irq, handle_level_irq);
264 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
265 }
266
267 PCM990_INTMSKENA = 0x00; /* disable all Interrupts */
268 PCM990_INTSETCLR = 0xFF;
269
270 set_irq_chained_handler(PCM990_CTRL_INT_IRQ, pcm990_irq_handler);
271 set_irq_type(PCM990_CTRL_INT_IRQ, PCM990_CTRL_INT_IRQ_EDGE);
272}
273
274static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int,
275 void *data)
276{
277 int err;
278
279 /*
280 * enable GPIO for PXA27x MMC controller
281 */
282 pxa_gpio_mode(GPIO32_MMCCLK_MD);
283 pxa_gpio_mode(GPIO112_MMCCMD_MD);
284 pxa_gpio_mode(GPIO92_MMCDAT0_MD);
285 pxa_gpio_mode(GPIO109_MMCDAT1_MD);
286 pxa_gpio_mode(GPIO110_MMCDAT2_MD);
287 pxa_gpio_mode(GPIO111_MMCDAT3_MD);
288
289 err = request_irq(PCM027_MMCDET_IRQ, mci_detect_int, IRQF_DISABLED,
290 "MMC card detect", data);
291 if (err)
292 printk(KERN_ERR "pcm990_mci_init: MMC/SD: can't request MMC "
293 "card detect IRQ\n");
294
295 return err;
296}
297
298static void pcm990_mci_setpower(struct device *dev, unsigned int vdd)
299{
300 struct pxamci_platform_data *p_d = dev->platform_data;
301
302 if ((1 << vdd) & p_d->ocr_mask)
303 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) =
304 PCM990_CTRL_MMC2PWR;
305 else
306 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) =
307 ~PCM990_CTRL_MMC2PWR;
308}
309
310static void pcm990_mci_exit(struct device *dev, void *data)
311{
312 free_irq(PCM027_MMCDET_IRQ, data);
313}
314
315#define MSECS_PER_JIFFY (1000/HZ)
316
317static struct pxamci_platform_data pcm990_mci_platform_data = {
318 .detect_delay = 250 / MSECS_PER_JIFFY,
319 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
320 .init = pcm990_mci_init,
321 .setpower = pcm990_mci_setpower,
322 .exit = pcm990_mci_exit,
323};
324
325/*
326 * init OHCI hardware to work with
327 *
328 * Note: Only USB port 1 (host only) is connected
329 *
330 * GPIO88 (USBHPWR#1): overcurrent in, overcurrent when low
331 * GPIO89 (USBHPEN#1): power-on out, on when low
332 */
333static int pcm990_ohci_init(struct device *dev)
334{
335 pxa_gpio_mode(PCM990_USB_OVERCURRENT);
336 pxa_gpio_mode(PCM990_USB_PWR_EN);
337 /*
338 * disable USB port 2 and 3
339 * power sense is active low
340 */
341 UHCHR = ((UHCHR) | UHCHR_PCPL | UHCHR_PSPL | UHCHR_SSEP2 |
342 UHCHR_SSEP3) & ~(UHCHR_SSEP1 | UHCHR_SSE);
343 /*
344 * wait 10ms after Power on
345 * overcurrent per port
346 * power switch per port
347 */
348 UHCRHDA = (5<<24) | (1<<11) | (1<<8); /* FIXME: Required? */
349
350 return 0;
351}
352
353static struct pxaohci_platform_data pcm990_ohci_platform_data = {
354 .port_mode = PMM_PERPORT_MODE,
355 .init = pcm990_ohci_init,
356 .exit = NULL,
357};
358
359/*
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200360 * PXA27x Camera specific stuff
361 */
362#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
363static int pcm990_pxacamera_init(struct device *dev)
364{
365 pxa_gpio_mode(GPIO98_CIF_DD_0_MD);
366 pxa_gpio_mode(GPIO105_CIF_DD_1_MD);
367 pxa_gpio_mode(GPIO104_CIF_DD_2_MD);
368 pxa_gpio_mode(GPIO103_CIF_DD_3_MD);
369 pxa_gpio_mode(GPIO95_CIF_DD_4_MD);
370 pxa_gpio_mode(GPIO94_CIF_DD_5_MD);
371 pxa_gpio_mode(GPIO93_CIF_DD_6_MD);
372 pxa_gpio_mode(GPIO108_CIF_DD_7_MD);
373 pxa_gpio_mode(GPIO107_CIF_DD_8_MD);
374 pxa_gpio_mode(GPIO106_CIF_DD_9_MD);
375 pxa_gpio_mode(GPIO42_CIF_MCLK_MD);
376 pxa_gpio_mode(GPIO45_CIF_PCLK_MD);
377 pxa_gpio_mode(GPIO43_CIF_FV_MD);
378 pxa_gpio_mode(GPIO44_CIF_LV_MD);
379
380 return 0;
381}
382
383/*
384 * CICR4: PCLK_EN: Pixel clock is supplied by the sensor
385 * MCLK_EN: Master clock is generated by PXA
386 * PCP: Data sampled on the falling edge of pixel clock
387 */
388struct pxacamera_platform_data pcm990_pxacamera_platform_data = {
389 .init = pcm990_pxacamera_init,
390 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | PXA_CAMERA_DATAWIDTH_10 |
391 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN/* | PXA_CAMERA_PCP*/,
392 .mclk_10khz = 1000,
393};
394
395#include <linux/i2c/pca953x.h>
396
397static struct pca953x_platform_data pca9536_data = {
398 .gpio_base = NR_BUILTIN_GPIO + 1,
399};
400
401static struct soc_camera_link iclink[] = {
402 {
403 .bus_id = 0, /* Must match with the camera ID above */
404 .gpio = NR_BUILTIN_GPIO + 1,
405 }, {
406 .bus_id = 0, /* Must match with the camera ID above */
407 }
408};
409
410/* Board I2C devices. */
411static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
412 {
413 /* Must initialize before the camera(s) */
Jean Delvare3760f732008-04-29 23:11:40 +0200414 I2C_BOARD_INFO("pca9536", 0x41),
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200415 .platform_data = &pca9536_data,
416 }, {
417 I2C_BOARD_INFO("mt9v022", 0x48),
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200418 .platform_data = &iclink[0], /* With extender */
419 }, {
420 I2C_BOARD_INFO("mt9m001", 0x5d),
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200421 .platform_data = &iclink[0], /* With extender */
422 },
423};
424#endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
425
426/*
Robert Schwebel2e927b72008-01-08 08:52:04 +0100427 * AC97 support
428 * Note: The connected AC97 mixer also reports interrupts at PCM990_AC97_IRQ
429 */
430static struct resource pxa27x_ac97_resources[] = {
431 [0] = {
432 .start = 0x40500000,
433 .end = 0x40500000 + 0xfff,
434 .flags = IORESOURCE_MEM,
435 },
436 [1] = {
437 .start = IRQ_AC97,
438 .end = IRQ_AC97,
439 .flags = IORESOURCE_IRQ,
440 },
441};
442
443static u64 pxa_ac97_dmamask = 0xffffffffUL;
444
445static struct platform_device pxa27x_device_ac97 = {
446 .name = "pxa2xx-ac97",
447 .id = -1,
448 .dev = {
449 .dma_mask = &pxa_ac97_dmamask,
450 .coherent_dma_mask = 0xffffffff,
451 },
452 .num_resources = ARRAY_SIZE(pxa27x_ac97_resources),
453 .resource = pxa27x_ac97_resources,
454};
455
456/*
457 * enable generic access to the base board control CPLDs U6 and U7
458 */
459static struct map_desc pcm990_io_desc[] __initdata = {
460 {
461 .virtual = PCM990_CTRL_BASE,
462 .pfn = __phys_to_pfn(PCM990_CTRL_PHYS),
463 .length = PCM990_CTRL_SIZE,
464 .type = MT_DEVICE /* CPLD */
465 }, {
466 .virtual = PCM990_CF_PLD_BASE,
467 .pfn = __phys_to_pfn(PCM990_CF_PLD_PHYS),
468 .length = PCM990_CF_PLD_SIZE,
469 .type = MT_DEVICE /* CPLD */
470 }
471};
472
473/*
474 * system init for baseboard usage. Will be called by pcm027 init.
475 *
476 * Add platform devices present on this baseboard and init
477 * them from CPU side as far as required to use them later on
478 */
479void __init pcm990_baseboard_init(void)
480{
481 /* register CPLD access */
482 iotable_init(pcm990_io_desc, ARRAY_SIZE(pcm990_io_desc));
483
484 /* register CPLD's IRQ controller */
485 pcm990_init_irq();
486
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100487#ifndef CONFIG_PCM990_DISPLAY_NONE
488 set_pxa_fb_info(&pcm990_fbinfo);
489#endif
490 pxa_gpio_mode(GPIO16_PWM0_MD);
491 platform_device_register(&pcm990_backlight_device);
492
Robert Schwebel2e927b72008-01-08 08:52:04 +0100493 platform_device_register(&pxa27x_device_ac97);
494
495 /* MMC */
496 pxa_set_mci_info(&pcm990_mci_platform_data);
497
498 /* USB host */
499 pxa_set_ohci_info(&pcm990_ohci_platform_data);
500
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200501 pxa_set_i2c_info(NULL);
502
503#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
504 pxa_set_camera_info(&pcm990_pxacamera_platform_data);
505
506 i2c_register_board_info(0, pcm990_i2c_devices,
507 ARRAY_SIZE(pcm990_i2c_devices));
508#endif
509
Robert Schwebel2e927b72008-01-08 08:52:04 +0100510 printk(KERN_INFO"PCM-990 Evaluation baseboard initialized\n");
511}