2 * linux/arch/arm/mach-ebsa110/core.c
4 * Copyright (C) 1998-2001 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * Extra MM routines for the EBSA-110 architecture
12 #include <linux/kernel.h>
14 #include <linux/interrupt.h>
15 #include <linux/serial_8250.h>
16 #include <linux/init.h>
18 #include <asm/hardware.h>
21 #include <asm/setup.h>
22 #include <asm/mach-types.h>
23 #include <asm/pgtable.h>
25 #include <asm/system.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/irq.h>
29 #include <asm/mach/map.h>
31 #include <asm/mach/time.h>
33 #define IRQ_MASK 0xfe000000 /* read */
34 #define IRQ_MSET 0xfe000000 /* write */
35 #define IRQ_STAT 0xff000000 /* read */
36 #define IRQ_MCLR 0xff000000 /* write */
38 static void ebsa110_mask_irq(unsigned int irq)
40 __raw_writeb(1 << irq, IRQ_MCLR);
43 static void ebsa110_unmask_irq(unsigned int irq)
45 __raw_writeb(1 << irq, IRQ_MSET);
48 static struct irq_chip ebsa110_irq_chip = {
49 .ack = ebsa110_mask_irq,
50 .mask = ebsa110_mask_irq,
51 .unmask = ebsa110_unmask_irq,
54 static void __init ebsa110_init_irq(void)
59 local_irq_save(flags);
60 __raw_writeb(0xff, IRQ_MCLR);
61 __raw_writeb(0x55, IRQ_MSET);
62 __raw_writeb(0x00, IRQ_MSET);
63 if (__raw_readb(IRQ_MASK) != 0x55)
65 __raw_writeb(0xff, IRQ_MCLR); /* clear all interrupt enables */
66 local_irq_restore(flags);
68 for (irq = 0; irq < NR_IRQS; irq++) {
69 set_irq_chip(irq, &ebsa110_irq_chip);
70 set_irq_handler(irq, handle_level_irq);
71 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
75 static struct map_desc ebsa110_io_desc[] __initdata = {
77 * sparse external-decode ISAIO space
79 { /* IRQ_STAT/IRQ_MCLR */
81 .pfn = __phys_to_pfn(TRICK4_PHYS),
84 }, { /* IRQ_MASK/IRQ_MSET */
86 .pfn = __phys_to_pfn(TRICK3_PHYS),
91 .pfn = __phys_to_pfn(TRICK1_PHYS),
96 .pfn = __phys_to_pfn(TRICK0_PHYS),
102 * self-decode ISAIO space
105 .virtual = ISAIO_BASE,
106 .pfn = __phys_to_pfn(ISAIO_PHYS),
107 .length = ISAIO_SIZE,
110 .virtual = ISAMEM_BASE,
111 .pfn = __phys_to_pfn(ISAMEM_PHYS),
112 .length = ISAMEM_SIZE,
117 static void __init ebsa110_map_io(void)
119 iotable_init(ebsa110_io_desc, ARRAY_SIZE(ebsa110_io_desc));
123 #define PIT_CTRL (PIT_BASE + 0x0d)
124 #define PIT_T2 (PIT_BASE + 0x09)
125 #define PIT_T1 (PIT_BASE + 0x05)
126 #define PIT_T0 (PIT_BASE + 0x01)
129 * This is the rate at which your MCLK signal toggles (in Hz)
130 * This was measured on a 10 digit frequency counter sampling
133 #define MCLK 47894000
136 * This is the rate at which the PIT timers get clocked
138 #define CLKBY7 (MCLK / 7)
141 * This is the counter value. We tick at 200Hz on this platform.
143 #define COUNT ((CLKBY7 + (HZ / 2)) / HZ)
146 * Get the time offset from the system PIT. Note that if we have missed an
147 * interrupt, then the PIT counter will roll over (ie, be negative).
148 * This actually works out to be convenient.
150 static unsigned long ebsa110_gettimeoffset(void)
152 unsigned long offset, count;
154 __raw_writeb(0x40, PIT_CTRL);
155 count = __raw_readb(PIT_T1);
156 count |= __raw_readb(PIT_T1) << 8;
159 * If count > COUNT, make the number negative.
168 * `offset' is in units of timer counts. Convert
169 * offset to units of microseconds.
171 offset = offset * (1000000 / HZ) / COUNT;
177 ebsa110_timer_interrupt(int irq, void *dev_id)
181 write_seqlock(&xtime_lock);
183 /* latch and read timer 1 */
184 __raw_writeb(0x40, PIT_CTRL);
185 count = __raw_readb(PIT_T1);
186 count |= __raw_readb(PIT_T1) << 8;
190 __raw_writeb(count & 0xff, PIT_T1);
191 __raw_writeb(count >> 8, PIT_T1);
195 write_sequnlock(&xtime_lock);
200 static struct irqaction ebsa110_timer_irq = {
201 .name = "EBSA110 Timer Tick",
202 .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
203 .handler = ebsa110_timer_interrupt,
207 * Set up timer interrupt.
209 static void __init ebsa110_timer_init(void)
212 * Timer 1, mode 2, LSB/MSB
214 __raw_writeb(0x70, PIT_CTRL);
215 __raw_writeb(COUNT & 0xff, PIT_T1);
216 __raw_writeb(COUNT >> 8, PIT_T1);
218 setup_irq(IRQ_EBSA110_TIMER0, &ebsa110_timer_irq);
221 static struct sys_timer ebsa110_timer = {
222 .init = ebsa110_timer_init,
223 .offset = ebsa110_gettimeoffset,
226 static struct plat_serial8250_port serial_platform_data[] = {
233 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
241 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
246 static struct platform_device serial_device = {
247 .name = "serial8250",
248 .id = PLAT8250_DEV_PLATFORM,
250 .platform_data = serial_platform_data,
254 static struct resource am79c961_resources[] = {
258 .flags = IORESOURCE_IO,
260 .start = IRQ_EBSA110_ETHERNET,
261 .end = IRQ_EBSA110_ETHERNET,
262 .flags = IORESOURCE_IRQ,
266 static struct platform_device am79c961_device = {
269 .num_resources = ARRAY_SIZE(am79c961_resources),
270 .resource = am79c961_resources,
273 static struct platform_device *ebsa110_devices[] = {
278 static int __init ebsa110_init(void)
280 return platform_add_devices(ebsa110_devices, ARRAY_SIZE(ebsa110_devices));
283 arch_initcall(ebsa110_init);
285 MACHINE_START(EBSA110, "EBSA110")
286 /* Maintainer: Russell King */
287 .phys_io = 0xe0000000,
288 .io_pg_offst = ((0xe0000000) >> 18) & 0xfffc,
289 .boot_params = 0x00000400,
293 .map_io = ebsa110_map_io,
294 .init_irq = ebsa110_init_irq,
295 .timer = &ebsa110_timer,