39 #define VT8500_TIMER_OFFSET 0x0100
40 #define VT8500_TIMER_HZ 3000000
41 #define TIMER_MATCH_VAL 0x0000
42 #define TIMER_COUNT_VAL 0x0010
43 #define TIMER_STATUS_VAL 0x0014
44 #define TIMER_IER_VAL 0x001c
45 #define TIMER_CTRL_VAL 0x0020
46 #define TIMER_AS_VAL 0x0024
47 #define TIMER_COUNT_R_ACTIVE (1 << 5)
48 #define TIMER_COUNT_W_ACTIVE (1 << 4)
49 #define TIMER_MATCH_W_ACTIVE (1 << 0)
51 #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
66 .
name =
"vt8500_timer",
68 .read = vt8500_timer_read,
73 static int vt8500_timer_set_next_event(
unsigned long cycles,
74 struct clock_event_device *
evt)
83 if ((
signed)(alarm - clocksource.
read(&clocksource)) <= 16)
91 static void vt8500_timer_set_mode(
enum clock_event_mode
mode,
92 struct clock_event_device *evt)
95 case CLOCK_EVT_MODE_RESUME:
96 case CLOCK_EVT_MODE_PERIODIC:
98 case CLOCK_EVT_MODE_ONESHOT:
99 case CLOCK_EVT_MODE_UNUSED:
100 case CLOCK_EVT_MODE_SHUTDOWN:
108 static struct clock_event_device clockevent = {
109 .name =
"vt8500_timer",
110 .features = CLOCK_EVT_FEAT_ONESHOT,
112 .set_next_event = vt8500_timer_set_next_event,
113 .set_mode = vt8500_timer_set_mode,
118 struct clock_event_device *evt =
dev_id;
120 evt->event_handler(evt);
126 .
name =
"vt8500_timer",
128 .handler = vt8500_timer_interrupt,
129 .dev_id = &clockevent,
133 { .compatible =
"via,vt8500-timer" },
144 pr_err(
"%s: Timer description missing from Device Tree\n",
150 pr_err(
"%s: Missing iobase description in Device Tree\n",
157 pr_err(
"%s: Missing irq description in Device Tree\n",
168 pr_err(
"%s: vt8500_timer_init: clocksource_register failed for %s\n",
169 __func__, clocksource.
name);
174 clockevent.max_delta_ns =
180 pr_err(
"%s: setup_irq failed for %s\n", __func__,