36 #include <linux/kernel.h>
50 #include <mach/hardware.h>
57 #ifdef CONFIG_OMAP_MPU_TIMER
59 #define OMAP_MPU_TIMER_BASE OMAP_MPU_TIMER1_BASE
60 #define OMAP_MPU_TIMER_OFFSET 0x100
66 } omap_mpu_timer_regs_t;
68 #define omap_mpu_timer_base(n) \
69 ((omap_mpu_timer_regs_t __iomem *)OMAP1_IO_ADDRESS(OMAP_MPU_TIMER_BASE + \
70 (n)*OMAP_MPU_TIMER_OFFSET))
72 static inline unsigned long notrace omap_mpu_timer_read(
int nr)
74 omap_mpu_timer_regs_t
__iomem *
timer = omap_mpu_timer_base(nr);
75 return readl(&timer->read_tim);
78 static inline void omap_mpu_set_autoreset(
int nr)
80 omap_mpu_timer_regs_t
__iomem *
timer = omap_mpu_timer_base(nr);
85 static inline void omap_mpu_remove_autoreset(
int nr)
87 omap_mpu_timer_regs_t
__iomem *timer = omap_mpu_timer_base(nr);
92 static inline void omap_mpu_timer_start(
int nr,
unsigned long load_val,
95 omap_mpu_timer_regs_t
__iomem *timer = omap_mpu_timer_base(nr);
103 writel(load_val, &timer->load_tim);
105 writel(timerflags, &timer->cntl);
108 static inline void omap_mpu_timer_stop(
int nr)
110 omap_mpu_timer_regs_t
__iomem *timer = omap_mpu_timer_base(nr);
120 static int omap_mpu_set_next_event(
unsigned long cycles,
121 struct clock_event_device *
evt)
123 omap_mpu_timer_start(0, cycles, 0);
127 static void omap_mpu_set_mode(
enum clock_event_mode
mode,
128 struct clock_event_device *
evt)
131 case CLOCK_EVT_MODE_PERIODIC:
132 omap_mpu_set_autoreset(0);
134 case CLOCK_EVT_MODE_ONESHOT:
135 omap_mpu_timer_stop(0);
136 omap_mpu_remove_autoreset(0);
138 case CLOCK_EVT_MODE_UNUSED:
139 case CLOCK_EVT_MODE_SHUTDOWN:
140 case CLOCK_EVT_MODE_RESUME:
145 static struct clock_event_device clockevent_mpu_timer1 = {
146 .name =
"mpu_timer1",
147 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
149 .set_next_event = omap_mpu_set_next_event,
150 .set_mode = omap_mpu_set_mode,
155 struct clock_event_device *evt = &clockevent_mpu_timer1;
157 evt->event_handler(evt);
162 static struct irqaction omap_mpu_timer1_irq = {
163 .
name =
"mpu_timer1",
165 .handler = omap_mpu_timer1_interrupt,
168 static __init void omap_init_mpu_timer(
unsigned long rate)
171 omap_mpu_timer_start(0, (rate /
HZ) - 1, 1);
174 clockevent_mpu_timer1.shift);
175 clockevent_mpu_timer1.max_delta_ns =
177 clockevent_mpu_timer1.min_delta_ns =
180 clockevent_mpu_timer1.cpumask =
cpumask_of(0);
191 static u32 notrace omap_mpu_read_sched_clock(
void)
193 return ~omap_mpu_timer_read(1);
196 static void __init omap_init_clocksource(
unsigned long rate)
198 omap_mpu_timer_regs_t
__iomem *timer = omap_mpu_timer_base(1);
200 "%s: can't register clocksource!\n";
202 omap_mpu_timer_start(1, ~0, 1);
210 static void __init omap_mpu_timer_init(
void)
223 omap_init_mpu_timer(rate);
224 omap_init_clocksource(rate);
228 static inline void omap_mpu_timer_init(
void)
230 pr_err(
"Bogus timer, should not happen\n");
239 static void __init omap1_timer_init(
void)
242 omap_mpu_timer_init();
246 .init = omap1_timer_init,