clk: samsung: Update CPU clk registration
authorWill McVicker <willmcvicker@google.com>
Fri, 15 Oct 2021 19:05:14 +0000 (19:05 +0000)
committerSylwester Nawrocki <s.nawrocki@samsung.com>
Sat, 20 Nov 2021 13:22:49 +0000 (14:22 +0100)
Convert the remaining exynos clock drivers to use
samsung_clk_register_cpu() or if possible use samsung_cmu_register_one().
With this we can now make exynos_register_cpu_clock() a static function
so that future CPU clock registration changes will use the samsung common
clock driver.

The main benefit of this change is that it standardizes the CPU clock
registration for the samsung clock drivers.

Link: https://lore.kernel.org/r/20211015190515.3760577-1-willmcvicker@google.com
Signed-off-by: Will McVicker <willmcvicker@google.com>
Tested-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
[snawrocki@kernel.org: Fixed build break in clk-exynos4.c, clk-exynos5250.c]
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
drivers/clk/samsung/clk-cpu.c
drivers/clk/samsung/clk-cpu.h
drivers/clk/samsung/clk-exynos3250.c
drivers/clk/samsung/clk-exynos4.c
drivers/clk/samsung/clk-exynos5250.c
drivers/clk/samsung/clk-exynos5420.c

index 7f20d9aedaa92c67cc3305aef7d698a78d3d463e..3e62ade120c5ddb68adac0c4e6f4f05cf36c5261 100644 (file)
@@ -400,7 +400,7 @@ static int exynos5433_cpuclk_notifier_cb(struct notifier_block *nb,
 }
 
 /* helper function to register a CPU clock */
-int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
+static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
                unsigned int lookup_id, const char *name,
                const struct clk_hw *parent, const struct clk_hw *alt_parent,
                unsigned long offset, const struct exynos_cpuclk_cfg_data *cfg,
index fd885d2bf74c9495132b9dc03fae917ed8e91089..fc9f67a3b22e8b948de7db411c4ba84984464c15 100644 (file)
@@ -62,11 +62,4 @@ struct exynos_cpuclk {
 #define CLK_CPU_HAS_E5433_REGS_LAYOUT  (1 << 2)
 };
 
-int exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
-                       unsigned int lookup_id, const char *name,
-                       const struct clk_hw *parent, const struct clk_hw *alt_parent,
-                       unsigned long offset,
-                       const struct exynos_cpuclk_cfg_data *cfg,
-                       unsigned long num_cfgs, unsigned long flags);
-
 #endif /* __SAMSUNG_CLK_CPU_H */
index 17df7f9755aabc25d14f46fbc26882eee9f7a39c..6cc65ccf867ce8b2e150f2cbde3cbd3bb2089cdf 100644 (file)
@@ -748,6 +748,31 @@ static const struct samsung_pll_clock exynos3250_plls[] __initconst = {
                        UPLL_LOCK, UPLL_CON0, exynos3250_pll_rates),
 };
 
