aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-11-08 13:51:58 -0500
committerStephen Warren <swarren@nvidia.com>2012-12-24 11:36:35 -0500
commit23c197b77f9553c30f9c8a5ab41279a35f135f37 (patch)
tree7da1f4b032ff24482afb1f289ab9c633de684d7a /arch/arm
parentc8d5ba1891eda2aa63800f052cb5af128283d130 (diff)
ARM: set arch_gettimeoffset directly
remove ARM's struct sys_timer .offset function pointer, and instead directly set the arch_gettimeoffset function pointer when the timer driver is initialized. This requires multiplying all function results by 1000, since the removed arm_gettimeoffset() did this. Also, s/unsigned long/u32/ just to make the function prototypes exactly match that of arch_gettimeoffset. Cc: Russell King <linux@arm.linux.org.uk> Cc: Andrew Victor <linux@maxim.org.za> Cc: Nicolas Ferre <nicolas.ferre@atmel.com> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com> Cc: Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ryan Mallon <rmallon@gmail.com> Cc: Ben Dooks <ben-linux@fluff.org> Cc: Kukjin Kim <kgene.kim@samsung.com> Signed-off-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/include/asm/mach/time.h3
-rw-r--r--arch/arm/kernel/time.c14
-rw-r--r--arch/arm/mach-at91/at91x40_time.c8
-rw-r--r--arch/arm/mach-ebsa110/core.c7
-rw-r--r--arch/arm/mach-ep93xx/core.c29
-rw-r--r--arch/arm/mach-h720x/common.c6
-rw-r--r--arch/arm/mach-h720x/common.h2
-rw-r--r--arch/arm/mach-h720x/cpu-h7201.c3
-rw-r--r--arch/arm/mach-h720x/cpu-h7202.c3
-rw-r--r--arch/arm/mach-rpc/time.c6
-rw-r--r--arch/arm/plat-samsung/time.c7
11 files changed, 42 insertions, 46 deletions
diff --git a/arch/arm/include/asm/mach/time.h b/arch/arm/include/asm/mach/time.h
index 6ca945f534ab..cac8d9c7d5d9 100644
--- a/arch/arm/include/asm/mach/time.h
+++ b/arch/arm/include/asm/mach/time.h
@@ -35,9 +35,6 @@ struct sys_timer {
35 void (*init)(void); 35 void (*init)(void);
36 void (*suspend)(void); 36 void (*suspend)(void);
37 void (*resume)(void); 37 void (*resume)(void);
38#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
39 unsigned long (*offset)(void);
40#endif
41}; 38};
42 39
43extern void timer_tick(void); 40extern void timer_tick(void);
diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index b0190b41cb33..ea36bfaeba91 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -69,16 +69,6 @@ unsigned long profile_pc(struct pt_regs *regs)
69EXPORT_SYMBOL(profile_pc); 69EXPORT_SYMBOL(profile_pc);
70#endif 70#endif
71 71
72#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
73static u32 arm_gettimeoffset(void)
74{
75 if (system_timer->offset != NULL)
76 return system_timer->offset() * 1000;
77
78 return 0;
79}
80#endif /* CONFIG_ARCH_USES_GETTIMEOFFSET */
81
82#ifndef CONFIG_GENERIC_CLOCKEVENTS 72#ifndef CONFIG_GENERIC_CLOCKEVENTS
83/* 73/*
84 * Kernel system timer support. 74 * Kernel system timer support.
@@ -164,10 +154,6 @@ device_initcall(timer_init_syscore_ops);
164 154
165void __init time_init(void) 155void __init time_init(void)
166{ 156{
167#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
168 arch_gettimeoffset = arm_gettimeoffset;
169#endif
170
171 system_timer = machine_desc->timer; 157 system_timer = machine_desc->timer;
172 system_timer->init(); 158 system_timer->init();
173 sched_clock_postinit(); 159 sched_clock_postinit();
diff --git a/arch/arm/mach-at91/at91x40_time.c b/arch/arm/mach-at91/at91x40_time.c
index 0e57e440c061..fb3c70124ac3 100644
--- a/arch/arm/mach-at91/at91x40_time.c
+++ b/arch/arm/mach-at91/at91x40_time.c
@@ -42,9 +42,10 @@
42#define AT91_TC_CLK1BASE 0x40 42#define AT91_TC_CLK1BASE 0x40
43#define AT91_TC_CLK2BASE 0x80 43#define AT91_TC_CLK2BASE 0x80
44 44
45static unsigned long at91x40_gettimeoffset(void) 45static u32 at91x40_gettimeoffset(void)
46{ 46{
47 return (at91_tc_read(AT91_TC_CLK1BASE + AT91_TC_CV) * 1000000 / (AT91X40_MASTER_CLOCK / 128)); 47 return (at91_tc_read(AT91_TC_CLK1BASE + AT91_TC_CV) * 1000000 /
48 (AT91X40_MASTER_CLOCK / 128)) * 1000;
48} 49}
49 50
50static irqreturn_t at91x40_timer_interrupt(int irq, void *dev_id) 51static irqreturn_t at91x40_timer_interrupt(int irq, void *dev_id)
@@ -64,6 +65,8 @@ void __init at91x40_timer_init(void)
64{ 65{
65 unsigned int v; 66 unsigned int v;
66 67
68 arch_gettimeoffset = at91x40_gettimeoffset;
69
67 at91_tc_write(AT91_TC_BCR, 0); 70 at91_tc_write(AT91_TC_BCR, 0);
68 v = at91_tc_read(AT91_TC_BMR); 71 v = at91_tc_read(AT91_TC_BMR);
69 v = (v & ~AT91_TC_TC1XC1S) | AT91_TC_TC1XC1S_NONE; 72 v = (v & ~AT91_TC_TC1XC1S) | AT91_TC_TC1XC1S_NONE;
@@ -82,6 +85,5 @@ void __init at91x40_timer_init(void)
82 85
83struct sys_timer at91x40_timer = { 86struct sys_timer at91x40_timer = {
84 .init = at91x40_timer_init, 87 .init = at91x40_timer_init,
85 .offset = at91x40_gettimeoffset,
86}; 88};
87 89
diff --git a/arch/arm/mach-ebsa110/core.c b/arch/arm/mach-ebsa110/core.c
index f0fe6b5350e2..d96dd94fb582 100644
--- a/arch/arm/mach-ebsa110/core.c
+++ b/arch/arm/mach-ebsa110/core.c
@@ -158,7 +158,7 @@ static void __init ebsa110_init_early(void)
158 * interrupt, then the PIT counter will roll over (ie, be negative). 158 * interrupt, then the PIT counter will roll over (ie, be negative).
159 * This actually works out to be convenient. 159 * This actually works out to be convenient.
160 */ 160 */
161static unsigned long ebsa110_gettimeoffset(void) 161static u32 ebsa110_gettimeoffset(void)
162{ 162{
163 unsigned long offset, count; 163 unsigned long offset, count;
164 164
@@ -181,7 +181,7 @@ static unsigned long ebsa110_gettimeoffset(void)
181 */ 181 */
182 offset = offset * (1000000 / HZ) / COUNT; 182 offset = offset * (1000000 / HZ) / COUNT;
183 183
184 return offset; 184 return offset * 1000;
185} 185}
186 186
187static irqreturn_t 187static irqreturn_t
@@ -215,6 +215,8 @@ static struct irqaction ebsa110_timer_irq = {
215 */ 215 */
216static void __init ebsa110_timer_init(void) 216static void __init ebsa110_timer_init(void)
217{ 217{
218 arch_gettimeoffset = ebsa110_gettimeoffset;
219
218 /* 220 /*
219 * Timer 1, mode 2, LSB/MSB 221 * Timer 1, mode 2, LSB/MSB
220 */ 222 */
@@ -227,7 +229,6 @@ static void __init ebsa110_timer_init(void)
227 229
228static struct sys_timer ebsa110_timer = { 230static struct sys_timer ebsa110_timer = {
229 .init = ebsa110_timer_init, 231 .init = ebsa110_timer_init,
230 .offset = ebsa110_gettimeoffset,
231}; 232};
232 233
233static struct plat_serial8250_port serial_platform_data[] = { 234static struct plat_serial8250_port serial_platform_data[] = {
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index e85bf17f2d2a..6f48b87a1ace 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 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
143static void __init ep93xx_timer_init(void) 159static void __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,19 +176,8 @@ 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 = { 179struct sys_timer ep93xx_timer = {
172 .init = ep93xx_timer_init, 180 .init = ep93xx_timer_init,
173 .offset = ep93xx_gettimeoffset,
174}; 181};
175 182
176 183
diff --git a/arch/arm/mach-h720x/common.c b/arch/arm/mach-h720x/common.c
index aa1331e86bcf..17ef91fa3d56 100644
--- a/arch/arm/mach-h720x/common.c
+++ b/arch/arm/mach-h720x/common.c
@@ -42,12 +42,12 @@ void __init arch_dma_init(dma_t *dma)
42} 42}
43 43
44/* 44/*
45 * Return usecs since last timer reload 45 * Return nsecs since last timer reload
46 * (timercount * (usecs perjiffie)) / (ticks per jiffie) 46 * (timercount * (usecs perjiffie)) / (ticks per jiffie)
47 */ 47 */
48unsigned long h720x_gettimeoffset(void) 48u32 h720x_gettimeoffset(void)
49{ 49{
50 return (CPU_REG (TIMER_VIRT, TM0_COUNT) * tick_usec) / LATCH; 50 return ((CPU_REG(TIMER_VIRT, TM0_COUNT) * tick_usec) / LATCH) * 1000;
51} 51}
52 52
53/* 53/*
diff --git a/arch/arm/mach-h720x/common.h b/arch/arm/mach-h720x/common.h
index 2489537d33dd..79cfb9706360 100644
--- a/arch/arm/mach-h720x/common.h
+++ b/arch/arm/mach-h720x/common.h
@@ -13,7 +13,7 @@
13 * 13 *
14 */ 14 */
15 15
16extern unsigned long h720x_gettimeoffset(void); 16extern u32 h720x_gettimeoffset(void);
17extern void __init h720x_init_irq(void); 17extern void __init h720x_init_irq(void);
18extern void __init h720x_map_io(void); 18extern void __init h720x_map_io(void);
19extern void h720x_restart(char, const char *); 19extern void h720x_restart(char, const char *);
diff --git a/arch/arm/mach-h720x/cpu-h7201.c b/arch/arm/mach-h720x/cpu-h7201.c
index 24df2a349a98..ba349cffcd3a 100644
--- a/arch/arm/mach-h720x/cpu-h7201.c
+++ b/arch/arm/mach-h720x/cpu-h7201.c
@@ -46,6 +46,8 @@ static struct irqaction h7201_timer_irq = {
46 */ 46 */
47void __init h7201_init_time(void) 47void __init h7201_init_time(void)
48{ 48{
49 arch_gettimeoffset = h720x_gettimeoffset;
50
49 CPU_REG (TIMER_VIRT, TM0_PERIOD) = LATCH; 51 CPU_REG (TIMER_VIRT, TM0_PERIOD) = LATCH;
50 CPU_REG (TIMER_VIRT, TM0_CTRL) = TM_RESET; 52 CPU_REG (TIMER_VIRT, TM0_CTRL) = TM_RESET;
51 CPU_REG (TIMER_VIRT, TM0_CTRL) = TM_REPEAT | TM_START; 53 CPU_REG (TIMER_VIRT, TM0_CTRL) = TM_REPEAT | TM_START;
@@ -56,5 +58,4 @@ void __init h7201_init_time(void)
56 58
57struct sys_timer h7201_timer = { 59struct sys_timer h7201_timer = {
58 .init = h7201_init_time, 60 .init = h7201_init_time,
59 .offset = h720x_gettimeoffset,
60}; 61};
diff --git a/arch/arm/mach-h720x/cpu-h7202.c b/arch/arm/mach-h720x/cpu-h7202.c
index c37d570b852d..fb9ca76c7313 100644
--- a/arch/arm/mach-h720x/cpu-h7202.c
+++ b/arch/arm/mach-h720x/cpu-h7202.c
@@ -180,6 +180,8 @@ static struct irqaction h7202_timer_irq = {
180 */ 180 */
181void __init h7202_init_time(void) 181void __init h7202_init_time(void)
182{ 182{
183 arch_gettimeoffset = h720x_gettimeoffset;
184
183 CPU_REG (TIMER_VIRT, TM0_PERIOD) = LATCH; 185 CPU_REG (TIMER_VIRT, TM0_PERIOD) = LATCH;
184 CPU_REG (TIMER_VIRT, TM0_CTRL) = TM_RESET; 186 CPU_REG (TIMER_VIRT, TM0_CTRL) = TM_RESET;
185 CPU_REG (TIMER_VIRT, TM0_CTRL) = TM_REPEAT | TM_START; 187 CPU_REG (TIMER_VIRT, TM0_CTRL) = TM_REPEAT | TM_START;
@@ -190,7 +192,6 @@ void __init h7202_init_time(void)
190 192
191struct sys_timer h7202_timer = { 193struct sys_timer h7202_timer = {
192 .init = h7202_init_time, 194 .init = h7202_init_time,
193 .offset = h720x_gettimeoffset,
194}; 195};
195 196
196void __init h7202_init_irq (void) 197void __init h7202_init_irq (void)
diff --git a/arch/arm/mach-rpc/time.c b/arch/arm/mach-rpc/time.c
index 581fca934bb3..6ddccb0210ac 100644
--- a/arch/arm/mach-rpc/time.c
+++ b/arch/arm/mach-rpc/time.c
@@ -24,7 +24,7 @@
24 24
25#include <asm/mach/time.h> 25#include <asm/mach/time.h>
26 26
27unsigned long ioc_timer_gettimeoffset(void) 27static u32 ioc_timer_gettimeoffset(void)
28{ 28{
29 unsigned int count1, count2, status; 29 unsigned int count1, count2, status;
30 long offset; 30 long offset;
@@ -56,7 +56,7 @@ unsigned long ioc_timer_gettimeoffset(void)
56 } 56 }
57 57
58 offset = (LATCH - offset) * (tick_nsec / 1000); 58 offset = (LATCH - offset) * (tick_nsec / 1000);
59 return (offset + LATCH/2) / LATCH; 59 return ((offset + LATCH/2) / LATCH) * 1000;
60} 60}
61 61
62void __init ioctime_init(void) 62void __init ioctime_init(void)
@@ -84,12 +84,12 @@ static struct irqaction ioc_timer_irq = {
84 */ 84 */
85static void __init ioc_timer_init(void) 85static void __init ioc_timer_init(void)
86{ 86{
87 arch_gettimeoffset = ioc_timer_gettimeoffset;
87 ioctime_init(); 88 ioctime_init();
88 setup_irq(IRQ_TIMER0, &ioc_timer_irq); 89 setup_irq(IRQ_TIMER0, &ioc_timer_irq);
89} 90}
90 91
91struct sys_timer ioc_timer = { 92struct sys_timer ioc_timer = {
92 .init = ioc_timer_init, 93 .init = ioc_timer_init,
93 .offset = ioc_timer_gettimeoffset,
94}; 94};
95 95
diff --git a/arch/arm/plat-samsung/time.c b/arch/arm/plat-samsung/time.c
index 60552e22f22e..67206df94aa8 100644
--- a/arch/arm/plat-samsung/time.c
+++ b/arch/arm/plat-samsung/time.c
@@ -95,7 +95,7 @@ static inline unsigned long timer_ticks_to_usec(unsigned long ticks)
95 * IRQs are disabled before entering here from do_gettimeofday() 95 * IRQs are disabled before entering here from do_gettimeofday()
96 */ 96 */
97 97
98static unsigned long s3c2410_gettimeoffset (void) 98static u32 s3c2410_gettimeoffset(void)
99{ 99{
100 unsigned long tdone; 100 unsigned long tdone;
101 unsigned long tval; 101 unsigned long tval;
@@ -120,7 +120,7 @@ static unsigned long s3c2410_gettimeoffset (void)
120 tdone += timer_startval; 120 tdone += timer_startval;
121 } 121 }
122 122
123 return timer_ticks_to_usec(tdone); 123 return timer_ticks_to_usec(tdone) * 1000;
124} 124}
125 125
126 126
@@ -273,6 +273,8 @@ static void __init s3c2410_timer_resources(void)
273 273
274static void __init s3c2410_timer_init(void) 274static void __init s3c2410_timer_init(void)
275{ 275{
276 arch_gettimeoffset = s3c2410_gettimeoffset;
277
276 s3c2410_timer_resources(); 278 s3c2410_timer_resources();
277 s3c2410_timer_setup(); 279 s3c2410_timer_setup();
278 setup_irq(IRQ_TIMER4, &s3c2410_timer_irq); 280 setup_irq(IRQ_TIMER4, &s3c2410_timer_irq);
@@ -280,6 +282,5 @@ static void __init s3c2410_timer_init(void)
280 282
281struct sys_timer s3c24xx_timer = { 283struct sys_timer s3c24xx_timer = {
282 .init = s3c2410_timer_init, 284 .init = s3c2410_timer_init,
283 .offset = s3c2410_gettimeoffset,
284 .resume = s3c2410_timer_setup 285 .resume = s3c2410_timer_setup
285}; 286};