blob: 20b2974e39604b03947a9b79e754ecaf20709213 [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>
26#include <asm/mach/map.h>
27#include <asm/arch/pxa-regs.h>
eric miaoa683b142008-03-03 09:44:25 +080028#include <asm/arch/pxa2xx-gpio.h>
Robert Schwebel2e927b72008-01-08 08:52:04 +010029#include <asm/arch/mmc.h>
30#include <asm/arch/ohci.h>
31#include <asm/arch/pcm990_baseboard.h>
32
33/*
34 * The PCM-990 development baseboard uses PCM-027's hardeware in the
35 * following way:
36 *
37 * - LCD support is in use
38 * - GPIO16 is output for back light on/off with PWM
39 * - GPIO58 ... GPIO73 are outputs for display data
40 * - GPIO74 is output output for LCDFCLK
41 * - GPIO75 is output for LCDLCLK
42 * - GPIO76 is output for LCDPCLK
43 * - GPIO77 is output for LCDBIAS
44 * - MMC support is in use
45 * - GPIO32 is output for MMCCLK
46 * - GPIO92 is MMDAT0
47 * - GPIO109 is MMDAT1
48 * - GPIO110 is MMCS0
49 * - GPIO111 is MMCS1
50 * - GPIO112 is MMCMD
51 * - IDE/CF card is in use
52 * - GPIO48 is output /POE
53 * - GPIO49 is output /PWE
54 * - GPIO50 is output /PIOR
55 * - GPIO51 is output /PIOW
56 * - GPIO54 is output /PCE2
57 * - GPIO55 is output /PREG
58 * - GPIO56 is input /PWAIT
59 * - GPIO57 is output /PIOS16
60 * - GPIO79 is output PSKTSEL
61 * - GPIO85 is output /PCE1
62 * - FFUART is in use
63 * - GPIO34 is input FFRXD
64 * - GPIO35 is input FFCTS
65 * - GPIO36 is input FFDCD
66 * - GPIO37 is input FFDSR
67 * - GPIO38 is input FFRI
68 * - GPIO39 is output FFTXD
69 * - GPIO40 is output FFDTR
70 * - GPIO41 is output FFRTS
71 * - BTUART is in use
72 * - GPIO42 is input BTRXD
73 * - GPIO43 is output BTTXD
74 * - GPIO44 is input BTCTS
75 * - GPIO45 is output BTRTS
76 * - IRUART is in use
77 * - GPIO46 is input STDRXD
78 * - GPIO47 is output STDTXD
79 * - AC97 is in use*)
80 * - GPIO28 is input AC97CLK
81 * - GPIO29 is input AC97DatIn
82 * - GPIO30 is output AC97DatO
83 * - GPIO31 is output AC97SYNC
84 * - GPIO113 is output AC97_RESET
85 * - SSP is in use
86 * - GPIO23 is output SSPSCLK
87 * - GPIO24 is output chip select to Max7301
88 * - GPIO25 is output SSPTXD
89 * - GPIO26 is input SSPRXD
90 * - GPIO27 is input for Max7301 IRQ
91 * - GPIO53 is input SSPSYSCLK
92 * - SSP3 is in use
93 * - GPIO81 is output SSPTXD3
94 * - GPIO82 is input SSPRXD3
95 * - GPIO83 is output SSPSFRM
96 * - GPIO84 is output SSPCLK3
97 *
98 * Otherwise claimed GPIOs:
99 * GPIO1 -> IRQ from user switch
100 * GPIO9 -> IRQ from power management
101 * GPIO10 -> IRQ from WML9712 AC97 controller
102 * GPIO11 -> IRQ from IDE controller
103 * GPIO12 -> IRQ from CF controller
104 * GPIO13 -> IRQ from CF controller
105 * GPIO14 -> GPIO free
106 * GPIO15 -> /CS1 selects baseboard's Control CPLD (U7, 16 bit wide data path)
107 * GPIO19 -> GPIO free
108 * GPIO20 -> /SDCS2
109 * GPIO21 -> /CS3 PC card socket select
110 * GPIO33 -> /CS5 network controller select
111 * GPIO78 -> /CS2 (16 bit wide data path)
112 * GPIO80 -> /CS4 (16 bit wide data path)
113 * GPIO86 -> GPIO free
114 * GPIO87 -> GPIO free
115 * GPIO90 -> LED0 on CPU module
116 * GPIO91 -> LED1 on CPI module
117 * GPIO117 -> SCL
118 * GPIO118 -> SDA
119 */
120
121static unsigned long pcm990_irq_enabled;
122
123static void pcm990_mask_ack_irq(unsigned int irq)
124{
125 int pcm990_irq = (irq - PCM027_IRQ(0));
126 PCM990_INTMSKENA = (pcm990_irq_enabled &= ~(1 << pcm990_irq));
127}
128
129static void pcm990_unmask_irq(unsigned int irq)
130{
131 int pcm990_irq = (irq - PCM027_IRQ(0));
132 /* the irq can be acknowledged only if deasserted, so it's done here */
133 PCM990_INTSETCLR |= 1 << pcm990_irq;
134 PCM990_INTMSKENA = (pcm990_irq_enabled |= (1 << pcm990_irq));
135}
136
137static struct irq_chip pcm990_irq_chip = {
138 .mask_ack = pcm990_mask_ack_irq,
139 .unmask = pcm990_unmask_irq,
140};
141
142static void pcm990_irq_handler(unsigned int irq, struct irq_desc *desc)
143{
144 unsigned long pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
145
146 do {
147 GEDR(PCM990_CTRL_INT_IRQ_GPIO) =
148 GPIO_bit(PCM990_CTRL_INT_IRQ_GPIO);
149 if (likely(pending)) {
150 irq = PCM027_IRQ(0) + __ffs(pending);
151 desc = irq_desc + irq;
152 desc_handle_irq(irq, desc);
153 }
154 pending = (~PCM990_INTSETCLR) & pcm990_irq_enabled;
155 } while (pending);
156}
157
158static void __init pcm990_init_irq(void)
159{
160 int irq;
161
162 /* setup extra PCM990 irqs */
163 for (irq = PCM027_IRQ(0); irq <= PCM027_IRQ(3); irq++) {
164 set_irq_chip(irq, &pcm990_irq_chip);
165 set_irq_handler(irq, handle_level_irq);
166 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
167 }
168
169 PCM990_INTMSKENA = 0x00; /* disable all Interrupts */
170 PCM990_INTSETCLR = 0xFF;
171
172 set_irq_chained_handler(PCM990_CTRL_INT_IRQ, pcm990_irq_handler);
173 set_irq_type(PCM990_CTRL_INT_IRQ, PCM990_CTRL_INT_IRQ_EDGE);
174}
175
176static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int,
177 void *data)
178{
179 int err;
180
181 /*
182 * enable GPIO for PXA27x MMC controller
183 */
184 pxa_gpio_mode(GPIO32_MMCCLK_MD);
185 pxa_gpio_mode(GPIO112_MMCCMD_MD);
186 pxa_gpio_mode(GPIO92_MMCDAT0_MD);
187 pxa_gpio_mode(GPIO109_MMCDAT1_MD);
188 pxa_gpio_mode(GPIO110_MMCDAT2_MD);
189 pxa_gpio_mode(GPIO111_MMCDAT3_MD);
190
191 err = request_irq(PCM027_MMCDET_IRQ, mci_detect_int, IRQF_DISABLED,
192 "MMC card detect", data);
193 if (err)
194 printk(KERN_ERR "pcm990_mci_init: MMC/SD: can't request MMC "
195 "card detect IRQ\n");
196
197 return err;
198}
199
200static void pcm990_mci_setpower(struct device *dev, unsigned int vdd)
201{
202 struct pxamci_platform_data *p_d = dev->platform_data;
203
204 if ((1 << vdd) & p_d->ocr_mask)
205 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) =
206 PCM990_CTRL_MMC2PWR;
207 else
208 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5) =
209 ~PCM990_CTRL_MMC2PWR;
210}
211
212static void pcm990_mci_exit(struct device *dev, void *data)
213{
214 free_irq(PCM027_MMCDET_IRQ, data);
215}
216
217#define MSECS_PER_JIFFY (1000/HZ)
218
219static struct pxamci_platform_data pcm990_mci_platform_data = {
220 .detect_delay = 250 / MSECS_PER_JIFFY,
221 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
222 .init = pcm990_mci_init,
223 .setpower = pcm990_mci_setpower,
224 .exit = pcm990_mci_exit,
225};
226
227/*
228 * init OHCI hardware to work with
229 *
230 * Note: Only USB port 1 (host only) is connected
231 *
232 * GPIO88 (USBHPWR#1): overcurrent in, overcurrent when low
233 * GPIO89 (USBHPEN#1): power-on out, on when low
234 */
235static int pcm990_ohci_init(struct device *dev)
236{
237 pxa_gpio_mode(PCM990_USB_OVERCURRENT);
238 pxa_gpio_mode(PCM990_USB_PWR_EN);
239 /*
240 * disable USB port 2 and 3
241 * power sense is active low
242 */
243 UHCHR = ((UHCHR) | UHCHR_PCPL | UHCHR_PSPL | UHCHR_SSEP2 |
244 UHCHR_SSEP3) & ~(UHCHR_SSEP1 | UHCHR_SSE);
245 /*
246 * wait 10ms after Power on
247 * overcurrent per port
248 * power switch per port
249 */
250 UHCRHDA = (5<<24) | (1<<11) | (1<<8); /* FIXME: Required? */
251
252 return 0;
253}
254
255static struct pxaohci_platform_data pcm990_ohci_platform_data = {
256 .port_mode = PMM_PERPORT_MODE,
257 .init = pcm990_ohci_init,
258 .exit = NULL,
259};
260
261/*
262 * AC97 support
263 * Note: The connected AC97 mixer also reports interrupts at PCM990_AC97_IRQ
264 */
265static struct resource pxa27x_ac97_resources[] = {
266 [0] = {
267 .start = 0x40500000,
268 .end = 0x40500000 + 0xfff,
269 .flags = IORESOURCE_MEM,
270 },
271 [1] = {
272 .start = IRQ_AC97,
273 .end = IRQ_AC97,
274 .flags = IORESOURCE_IRQ,
275 },
276};
277
278static u64 pxa_ac97_dmamask = 0xffffffffUL;
279
280static struct platform_device pxa27x_device_ac97 = {
281 .name = "pxa2xx-ac97",
282 .id = -1,
283 .dev = {
284 .dma_mask = &pxa_ac97_dmamask,
285 .coherent_dma_mask = 0xffffffff,
286 },
287 .num_resources = ARRAY_SIZE(pxa27x_ac97_resources),
288 .resource = pxa27x_ac97_resources,
289};
290
291/*
292 * enable generic access to the base board control CPLDs U6 and U7
293 */
294static struct map_desc pcm990_io_desc[] __initdata = {
295 {
296 .virtual = PCM990_CTRL_BASE,
297 .pfn = __phys_to_pfn(PCM990_CTRL_PHYS),
298 .length = PCM990_CTRL_SIZE,
299 .type = MT_DEVICE /* CPLD */
300 }, {
301 .virtual = PCM990_CF_PLD_BASE,
302 .pfn = __phys_to_pfn(PCM990_CF_PLD_PHYS),
303 .length = PCM990_CF_PLD_SIZE,
304 .type = MT_DEVICE /* CPLD */
305 }
306};
307
308/*
309 * system init for baseboard usage. Will be called by pcm027 init.
310 *
311 * Add platform devices present on this baseboard and init
312 * them from CPU side as far as required to use them later on
313 */
314void __init pcm990_baseboard_init(void)
315{
316 /* register CPLD access */
317 iotable_init(pcm990_io_desc, ARRAY_SIZE(pcm990_io_desc));
318
319 /* register CPLD's IRQ controller */
320 pcm990_init_irq();
321
322 platform_device_register(&pxa27x_device_ac97);
323
324 /* MMC */
325 pxa_set_mci_info(&pcm990_mci_platform_data);
326
327 /* USB host */
328 pxa_set_ohci_info(&pcm990_ohci_platform_data);
329
330 printk(KERN_INFO"PCM-990 Evaluation baseboard initialized\n");
331}