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/init.h>
17 #include <asm/hardware.h>
20 #include <asm/setup.h>
21 #include <asm/mach-types.h>
22 #include <asm/pgtable.h>
24 #include <asm/system.h>
26 #include <asm/mach/arch.h>
27 #include <asm/mach/irq.h>
28 #include <asm/mach/map.h>
30 #include <asm/mach/time.h>
32 #define IRQ_MASK 0xfe000000 /* read */
33 #define IRQ_MSET 0xfe000000 /* write */
34 #define IRQ_STAT 0xff000000 /* read */
35 #define IRQ_MCLR 0xff000000 /* write */
37 static void ebsa110_mask_irq(unsigned int irq
)
39 __raw_writeb(1 << irq
, IRQ_MCLR
);
42 static void ebsa110_unmask_irq(unsigned int irq
)
44 __raw_writeb(1 << irq
, IRQ_MSET
);
47 static struct irqchip ebsa110_irq_chip
= {
48 .ack
= ebsa110_mask_irq
,
49 .mask
= ebsa110_mask_irq
,
50 .unmask
= ebsa110_unmask_irq
,
53 static void __init
ebsa110_init_irq(void)
58 local_irq_save(flags
);
59 __raw_writeb(0xff, IRQ_MCLR
);
60 __raw_writeb(0x55, IRQ_MSET
);
61 __raw_writeb(0x00, IRQ_MSET
);
62 if (__raw_readb(IRQ_MASK
) != 0x55)
64 __raw_writeb(0xff, IRQ_MCLR
); /* clear all interrupt enables */
65 local_irq_restore(flags
);
67 for (irq
= 0; irq
< NR_IRQS
; irq
++) {
68 set_irq_chip(irq
, &ebsa110_irq_chip
);
69 set_irq_handler(irq
, do_level_IRQ
);
70 set_irq_flags(irq
, IRQF_VALID
| IRQF_PROBE
);
74 static struct map_desc ebsa110_io_desc
[] __initdata
= {
76 * sparse external-decode ISAIO space
78 { IRQ_STAT
, TRICK4_PHYS
, PGDIR_SIZE
, MT_DEVICE
}, /* IRQ_STAT/IRQ_MCLR */
79 { IRQ_MASK
, TRICK3_PHYS
, PGDIR_SIZE
, MT_DEVICE
}, /* IRQ_MASK/IRQ_MSET */
80 { SOFT_BASE
, TRICK1_PHYS
, PGDIR_SIZE
, MT_DEVICE
}, /* SOFT_BASE */
81 { PIT_BASE
, TRICK0_PHYS
, PGDIR_SIZE
, MT_DEVICE
}, /* PIT_BASE */
84 * self-decode ISAIO space
86 { ISAIO_BASE
, ISAIO_PHYS
, ISAIO_SIZE
, MT_DEVICE
},
87 { ISAMEM_BASE
, ISAMEM_PHYS
, ISAMEM_SIZE
, MT_DEVICE
}
90 static void __init
ebsa110_map_io(void)
92 iotable_init(ebsa110_io_desc
, ARRAY_SIZE(ebsa110_io_desc
));
96 #define PIT_CTRL (PIT_BASE + 0x0d)
97 #define PIT_T2 (PIT_BASE + 0x09)
98 #define PIT_T1 (PIT_BASE + 0x05)
99 #define PIT_T0 (PIT_BASE + 0x01)
102 * This is the rate at which your MCLK signal toggles (in Hz)
103 * This was measured on a 10 digit frequency counter sampling
106 #define MCLK 47894000
109 * This is the rate at which the PIT timers get clocked
111 #define CLKBY7 (MCLK / 7)
114 * This is the counter value. We tick at 200Hz on this platform.
116 #define COUNT ((CLKBY7 + (HZ / 2)) / HZ)
119 * Get the time offset from the system PIT. Note that if we have missed an
120 * interrupt, then the PIT counter will roll over (ie, be negative).
121 * This actually works out to be convenient.
123 static unsigned long ebsa110_gettimeoffset(void)
125 unsigned long offset
, count
;
127 __raw_writeb(0x40, PIT_CTRL
);
128 count
= __raw_readb(PIT_T1
);
129 count
|= __raw_readb(PIT_T1
) << 8;
132 * If count > COUNT, make the number negative.
141 * `offset' is in units of timer counts. Convert
142 * offset to units of microseconds.
144 offset
= offset
* (1000000 / HZ
) / COUNT
;
150 ebsa110_timer_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
154 /* latch and read timer 1 */
155 __raw_writeb(0x40, PIT_CTRL
);
156 count
= __raw_readb(PIT_T1
);
157 count
|= __raw_readb(PIT_T1
) << 8;
161 __raw_writeb(count
& 0xff, PIT_T1
);
162 __raw_writeb(count
>> 8, PIT_T1
);
169 static struct irqaction ebsa110_timer_irq
= {
170 .name
= "EBSA110 Timer Tick",
171 .flags
= SA_INTERRUPT
,
172 .handler
= ebsa110_timer_interrupt
176 * Set up timer interrupt.
178 static void __init
ebsa110_init_time(void)
181 * Timer 1, mode 2, LSB/MSB
183 __raw_writeb(0x70, PIT_CTRL
);
184 __raw_writeb(COUNT
& 0xff, PIT_T1
);
185 __raw_writeb(COUNT
>> 8, PIT_T1
);
187 gettimeoffset
= ebsa110_gettimeoffset
;
189 setup_irq(IRQ_EBSA110_TIMER0
, &ebsa110_timer_irq
);
192 MACHINE_START(EBSA110
, "EBSA110")
193 MAINTAINER("Russell King")
194 BOOT_MEM(0x00000000, 0xe0000000, 0xe0000000)
195 BOOT_PARAMS(0x00000400)
199 MAPIO(ebsa110_map_io
)
200 INITIRQ(ebsa110_init_irq
)
201 INITTIME(ebsa110_init_time
)