diff options
author | Paul Mundt <lethal@linux-sh.org> | 2006-11-05 02:48:42 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2006-12-05 20:45:37 -0500 |
commit | 710ee0cc45d095f7697821b330a3f8280205c2be (patch) | |
tree | 8bce794be73a6961d118d485c097232628812e94 /arch/sh/kernel/timers/timer-mtu2.c | |
parent | f36af3fd377081d3ac2ff6b63a60f8db8b3bf531 (diff) |
sh: SE7206 build fixes.
A number of API changes happened underneath the 7206 patches, update
for everything that broke.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/kernel/timers/timer-mtu2.c')
-rw-r--r-- | arch/sh/kernel/timers/timer-mtu2.c | 62 |
1 files changed, 5 insertions, 57 deletions
diff --git a/arch/sh/kernel/timers/timer-mtu2.c b/arch/sh/kernel/timers/timer-mtu2.c index 73a5ef3c457d..045b2aba13fa 100644 --- a/arch/sh/kernel/timers/timer-mtu2.c +++ b/arch/sh/kernel/timers/timer-mtu2.c | |||
@@ -98,8 +98,7 @@ static unsigned long mtu2_timer_get_offset(void) | |||
98 | return count; | 98 | return count; |
99 | } | 99 | } |
100 | 100 | ||
101 | static irqreturn_t mtu2_timer_interrupt(int irq, void *dev_id, | 101 | static irqreturn_t mtu2_timer_interrupt(int irq, void *dev_id) |
102 | struct pt_regs *regs) | ||
103 | { | 102 | { |
104 | unsigned long timer_status; | 103 | unsigned long timer_status; |
105 | 104 | ||
@@ -110,7 +109,7 @@ static irqreturn_t mtu2_timer_interrupt(int irq, void *dev_id, | |||
110 | 109 | ||
111 | /* Do timer tick */ | 110 | /* Do timer tick */ |
112 | write_seqlock(&xtime_lock); | 111 | write_seqlock(&xtime_lock); |
113 | handle_timer_tick(regs); | 112 | handle_timer_tick(); |
114 | write_sequnlock(&xtime_lock); | 113 | write_sequnlock(&xtime_lock); |
115 | 114 | ||
116 | return IRQ_HANDLED; | 115 | return IRQ_HANDLED; |
@@ -119,62 +118,10 @@ static irqreturn_t mtu2_timer_interrupt(int irq, void *dev_id, | |||
119 | static struct irqaction mtu2_irq = { | 118 | static struct irqaction mtu2_irq = { |
120 | .name = "timer", | 119 | .name = "timer", |
121 | .handler = mtu2_timer_interrupt, | 120 | .handler = mtu2_timer_interrupt, |
122 | .flags = SA_INTERRUPT, | 121 | .flags = IRQF_DISABLED, |
123 | .mask = CPU_MASK_NONE, | 122 | .mask = CPU_MASK_NONE, |
124 | }; | 123 | }; |
125 | 124 | ||
126 | /* | ||
127 | * Hah! We'll see if this works (switching from usecs to nsecs). | ||
128 | */ | ||
129 | static unsigned long mtu2_timer_get_frequency(void) | ||
130 | { | ||
131 | u32 freq; | ||
132 | struct timespec ts1, ts2; | ||
133 | unsigned long diff_nsec; | ||
134 | unsigned long factor; | ||
135 | |||
136 | /* Setup the timer: We don't want to generate interrupts, just | ||
137 | * have it count down at its natural rate. | ||
138 | */ | ||
139 | |||
140 | ctrl_outb(ctrl_inb(MTU2_TSTR) & ~MTU2_TSTR_CST1, MTU2_TSTR); | ||
141 | ctrl_outb(MTU2_TCR_CALIB, MTU2_TCR_1); | ||
142 | ctrl_outb(ctrl_inb(MTU2_TIER_1) & ~MTU2_TIER_TGIEA, MTU2_TIER_1); | ||
143 | ctrl_outw(0, MTU2_TCNT_1); | ||
144 | |||
145 | rtc_get_time(&ts2); | ||
146 | |||
147 | do { | ||
148 | rtc_get_time(&ts1); | ||
149 | } while (ts1.tv_nsec == ts2.tv_nsec && ts1.tv_sec == ts2.tv_sec); | ||
150 | |||
151 | /* actually start the timer */ | ||
152 | ctrl_outw(ctrl_inw(CMT_CMSTR) | 0x01, CMT_CMSTR); | ||
153 | |||
154 | do { | ||
155 | rtc_get_time(&ts2); | ||
156 | } while (ts1.tv_nsec == ts2.tv_nsec && ts1.tv_sec == ts2.tv_sec); | ||
157 | |||
158 | freq = ctrl_inw(MTU2_TCNT_0); | ||
159 | if (ts2.tv_nsec < ts1.tv_nsec) { | ||
160 | ts2.tv_nsec += 1000000000; | ||
161 | ts2.tv_sec--; | ||
162 | } | ||
163 | |||
164 | diff_nsec = (ts2.tv_sec - ts1.tv_sec) * 1000000000 + (ts2.tv_nsec - ts1.tv_nsec); | ||
165 | |||
166 | /* this should work well if the RTC has a precision of n Hz, where | ||
167 | * n is an integer. I don't think we have to worry about the other | ||
168 | * cases. */ | ||
169 | factor = (1000000000 + diff_nsec/2) / diff_nsec; | ||
170 | |||
171 | if (factor * diff_nsec > 1100000000 || | ||
172 | factor * diff_nsec < 900000000) | ||
173 | panic("weird RTC (diff_nsec %ld)", diff_nsec); | ||
174 | |||
175 | return freq * factor; | ||
176 | } | ||
177 | |||
178 | static unsigned int divisors[] = { 1, 4, 16, 64, 1, 1, 256 }; | 125 | static unsigned int divisors[] = { 1, 4, 16, 64, 1, 1, 256 }; |
179 | 126 | ||
180 | static void mtu2_clk_init(struct clk *clk) | 127 | static void mtu2_clk_init(struct clk *clk) |
@@ -250,8 +197,9 @@ struct sys_timer_ops mtu2_timer_ops = { | |||
250 | .init = mtu2_timer_init, | 197 | .init = mtu2_timer_init, |
251 | .start = mtu2_timer_start, | 198 | .start = mtu2_timer_start, |
252 | .stop = mtu2_timer_stop, | 199 | .stop = mtu2_timer_stop, |
253 | .get_frequency = mtu2_timer_get_frequency, | 200 | #ifndef CONFIG_GENERIC_TIME |
254 | .get_offset = mtu2_timer_get_offset, | 201 | .get_offset = mtu2_timer_get_offset, |
202 | #endif | ||
255 | }; | 203 | }; |
256 | 204 | ||
257 | struct sys_timer mtu2_timer = { | 205 | struct sys_timer mtu2_timer = { |