2 * linux/arch/arm/mach-integrator/integrator_ap.c
4 * Copyright (C) 2000-2003 Deep Blue Solutions Ltd
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <linux/types.h>
21 #include <linux/kernel.h>
22 #include <linux/init.h>
23 #include <linux/list.h>
24 #include <linux/device.h>
25 #include <linux/slab.h>
26 #include <linux/string.h>
27 #include <linux/sysdev.h>
29 #include <asm/hardware.h>
32 #include <asm/setup.h>
33 #include <asm/mach-types.h>
34 #include <asm/hardware/amba.h>
35 #include <asm/hardware/amba_kmi.h>
37 #include <asm/arch/lm.h>
39 #include <asm/mach/arch.h>
40 #include <asm/mach/flash.h>
41 #include <asm/mach/irq.h>
42 #include <asm/mach/map.h>
43 #include <asm/mach/time.h>
48 * All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx
51 * Setup a VA for the Integrator interrupt controller (for header #0,
54 #define VA_IC_BASE IO_ADDRESS(INTEGRATOR_IC_BASE)
55 #define VA_SC_BASE IO_ADDRESS(INTEGRATOR_SC_BASE)
56 #define VA_EBI_BASE IO_ADDRESS(INTEGRATOR_EBI_BASE)
57 #define VA_CMIC_BASE IO_ADDRESS(INTEGRATOR_HDR_BASE) + INTEGRATOR_HDR_IC_OFFSET
61 * e8000000 40000000 PCI memory PHYS_PCI_MEM_BASE (max 512M)
62 * ec000000 61000000 PCI config space PHYS_PCI_CONFIG_BASE (max 16M)
63 * ed000000 62000000 PCI V3 regs PHYS_PCI_V3_BASE (max 64k)
64 * ee000000 60000000 PCI IO PHYS_PCI_IO_BASE (max 16M)
65 * ef000000 Cache flush
66 * f1000000 10000000 Core module registers
67 * f1100000 11000000 System controller registers
68 * f1200000 12000000 EBI registers
69 * f1300000 13000000 Counter/Timer
70 * f1400000 14000000 Interrupt controller
71 * f1600000 16000000 UART 0
72 * f1700000 17000000 UART 1
73 * f1a00000 1a000000 Debug LEDs
74 * f1b00000 1b000000 GPIO
77 static struct map_desc ap_io_desc[] __initdata = {
79 .virtual = IO_ADDRESS(INTEGRATOR_HDR_BASE),
80 .pfn = __phys_to_pfn(INTEGRATOR_HDR_BASE),
84 .virtual = IO_ADDRESS(INTEGRATOR_SC_BASE),
85 .pfn = __phys_to_pfn(INTEGRATOR_SC_BASE),
89 .virtual = IO_ADDRESS(INTEGRATOR_EBI_BASE),
90 .pfn = __phys_to_pfn(INTEGRATOR_EBI_BASE),
94 .virtual = IO_ADDRESS(INTEGRATOR_CT_BASE),
95 .pfn = __phys_to_pfn(INTEGRATOR_CT_BASE),
99 .virtual = IO_ADDRESS(INTEGRATOR_IC_BASE),
100 .pfn = __phys_to_pfn(INTEGRATOR_IC_BASE),
104 .virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE),
105 .pfn = __phys_to_pfn(INTEGRATOR_UART0_BASE),
109 .virtual = IO_ADDRESS(INTEGRATOR_UART1_BASE),
110 .pfn = __phys_to_pfn(INTEGRATOR_UART1_BASE),
114 .virtual = IO_ADDRESS(INTEGRATOR_DBG_BASE),
115 .pfn = __phys_to_pfn(INTEGRATOR_DBG_BASE),
119 .virtual = IO_ADDRESS(INTEGRATOR_GPIO_BASE),
120 .pfn = __phys_to_pfn(INTEGRATOR_GPIO_BASE),
124 .virtual = PCI_MEMORY_VADDR,
125 .pfn = __phys_to_pfn(PHYS_PCI_MEM_BASE),
129 .virtual = PCI_CONFIG_VADDR,
130 .pfn = __phys_to_pfn(PHYS_PCI_CONFIG_BASE),
134 .virtual = PCI_V3_VADDR,
135 .pfn = __phys_to_pfn(PHYS_PCI_V3_BASE),
139 .virtual = PCI_IO_VADDR,
140 .pfn = __phys_to_pfn(PHYS_PCI_IO_BASE),
146 static void __init ap_map_io(void)
148 iotable_init(ap_io_desc, ARRAY_SIZE(ap_io_desc));
151 #define INTEGRATOR_SC_VALID_INT 0x003fffff
153 static void sc_mask_irq(unsigned int irq)
155 writel(1 << irq, VA_IC_BASE + IRQ_ENABLE_CLEAR);
158 static void sc_unmask_irq(unsigned int irq)
160 writel(1 << irq, VA_IC_BASE + IRQ_ENABLE_SET);
163 static struct irqchip sc_chip = {
166 .unmask = sc_unmask_irq,
169 static void __init ap_init_irq(void)
173 /* Disable all interrupts initially. */
174 /* Do the core module ones */
175 writel(-1, VA_CMIC_BASE + IRQ_ENABLE_CLEAR);
177 /* do the header card stuff next */
178 writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR);
179 writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR);
181 for (i = 0; i < NR_IRQS; i++) {
182 if (((1 << i) & INTEGRATOR_SC_VALID_INT) != 0) {
183 set_irq_chip(i, &sc_chip);
184 set_irq_handler(i, do_level_IRQ);
185 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
191 static unsigned long ic_irq_enable;
193 static int irq_suspend(struct sys_device *dev, pm_message_t state)
195 ic_irq_enable = readl(VA_IC_BASE + IRQ_ENABLE);
199 static int irq_resume(struct sys_device *dev)
201 /* disable all irq sources */
202 writel(-1, VA_CMIC_BASE + IRQ_ENABLE_CLEAR);
203 writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR);
204 writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR);
206 writel(ic_irq_enable, VA_IC_BASE + IRQ_ENABLE_SET);
210 #define irq_suspend NULL
211 #define irq_resume NULL
214 static struct sysdev_class irq_class = {
215 set_kset_name("irq"),
216 .suspend = irq_suspend,
217 .resume = irq_resume,
220 static struct sys_device irq_device = {
225 static int __init irq_init_sysfs(void)
227 int ret = sysdev_class_register(&irq_class);
229 ret = sysdev_register(&irq_device);
233 device_initcall(irq_init_sysfs);
238 #define SC_CTRLC (VA_SC_BASE + INTEGRATOR_SC_CTRLC_OFFSET)
239 #define SC_CTRLS (VA_SC_BASE + INTEGRATOR_SC_CTRLS_OFFSET)
240 #define EBI_CSR1 (VA_EBI_BASE + INTEGRATOR_EBI_CSR1_OFFSET)
241 #define EBI_LOCK (VA_EBI_BASE + INTEGRATOR_EBI_LOCK_OFFSET)
243 static int ap_flash_init(void)
247 writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP, SC_CTRLC);
249 tmp = readl(EBI_CSR1) | INTEGRATOR_EBI_WRITE_ENABLE;
250 writel(tmp, EBI_CSR1);
252 if (!(readl(EBI_CSR1) & INTEGRATOR_EBI_WRITE_ENABLE)) {
253 writel(0xa05f, EBI_LOCK);
254 writel(tmp, EBI_CSR1);
260 static void ap_flash_exit(void)
264 writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP, SC_CTRLC);
266 tmp = readl(EBI_CSR1) & ~INTEGRATOR_EBI_WRITE_ENABLE;
267 writel(tmp, EBI_CSR1);
269 if (readl(EBI_CSR1) & INTEGRATOR_EBI_WRITE_ENABLE) {
270 writel(0xa05f, EBI_LOCK);
271 writel(tmp, EBI_CSR1);
276 static void ap_flash_set_vpp(int on)
278 unsigned long reg = on ? SC_CTRLS : SC_CTRLC;
280 writel(INTEGRATOR_SC_CTRL_nFLVPPEN, reg);
283 static struct flash_platform_data ap_flash_data = {
284 .map_name = "cfi_probe",
286 .init = ap_flash_init,
287 .exit = ap_flash_exit,
288 .set_vpp = ap_flash_set_vpp,
291 static struct resource cfi_flash_resource = {
292 .start = INTEGRATOR_FLASH_BASE,
293 .end = INTEGRATOR_FLASH_BASE + INTEGRATOR_FLASH_SIZE - 1,
294 .flags = IORESOURCE_MEM,
297 static struct platform_device cfi_flash_device = {
301 .platform_data = &ap_flash_data,
304 .resource = &cfi_flash_resource,
307 static void __init ap_init(void)
309 unsigned long sc_dec;
312 platform_device_register(&cfi_flash_device);
314 sc_dec = readl(VA_SC_BASE + INTEGRATOR_SC_DEC_OFFSET);
315 for (i = 0; i < 4; i++) {
316 struct lm_device *lmdev;
318 if ((sc_dec & (16 << i)) == 0)
321 lmdev = kmalloc(sizeof(struct lm_device), GFP_KERNEL);
325 memset(lmdev, 0, sizeof(struct lm_device));
327 lmdev->resource.start = 0xc0000000 + 0x10000000 * i;
328 lmdev->resource.end = lmdev->resource.start + 0x0fffffff;
329 lmdev->resource.flags = IORESOURCE_MEM;
330 lmdev->irq = IRQ_AP_EXPINT0 + i;
333 lm_device_register(lmdev);
337 static void __init ap_init_timer(void)
339 integrator_time_init(1000000 * TICKS_PER_uSEC / HZ, 0);
342 static struct sys_timer ap_timer = {
343 .init = ap_init_timer,
344 .offset = integrator_gettimeoffset,
347 MACHINE_START(INTEGRATOR, "ARM-Integrator")
348 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
349 .phys_ram = 0x00000000,
350 .phys_io = 0x16000000,
351 .io_pg_offst = ((0xf1600000) >> 18) & 0xfffc,
352 .boot_params = 0x00000100,
354 .init_irq = ap_init_irq,
356 .init_machine = ap_init,