diff options
author | Manuel Lauss <mano@roarinelk.homelinux.net> | 2008-12-21 03:26:24 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2009-01-11 04:57:27 -0500 |
commit | 2699cdfb765c3b7d77d28ea3bc7d84e486697177 (patch) | |
tree | 690eb6e847c7acfc0a5693a385907da480f33fd8 /arch/mips/alchemy/common/time.c | |
parent | 0c694de12b54fa96b9555e07603f567906ce21c8 (diff) |
MIPS: Alchemy: move calc_clock function.
Now that nothing in time.c depends on calc_clock, it can
be moved to clocks.c where it belongs.
While at it, give it a better non-generic name and call it
as soon as possible in plat_mem_init.
Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/alchemy/common/time.c')
-rw-r--r-- | arch/mips/alchemy/common/time.c | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/arch/mips/alchemy/common/time.c b/arch/mips/alchemy/common/time.c index 57f0aec590b8..32880146cbc1 100644 --- a/arch/mips/alchemy/common/time.c +++ b/arch/mips/alchemy/common/time.c | |||
@@ -44,53 +44,6 @@ | |||
44 | 44 | ||
45 | extern int allow_au1k_wait; /* default off for CP0 Counter */ | 45 | extern int allow_au1k_wait; /* default off for CP0 Counter */ |
46 | 46 | ||
47 | static DEFINE_SPINLOCK(time_lock); | ||
48 | |||
49 | /* | ||
50 | * I haven't found anyone that doesn't use a 12 MHz source clock, | ||
51 | * but just in case..... | ||
52 | */ | ||
53 | #define AU1000_SRC_CLK 12000000 | ||
54 | |||
55 | /* | ||
56 | * We read the real processor speed from the PLL. This is important | ||
57 | * because it is more accurate than computing it from the 32 KHz | ||
58 | * counter, if it exists. If we don't have an accurate processor | ||
59 | * speed, all of the peripherals that derive their clocks based on | ||
60 | * this advertised speed will introduce error and sometimes not work | ||
61 | * properly. This function is futher convoluted to still allow configurations | ||
62 | * to do that in case they have really, really old silicon with a | ||
63 | * write-only PLL register. -- Dan | ||
64 | */ | ||
65 | unsigned long calc_clock(void) | ||
66 | { | ||
67 | unsigned long cpu_speed; | ||
68 | unsigned long flags; | ||
69 | |||
70 | spin_lock_irqsave(&time_lock, flags); | ||
71 | |||
72 | /* | ||
73 | * On early Au1000, sys_cpupll was write-only. Since these | ||
74 | * silicon versions of Au1000 are not sold by AMD, we don't bend | ||
75 | * over backwards trying to determine the frequency. | ||
76 | */ | ||
77 | if (au1xxx_cpu_has_pll_wo()) | ||
78 | #ifdef CONFIG_SOC_AU1000_FREQUENCY | ||
79 | cpu_speed = CONFIG_SOC_AU1000_FREQUENCY; | ||
80 | #else | ||
81 | cpu_speed = 396000000; | ||
82 | #endif | ||
83 | else | ||
84 | cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * AU1000_SRC_CLK; | ||
85 | /* On Alchemy CPU:counter ratio is 1:1 */ | ||
86 | mips_hpt_frequency = cpu_speed; | ||
87 | /* Equation: Baudrate = CPU / (SD * 2 * CLKDIV * 16) */ | ||
88 | set_au1x00_uart_baud_base(cpu_speed / (2 * ((int)(au_readl(SYS_POWERCTRL) | ||
89 | & 0x03) + 2) * 16)); | ||
90 | spin_unlock_irqrestore(&time_lock, flags); | ||
91 | return cpu_speed; | ||
92 | } | ||
93 | |||
94 | static cycle_t au1x_counter1_read(void) | 47 | static cycle_t au1x_counter1_read(void) |
95 | { | 48 | { |
96 | return au_readl(SYS_RTCREAD); | 49 | return au_readl(SYS_RTCREAD); |
@@ -150,13 +103,6 @@ void __init plat_time_init(void) | |||
150 | { | 103 | { |
151 | struct clock_event_device *cd = &au1x_rtcmatch2_clockdev; | 104 | struct clock_event_device *cd = &au1x_rtcmatch2_clockdev; |
152 | unsigned long t; | 105 | unsigned long t; |
153 | unsigned int est_freq = calc_clock(); | ||
154 | |||
155 | est_freq += 5000; /* round */ | ||
156 | est_freq -= est_freq%10000; | ||
157 | printk(KERN_INFO "(PRId %08x) @ %u.%02u MHz\n", read_c0_prid(), | ||
158 | est_freq / 1000000, ((est_freq % 1000000) * 100) / 1000000); | ||
159 | set_au1x00_speed(est_freq); | ||
160 | 106 | ||
161 | /* Check if firmware (YAMON, ...) has enabled 32kHz and clock | 107 | /* Check if firmware (YAMON, ...) has enabled 32kHz and clock |
162 | * has been detected. If so install the rtcmatch2 clocksource, | 108 | * has been detected. If so install the rtcmatch2 clocksource, |