+#define E3250_CPU_DIV0(apll, pclk_dbg, atb, corem)                     \
+               (((apll) << 24) | ((pclk_dbg) << 20) | ((atb) << 16) |  \
+               ((corem) << 4))
+#define E3250_CPU_DIV1(hpm, copy)                                      \
+               (((hpm) << 4) | ((copy) << 0))
+
+static const struct exynos_cpuclk_cfg_data e3250_armclk_d[] __initconst = {
+       { 1000000, E3250_CPU_DIV0(1, 7, 4, 1), E3250_CPU_DIV1(7, 7), },
+       {  900000, E3250_CPU_DIV0(1, 7, 3, 1), E3250_CPU_DIV1(7, 7), },
+       {  800000, E3250_CPU_DIV0(1, 7, 3, 1), E3250_CPU_DIV1(7, 7), },
+       {  700000, E3250_CPU_DIV0(1, 7, 3, 1), E3250_CPU_DIV1(7, 7), },
+       {  600000, E3250_CPU_DIV0(1, 7, 3, 1), E3250_CPU_DIV1(7, 7), },
+       {  500000, E3250_CPU_DIV0(1, 7, 3, 1), E3250_CPU_DIV1(7, 7), },
+       {  400000, E3250_CPU_DIV0(1, 7, 3, 1), E3250_CPU_DIV1(7, 7), },
+       {  300000, E3250_CPU_DIV0(1, 5, 3, 1), E3250_CPU_DIV1(7, 7), },
+       {  200000, E3250_CPU_DIV0(1, 3, 3, 1), E3250_CPU_DIV1(7, 7), },
+       {  100000, E3250_CPU_DIV0(1, 1, 1, 1), E3250_CPU_DIV1(7, 7), },
+       {  0 },
+};
+
+static const struct samsung_cpu_clock exynos3250_cpu_clks[] __initconst = {
+       CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C,
+                       CLK_CPU_HAS_DIV1, 0x14200, e3250_armclk_d),
+};
+
 static void __init exynos3_core_down_clock(void __iomem *reg_base)
 {
        unsigned int tmp;
@@ -780,46 +805,21 @@ static const struct samsung_cmu_info cmu_info __initconst = {
        .nr_gate_clks           = ARRAY_SIZE(gate_clks),
        .fixed_factor_clks      = fixed_factor_clks,
        .nr_fixed_factor_clks   = ARRAY_SIZE(fixed_factor_clks),
+       .cpu_clks               = exynos3250_cpu_clks,
+       .nr_cpu_clks            = ARRAY_SIZE(exynos3250_cpu_clks),
        .nr_clk_ids             = CLK_NR_CLKS,
        .clk_regs               = exynos3250_cmu_clk_regs,
        .nr_clk_regs            = ARRAY_SIZE(exynos3250_cmu_clk_regs),
 };
 
-#define E3250_CPU_DIV0(apll, pclk_dbg, atb, corem)                     \
-               (((apll) << 24) | ((pclk_dbg) << 20) | ((atb) << 16) |  \
-               ((corem) << 4))
-#define E3250_CPU_DIV1(hpm, copy)                                      \
-               (((hpm) << 4) | ((copy) << 0))
-
-static const struct exynos_cpuclk_cfg_data e3250_armclk_d[] __initconst = {
-       { 1000000, E3250_CPU_DIV0(1, 7, 4, 1), E3250_CPU_DIV1(7, 7), },
-       {  900000, E3250_CPU_DIV0(1, 7, 3, 1), E3250_CPU_DIV1(7, 7), },
-       {  800000, E3250_CPU_DIV0(1, 7, 3, 1), E3250_CPU_DIV1(7, 7), },
-       {  700000, E3250_CPU_DIV0(1, 7, 3, 1), E3250_CPU_DIV1(7, 7), },
-       {  600000, E3250_CPU_DIV0(1, 7, 3, 1), E3250_CPU_DIV1(7, 7), },
-       {  500000, E3250_CPU_DIV0(1, 7, 3, 1), E3250_CPU_DIV1(7, 7), },
-       {  400000, E3250_CPU_DIV0(1, 7, 3, 1), E3250_CPU_DIV1(7, 7), },
-       {  300000, E3250_CPU_DIV0(1, 5, 3, 1), E3250_CPU_DIV1(7, 7), },
-       {  200000, E3250_CPU_DIV0(1, 3, 3, 1), E3250_CPU_DIV1(7, 7), },
-       {  100000, E3250_CPU_DIV0(1, 1, 1, 1), E3250_CPU_DIV1(7, 7), },
-       {  0 },
-};
-
 static void __init exynos3250_cmu_init(struct device_node *np)
 {
        struct samsung_clk_provider *ctx;
-       struct clk_hw **hws;
 
        ctx = samsung_cmu_register_one(np, &cmu_info);
        if (!ctx)
                return;
 
-       hws = ctx->clk_data.hws;
-       exynos_register_cpu_clock(ctx, CLK_ARM_CLK, "armclk",
-                       hws[CLK_MOUT_APLL], hws[CLK_MOUT_MPLL_USER_C],
-                       0x14200, e3250_armclk_d, ARRAY_SIZE(e3250_armclk_d),
-                       CLK_CPU_HAS_DIV1);
-
        exynos3_core_down_clock(ctx->reg_base);
 }
 CLK_OF_DECLARE(exynos3250_cmu, "samsung,exynos3250-cmu", exynos3250_cmu_init);
index 42b4b62bd483d3f2d8f35df546af34f36fd3fc4d..22009cb53428a09005456fcbde4fa4ca4ae06943 100644 (file)
@@ -1228,6 +1228,16 @@ static const struct exynos_cpuclk_cfg_data e4412_armclk_d[] __initconst = {
        {  0 },
 };
 
+static const struct samsung_cpu_clock exynos4210_cpu_clks[] __initconst = {
+       CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_SCLK_MPLL,
+                       CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14200, e4210_armclk_d),
+};
+
+static const struct samsung_cpu_clock exynos4412_cpu_clks[] __initconst = {
+       CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL_USER_C,
+                       CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1, 0x14200, e4412_armclk_d),
+};
+
 /* register exynos4 clocks */
 static void __init exynos4_clk_init(struct device_node *np,
                                    enum exynos4_soc soc)
