diff options
Diffstat (limited to 'arch/arm/mach-footbridge/isa-timer.c')
-rw-r--r-- | arch/arm/mach-footbridge/isa-timer.c | 45 |
1 files changed, 4 insertions, 41 deletions
diff --git a/arch/arm/mach-footbridge/isa-timer.c b/arch/arm/mach-footbridge/isa-timer.c index 441c6ce0d555..7020f1a3feca 100644 --- a/arch/arm/mach-footbridge/isa-timer.c +++ b/arch/arm/mach-footbridge/isa-timer.c | |||
@@ -10,53 +10,16 @@ | |||
10 | #include <linux/interrupt.h> | 10 | #include <linux/interrupt.h> |
11 | #include <linux/irq.h> | 11 | #include <linux/irq.h> |
12 | #include <linux/io.h> | 12 | #include <linux/io.h> |
13 | #include <linux/spinlock.h> | ||
13 | #include <linux/timex.h> | 14 | #include <linux/timex.h> |
14 | 15 | ||
15 | #include <asm/irq.h> | 16 | #include <asm/irq.h> |
16 | 17 | #include <asm/i8253.h> | |
17 | #include <asm/mach/time.h> | 18 | #include <asm/mach/time.h> |
18 | 19 | ||
19 | #include "common.h" | 20 | #include "common.h" |
20 | 21 | ||
21 | #define PIT_MODE 0x43 | 22 | DEFINE_RAW_SPINLOCK(i8253_lock); |
22 | #define PIT_CH0 0x40 | ||
23 | |||
24 | #define PIT_LATCH ((PIT_TICK_RATE + HZ / 2) / HZ) | ||
25 | |||
26 | static cycle_t pit_read(struct clocksource *cs) | ||
27 | { | ||
28 | unsigned long flags; | ||
29 | static int old_count; | ||
30 | static u32 old_jifs; | ||
31 | int count; | ||
32 | u32 jifs; | ||
33 | |||
34 | raw_local_irq_save(flags); | ||
35 | |||
36 | jifs = jiffies; | ||
37 | outb_p(0x00, PIT_MODE); /* latch the count */ | ||
38 | count = inb_p(PIT_CH0); /* read the latched count */ | ||
39 | count |= inb_p(PIT_CH0) << 8; | ||
40 | |||
41 | if (count > old_count && jifs == old_jifs) | ||
42 | count = old_count; | ||
43 | |||
44 | old_count = count; | ||
45 | old_jifs = jifs; | ||
46 | |||
47 | raw_local_irq_restore(flags); | ||
48 | |||
49 | count = (PIT_LATCH - 1) - count; | ||
50 | |||
51 | return (cycle_t)(jifs * PIT_LATCH) + count; | ||
52 | } | ||
53 | |||
54 | static struct clocksource pit_cs = { | ||
55 | .name = "pit", | ||
56 | .rating = 110, | ||
57 | .read = pit_read, | ||
58 | .mask = CLOCKSOURCE_MASK(32), | ||
59 | }; | ||
60 | 23 | ||
61 | static void pit_set_mode(enum clock_event_mode mode, | 24 | static void pit_set_mode(enum clock_event_mode mode, |
62 | struct clock_event_device *evt) | 25 | struct clock_event_device *evt) |
@@ -121,7 +84,7 @@ static void __init isa_timer_init(void) | |||
121 | pit_ce.max_delta_ns = clockevent_delta2ns(0x7fff, &pit_ce); | 84 | pit_ce.max_delta_ns = clockevent_delta2ns(0x7fff, &pit_ce); |
122 | pit_ce.min_delta_ns = clockevent_delta2ns(0x000f, &pit_ce); | 85 | pit_ce.min_delta_ns = clockevent_delta2ns(0x000f, &pit_ce); |
123 | 86 | ||
124 | clocksource_register_hz(&pit_cs, PIT_TICK_RATE); | 87 | clocksource_i8253_init(); |
125 | 88 | ||
126 | setup_irq(pit_ce.irq, &pit_timer_irq); | 89 | setup_irq(pit_ce.irq, &pit_timer_irq); |
127 | clockevents_register_device(&pit_ce); | 90 | clockevents_register_device(&pit_ce); |