aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-ep93xx/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-ep93xx/core.c')
-rw-r--r--arch/arm/mach-ep93xx/core.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index e85bf17f2d2a..ee27b4b0ab07 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -140,11 +140,29 @@ static struct irqaction ep93xx_timer_irq = {
140 .handler = ep93xx_timer_interrupt, 140 .handler = ep93xx_timer_interrupt,
141}; 141};
142 142
143static void __init ep93xx_timer_init(void) 143static u32 ep93xx_gettimeoffset(void)
144{
145 int offset;
146
147 offset = __raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time;
148
149 /*
150 * Timer 4 is based on a 983.04 kHz reference clock,
151 * so dividing by 983040 gives the fraction of a second,
152 * so dividing by 0.983040 converts to uS.
153 * Refactor the calculation to avoid overflow.
154 * Finally, multiply by 1000 to give nS.
155 */
156 return (offset + (53 * offset / 3072)) * 1000;
157}
158
159void __init ep93xx_timer_init(void)
144{ 160{
145 u32 tmode = EP93XX_TIMER123_CONTROL_MODE | 161 u32 tmode = EP93XX_TIMER123_CONTROL_MODE |
146 EP93XX_TIMER123_CONTROL_CLKSEL; 162 EP93XX_TIMER123_CONTROL_CLKSEL;
147 163
164 arch_gettimeoffset = ep93xx_gettimeoffset;
165
148 /* Enable periodic HZ timer. */ 166 /* Enable periodic HZ timer. */
149 __raw_writel(tmode, EP93XX_TIMER1_CONTROL); 167 __raw_writel(tmode, EP93XX_TIMER1_CONTROL);
150 __raw_writel(TIMER1_RELOAD, EP93XX_TIMER1_LOAD); 168 __raw_writel(TIMER1_RELOAD, EP93XX_TIMER1_LOAD);
@@ -158,21 +176,6 @@ static void __init ep93xx_timer_init(void)
158 setup_irq(IRQ_EP93XX_TIMER1, &ep93xx_timer_irq); 176 setup_irq(IRQ_EP93XX_TIMER1, &ep93xx_timer_irq);
159} 177}
160 178
161static unsigned long ep93xx_gettimeoffset(void)
162{
163 int offset;
164
165 offset = __raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time;
166
167 /* Calculate (1000000 / 983040) * offset. */
168 return offset + (53 * offset / 3072);
169}
170
171struct sys_timer ep93xx_timer = {
172 .init = ep93xx_timer_init,
173 .offset = ep93xx_gettimeoffset,
174};
175
176 179
177/************************************************************************* 180/*************************************************************************
178 * EP93xx IRQ handling 181 * EP93xx IRQ handling