blob: 1e7515452285214b56ba0c9354cc153346a7fc3b [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>
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +020025#include <linux/i2c.h>
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010026#include <linux/pwm_backlight.h>
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +020027
28#include <media/soc_camera.h>
29
30#include <asm/gpio.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010031#include <mach/i2c.h>
32#include <mach/camera.h>
Robert Schwebel2e927b72008-01-08 08:52:04 +010033#include <asm/mach/map.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010034#include <mach/pxa-regs.h>
35#include <mach/audio.h>
36#include <mach/mmc.h>
37#include <mach/ohci.h>
38#include <mach/pcm990_baseboard.h>
39#include <mach/pxafb.h>
40#include <mach/mfp-pxa27x.h>
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010041
42#include "devices.h"
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +010043#include "generic.h"
44
45static unsigned long pcm990_pin_config[] __initdata = {
46 /* MMC */
47 GPIO32_MMC_CLK,
48 GPIO112_MMC_CMD,
49 GPIO92_MMC_DAT_0,
50 GPIO109_MMC_DAT_1,
51 GPIO110_MMC_DAT_2,
52 GPIO111_MMC_DAT_3,
53 /* USB */
54 GPIO88_USBH1_PWR,
55 GPIO89_USBH1_PEN,
56 /* PWM0 */
57 GPIO16_PWM0_OUT,
Eric Miao6f584cf2008-11-28 16:00:24 +080058
59 /* I2C */
60 GPIO117_I2C_SCL,
61 GPIO118_I2C_SDA,
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +010062};
Robert Schwebel2e927b72008-01-08 08:52:04 +010063
64/*
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +010065 * pcm990_lcd_power - control power supply to the LCD
66 * @on: 0 = switch off, 1 = switch on
67 *
68 * Called by the pxafb driver
69 */
70#ifndef CONFIG_PCM990_DISPLAY_NONE
71static void pcm990_lcd_power(int on, struct fb_var_screeninfo *var)
72{
73 if (on) {
74 /* enable LCD-Latches
75 * power on LCD
76 */
77 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG3) =
78 PCM990_CTRL_LCDPWR + PCM990_CTRL_LCDON;
79 } else {
80 /* disable LCD-Latches
81 * power off LCD
82 */
83 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG3) = 0x00;
84 }
85}
86#endif
87
88#if defined(CONFIG_PCM990_DISPLAY_SHARP)
89static struct pxafb_mode_info fb_info_sharp_lq084v1dg21 = {
90 .pixclock = 28000,
91 .xres = 640,
92 .yres = 480,
93 .bpp = 16,
94 .hsync_len = 20,
95 .left_margin = 103,
96 .right_margin = 47,
97 .vsync_len = 6,
98 .upper_margin = 28,
99 .lower_margin = 5,
100 .sync = 0,
101 .cmap_greyscale = 0,
102};
103
104static struct pxafb_mach_info pcm990_fbinfo __initdata = {
105 .modes = &fb_info_sharp_lq084v1dg21,
106 .num_modes = 1,
107 .lccr0 = LCCR0_PAS,
108 .lccr3 = LCCR3_PCP,
109 .pxafb_lcd_power = pcm990_lcd_power,
110};
111#elif defined(CONFIG_PCM990_DISPLAY_NEC)
112struct pxafb_mode_info fb_info_nec_nl6448bc20_18d = {
113 .pixclock = 39720,
114 .xres = 640,
115 .yres = 480,
116 .bpp = 16,
117 .hsync_len = 32,
118 .left_margin = 16,
119 .right_margin = 48,
120 .vsync_len = 2,
121 .upper_margin = 12,
122 .lower_margin = 17,
123 .sync = 0,
124 .cmap_greyscale = 0,
125};
126
127static struct pxafb_mach_info pcm990_fbinfo __initdata = {
128 .modes = &fb_info_nec_nl6448bc20_18d,
129 .num_modes = 1,
130 .lccr0 = LCCR0_Act,
131 .lccr3 = LCCR3_PixFlEdg,
132 .pxafb_lcd_power = pcm990_lcd_power,
133};
134#endif
135
136static struct platform_pwm_backlight_data pcm990_backlight_data = {
137 .pwm_id = 0,
138 .max_brightness = 1023,
139 .dft_brightness = 1023,
140 .pwm_period_ns = 78770,
141};
142
143static struct platform_device pcm990_backlight_device = {
144 .name = "pwm-backlight",
145 .dev = {
146 .parent = &pxa27x_device_pwm0.dev,
147 .platform_data = &pcm990_backlight_data,
148 },
149};
150
151/*
152 * The PCM-990 development baseboard uses PCM-027's hardware in the
Robert Schwebel2e927b72008-01-08 08:52:04 +0100153 * following way:
154 *
155 * - LCD support is in use
156 * - GPIO16 is output for back light on/off with PWM
157 * - GPIO58 ... GPIO73 are outputs for display data
158 * - GPIO74 is output output for LCDFCLK
159 * - GPIO75 is output for LCDLCLK
160 * - GPIO76 is output for LCDPCLK
161 * - GPIO77 is output for LCDBIAS
162 * - MMC support is in use
163 * - GPIO32 is output for MMCCLK
164 * - GPIO92 is MMDAT0
165 * - GPIO109 is MMDAT1
166 * - GPIO110 is MMCS0
167 * - GPIO111 is MMCS1
168 * - GPIO112 is MMCMD
169 * - IDE/CF card is in use
170 * - GPIO48 is output /POE
171 * - GPIO49 is output /PWE
172 * - GPIO50 is output /PIOR
173 * - GPIO51 is output /PIOW
174 * - GPIO54 is output /PCE2
175 * - GPIO55 is output /PREG
176 * - GPIO56 is input /PWAIT
177 * - GPIO57 is output /PIOS16
178 * - GPIO79 is output PSKTSEL
179 * - GPIO85 is output /PCE1
180 * - FFUART is in use
181 * - GPIO34 is input FFRXD
182 * - GPIO35 is input FFCTS
183 * - GPIO36 is input FFDCD
184 * - GPIO37 is input FFDSR
185 * - GPIO38 is input FFRI
186 * - GPIO39 is output FFTXD
187 * - GPIO40 is output FFDTR
188 * - GPIO41 is output FFRTS
189 * - BTUART is in use
190 * - GPIO42 is input BTRXD
191 * - GPIO43 is output BTTXD
192 * - GPIO44 is input BTCTS
193 * - GPIO45 is output BTRTS
194 * - IRUART is in use
195 * - GPIO46 is input STDRXD
196 * - GPIO47 is output STDTXD
197 * - AC97 is in use*)
198 * - GPIO28 is input AC97CLK
199 * - GPIO29 is input AC97DatIn
200 * - GPIO30 is output AC97DatO
201 * - GPIO31 is output AC97SYNC
202 * - GPIO113 is output AC97_RESET
203 * - SSP is in use
204 * - GPIO23 is output SSPSCLK
205 * - GPIO24 is output chip select to Max7301
206 * - GPIO25 is output SSPTXD
207 * - GPIO26 is input SSPRXD
208 * - GPIO27 is input for Max7301 IRQ
209 * - GPIO53 is input SSPSYSCLK
210 * - SSP3 is in use
211 * - GPIO81 is output SSPTXD3
212 * - GPIO82 is input SSPRXD3
213 * - GPIO83 is output SSPSFRM
214 * - GPIO84 is output SSPCLK3
215 *
216 * Otherwise claimed GPIOs:
217 * GPIO1 -> IRQ from user switch
218 * GPIO9 -> IRQ from power management
219 * GPIO10 -> IRQ from WML9712 AC97 controller
220 * GPIO11 -> IRQ from IDE controller
221 * GPIO12 -> IRQ from CF controller
222 * GPIO13 -> IRQ from CF controller
223 * GPIO14 -> GPIO free
224 * GPIO15 -> /CS1 selects baseboard's Control CPLD (U7, 16 bit wide data path)
225 * GPIO19 -> GPIO free
226 * GPIO20 -> /SDCS2
227 * GPIO21 -> /CS3 PC card socket select
228 * GPIO33 -> /CS5 network controller select
229 * GPIO78 -> /CS2 (16 bit wide data path)
230 * GPIO80 -> /CS4 (16 bit wide data path)
231 * GPIO86 -> GPIO free
232 * GPIO87 -> GPIO free
233 * GPIO90 -> LED0 on CPU module
234 * GPIO91 -> LED1 on CPI module
235 * GPIO117 -> SCL
236 * GPIO118 -> SDA
237 */
238
239static unsigned long pcm990_irq_enabled;
240
241static void pcm990_mask_ack_irq(unsigned int irq)
242{
243 int pcm990_irq = (irq - PCM027_IRQ(0));
244 PCM990_INTMSKENA = (pcm990_irq_enabled &= ~(1 << pcm990_irq));
245}
246
247static void pcm990_unmask_irq(unsigned int irq)
248{
249 int pcm990_irq = (irq - PCM027_IRQ(0));
250 /* the irq can be acknowledged only if deasserted, so it's done here */
251 PCM990_INTSETCLR |= 1 << pcm990_irq;
252 PCM990_INTMSKENA = (pcm990_irq_enabled |= (1 << pcm990_irq));
253}
254
255static struct irq_chip pcm990_irq_chip = {
256 .mask_ack = pcm990_mask_ack_irq,
257 .unmask = pcm990_unmask_irq,
258};
259
260static void pcm990_irq_handler(unsigned int irq, struct irq_desc *desc)
261{
262 unsigned long pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
263
264 do {
265 GEDR(PCM990_CTRL_INT_IRQ_GPIO) =
266 GPIO_bit(PCM990_CTRL_INT_IRQ_GPIO);
267 if (likely(pending)) {
268 irq = PCM027_IRQ(0) + __ffs(pending);
Dmitry Baryshkovd8aa0252008-10-09 13:36:24 +0100269 generic_handle_irq(irq);
Robert Schwebel2e927b72008-01-08 08:52:04 +0100270 }
271 pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
272 } while (pending);
273}
274
275static void __init pcm990_init_irq(void)
276{
277 int irq;
278
279 /* setup extra PCM990 irqs */
280 for (irq = PCM027_IRQ(0); irq <= PCM027_IRQ(3); irq++) {
281 set_irq_chip(irq, &pcm990_irq_chip);
282 set_irq_handler(irq, handle_level_irq);
283 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
284 }
285
286 PCM990_INTMSKENA = 0x00; /* disable all Interrupts */
287 PCM990_INTSETCLR = 0xFF;
288
289 set_irq_chained_handler(PCM990_CTRL_INT_IRQ, pcm990_irq_handler);
290 set_irq_type(PCM990_CTRL_INT_IRQ, PCM990_CTRL_INT_IRQ_EDGE);
291}
292
293static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int,
294 void *data)
295{
296 int err;
297
Robert Schwebel2e927b72008-01-08 08:52:04 +0100298 err = request_irq(PCM027_MMCDET_IRQ, mci_detect_int, IRQF_DISABLED,
299 "MMC card detect", data);
300 if (err)
301 printk(KERN_ERR "pcm990_mci_init: MMC/SD: can't request MMC "
302 "card detect IRQ\n");
303
304 return err;
305}
306
307static void pcm990_mci_setpower(struct device *dev, unsigned int vdd)
308{
309 struct pxamci_platform_data *p_d = dev->platform_data;
310
311 if ((1 << vdd) & p_d->ocr_mask)
312 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) =
313 PCM990_CTRL_MMC2PWR;
314 else
315 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) =
316 ~PCM990_CTRL_MMC2PWR;
317}
318
319static void pcm990_mci_exit(struct device *dev, void *data)
320{
321 free_irq(PCM027_MMCDET_IRQ, data);
322}
323
324#define MSECS_PER_JIFFY (1000/HZ)
325
326static struct pxamci_platform_data pcm990_mci_platform_data = {
327 .detect_delay = 250 / MSECS_PER_JIFFY,
328 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
329 .init = pcm990_mci_init,
330 .setpower = pcm990_mci_setpower,
331 .exit = pcm990_mci_exit,
332};
333
Robert Schwebel2e927b72008-01-08 08:52:04 +0100334static struct pxaohci_platform_data pcm990_ohci_platform_data = {
335 .port_mode = PMM_PERPORT_MODE,
Eric Miao097b5332008-09-27 15:49:57 +0800336 .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
337 .power_on_delay = 10,
Robert Schwebel2e927b72008-01-08 08:52:04 +0100338};
339
340/*
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200341 * PXA27x Camera specific stuff
342 */
343#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100344static unsigned long pcm990_camera_pin_config[] = {
345 /* CIF */
346 GPIO98_CIF_DD_0,
347 GPIO105_CIF_DD_1,
348 GPIO104_CIF_DD_2,
349 GPIO103_CIF_DD_3,
350 GPIO95_CIF_DD_4,
351 GPIO94_CIF_DD_5,
352 GPIO93_CIF_DD_6,
353 GPIO108_CIF_DD_7,
354 GPIO107_CIF_DD_8,
355 GPIO106_CIF_DD_9,
356 GPIO42_CIF_MCLK,
357 GPIO45_CIF_PCLK,
358 GPIO43_CIF_FV,
359 GPIO44_CIF_LV,
360};
361
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200362static int pcm990_pxacamera_init(struct device *dev)
363{
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100364 pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_camera_pin_config));
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200365 return 0;
366}
367
368/*
369 * CICR4: PCLK_EN: Pixel clock is supplied by the sensor
370 * MCLK_EN: Master clock is generated by PXA
371 * PCP: Data sampled on the falling edge of pixel clock
372 */
373struct pxacamera_platform_data pcm990_pxacamera_platform_data = {
374 .init = pcm990_pxacamera_init,
375 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | PXA_CAMERA_DATAWIDTH_10 |
376 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN/* | PXA_CAMERA_PCP*/,
377 .mclk_10khz = 1000,
378};
379
380#include <linux/i2c/pca953x.h>
381
382static struct pca953x_platform_data pca9536_data = {
383 .gpio_base = NR_BUILTIN_GPIO + 1,
384};
385
386static struct soc_camera_link iclink[] = {
387 {
388 .bus_id = 0, /* Must match with the camera ID above */
389 .gpio = NR_BUILTIN_GPIO + 1,
390 }, {
391 .bus_id = 0, /* Must match with the camera ID above */
392 }
393};
394
395/* Board I2C devices. */
396static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
397 {
398 /* Must initialize before the camera(s) */
Jean Delvare3760f732008-04-29 23:11:40 +0200399 I2C_BOARD_INFO("pca9536", 0x41),
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200400 .platform_data = &pca9536_data,
401 }, {
402 I2C_BOARD_INFO("mt9v022", 0x48),
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200403 .platform_data = &iclink[0], /* With extender */
404 }, {
405 I2C_BOARD_INFO("mt9m001", 0x5d),
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200406 .platform_data = &iclink[0], /* With extender */
407 },
408};
409#endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
410
411/*
Robert Schwebel2e927b72008-01-08 08:52:04 +0100412 * enable generic access to the base board control CPLDs U6 and U7
413 */
414static struct map_desc pcm990_io_desc[] __initdata = {
415 {
416 .virtual = PCM990_CTRL_BASE,
417 .pfn = __phys_to_pfn(PCM990_CTRL_PHYS),
418 .length = PCM990_CTRL_SIZE,
419 .type = MT_DEVICE /* CPLD */
420 }, {
421 .virtual = PCM990_CF_PLD_BASE,
422 .pfn = __phys_to_pfn(PCM990_CF_PLD_PHYS),
423 .length = PCM990_CF_PLD_SIZE,
424 .type = MT_DEVICE /* CPLD */
425 }
426};
427
428/*
429 * system init for baseboard usage. Will be called by pcm027 init.
430 *
431 * Add platform devices present on this baseboard and init
432 * them from CPU side as far as required to use them later on
433 */
434void __init pcm990_baseboard_init(void)
435{
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100436 pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_pin_config));
437
Robert Schwebel2e927b72008-01-08 08:52:04 +0100438 /* register CPLD access */
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100439 iotable_init(ARRAY_AND_SIZE(pcm990_io_desc));
Robert Schwebel2e927b72008-01-08 08:52:04 +0100440
441 /* register CPLD's IRQ controller */
442 pcm990_init_irq();
443
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100444#ifndef CONFIG_PCM990_DISPLAY_NONE
445 set_pxa_fb_info(&pcm990_fbinfo);
446#endif
Guennadi Liakhovetskic0f7edb2008-06-13 11:50:44 +0100447 platform_device_register(&pcm990_backlight_device);
448
Robert Schwebel2e927b72008-01-08 08:52:04 +0100449 /* MMC */
450 pxa_set_mci_info(&pcm990_mci_platform_data);
451
452 /* USB host */
453 pxa_set_ohci_info(&pcm990_ohci_platform_data);
454
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200455 pxa_set_i2c_info(NULL);
Mark Brown9f19d632008-06-10 12:30:05 +0100456 pxa_set_ac97_info(NULL);
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200457
458#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
459 pxa_set_camera_info(&pcm990_pxacamera_platform_data);
460
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100461 i2c_register_board_info(0, ARRAY_AND_SIZE(pcm990_i2c_devices));
Guennadi Liakhovetski58762e772008-04-06 23:08:15 +0200462#endif
463
Guennadi Liakhovetski6a566fb2008-06-16 08:16:46 +0100464 printk(KERN_INFO "PCM-990 Evaluation baseboard initialized\n");
Robert Schwebel2e927b72008-01-08 08:52:04 +0100465}