diff options
author | Colin Cross <ccross@google.com> | 2010-08-19 22:07:43 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2010-10-06 16:27:39 -0700 |
commit | 128f79c82dccb1ac9eacf8fa0b4d52bb29e05278 (patch) | |
tree | 84254d83c464104ee55b5be7467603a482b6cab8 /arch/arm/include/asm | |
parent | dada76ee1116155b3195c7dee63332ba74be6cb8 (diff) |
[ARM] twd: Allow twd rescaling to match cpu frequency
The clock to the ARM TWD local timer scales with the cpu
frequency. To allow the cpu frequency to change while
maintaining a constant TWD frequency, pick a lower target
frequency for the TWD and use the prescaler to divide down
to the closest lower frequency.
This patch provides a new initialization function that takes
a target TWD frequency and the relation between the cpu
clock and the TWD clock, required to be an integer divider
>= 2 by the ARM spec. It also provides a function to be
called from cpufreq drivers to set the prescaler whenever
the cpu frequency changes.
Also fixes a typo in the printk of the calibrated frequency.
Change-Id: I3fa8ef718ff5518170f1b2bab29efe960741853e
Signed-off-by: Colin Cross <ccross@google.com>
Diffstat (limited to 'arch/arm/include/asm')
-rw-r--r-- | arch/arm/include/asm/smp_twd.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/arch/arm/include/asm/smp_twd.h b/arch/arm/include/asm/smp_twd.h index 634f357be6bb..79aebe2ad7a8 100644 --- a/arch/arm/include/asm/smp_twd.h +++ b/arch/arm/include/asm/smp_twd.h @@ -17,6 +17,7 @@ #define TWD_TIMER_CONTROL_ONESHOT (0 << 1) #define TWD_TIMER_CONTROL_PERIODIC (1 << 1) #define TWD_TIMER_CONTROL_IT_ENABLE (1 << 2) +#define TWD_TIMER_CONTROL_PRESCALE_MASK (0xFF << 8) struct clock_event_device; @@ -26,4 +27,22 @@ void twd_timer_stop(void); int twd_timer_ack(void); void twd_timer_setup(struct clock_event_device *); +/* + * Use this setup function on systems where the cpu clock frequency may + * change. periphclk_prescaler is the fixed divider value between the cpu + * clock and the PERIPHCLK clock that feeds the TWD. target_rate should be + * low enough that the prescaler can accurately reach the target rate from the + * lowest cpu frequency. + */ +void twd_timer_setup_scalable(struct clock_event_device *, + unsigned long target_rate, unsigned int periphclk_prescaler); + +/* + * Recalculate the twd prescaler value when the cpu frequency changes. To + * prevent early timer interrupts, must be called before changing the cpu + * frequency if the frequency is increasing, or after if the frequency is + * decreasing. + */ +void twd_recalc_prescaler(unsigned long new_rate); + #endif |