clk: at91: clk-programmable: add mux_table option
authorClaudiu Beznea <claudiu.beznea@microchip.com>
Wed, 22 Jul 2020 07:38:22 +0000 (10:38 +0300)
committerStephen Boyd <sboyd@kernel.org>
Fri, 24 Jul 2020 09:19:08 +0000 (02:19 -0700)
Add mux table option. This is necessary for IP versions that has
gaps in the range of available clock sources (e.g. SAMA7G5).

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/1595403506-8209-15-git-send-email-claudiu.beznea@microchip.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
13 files changed:
drivers/clk/at91/at91rm9200.c
drivers/clk/at91/at91sam9260.c
drivers/clk/at91/at91sam9g45.c
drivers/clk/at91/at91sam9n12.c
drivers/clk/at91/at91sam9rl.c
drivers/clk/at91/at91sam9x5.c
drivers/clk/at91/clk-programmable.c
drivers/clk/at91/dt-compat.c
drivers/clk/at91/pmc.h
drivers/clk/at91/sam9x60.c
drivers/clk/at91/sama5d2.c
drivers/clk/at91/sama5d3.c
drivers/clk/at91/sama5d4.c

index 38bdb498131584d4c1270f1b37f0f5f8b40f9124..2c3d8e6ca63cacdfec37c8e9f468c2168af347ac 100644 (file)
@@ -160,7 +160,8 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
 
                hw = at91_clk_register_programmable(regmap, name,
                                                    parent_names, 4, i,
-                                                   &at91rm9200_programmable_layout);
+                                                   &at91rm9200_programmable_layout,
+                                                   NULL);
                if (IS_ERR(hw))
                        goto err_free;
 
index 6d0723aa8b1380e2419ba084ec5797b6605ee7be..bb81ff731ad83009fb8cc7a66219107f65e44b29 100644 (file)
@@ -436,7 +436,8 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
 
                hw = at91_clk_register_programmable(regmap, name,
                                                    parent_names, 4, i,
-                                                   &at91rm9200_programmable_layout);
+                                                   &at91rm9200_programmable_layout,
+                                                   NULL);
                if (IS_ERR(hw))
                        goto err_free;
 
index fe9d391adebaedf170de4ee820f157548fd5fa1a..c88ee20bee311576b5551c5a9dbd5fa07047dea9 100644 (file)
@@ -181,7 +181,8 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
 
                hw = at91_clk_register_programmable(regmap, name,
                                                    parent_names, 5, i,
-                                                   &at91sam9g45_programmable_layout);
+                                                   &at91sam9g45_programmable_layout,
+                                                   NULL);
                if (IS_ERR(hw))
                        goto err_free;
 
index aaf4da30584e1fc3a64dc87e753deb04867dd7d9..93f7eb216122a4de1ec7176280a980aa672c8b83 100644 (file)
@@ -199,7 +199,8 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
 
                hw = at91_clk_register_programmable(regmap, name,
                                                    parent_names, 5, i,
-                                                   &at91sam9x5_programmable_layout);
+                                                   &at91sam9x5_programmable_layout,
+                                                   NULL);
                if (IS_ERR(hw))
                        goto err_free;
 
index 0d1cc44b056ff42e8aeff4386fb307f4a0a0b785..a343eb69bb353cd3049a3f42365dbfa5b345a741 100644 (file)
@@ -137,7 +137,8 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
 
                hw = at91_clk_register_programmable(regmap, name,
                                                    parent_names, 5, i,
-                                                   &at91rm9200_programmable_layout);
+                                                   &at91rm9200_programmable_layout,
+                                                   NULL);
                if (IS_ERR(hw))
                        goto err_free;
 
index 52a9d2f7ec83f26037f9d0a052ca290845dd403b..22b9aad9efb8dbb5d3780eb299e8be8e2ca12f35 100644 (file)
@@ -226,7 +226,8 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
 
                hw = at91_clk_register_programmable(regmap, name,
                                                    parent_names, 5, i,
-                                                   &at91sam9x5_programmable_layout);
+                                                   &at91sam9x5_programmable_layout,
+                                                   NULL);
                if (IS_ERR(hw))
                        goto err_free;
 
index 8ee66fbee3d9e614a26f1b2a431ab5e6ada1eae8..fcf8f6a1c2c60ec1ddfc8920ccfb33d4fb6d466c 100644 (file)
@@ -21,6 +21,7 @@
 struct clk_programmable {
        struct clk_hw hw;
        struct regmap *regmap;
+       u32 *mux_table;
        u8 id;
        const struct clk_programmable_layout *layout;
 };
@@ -108,6 +109,9 @@ static int clk_programmable_set_parent(struct clk_hw *hw, u8 index)
        if (layout->have_slck_mck)
                mask |= AT91_PMC_CSSMCK_MCK;
 
+       if (prog->mux_table)
+               pckr = clk_mux_index_to_val(prog->mux_table, 0, index);
+
        if (index > layout->css_mask) {
                if (index > PROG_MAX_RM9200_CSS && !layout->have_slck_mck)
                        return -EINVAL;
@@ -134,6 +138,9 @@ static u8 clk_programmable_get_parent(struct clk_hw *hw)
        if (layout->have_slck_mck && (pckr & AT91_PMC_CSSMCK_MCK) && !ret)
                ret = PROG_MAX_RM9200_CSS + 1;
 
+       if (prog->mux_table)
+               ret = clk_mux_val_to_index(&prog->hw, prog->mux_table, 0, ret);
+
        return ret;
 }
 
