Commit ceaa1a13 authored by Russell King's avatar Russell King

Merge branch 'arch-timers' into for-linus

Conflicts:
	arch/arm/include/asm/timex.h
	arch/arm/lib/delay.c
parents ba4a63f8 56942fec
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
#define __ASMARM_ARCH_TIMER_H #define __ASMARM_ARCH_TIMER_H
#include <asm/errno.h> #include <asm/errno.h>
#include <linux/clocksource.h>
#ifdef CONFIG_ARM_ARCH_TIMER #ifdef CONFIG_ARM_ARCH_TIMER
#define ARCH_HAS_READ_CURRENT_TIMER
int arch_timer_of_register(void); int arch_timer_of_register(void);
int arch_timer_sched_clock_init(void); int arch_timer_sched_clock_init(void);
struct timecounter *arch_timer_get_timecounter(void);
#else #else
static inline int arch_timer_of_register(void) static inline int arch_timer_of_register(void)
{ {
...@@ -17,6 +18,11 @@ static inline int arch_timer_sched_clock_init(void) ...@@ -17,6 +18,11 @@ static inline int arch_timer_sched_clock_init(void)
{ {
return -ENXIO; return -ENXIO;
} }
static inline struct timecounter *arch_timer_get_timecounter(void)
{
return NULL;
}
#endif #endif
#endif #endif
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
struct delay_timer {
unsigned long (*read_current_timer)(void);
unsigned long freq;
};
extern struct arm_delay_ops { extern struct arm_delay_ops {
void (*delay)(unsigned long); void (*delay)(unsigned long);
void (*const_udelay)(unsigned long); void (*const_udelay)(unsigned long);
...@@ -56,6 +61,10 @@ extern void __loop_delay(unsigned long loops); ...@@ -56,6 +61,10 @@ extern void __loop_delay(unsigned long loops);
extern void __loop_udelay(unsigned long usecs); extern void __loop_udelay(unsigned long usecs);
extern void __loop_const_udelay(unsigned long); extern void __loop_const_udelay(unsigned long);
/* Delay-loop timer registration. */
#define ARCH_HAS_READ_CURRENT_TIMER
extern void register_current_timer_delay(const struct delay_timer *timer);
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* defined(_ARM_DELAY_H) */ #endif /* defined(_ARM_DELAY_H) */
......
...@@ -12,13 +12,9 @@ ...@@ -12,13 +12,9 @@
#ifndef _ASMARM_TIMEX_H #ifndef _ASMARM_TIMEX_H
#define _ASMARM_TIMEX_H #define _ASMARM_TIMEX_H
#include <asm/arch_timer.h>
#include <mach/timex.h> #include <mach/timex.h>
#ifdef ARCH_HAS_READ_CURRENT_TIMER typedef unsigned long cycles_t;
#define get_cycles() ({ cycles_t c; read_current_timer(&c) ? 0 : c; }) #define get_cycles() ({ cycles_t c; read_current_timer(&c) ? 0 : c; })
#endif
#include <asm-generic/timex.h>
#endif #endif
This diff is collapsed.
...@@ -34,7 +34,18 @@ struct arm_delay_ops arm_delay_ops = { ...@@ -34,7 +34,18 @@ struct arm_delay_ops arm_delay_ops = {
.udelay = __loop_udelay, .udelay = __loop_udelay,
}; };
#ifdef ARCH_HAS_READ_CURRENT_TIMER static const struct delay_timer *delay_timer;
static bool delay_calibrated;
int read_current_timer(unsigned long *timer_val)
{
if (!delay_timer)
return -ENXIO;
*timer_val = delay_timer->read_current_timer();
return 0;
}
static void __timer_delay(unsigned long cycles) static void __timer_delay(unsigned long cycles)
{ {
cycles_t start = get_cycles(); cycles_t start = get_cycles();
...@@ -55,18 +66,24 @@ static void __timer_udelay(unsigned long usecs) ...@@ -55,18 +66,24 @@ static void __timer_udelay(unsigned long usecs)
__timer_const_udelay(usecs * UDELAY_MULT); __timer_const_udelay(usecs * UDELAY_MULT);
} }
void __init init_current_timer_delay(unsigned long freq) void __init register_current_timer_delay(const struct delay_timer *timer)
{ {
pr_info("Switching to timer-based delay loop\n"); if (!delay_calibrated) {
lpj_fine = freq / HZ; pr_info("Switching to timer-based delay loop\n");
loops_per_jiffy = lpj_fine; delay_timer = timer;
arm_delay_ops.delay = __timer_delay; lpj_fine = timer->freq / HZ;
arm_delay_ops.const_udelay = __timer_const_udelay; loops_per_jiffy = lpj_fine;
arm_delay_ops.udelay = __timer_udelay; arm_delay_ops.delay = __timer_delay;
arm_delay_ops.const_udelay = __timer_const_udelay;
arm_delay_ops.udelay = __timer_udelay;
delay_calibrated = true;
} else {
pr_info("Ignoring duplicate/late registration of read_current_timer delay\n");
}
} }
unsigned long __cpuinit calibrate_delay_is_known(void) unsigned long __cpuinit calibrate_delay_is_known(void)
{ {
delay_calibrated = true;
return lpj_fine; return lpj_fine;
} }
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment