aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@gmail.com>2015-01-29 10:06:42 -0500
committerRalf Baechle <ralf@linux-mips.org>2015-02-20 07:00:08 -0500
commit51f105d3074e8711698902ff89fcdc56193389ff (patch)
treedb846af7cef14e459e35666d36a8c6938c9e5ef4
parenta5770df09541f88021390375f324b25124675355 (diff)
MIPS: Alchemy: fix Au1000/Au1500 LRCLK calculation
The Au1000 and Au1500 calculate the LRCLK a bit differently than newer models: a single bit in MEM_STCFG0 selects if pclk is divided by 4 or 5. Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com> Cc: Linux-MIPS <linux-mips@linux-mips.org> Patchwork: https://patchwork.linux-mips.org/patch/9148/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/alchemy/common/clock.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/arch/mips/alchemy/common/clock.c b/arch/mips/alchemy/common/clock.c
index 48a9dfc55b51..ade73375ede6 100644
--- a/arch/mips/alchemy/common/clock.c
+++ b/arch/mips/alchemy/common/clock.c
@@ -315,17 +315,26 @@ static struct clk __init *alchemy_clk_setup_mem(const char *pn, int ct)
315 315
316/* lrclk: external synchronous static bus clock ***********************/ 316/* lrclk: external synchronous static bus clock ***********************/
317 317
318static struct clk __init *alchemy_clk_setup_lrclk(const char *pn) 318static struct clk __init *alchemy_clk_setup_lrclk(const char *pn, int t)
319{ 319{
320 /* MEM_STCFG0[15:13] = divisor. 320 /* Au1000, Au1500: MEM_STCFG0[11]: If bit is set, lrclk=pclk/5,
321 * otherwise lrclk=pclk/4.
322 * All other variants: MEM_STCFG0[15:13] = divisor.
321 * L/RCLK = periph_clk / (divisor + 1) 323 * L/RCLK = periph_clk / (divisor + 1)
322 * On Au1000, Au1500, Au1100 it's called LCLK, 324 * On Au1000, Au1500, Au1100 it's called LCLK,
323 * on later models it's called RCLK, but it's the same thing. 325 * on later models it's called RCLK, but it's the same thing.
324 */ 326 */
325 struct clk *c; 327 struct clk *c;
326 unsigned long v = alchemy_rdsmem(AU1000_MEM_STCFG0) >> 13; 328 unsigned long v = alchemy_rdsmem(AU1000_MEM_STCFG0);
327 329
328 v = (v & 7) + 1; 330 switch (t) {
331 case ALCHEMY_CPU_AU1000:
332 case ALCHEMY_CPU_AU1500:
333 v = 4 + ((v >> 11) & 1);
334 break;
335 default: /* all other models */
336 v = ((v >> 13) & 7) + 1;
337 }
329 c = clk_register_fixed_factor(NULL, ALCHEMY_LR_CLK, 338 c = clk_register_fixed_factor(NULL, ALCHEMY_LR_CLK,
330 pn, 0, 1, v); 339 pn, 0, 1, v);
331 if (!IS_ERR(c)) 340 if (!IS_ERR(c))
@@ -1060,7 +1069,7 @@ static int __init alchemy_clk_init(void)
1060 ERRCK(c) 1069 ERRCK(c)
1061 1070
1062 /* L/RCLK: external static bus clock for synchronous mode */ 1071 /* L/RCLK: external static bus clock for synchronous mode */
1063 c = alchemy_clk_setup_lrclk(ALCHEMY_PERIPH_CLK); 1072 c = alchemy_clk_setup_lrclk(ALCHEMY_PERIPH_CLK, ctype);
1064 ERRCK(c) 1073 ERRCK(c)
1065 1074
1066 /* Frequency dividers 0-5 */ 1075 /* Frequency dividers 0-5 */