@@ -1304,10 +1314,8 @@ static void __init exynos4_clk_init(struct device_node *np,
                samsung_clk_register_fixed_factor(ctx,
                        exynos4210_fixed_factor_clks,
                        ARRAY_SIZE(exynos4210_fixed_factor_clks));
-               exynos_register_cpu_clock(ctx, CLK_ARM_CLK, "armclk",
-                       hws[CLK_MOUT_APLL], hws[CLK_SCLK_MPLL], 0x14200,
-                       e4210_armclk_d, ARRAY_SIZE(e4210_armclk_d),
-                       CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1);
+               samsung_clk_register_cpu(ctx, exynos4210_cpu_clks,
+                               ARRAY_SIZE(exynos4210_cpu_clks));
        } else {
                samsung_clk_register_mux(ctx, exynos4x12_mux_clks,
                        ARRAY_SIZE(exynos4x12_mux_clks));
@@ -1318,11 +1326,8 @@ static void __init exynos4_clk_init(struct device_node *np,
                samsung_clk_register_fixed_factor(ctx,
                        exynos4x12_fixed_factor_clks,
                        ARRAY_SIZE(exynos4x12_fixed_factor_clks));
-
-               exynos_register_cpu_clock(ctx, CLK_ARM_CLK, "armclk",
-                       hws[CLK_MOUT_APLL], hws[CLK_MOUT_MPLL_USER_C], 0x14200,
-                       e4412_armclk_d, ARRAY_SIZE(e4412_armclk_d),
-                       CLK_CPU_NEEDS_DEBUG_ALT_DIV | CLK_CPU_HAS_DIV1);
+               samsung_clk_register_cpu(ctx, exynos4412_cpu_clks,
+                               ARRAY_SIZE(exynos4412_cpu_clks));
        }
 
        if (soc == EXYNOS4X12)
index fde4998d2aab67ee837c2514bd350f07b7518e2f..113df773ee4490db0155e6219c303fba1e947d7c 100644 (file)
@@ -772,6 +772,11 @@ static const struct exynos_cpuclk_cfg_data exynos5250_armclk_d[] __initconst = {
        {  0 },
 };
 
+static const struct samsung_cpu_clock exynos5250_cpu_clks[] __initconst = {
+       CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MPLL, CLK_CPU_HAS_DIV1, 0x200,
+                       exynos5250_armclk_d),
+};
+
 static const struct of_device_id ext_clk_match[] __initconst = {
        { .compatible = "samsung,clock-xxti", .data = (void *)0, },
        { },
@@ -822,10 +827,8 @@ static void __init exynos5250_clk_init(struct device_node *np)
                        ARRAY_SIZE(exynos5250_div_clks));
        samsung_clk_register_gate(ctx, exynos5250_gate_clks,
                        ARRAY_SIZE(exynos5250_gate_clks));
-       exynos_register_cpu_clock(ctx, CLK_ARM_CLK, "armclk",
-                       hws[CLK_MOUT_APLL], hws[CLK_MOUT_MPLL], 0x200,
-                       exynos5250_armclk_d, ARRAY_SIZE(exynos5250_armclk_d),
-                       CLK_CPU_HAS_DIV1);
+       samsung_clk_register_cpu(ctx, exynos5250_cpu_clks,
+                       ARRAY_SIZE(exynos5250_cpu_clks));
 
        /*
         * Enable arm clock down (in idle) and set arm divider
index 747196bbea2a809646f2130ef64473104c18111b..caad74dee2971b02bfc98d598f1480f6a20cd557 100644 (file)
@@ -1551,6 +1551,20 @@ static const struct exynos_cpuclk_cfg_data exynos5420_kfcclk_d[] __initconst = {
        {  0 },
 };
 
+static const struct samsung_cpu_clock exynos5420_cpu_clks[] __initconst = {
+       CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0, 0x200,
+                       exynos5420_eglclk_d),
+       CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0, 0x28200,
+                       exynos5420_kfcclk_d),
+};
+
+static const struct samsung_cpu_clock exynos5800_cpu_clks[] __initconst = {
+       CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0, 0x200,
+                       exynos5800_eglclk_d),
+       CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0, 0x28200,
+                       exynos5420_kfcclk_d),
+};
+
 static const struct of_device_id ext_clk_match[] __initconst = {
        { .compatible = "samsung,exynos5420-oscclk", .data = (void *)0, },
        { },
@@ -1625,17 +1639,12 @@ static void __init exynos5x_clk_init(struct device_node *np,
        }
 
        if (soc == EXYNOS5420) {
-               exynos_register_cpu_clock(ctx, CLK_ARM_CLK, "armclk",
-                       hws[CLK_MOUT_APLL], hws[CLK_MOUT_MSPLL_CPU], 0x200,
-                       exynos5420_eglclk_d, ARRAY_SIZE(exynos5420_eglclk_d), 0);
+               samsung_clk_register_cpu(ctx, exynos5420_cpu_clks,
+                               ARRAY_SIZE(exynos5420_cpu_clks));
        } else {
-               exynos_register_cpu_clock(ctx, CLK_ARM_CLK, "armclk",
-                       hws[CLK_MOUT_APLL], hws[CLK_MOUT_MSPLL_CPU], 0x200,
-                       exynos5800_eglclk_d, ARRAY_SIZE(exynos5800_eglclk_d), 0);
+               samsung_clk_register_cpu(ctx, exynos5800_cpu_clks,
+                               ARRAY_SIZE(exynos5800_cpu_clks));
        }
-       exynos_register_cpu_clock(ctx, CLK_KFC_CLK, "kfcclk",
-               hws[CLK_MOUT_KPLL], hws[CLK_MOUT_MSPLL_KFC],  0x28200,
-               exynos5420_kfcclk_d, ARRAY_SIZE(exynos5420_kfcclk_d), 0);
 
        samsung_clk_extended_sleep_init(reg_base,
                exynos5x_clk_regs, ARRAY_SIZE(exynos5x_clk_regs),