1 #include <linux/types.h>
6 #include <linux/time.h>
13 #define SNI_CLOCK_TICK_RATE 3686400
14 #define SNI_COUNTER2_DIV 64
15 #define SNI_COUNTER0_DIV ((SNI_CLOCK_TICK_RATE / SNI_COUNTER2_DIV) / HZ)
17 static void a20r_set_mode(
enum clock_event_mode
mode,
18 struct clock_event_device *
evt)
21 case CLOCK_EVT_MODE_PERIODIC:
37 case CLOCK_EVT_MODE_ONESHOT:
38 case CLOCK_EVT_MODE_UNUSED:
39 case CLOCK_EVT_MODE_SHUTDOWN:
41 case CLOCK_EVT_MODE_RESUME:
46 static struct clock_event_device a20r_clockevent_device = {
48 .features = CLOCK_EVT_FEAT_PERIODIC,
54 .set_mode = a20r_set_mode,
59 struct clock_event_device *
cd =
dev_id;
64 cd->event_handler(cd);
69 static struct irqaction a20r_irqaction = {
70 .handler = a20r_interrupt,
79 static void __init sni_a20r_timer_setup(
void)
81 struct clock_event_device *cd = &a20r_clockevent_device;
91 #define SNI_8254_TICK_RATE 1193182UL
93 #define SNI_8254_TCSAMP_COUNTER ((SNI_8254_TICK_RATE / HZ) + 255)
95 static __init unsigned long dosample(
void)
124 return (ct1 - ct0) / (500000/
HZ) * (500000/
HZ);
132 unsigned long r4k_ticks[3];
133 unsigned long r4k_tick;
149 r4k_ticks[0] = dosample();
150 }
while (!r4k_ticks[0]);
152 r4k_ticks[1] = dosample();
153 }
while (!r4k_ticks[1]);
155 if (r4k_ticks[0] != r4k_ticks[1]) {
156 printk(
"warning: timer counts differ, retrying... ");
157 r4k_ticks[2] = dosample();
158 if (r4k_ticks[2] == r4k_ticks[0]
159 || r4k_ticks[2] == r4k_ticks[1])
160 r4k_tick = r4k_ticks[2];
162 printk(
"disagreement, using average... ");
163 r4k_tick = (r4k_ticks[0] + r4k_ticks[1]
167 r4k_tick = r4k_ticks[0];
169 printk(
"%d [%d.%04d MHz CPU]\n", (
int) r4k_tick,
170 (
int) (r4k_tick / (500000 /
HZ)),
171 (
int) (r4k_tick % (500000 /
HZ)));
180 sni_a20r_timer_setup();