20 #include <linux/bitops.h>
25 #include <linux/kernel.h>
26 #include <linux/module.h>
30 #include <linux/slab.h>
31 #include <linux/string.h>
36 #define REG_CONTROL 0x00
37 #define REG_COUNTER_LO 0x04
38 #define REG_COUNTER_HI 0x08
39 #define REG_COMPARE(n) (0x0c + (n) * 4)
41 #define DEFAULT_TIMER 3
47 struct clock_event_device
evt;
58 static void bcm2835_time_set_mode(
enum clock_event_mode
mode,
59 struct clock_event_device *evt_dev)
62 case CLOCK_EVT_MODE_ONESHOT:
63 case CLOCK_EVT_MODE_UNUSED:
64 case CLOCK_EVT_MODE_SHUTDOWN:
65 case CLOCK_EVT_MODE_RESUME:
68 WARN(1,
"%s: unhandled event mode %d\n", __func__, mode);
73 static int bcm2835_time_set_next_event(
unsigned long event,
74 struct clock_event_device *evt_dev)
100 { .compatible =
"brcm,bcm2835-system-timer" },
104 static void __init bcm2835_time_init(
void)
114 panic(
"No bcm2835 timer node");
118 panic(
"Can't remap registers");
120 if (of_property_read_u32(node,
"clock-frequency", &freq))
121 panic(
"Can't read clock-frequency");
131 panic(
"Can't parse IRQ");
135 panic(
"Can't allocate timer struct\n");
141 timer->
evt.rating = 300;
142 timer->
evt.features = CLOCK_EVT_FEAT_ONESHOT;
143 timer->
evt.set_mode = bcm2835_time_set_mode;
144 timer->
evt.set_next_event = bcm2835_time_set_next_event;
149 timer->
act.handler = bcm2835_time_interrupt;
152 panic(
"Can't set up timer IRQ\n");
156 pr_info(
"bcm2835: system timer (irq = %d)\n", irq);
160 .init = bcm2835_time_init,