17 #include <linux/kernel.h>
18 #include <linux/time.h>
28 #define TIMER_CLOCKEVENT 0
29 #define TIMER_CLOCKSOURCE 1
31 static uint16_t jz4740_jiffies_per_tick;
39 .name =
"jz4740-timer",
41 .read = jz4740_clocksource_read,
48 struct clock_event_device *
cd =
devid;
52 if (cd->mode != CLOCK_EVT_MODE_PERIODIC)
55 cd->event_handler(cd);
60 static void jz4740_clockevent_set_mode(
enum clock_event_mode
mode,
61 struct clock_event_device *cd)
64 case CLOCK_EVT_MODE_PERIODIC:
67 case CLOCK_EVT_MODE_RESUME:
71 case CLOCK_EVT_MODE_ONESHOT:
72 case CLOCK_EVT_MODE_SHUTDOWN:
80 static int jz4740_clockevent_set_next(
unsigned long evt,
81 struct clock_event_device *cd)
90 static struct clock_event_device jz4740_clockevent = {
91 .name =
"jz4740-timer",
92 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
93 .set_next_event = jz4740_clockevent_set_next,
94 .set_mode = jz4740_clockevent_set_mode,
100 .handler = jz4740_clockevent_irq,
102 .name =
"jz4740-timerirq",
103 .dev_id = &jz4740_clockevent,
117 clockevent_set_clock(&jz4740_clockevent, clk_rate);
124 ret = clocksource_register_hz(&jz4740_clocksource, clk_rate);