27 #define EPITCR_EN (1 << 0)
28 #define EPITCR_ENMOD (1 << 1)
29 #define EPITCR_OCIEN (1 << 2)
30 #define EPITCR_RLD (1 << 3)
31 #define EPITCR_PRESC(x) (((x) & 0xfff) << 4)
32 #define EPITCR_SWR (1 << 16)
33 #define EPITCR_IOVW (1 << 17)
34 #define EPITCR_DBGEN (1 << 18)
35 #define EPITCR_WAITEN (1 << 19)
36 #define EPITCR_RES (1 << 20)
37 #define EPITCR_STOPEN (1 << 21)
38 #define EPITCR_OM_DISCON (0 << 22)
39 #define EPITCR_OM_TOGGLE (1 << 22)
40 #define EPITCR_OM_CLEAR (2 << 22)
41 #define EPITCR_OM_SET (3 << 22)
42 #define EPITCR_CLKSRC_OFF (0 << 24)
43 #define EPITCR_CLKSRC_PERIPHERAL (1 << 24)
44 #define EPITCR_CLKSRC_REF_HIGH (1 << 24)
45 #define EPITCR_CLKSRC_REF_LOW (3 << 24)
47 #define EPITSR_OCIF (1 << 0)
55 #include <mach/hardware.h>
57 #include <mach/common.h>
59 static struct clock_event_device clockevent_epit;
60 static enum clock_event_mode clockevent_mode = CLOCK_EVT_MODE_UNUSED;
62 static void __iomem *timer_base;
64 static inline void epit_irq_disable(
void)
73 static inline void epit_irq_enable(
void)
82 static void epit_irq_acknowledge(
void)
87 static int __init epit_clocksource_init(
struct clk *timer_clk)
97 static int epit_set_next_event(
unsigned long evt,
98 struct clock_event_device *
unused)
109 static void epit_set_mode(
enum clock_event_mode
mode,
110 struct clock_event_device *
evt)
123 if (mode != clockevent_mode) {
127 epit_irq_acknowledge();
131 clockevent_mode =
mode;
135 case CLOCK_EVT_MODE_PERIODIC:
137 "supported for i.MX EPIT\n");
139 case CLOCK_EVT_MODE_ONESHOT:
150 case CLOCK_EVT_MODE_SHUTDOWN:
151 case CLOCK_EVT_MODE_UNUSED:
152 case CLOCK_EVT_MODE_RESUME:
163 struct clock_event_device *evt = &clockevent_epit;
165 epit_irq_acknowledge();
167 evt->event_handler(evt);
172 static struct irqaction epit_timer_irq = {
173 .name =
"i.MX EPIT Timer Tick",
175 .handler = epit_timer_interrupt,
178 static struct clock_event_device clockevent_epit = {
180 .features = CLOCK_EVT_FEAT_ONESHOT,
182 .set_mode = epit_set_mode,
183 .set_next_event = epit_set_next_event,
187 static int __init epit_clockevent_init(
struct clk *timer_clk)
192 clockevent_epit.shift);
193 clockevent_epit.max_delta_ns =
195 clockevent_epit.min_delta_ns =
207 struct clk *timer_clk;
210 if (IS_ERR(timer_clk)) {
211 pr_err(
"i.MX epit: unable to get clk\n");
215 clk_prepare_enable(timer_clk);
229 epit_clocksource_init(timer_clk);
230 epit_clockevent_init(timer_clk);