clk: samsung: Pass register layout type explicitly to CLK_CPU()
authorSam Protsenko <semen.protsenko@linaro.org>
Sat, 24 Feb 2024 20:20:46 +0000 (14:20 -0600)
committerKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Sun, 25 Feb 2024 15:58:03 +0000 (16:58 +0100)
Use a dedicated enum field to explicitly specify which register layout
should be used for the CPU clock, instead of passing it as a bit flag.
This way it would be possible to keep the chip-specific data in some
array, where each chip structure could be accessed by its corresponding
layout index. It prepares clk-cpu.c for adding new chips support, which
might have different data for different CPU clusters.

No functional change.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Link: https://lore.kernel.org/r/20240224202053.25313-9-semen.protsenko@linaro.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
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
drivers/clk/samsung/clk-exynos5433.c
drivers/clk/samsung/clk.h

index 82d54b0c90402ef86a592a78f92505b8223a58f4..635ab8cc54a222d6f8b511c2dd19c4c6ee35ee17 100644 (file)
@@ -465,7 +465,7 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx,
        cpuclk->lock = &ctx->lock;
        cpuclk->flags = clk_data->flags;
        cpuclk->clk_nb.notifier_call = exynos_cpuclk_notifier_cb;
-       if (clk_data->flags & CLK_CPU_HAS_E5433_REGS_LAYOUT) {
+       if (clk_data->reg_layout == CPUCLK_LAYOUT_E5433) {
                cpuclk->pre_rate_cb = exynos5433_cpuclk_pre_rate_change;
                cpuclk->post_rate_cb = exynos5433_cpuclk_post_rate_change;
        } else {
index ee57f3638fedeb65434892194e136866e146f412..4382ab005ad3e9a3bcb8ef093eb23f5fb2d00672 100644 (file)
 #define CLK_CPU_HAS_DIV1               BIT(0)
 /* When ALT parent is active, debug clocks need safe divider values */
 #define CLK_CPU_NEEDS_DEBUG_ALT_DIV    BIT(1)
-/* The CPU clock registers have Exynos5433-compatible layout */
-#define CLK_CPU_HAS_E5433_REGS_LAYOUT  BIT(2)
+
+/**
+ * enum exynos_cpuclk_layout - CPU clock registers layout compatibility
+ * @CPUCLK_LAYOUT_E4210: Exynos4210 compatible layout
+ * @CPUCLK_LAYOUT_E5433: Exynos5433 compatible layout
+ */
+enum exynos_cpuclk_layout {
+       CPUCLK_LAYOUT_E4210,
+       CPUCLK_LAYOUT_E5433,
+};
 
 /**
  * struct exynos_cpuclk_cfg_data - config data to setup cpu clocks
index bf149fae04c37bad551e40516fc53c74c3abd798..cd4fec323a4274147a0f8d4ded57b8c45a0e7d32 100644 (file)
@@ -775,7 +775,7 @@ static const struct exynos_cpuclk_cfg_data e3250_armclk_d[] __initconst = {
 
 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, 0x14000, e3250_armclk_d),
+               CLK_CPU_HAS_DIV1, 0x14000, CPUCLK_LAYOUT_E4210, e3250_armclk_d),
 };
 
 static void __init exynos3_core_down_clock(void __iomem *reg_base)
index d5b1e9f49d8bd78de8281cc02088b78305404068..a026ccca7315f1c403daa9e1201c8536e8a83ae7 100644 (file)
@@ -1253,19 +1253,19 @@ static const struct exynos_cpuclk_cfg_data e4412_armclk_d[] __initconst = {
 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, 0x14000,
-               e4210_armclk_d),
+               CPUCLK_LAYOUT_E4210, e4210_armclk_d),
 };
 
 static const struct samsung_cpu_clock exynos4212_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, 0x14000,
-               e4212_armclk_d),
+               CPUCLK_LAYOUT_E4210, e4212_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, 0x14000,
-               e4412_armclk_d),
+               CPUCLK_LAYOUT_E4210, e4412_armclk_d),
 };
 
 /* register exynos4 clocks */
index 58df80de52effb1dd5d16521f4d8deff278a80a2..e02e7c013f3d2adfe6ca6b15fa572c4e11e9f8e4 100644 (file)
@@ -777,7 +777,8 @@ static const struct exynos_cpuclk_cfg_data exynos5250_armclk_d[] __initconst = {
 
 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, 0x0, exynos5250_armclk_d),
+               CLK_CPU_HAS_DIV1, 0x0, CPUCLK_LAYOUT_E4210,
+               exynos5250_armclk_d),
 };
 
 static const struct of_device_id ext_clk_match[] __initconst = {
index bd7b304d2c002d312c257ae878b5ad07165cf7c6..c630135c686bba0b7aef3a9caa53ac0a75ac2bfe 100644 (file)
@@ -1556,16 +1556,16 @@ static const struct exynos_cpuclk_cfg_data exynos5420_kfcclk_d[] __initconst = {
 
 static const struct samsung_cpu_clock exynos5420_cpu_clks[] __initconst = {
        CPU_CLK(CLK_ARM_CLK, "armclk", CLK_MOUT_APLL, CLK_MOUT_MSPLL_CPU, 0,
-               0x0, exynos5420_eglclk_d),
+               0x0, CPUCLK_LAYOUT_E4210, exynos5420_eglclk_d),
        CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0,
-               0x28000, exynos5420_kfcclk_d),
+               0x28000, CPUCLK_LAYOUT_E4210, 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,
-               0x0, exynos5800_eglclk_d),
+               0x0, CPUCLK_LAYOUT_E4210, exynos5800_eglclk_d),
        CPU_CLK(CLK_KFC_CLK, "kfcclk", CLK_MOUT_KPLL, CLK_MOUT_MSPLL_KFC, 0,
-               0x28000, exynos5420_kfcclk_d),
+               0x28000, CPUCLK_LAYOUT_E4210, exynos5420_kfcclk_d),
 };
 
 static const struct of_device_id ext_clk_match[] __initconst = {
index d3779eefb438a8a2ae98835fc70cd952153a761f..609d31a7aa5247e6318884609d1e651001616b73 100644 (file)
@@ -3700,8 +3700,8 @@ static const struct exynos_cpuclk_cfg_data exynos5433_apolloclk_d[] __initconst
 
 static const struct samsung_cpu_clock apollo_cpu_clks[] __initconst = {
        CPU_CLK(CLK_SCLK_APOLLO, "apolloclk", CLK_MOUT_APOLLO_PLL,
-               CLK_MOUT_BUS_PLL_APOLLO_USER, CLK_CPU_HAS_E5433_REGS_LAYOUT,
-               0x0, exynos5433_apolloclk_d),
+               CLK_MOUT_BUS_PLL_APOLLO_USER, 0, 0x0,
+               CPUCLK_LAYOUT_E5433, exynos5433_apolloclk_d),
 };
 
 static const struct samsung_cmu_info apollo_cmu_info __initconst = {
@@ -3944,8 +3944,8 @@ static const struct exynos_cpuclk_cfg_data exynos5433_atlasclk_d[] __initconst =
 
 static const struct samsung_cpu_clock atlas_cpu_clks[] __initconst = {
        CPU_CLK(CLK_SCLK_ATLAS, "atlasclk", CLK_MOUT_ATLAS_PLL,
-               CLK_MOUT_BUS_PLL_ATLAS_USER, CLK_CPU_HAS_E5433_REGS_LAYOUT,
-               0x0, exynos5433_atlasclk_d),
+               CLK_MOUT_BUS_PLL_ATLAS_USER, 0, 0x0,
+               CPUCLK_LAYOUT_E5433, exynos5433_atlasclk_d),
 };
 
 static const struct samsung_cmu_info atlas_cmu_info __initconst = {
index 516b716407e550f74aabdc862d1cdd6f7977cd98..a763309e6f129f546e0bb2b4f4848274f2aa2c9e 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/clk-provider.h>
 #include "clk-pll.h"
+#include "clk-cpu.h"
 
 /**
  * struct samsung_clk_provider - information about clock provider
@@ -282,10 +283,11 @@ struct samsung_cpu_clock {
        unsigned int    alt_parent_id;
        unsigned long   flags;
        int             offset;
+       enum exynos_cpuclk_layout reg_layout;
        const struct exynos_cpuclk_cfg_data *cfg;
 };
 
-#define CPU_CLK(_id, _name, _pid, _apid, _flags, _offset, _cfg) \
+#define CPU_CLK(_id, _name, _pid, _apid, _flags, _offset, _layout, _cfg) \
        {                                                       \
                .id               = _id,                        \
                .name             = _name,                      \
@@ -293,6 +295,7 @@ struct samsung_cpu_clock {
                .alt_parent_id    = _apid,                      \
                .flags            = _flags,                     \
                .offset           = _offset,                    \
+               .reg_layout       = _layout,                    \
                .cfg              = _cfg,                       \
        }