@@ -182,7 +189,8 @@ struct clk_hw * __init
 at91_clk_register_programmable(struct regmap *regmap,
                               const char *name, const char **parent_names,
                               u8 num_parents, u8 id,
-                              const struct clk_programmable_layout *layout)
+                              const struct clk_programmable_layout *layout,
+                              u32 *mux_table)
 {
        struct clk_programmable *prog;
        struct clk_hw *hw;
@@ -206,6 +214,7 @@ at91_clk_register_programmable(struct regmap *regmap,
        prog->layout = layout;
        prog->hw.init = &init;
        prog->regmap = regmap;
+       prog->mux_table = mux_table;
 
        hw = &prog->hw;
        ret = clk_hw_register(NULL, &prog->hw);
index 1b90c4f7b1d1373ed8a02f5194a6d6bad93c0c3f..a50084de97d41b7919d0ad3f2af08a5c41d8cb57 100644 (file)
@@ -677,7 +677,8 @@ CLK_OF_DECLARE(at91sam9x5_clk_plldiv, "atmel,at91sam9x5-clk-plldiv",
 
 static void __init
 of_at91_clk_prog_setup(struct device_node *np,
-                      const struct clk_programmable_layout *layout)
+                      const struct clk_programmable_layout *layout,
+                      u32 *mux_table)
 {
        int num;
        u32 id;
@@ -711,7 +712,7 @@ of_at91_clk_prog_setup(struct device_node *np,
 
                hw = at91_clk_register_programmable(regmap, name,
                                                    parent_names, num_parents,
-                                                   id, layout);
+                                                   id, layout, mux_table);
                if (IS_ERR(hw))
                        continue;
 
@@ -721,21 +722,21 @@ of_at91_clk_prog_setup(struct device_node *np,
 
 static void __init of_at91rm9200_clk_prog_setup(struct device_node *np)
 {
-       of_at91_clk_prog_setup(np, &at91rm9200_programmable_layout);
+       of_at91_clk_prog_setup(np, &at91rm9200_programmable_layout, NULL);
 }
 CLK_OF_DECLARE(at91rm9200_clk_prog, "atmel,at91rm9200-clk-programmable",
               of_at91rm9200_clk_prog_setup);
 
 static void __init of_at91sam9g45_clk_prog_setup(struct device_node *np)
 {
-       of_at91_clk_prog_setup(np, &at91sam9g45_programmable_layout);
+       of_at91_clk_prog_setup(np, &at91sam9g45_programmable_layout, NULL);
 }
 CLK_OF_DECLARE(at91sam9g45_clk_prog, "atmel,at91sam9g45-clk-programmable",
               of_at91sam9g45_clk_prog_setup);
 
 static void __init of_at91sam9x5_clk_prog_setup(struct device_node *np)
 {
-       of_at91_clk_prog_setup(np, &at91sam9x5_programmable_layout);
+       of_at91_clk_prog_setup(np, &at91sam9x5_programmable_layout, NULL);
 }
 CLK_OF_DECLARE(at91sam9x5_clk_prog, "atmel,at91sam9x5-clk-programmable",
               of_at91sam9x5_clk_prog_setup);
index 34c9506e6275da172eb8a5265a13d3cb021054c3..8d3e22f566cf7886d79a91a7a9f519b6eef9f953 100644 (file)
@@ -188,7 +188,8 @@ sam9x60_clk_register_pll(struct regmap *regmap, spinlock_t *lock,
 struct clk_hw * __init
 at91_clk_register_programmable(struct regmap *regmap, const char *name,
                               const char **parent_names, u8 num_parents, u8 id,
-                              const struct clk_programmable_layout *layout);
+                              const struct clk_programmable_layout *layout,
+                              u32 *mux_table);
 
 struct clk_hw * __init
 at91_clk_register_sam9260_slow(struct regmap *regmap,
index f090518d24a75d02e1d2b2ea5e81b9ae5a1a8d31..d8d4b28ec4cb6d9341a93dd496ed0b4805926be3 100644 (file)
@@ -254,7 +254,8 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
 
                hw = at91_clk_register_programmable(regmap, name,
                                                    parent_names, 6, i,
-                                                   &sam9x60_programmable_layout);
+                                                   &sam9x60_programmable_layout,
+                                                   NULL);
                if (IS_ERR(hw))
                        goto err_free;
 
index c7765b6649402d5b8ec99d3969b3d31585b77b82..8b220762941aba7d125fa23afdeb16435ea1f1d2 100644 (file)
@@ -268,7 +268,8 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
 
                hw = at91_clk_register_programmable(regmap, name,
                                                    parent_names, 6, i,
-                                                   &sama5d2_programmable_layout);
+                                                   &sama5d2_programmable_layout,
+                                                   NULL);
                if (IS_ERR(hw))
                        goto err_free;
 
index 49ec5964bcb362f226216a91aaee6651d98c5176..7c6e0a5b9dc87088caa2427a4b9197b87dc50a69 100644 (file)
@@ -200,7 +200,8 @@ static void __init sama5d3_pmc_setup(struct device_node *np)
 
                hw = at91_clk_register_programmable(regmap, name,
                                                    parent_names, 5, i,
-                                                   &at91sam9x5_programmable_layout);
+                                                   &at91sam9x5_programmable_layout,
+                                                   NULL);
                if (IS_ERR(hw))
                        goto err_free;
 
index fa121897d95d6796c8ec6c639912910a6dfc4e44..92d8d4141b4335b1aa39dba170cc8f3f8ff47d48 100644 (file)
@@ -223,7 +223,8 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
 
                hw = at91_clk_register_programmable(regmap, name,
                                                    parent_names, 5, i,
-                                                   &at91sam9x5_programmable_layout);
+                                                   &at91sam9x5_programmable_layout,
+                                                   NULL);
                if (IS_ERR(hw))
                        goto err_free;