]> git.hungrycats.org Git - linux/commitdiff
clk: aspeed: Support HPLL strapping on ast2400
authorJoel Stanley <joel@jms.id.au>
Thu, 28 Jun 2018 23:15:40 +0000 (08:45 +0930)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 28 Jul 2018 05:57:12 +0000 (07:57 +0200)
commit 565b9937f44d5ab7956339b6c105c03471ce3243 upstream.

The HPLL can be configured through a register (SCU24), however some
platforms chose to configure it through the strapping settings and do
not use the register. This was not noticed as the logic for bit 18 in
SCU24 was confused: set means programmed, but the driver read it as set
means strapped.

This gives us the correct HPLL value on Palmetto systems, from which
most of the peripheral clocks are generated.

Fixes: 5eda5d79e4be ("clk: Add clock driver for ASPEED BMC SoCs")
Cc: stable@vger.kernel.org # v4.15
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/clk/clk-aspeed.c

index 37eaf21e8b765092031deb1a93b50fdd3e8281b5..43e0c33ee648e65da992953784fcb138a956b869 100644 (file)
@@ -22,7 +22,7 @@
 #define ASPEED_MPLL_PARAM      0x20
 #define ASPEED_HPLL_PARAM      0x24
 #define  AST2500_HPLL_BYPASS_EN        BIT(20)
-#define  AST2400_HPLL_STRAPPED BIT(18)
+#define  AST2400_HPLL_PROGRAMMED BIT(18)
 #define  AST2400_HPLL_BYPASS_EN        BIT(17)
 #define ASPEED_MISC_CTRL       0x2c
 #define  UART_DIV13_EN         BIT(12)
@@ -530,29 +530,45 @@ builtin_platform_driver(aspeed_clk_driver);
 static void __init aspeed_ast2400_cc(struct regmap *map)
 {
        struct clk_hw *hw;
-       u32 val, freq, div;
+       u32 val, div, clkin, hpll;
+       const u16 hpll_rates[][4] = {
+               {384, 360, 336, 408},
+               {400, 375, 350, 425},
+       };
+       int rate;
 
        /*
         * CLKIN is the crystal oscillator, 24, 48 or 25MHz selected by
         * strapping
         */
        regmap_read(map, ASPEED_STRAP, &val);
-       if (val & CLKIN_25MHZ_EN)
-               freq = 25000000;
-       else if (val & AST2400_CLK_SOURCE_SEL)
-               freq = 48000000;
-       else
-               freq = 24000000;
-       hw = clk_hw_register_fixed_rate(NULL, "clkin", NULL, 0, freq);
-       pr_debug("clkin @%u MHz\n", freq / 1000000);
+       rate = (val >> 8) & 3;
+       if (val & CLKIN_25MHZ_EN) {
+               clkin = 25000000;
+               hpll = hpll_rates[1][rate];
+       } else if (val & AST2400_CLK_SOURCE_SEL) {
+               clkin = 48000000;
+               hpll = hpll_rates[0][rate];
+       } else {
+               clkin = 24000000;
+               hpll = hpll_rates[0][rate];
+       }
+       hw = clk_hw_register_fixed_rate(NULL, "clkin", NULL, 0, clkin);
+       pr_debug("clkin @%u MHz\n", clkin / 1000000);
 
        /*
         * High-speed PLL clock derived from the crystal. This the CPU clock,
-        * and we assume that it is enabled
+        * and we assume that it is enabled. It can be configured through the
+        * HPLL_PARAM register, or set to a specified frequency by strapping.
         */
        regmap_read(map, ASPEED_HPLL_PARAM, &val);
-       WARN(val & AST2400_HPLL_STRAPPED, "hpll is strapped not configured");
-       aspeed_clk_data->hws[ASPEED_CLK_HPLL] = aspeed_ast2400_calc_pll("hpll", val);
+       if (val & AST2400_HPLL_PROGRAMMED)
+               hw = aspeed_ast2400_calc_pll("hpll", val);
+       else
+               hw = clk_hw_register_fixed_rate(NULL, "hpll", "clkin", 0,
+                               hpll * 1000000);
+
+       aspeed_clk_data->hws[ASPEED_CLK_HPLL] = hw;
 
        /*
         * Strap bits 11:10 define the CPU/AHB clock frequency ratio (aka HCLK)