13 #include <linux/kernel.h>
14 #include <linux/time.h>
34 .name =
"avr32_counter",
36 .read = read_cycle_count,
54 evdev->event_handler(evdev);
62 .name =
"avr32_comparator",
65 static int comparator_next_event(
unsigned long delta,
66 struct clock_event_device *evdev)
82 static void comparator_mode(
enum clock_event_mode
mode,
83 struct clock_event_device *evdev)
86 case CLOCK_EVT_MODE_ONESHOT:
87 pr_debug(
"%s: start\n", evdev->name);
89 case CLOCK_EVT_MODE_RESUME:
90 cpu_disable_idle_sleep();
92 case CLOCK_EVT_MODE_UNUSED:
93 case CLOCK_EVT_MODE_SHUTDOWN:
96 cpu_enable_idle_sleep();
103 static struct clock_event_device
comparator = {
104 .
name =
"avr32_comparator",
105 .features = CLOCK_EVT_FEAT_ONESHOT,
108 .set_next_event = comparator_next_event,
109 .set_mode = comparator_mode,
120 unsigned long counter_hz;
125 ret = clocksource_register_hz(&counter, counter_hz);
127 pr_debug(
"timer: could not register clocksource: %d\n", ret);
130 comparator.mult = div_sc(counter_hz,
NSEC_PER_SEC, comparator.shift);
136 timer_irqaction.
dev_id = &comparator;
140 pr_debug(
"timer: could not request IRQ 0: %d\n", ret);
144 pr_info(
"%s: irq 0, %lu.%03lu MHz\n", comparator.name,
145 ((counter_hz + 500) / 1000) / 1000,
146 ((counter_hz + 500) / 1000) % 1000);