diff options
Diffstat (limited to 'arch/mips/ath79/clock.c')
-rw-r--r-- | arch/mips/ath79/clock.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/arch/mips/ath79/clock.c b/arch/mips/ath79/clock.c index 680bde99a26c..54d0eb4db987 100644 --- a/arch/mips/ath79/clock.c +++ b/arch/mips/ath79/clock.c | |||
@@ -110,6 +110,59 @@ static void __init ar913x_clocks_init(void) | |||
110 | ath79_uart_clk.rate = ath79_ahb_clk.rate; | 110 | ath79_uart_clk.rate = ath79_ahb_clk.rate; |
111 | } | 111 | } |
112 | 112 | ||
113 | static void __init ar933x_clocks_init(void) | ||
114 | { | ||
115 | u32 clock_ctrl; | ||
116 | u32 cpu_config; | ||
117 | u32 freq; | ||
118 | u32 t; | ||
119 | |||
120 | t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP); | ||
121 | if (t & AR933X_BOOTSTRAP_REF_CLK_40) | ||
122 | ath79_ref_clk.rate = (40 * 1000 * 1000); | ||
123 | else | ||
124 | ath79_ref_clk.rate = (25 * 1000 * 1000); | ||
125 | |||
126 | clock_ctrl = ath79_pll_rr(AR933X_PLL_CLOCK_CTRL_REG); | ||
127 | if (clock_ctrl & AR933X_PLL_CLOCK_CTRL_BYPASS) { | ||
128 | ath79_cpu_clk.rate = ath79_ref_clk.rate; | ||
129 | ath79_ahb_clk.rate = ath79_ref_clk.rate; | ||
130 | ath79_ddr_clk.rate = ath79_ref_clk.rate; | ||
131 | } else { | ||
132 | cpu_config = ath79_pll_rr(AR933X_PLL_CPU_CONFIG_REG); | ||
133 | |||
134 | t = (cpu_config >> AR933X_PLL_CPU_CONFIG_REFDIV_SHIFT) & | ||
135 | AR933X_PLL_CPU_CONFIG_REFDIV_MASK; | ||
136 | freq = ath79_ref_clk.rate / t; | ||
137 | |||
138 | t = (cpu_config >> AR933X_PLL_CPU_CONFIG_NINT_SHIFT) & | ||
139 | AR933X_PLL_CPU_CONFIG_NINT_MASK; | ||
140 | freq *= t; | ||
141 | |||
142 | t = (cpu_config >> AR933X_PLL_CPU_CONFIG_OUTDIV_SHIFT) & | ||
143 | AR933X_PLL_CPU_CONFIG_OUTDIV_MASK; | ||
144 | if (t == 0) | ||
145 | t = 1; | ||
146 | |||
147 | freq >>= t; | ||
148 | |||
149 | t = ((clock_ctrl >> AR933X_PLL_CLOCK_CTRL_CPU_DIV_SHIFT) & | ||
150 | AR933X_PLL_CLOCK_CTRL_CPU_DIV_MASK) + 1; | ||
151 | ath79_cpu_clk.rate = freq / t; | ||
152 | |||
153 | t = ((clock_ctrl >> AR933X_PLL_CLOCK_CTRL_DDR_DIV_SHIFT) & | ||
154 | AR933X_PLL_CLOCK_CTRL_DDR_DIV_MASK) + 1; | ||
155 | ath79_ddr_clk.rate = freq / t; | ||
156 | |||
157 | t = ((clock_ctrl >> AR933X_PLL_CLOCK_CTRL_AHB_DIV_SHIFT) & | ||
158 | AR933X_PLL_CLOCK_CTRL_AHB_DIV_MASK) + 1; | ||
159 | ath79_ahb_clk.rate = freq / t; | ||
160 | } | ||
161 | |||
162 | ath79_wdt_clk.rate = ath79_ref_clk.rate; | ||
163 | ath79_uart_clk.rate = ath79_ref_clk.rate; | ||
164 | } | ||
165 | |||
113 | void __init ath79_clocks_init(void) | 166 | void __init ath79_clocks_init(void) |
114 | { | 167 | { |
115 | if (soc_is_ar71xx()) | 168 | if (soc_is_ar71xx()) |
@@ -118,6 +171,8 @@ void __init ath79_clocks_init(void) | |||
118 | ar724x_clocks_init(); | 171 | ar724x_clocks_init(); |
119 | else if (soc_is_ar913x()) | 172 | else if (soc_is_ar913x()) |
120 | ar913x_clocks_init(); | 173 | ar913x_clocks_init(); |
174 | else if (soc_is_ar933x()) | ||
175 | ar933x_clocks_init(); | ||
121 | else | 176 | else |
122 | BUG(); | 177 | BUG(); |
123 | 178 | ||