diff options
Diffstat (limited to 'arch/arm/mach-omap1/time.c')
-rw-r--r-- | arch/arm/mach-omap1/time.c | 69 |
1 files changed, 22 insertions, 47 deletions
diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c index 6885d2fac183..03e1e1062ad4 100644 --- a/arch/arm/mach-omap1/time.c +++ b/arch/arm/mach-omap1/time.c | |||
@@ -68,49 +68,50 @@ typedef struct { | |||
68 | } omap_mpu_timer_regs_t; | 68 | } omap_mpu_timer_regs_t; |
69 | 69 | ||
70 | #define omap_mpu_timer_base(n) \ | 70 | #define omap_mpu_timer_base(n) \ |
71 | ((volatile omap_mpu_timer_regs_t*)OMAP1_IO_ADDRESS(OMAP_MPU_TIMER_BASE + \ | 71 | ((omap_mpu_timer_regs_t __iomem *)OMAP1_IO_ADDRESS(OMAP_MPU_TIMER_BASE + \ |
72 | (n)*OMAP_MPU_TIMER_OFFSET)) | 72 | (n)*OMAP_MPU_TIMER_OFFSET)) |
73 | 73 | ||
74 | static inline unsigned long notrace omap_mpu_timer_read(int nr) | 74 | static inline unsigned long notrace omap_mpu_timer_read(int nr) |
75 | { | 75 | { |
76 | volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr); | 76 | omap_mpu_timer_regs_t __iomem *timer = omap_mpu_timer_base(nr); |
77 | return timer->read_tim; | 77 | return readl(&timer->read_tim); |
78 | } | 78 | } |
79 | 79 | ||
80 | static inline void omap_mpu_set_autoreset(int nr) | 80 | static inline void omap_mpu_set_autoreset(int nr) |
81 | { | 81 | { |
82 | volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr); | 82 | omap_mpu_timer_regs_t __iomem *timer = omap_mpu_timer_base(nr); |
83 | 83 | ||
84 | timer->cntl = timer->cntl | MPU_TIMER_AR; | 84 | writel(readl(&timer->cntl) | MPU_TIMER_AR, &timer->cntl); |
85 | } | 85 | } |
86 | 86 | ||
87 | static inline void omap_mpu_remove_autoreset(int nr) | 87 | static inline void omap_mpu_remove_autoreset(int nr) |
88 | { | 88 | { |
89 | volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr); | 89 | omap_mpu_timer_regs_t __iomem *timer = omap_mpu_timer_base(nr); |
90 | 90 | ||
91 | timer->cntl = timer->cntl & ~MPU_TIMER_AR; | 91 | writel(readl(&timer->cntl) & ~MPU_TIMER_AR, &timer->cntl); |
92 | } | 92 | } |
93 | 93 | ||
94 | static inline void omap_mpu_timer_start(int nr, unsigned long load_val, | 94 | static inline void omap_mpu_timer_start(int nr, unsigned long load_val, |
95 | int autoreset) | 95 | int autoreset) |
96 | { | 96 | { |
97 | volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr); | 97 | omap_mpu_timer_regs_t __iomem *timer = omap_mpu_timer_base(nr); |
98 | unsigned int timerflags = (MPU_TIMER_CLOCK_ENABLE | MPU_TIMER_ST); | 98 | unsigned int timerflags = MPU_TIMER_CLOCK_ENABLE | MPU_TIMER_ST; |
99 | 99 | ||
100 | if (autoreset) timerflags |= MPU_TIMER_AR; | 100 | if (autoreset) |
101 | timerflags |= MPU_TIMER_AR; | ||
101 | 102 | ||
102 | timer->cntl = MPU_TIMER_CLOCK_ENABLE; | 103 | writel(MPU_TIMER_CLOCK_ENABLE, &timer->cntl); |
103 | udelay(1); | 104 | udelay(1); |
104 | timer->load_tim = load_val; | 105 | writel(load_val, &timer->load_tim); |
105 | udelay(1); | 106 | udelay(1); |
106 | timer->cntl = timerflags; | 107 | writel(timerflags, &timer->cntl); |
107 | } | 108 | } |
108 | 109 | ||
109 | static inline void omap_mpu_timer_stop(int nr) | 110 | static inline void omap_mpu_timer_stop(int nr) |
110 | { | 111 | { |
111 | volatile omap_mpu_timer_regs_t* timer = omap_mpu_timer_base(nr); | 112 | omap_mpu_timer_regs_t __iomem *timer = omap_mpu_timer_base(nr); |
112 | 113 | ||
113 | timer->cntl &= ~MPU_TIMER_ST; | 114 | writel(readl(&timer->cntl) & ~MPU_TIMER_ST, &timer->cntl); |
114 | } | 115 | } |
115 | 116 | ||
116 | /* | 117 | /* |
@@ -189,38 +190,11 @@ static __init void omap_init_mpu_timer(unsigned long rate) | |||
189 | * --------------------------------------------------------------------------- | 190 | * --------------------------------------------------------------------------- |
190 | */ | 191 | */ |
191 | 192 | ||
192 | static unsigned long omap_mpu_timer2_overflows; | ||
193 | |||
194 | static irqreturn_t omap_mpu_timer2_interrupt(int irq, void *dev_id) | ||
195 | { | ||
196 | omap_mpu_timer2_overflows++; | ||
197 | return IRQ_HANDLED; | ||
198 | } | ||
199 | |||
200 | static struct irqaction omap_mpu_timer2_irq = { | ||
201 | .name = "mpu_timer2", | ||
202 | .flags = IRQF_DISABLED, | ||
203 | .handler = omap_mpu_timer2_interrupt, | ||
204 | }; | ||
205 | |||
206 | static cycle_t mpu_read(struct clocksource *cs) | ||
207 | { | ||
208 | return ~omap_mpu_timer_read(1); | ||
209 | } | ||
210 | |||
211 | static struct clocksource clocksource_mpu = { | ||
212 | .name = "mpu_timer2", | ||
213 | .rating = 300, | ||
214 | .read = mpu_read, | ||
215 | .mask = CLOCKSOURCE_MASK(32), | ||
216 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
217 | }; | ||
218 | |||
219 | static DEFINE_CLOCK_DATA(cd); | 193 | static DEFINE_CLOCK_DATA(cd); |
220 | 194 | ||
221 | static inline unsigned long long notrace _omap_mpu_sched_clock(void) | 195 | static inline unsigned long long notrace _omap_mpu_sched_clock(void) |
222 | { | 196 | { |
223 | u32 cyc = mpu_read(&clocksource_mpu); | 197 | u32 cyc = ~omap_mpu_timer_read(1); |
224 | return cyc_to_sched_clock(&cd, cyc, (u32)~0); | 198 | return cyc_to_sched_clock(&cd, cyc, (u32)~0); |
225 | } | 199 | } |
226 | 200 | ||
@@ -238,21 +212,22 @@ static unsigned long long notrace omap_mpu_sched_clock(void) | |||
238 | 212 | ||
239 | static void notrace mpu_update_sched_clock(void) | 213 | static void notrace mpu_update_sched_clock(void) |
240 | { | 214 | { |
241 | u32 cyc = mpu_read(&clocksource_mpu); | 215 | u32 cyc = ~omap_mpu_timer_read(1); |
242 | update_sched_clock(&cd, cyc, (u32)~0); | 216 | update_sched_clock(&cd, cyc, (u32)~0); |
243 | } | 217 | } |
244 | 218 | ||
245 | static void __init omap_init_clocksource(unsigned long rate) | 219 | static void __init omap_init_clocksource(unsigned long rate) |
246 | { | 220 | { |
221 | omap_mpu_timer_regs_t __iomem *timer = omap_mpu_timer_base(1); | ||
247 | static char err[] __initdata = KERN_ERR | 222 | static char err[] __initdata = KERN_ERR |
248 | "%s: can't register clocksource!\n"; | 223 | "%s: can't register clocksource!\n"; |
249 | 224 | ||
250 | setup_irq(INT_TIMER2, &omap_mpu_timer2_irq); | ||
251 | omap_mpu_timer_start(1, ~0, 1); | 225 | omap_mpu_timer_start(1, ~0, 1); |
252 | init_sched_clock(&cd, mpu_update_sched_clock, 32, rate); | 226 | init_sched_clock(&cd, mpu_update_sched_clock, 32, rate); |
253 | 227 | ||
254 | if (clocksource_register_hz(&clocksource_mpu, rate)) | 228 | if (clocksource_mmio_init(&timer->read_tim, "mpu_timer2", rate, |
255 | printk(err, clocksource_mpu.name); | 229 | 300, 32, clocksource_mmio_readl_down)) |
230 | printk(err, "mpu_timer2"); | ||
256 | } | 231 | } |
257 | 232 | ||
258 | static void __init omap_mpu_timer_init(void) | 233 | static void __init omap_mpu_timer_init(void) |