| From ccb5373448691d47807bfa160cc6bcfa06252c35 Mon Sep 17 00:00:00 2001 |
| From: Simon Horman <horms+renesas@verge.net.au> |
| Date: Tue, 13 May 2014 15:59:18 +0900 |
| Subject: ARM: shmobile: Set clock frequency in HZ from OF nodes |
| |
| shmobile_init_delay() looks for OF "clock-frequency" to determine |
| the delay which is set by calling shmobile_setup_delay(). |
| |
| Unfortunately this seems to be incorrect in detail as |
| "clock-frequency" node values are in HZ whereas the frequency |
| argument to shmobile_setup_delay() is in MHz. |
| |
| Provide a variant of shmobile_setup_delay() that accepts HZ to |
| correct this problem. |
| |
| Signed-off-by: Simon Horman <horms+renesas@verge.net.au> |
| (cherry picked from commit f492b81777c93b33afe892b424e022022b5bc297) |
| Signed-off-by: Simon Horman <horms+renesas@verge.net.au> |
| --- |
| arch/arm/mach-shmobile/timer.c | 23 ++++++++++++++++++++--- |
| 1 file changed, 20 insertions(+), 3 deletions(-) |
| |
| diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c |
| index ccecde9a3362..68bc0b82226d 100644 |
| --- a/arch/arm/mach-shmobile/timer.c |
| +++ b/arch/arm/mach-shmobile/timer.c |
| @@ -23,6 +23,23 @@ |
| #include <linux/delay.h> |
| #include <linux/of_address.h> |
| |
| +void __init shmobile_setup_delay_hz(unsigned int max_cpu_core_hz, |
| + unsigned int mult, unsigned int div) |
| +{ |
| + /* calculate a worst-case loops-per-jiffy value |
| + * based on maximum cpu core hz setting and the |
| + * __delay() implementation in arch/arm/lib/delay.S |
| + * |
| + * this will result in a longer delay than expected |
| + * when the cpu core runs on lower frequencies. |
| + */ |
| + |
| + unsigned int value = HZ * div / mult; |
| + |
| + if (!preset_lpj) |
| + preset_lpj = max_cpu_core_hz / value; |
| +} |
| + |
| void __init shmobile_setup_delay(unsigned int max_cpu_core_mhz, |
| unsigned int mult, unsigned int div) |
| { |
| @@ -58,12 +75,12 @@ void __init shmobile_init_delay(void) |
| |
| if (max_freq) { |
| if (of_find_compatible_node(NULL, NULL, "arm,cortex-a8")) |
| - shmobile_setup_delay(max_freq, 1, 3); |
| + shmobile_setup_delay_hz(max_freq, 1, 3); |
| else if (of_find_compatible_node(NULL, NULL, "arm,cortex-a9")) |
| - shmobile_setup_delay(max_freq, 1, 3); |
| + shmobile_setup_delay_hz(max_freq, 1, 3); |
| else if (of_find_compatible_node(NULL, NULL, "arm,cortex-a15")) |
| if (!IS_ENABLED(CONFIG_ARM_ARCH_TIMER)) |
| - shmobile_setup_delay(max_freq, 2, 4); |
| + shmobile_setup_delay_hz(max_freq, 2, 4); |
| } |
| } |
| |
| -- |
| 2.1.2 |
| |