16 #include <linux/kernel.h>
18 #include <linux/time.h>
20 #include <linux/timex.h>
24 #include <linux/export.h>
25 #include <mach/hardware.h>
28 #include <asm/uaccess.h>
31 #include <mach/time.h>
36 #define IOP_MIN_RANGE 4
43 return 0xffffffff
u - read_tcr1();
49 .read = iop_clocksource_read,
59 return 0xffffffff
u - read_tcr1();
65 static int iop_set_next_event(
unsigned long delta,
66 struct clock_event_device *
unused)
78 static unsigned long ticks_per_jiffy;
80 static void iop_set_mode(
enum clock_event_mode
mode,
81 struct clock_event_device *unused)
83 u32 tmr = read_tmr0();
86 case CLOCK_EVT_MODE_PERIODIC:
88 write_tcr0(ticks_per_jiffy - 1);
89 write_trr0(ticks_per_jiffy - 1);
92 case CLOCK_EVT_MODE_ONESHOT:
96 case CLOCK_EVT_MODE_RESUME:
99 case CLOCK_EVT_MODE_SHUTDOWN:
100 case CLOCK_EVT_MODE_UNUSED:
109 static struct clock_event_device iop_clockevent = {
110 .name =
"iop_timer0",
111 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
113 .set_next_event = iop_set_next_event,
114 .set_mode = iop_set_mode,
118 iop_timer_interrupt(
int irq,
void *
dev_id)
123 evt->event_handler(evt);
127 static struct irqaction iop_timer_irq = {
128 .name =
"IOP Timer Tick",
129 .handler = iop_timer_interrupt,
131 .dev_id = &iop_clockevent,
134 static unsigned long iop_tick_rate;
137 return iop_tick_rate;
148 iop_tick_rate = tick_rate;
159 clockevents_calc_mult_shift(&iop_clockevent,
161 iop_clockevent.max_delta_ns =
163 iop_clockevent.min_delta_ns =
171 write_trr1(0xffffffff);
172 write_tcr1(0xffffffff);
173 write_tmr1(timer_ctl);
174 clocksource_register_hz(&iop_clocksource, tick_rate);