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