diff options
Diffstat (limited to 'arch/mips/dec/time.c')
-rw-r--r-- | arch/mips/dec/time.c | 71 |
1 files changed, 23 insertions, 48 deletions
diff --git a/arch/mips/dec/time.c b/arch/mips/dec/time.c index 60349062595a..3965fda94a89 100644 --- a/arch/mips/dec/time.c +++ b/arch/mips/dec/time.c | |||
@@ -9,30 +9,15 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | #include <linux/bcd.h> | 11 | #include <linux/bcd.h> |
12 | #include <linux/errno.h> | ||
13 | #include <linux/init.h> | 12 | #include <linux/init.h> |
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/mc146818rtc.h> | 13 | #include <linux/mc146818rtc.h> |
17 | #include <linux/mm.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/param.h> | 14 | #include <linux/param.h> |
20 | #include <linux/sched.h> | ||
21 | #include <linux/string.h> | ||
22 | #include <linux/time.h> | ||
23 | #include <linux/types.h> | ||
24 | |||
25 | #include <asm/bootinfo.h> | ||
26 | #include <asm/cpu.h> | ||
27 | #include <asm/io.h> | ||
28 | #include <asm/irq.h> | ||
29 | #include <asm/mipsregs.h> | ||
30 | #include <asm/sections.h> | ||
31 | #include <asm/time.h> | ||
32 | 15 | ||
16 | #include <asm/cpu-features.h> | ||
17 | #include <asm/ds1287.h> | ||
18 | #include <asm/time.h> | ||
33 | #include <asm/dec/interrupts.h> | 19 | #include <asm/dec/interrupts.h> |
34 | #include <asm/dec/ioasic.h> | 20 | #include <asm/dec/ioasic.h> |
35 | #include <asm/dec/ioasic_addrs.h> | ||
36 | #include <asm/dec/machtype.h> | 21 | #include <asm/dec/machtype.h> |
37 | 22 | ||
38 | unsigned long read_persistent_clock(void) | 23 | unsigned long read_persistent_clock(void) |
@@ -139,42 +124,32 @@ int rtc_mips_set_mmss(unsigned long nowtime) | |||
139 | return retval; | 124 | return retval; |
140 | } | 125 | } |
141 | 126 | ||
142 | static int dec_timer_state(void) | 127 | void __init plat_time_init(void) |
143 | { | 128 | { |
144 | return (CMOS_READ(RTC_REG_C) & RTC_PF) != 0; | 129 | u32 start, end; |
145 | } | 130 | int i = HZ / 10; |
146 | 131 | ||
147 | static void dec_timer_ack(void) | 132 | /* Set up the rate of periodic DS1287 interrupts. */ |
148 | { | 133 | ds1287_set_base_clock(HZ); |
149 | CMOS_READ(RTC_REG_C); /* Ack the RTC interrupt. */ | ||
150 | } | ||
151 | |||
152 | static cycle_t dec_ioasic_hpt_read(void) | ||
153 | { | ||
154 | /* | ||
155 | * The free-running counter is 32-bit which is good for about | ||
156 | * 2 minutes, 50 seconds at possible count rates of up to 25MHz. | ||
157 | */ | ||
158 | return ioasic_read(IO_REG_FCTR); | ||
159 | } | ||
160 | 134 | ||
135 | if (cpu_has_counter) { | ||
136 | while (!ds1287_timer_state()) | ||
137 | ; | ||
161 | 138 | ||
162 | void __init plat_time_init(void) | 139 | start = read_c0_count(); |
163 | { | ||
164 | mips_timer_ack = dec_timer_ack; | ||
165 | 140 | ||
166 | if (!cpu_has_counter && IOASIC) | 141 | while (i--) |
167 | /* For pre-R4k systems we use the I/O ASIC's counter. */ | 142 | while (!ds1287_timer_state()) |
168 | clocksource_mips.read = dec_ioasic_hpt_read; | 143 | ; |
169 | 144 | ||
170 | /* Set up the rate of periodic DS1287 interrupts. */ | 145 | end = read_c0_count(); |
171 | CMOS_WRITE(RTC_REF_CLCK_32KHZ | (16 - __ffs(HZ)), RTC_REG_A); | ||
172 | } | ||
173 | 146 | ||
174 | void __init plat_timer_setup(struct irqaction *irq) | 147 | mips_hpt_frequency = (end - start) * 10; |
175 | { | 148 | printk(KERN_INFO "MIPS counter frequency %dHz\n", |
176 | setup_irq(dec_interrupt[DEC_IRQ_RTC], irq); | 149 | mips_hpt_frequency); |
150 | } else if (IOASIC) | ||
151 | /* For pre-R4k systems we use the I/O ASIC's counter. */ | ||
152 | dec_ioasic_clocksource_init(); | ||
177 | 153 | ||
178 | /* Enable periodic DS1287 interrupts. */ | 154 | ds1287_clockevent_init(dec_interrupt[DEC_IRQ_RTC]); |
179 | CMOS_WRITE(CMOS_READ(RTC_REG_B) | RTC_PIE, RTC_REG_B); | ||
180 | } | 155 | } |