1 /* arch/arm/mach-lh7a40x/arch-lpd7a40x.c
3 * Copyright (C) 2004 Logic Product Development
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
11 #include <linux/tty.h>
12 #include <linux/init.h>
13 #include <linux/device.h>
15 #include <asm/hardware.h>
16 #include <asm/setup.h>
17 #include <asm/mach-types.h>
18 #include <asm/mach/arch.h>
19 #include <asm/hardware.h> /* io_p2v() */
21 #include <asm/mach/irq.h>
22 #include <asm/mach/map.h>
24 #include <linux/interrupt.h>
26 static struct resource smc91x_resources[] = {
29 .end = CPLD00_PHYS + CPLD00_SIZE - 1, /* Only needs 16B */
30 .flags = IORESOURCE_MEM,
34 .start = IRQ_LPD7A40X_ETH_INT,
35 .end = IRQ_LPD7A40X_ETH_INT,
36 .flags = IORESOURCE_IRQ,
41 static struct platform_device smc91x_device = {
44 .num_resources = ARRAY_SIZE(smc91x_resources),
45 .resource = smc91x_resources,
49 static struct resource lh7a40x_usbclient_resources[] = {
52 .end = (USB_PHYS + 0xFF),
53 .flags = IORESOURCE_MEM,
58 .flags = IORESOURCE_IRQ,
62 static u64 lh7a40x_usbclient_dma_mask = 0xffffffffUL;
64 static struct platform_device lh7a40x_usbclient_device = {
65 .name = "lh7a40x-udc",
68 .dma_mask = &lh7a40x_usbclient_dma_mask,
69 .coherent_dma_mask = 0xffffffffUL,
71 .num_resources = ARRAY_SIZE (lh7a40x_usbclient_resources),
72 .resource = lh7a40x_usbclient_resources,
76 #if defined (CONFIG_ARCH_LH7A404)
78 static struct resource lh7a404_usbhost_resources [] = {
81 .end = (USBH_PHYS + 0xFF),
82 .flags = IORESOURCE_MEM,
87 .flags = IORESOURCE_IRQ,
91 static u64 lh7a404_usbhost_dma_mask = 0xffffffffUL;
93 static struct platform_device lh7a404_usbhost_device = {
94 .name = "lh7a404-ohci",
97 .dma_mask = &lh7a404_usbhost_dma_mask,
98 .coherent_dma_mask = 0xffffffffUL,
100 .num_resources = ARRAY_SIZE (lh7a404_usbhost_resources),
101 .resource = lh7a404_usbhost_resources,
106 static struct platform_device *lpd7a40x_devs[] __initdata = {
108 /* &lh7a40x_usbclient_device, */
110 #if defined (CONFIG_ARCH_LH7A404)
111 &lh7a404_usbhost_device,
115 extern void lpd7a400_map_io (void);
117 static void __init lpd7a40x_init (void)
119 CPLD_CONTROL |= (1<<6); /* Mask USB1 connection IRQ */
121 | (1<<1) /* Disable LCD */
122 | (1<<0) /* Enable WLAN */
125 platform_add_devices (lpd7a40x_devs, ARRAY_SIZE (lpd7a40x_devs));
128 static void lh7a40x_ack_cpld_irq (u32 irq)
130 /* CPLD doesn't have ack capability */
133 static void lh7a40x_mask_cpld_irq (u32 irq)
136 case IRQ_LPD7A40X_ETH_INT:
137 CPLD_INTERRUPTS = CPLD_INTERRUPTS | 0x4;
139 case IRQ_LPD7A400_TS:
140 CPLD_INTERRUPTS = CPLD_INTERRUPTS | 0x8;
145 static void lh7a40x_unmask_cpld_irq (u32 irq)
148 case IRQ_LPD7A40X_ETH_INT:
149 CPLD_INTERRUPTS = CPLD_INTERRUPTS & ~ 0x4;
151 case IRQ_LPD7A400_TS:
152 CPLD_INTERRUPTS = CPLD_INTERRUPTS & ~ 0x8;
157 static struct irqchip lpd7a40x_cpld_chip = {
158 .ack = lh7a40x_ack_cpld_irq,
159 .mask = lh7a40x_mask_cpld_irq,
160 .unmask = lh7a40x_unmask_cpld_irq,
163 #define IRQ_DISPATCH(irq) irq_desc[irq].handle ((irq), &irq_desc[irq], regs)
165 static void lpd7a40x_cpld_handler (unsigned int irq, struct irqdesc *desc,
166 struct pt_regs *regs)
168 unsigned int mask = CPLD_INTERRUPTS;
170 desc->chip->ack (irq);
172 if ((mask & 0x1) == 0) /* WLAN */
173 IRQ_DISPATCH (IRQ_LPD7A40X_ETH_INT);
175 if ((mask & 0x2) == 0) /* Touch */
176 IRQ_DISPATCH (IRQ_LPD7A400_TS);
178 desc->chip->unmask (irq); /* Level-triggered need this */
182 void __init lh7a40x_init_board_irq (void)
186 /* Rev A (v2.8): PF0, PF1, PF2, and PF3 are available IRQs.
187 PF7 supports the CPLD.
188 Rev B (v3.4): PF0, PF1, and PF2 are available IRQs.
189 PF3 supports the CPLD.
190 (Some) LPD7A404 prerelease boards report a version
191 number of 0x16, but we force an override since the
192 hardware is of the newer variety.
195 unsigned char cpld_version = CPLD_REVISION;
196 int pinCPLD = (cpld_version == 0x28) ? 7 : 3;
198 #if defined CONFIG_MACH_LPD7A404
199 cpld_version = 0x34; /* Coerce LPD7A404 to RevB */
202 /* First, configure user controlled GPIOF interrupts */
204 GPIO_PFDD &= ~0x0f; /* PF0-3 are inputs */
205 GPIO_INTTYPE1 &= ~0x0f; /* PF0-3 are level triggered */
206 GPIO_INTTYPE2 &= ~0x0f; /* PF0-3 are active low */
208 GPIO_GPIOFINTEN |= 0x0f; /* Enable PF0, PF1, PF2, and PF3 IRQs */
210 /* Then, configure CPLD interrupt */
212 CPLD_INTERRUPTS = 0x9c; /* Disable all CPLD interrupts */
213 GPIO_PFDD &= ~(1 << pinCPLD); /* Make input */
214 GPIO_INTTYPE1 |= (1 << pinCPLD); /* Edge triggered */
215 GPIO_INTTYPE2 &= ~(1 << pinCPLD); /* Active low */
217 GPIO_GPIOFINTEN |= (1 << pinCPLD); /* Enable */
219 /* Cascade CPLD interrupts */
221 for (irq = IRQ_BOARD_START;
222 irq < IRQ_BOARD_START + NR_IRQ_BOARD; ++irq) {
223 set_irq_chip (irq, &lpd7a40x_cpld_chip);
224 set_irq_handler (irq, do_edge_IRQ);
225 set_irq_flags (irq, IRQF_VALID);
228 set_irq_chained_handler ((cpld_version == 0x28)
231 lpd7a40x_cpld_handler);
234 static struct map_desc lpd7a400_io_desc[] __initdata = {
235 { IO_VIRT, IO_PHYS, IO_SIZE, MT_DEVICE },
236 /* Mapping added to work around chip select problems */
237 { IOBARRIER_VIRT, IOBARRIER_PHYS, IOBARRIER_SIZE, MT_DEVICE },
238 { CF_VIRT, CF_PHYS, CF_SIZE, MT_DEVICE },
239 /* This mapping is redundant since the smc driver performs another. */
240 /* { CPLD00_VIRT, CPLD00_PHYS, CPLD00_SIZE, MT_DEVICE }, */
241 { CPLD02_VIRT, CPLD02_PHYS, CPLD02_SIZE, MT_DEVICE },
242 { CPLD06_VIRT, CPLD06_PHYS, CPLD06_SIZE, MT_DEVICE },
243 { CPLD08_VIRT, CPLD08_PHYS, CPLD08_SIZE, MT_DEVICE },
244 { CPLD0C_VIRT, CPLD0C_PHYS, CPLD0C_SIZE, MT_DEVICE },
245 { CPLD0E_VIRT, CPLD0E_PHYS, CPLD0E_SIZE, MT_DEVICE },
246 { CPLD10_VIRT, CPLD10_PHYS, CPLD10_SIZE, MT_DEVICE },
247 { CPLD12_VIRT, CPLD12_PHYS, CPLD12_SIZE, MT_DEVICE },
248 { CPLD14_VIRT, CPLD14_PHYS, CPLD14_SIZE, MT_DEVICE },
249 { CPLD16_VIRT, CPLD16_PHYS, CPLD16_SIZE, MT_DEVICE },
250 { CPLD18_VIRT, CPLD18_PHYS, CPLD18_SIZE, MT_DEVICE },
251 { CPLD1A_VIRT, CPLD1A_PHYS, CPLD1A_SIZE, MT_DEVICE },
255 lpd7a400_map_io(void)
257 iotable_init (lpd7a400_io_desc, ARRAY_SIZE (lpd7a400_io_desc));
259 /* Fixup (improve) Static Memory Controller settings */
260 SMC_BCR0 = 0x200039af; /* Boot Flash */
261 SMC_BCR6 = 0x1000fbe0; /* CPLD */
262 SMC_BCR7 = 0x1000b2c2; /* Compact Flash */
265 #ifdef CONFIG_MACH_LPD7A400
267 extern void lh7a400_init_irq (void);
269 MACHINE_START (LPD7A400, "Logic Product Development LPD7A400-10")
270 MAINTAINER ("Marc Singer")
271 BOOT_MEM (0xc0000000, 0x80000000, io_p2v (0x80000000))
272 BOOT_PARAMS (0xc0000100)
273 MAPIO (lpd7a400_map_io)
274 INITIRQ (lh7a400_init_irq)
275 INIT_MACHINE (lpd7a40x_init)
280 #ifdef CONFIG_MACH_LPD7A404
282 extern void lh7a404_init_irq (void);
284 MACHINE_START (LPD7A404, "Logic Product Development LPD7A404-10")
285 MAINTAINER ("Marc Singer")
286 BOOT_MEM (0xc0000000, 0x80000000, io_p2v (0x80000000))
287 BOOT_PARAMS (0xc0000100)
288 MAPIO (lpd7a400_map_io)
289 INITIRQ (lh7a404_init_irq)
290 INIT_MACHINE (lpd7a40x_init)