clk: qcom: add parent map for regmap mux
authorAbhishek Sahu <absahu@codeaurora.org>
Wed, 13 Dec 2017 14:25:33 +0000 (19:55 +0530)
committerStephen Boyd <sboyd@codeaurora.org>
Fri, 22 Dec 2017 00:03:22 +0000 (16:03 -0800)
Currently the driver assumes the register configuration value
is identical to its index in the parent map. This patch adds
the parent map field in regmap mux clock node which contains
the mapping of parent index with actual register configuration
value. If regmap node contains this parent map then the
configuration value will be taken from this
parent map instead of simply writing the index value.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
drivers/clk/qcom/clk-rcg.h
drivers/clk/qcom/clk-regmap-mux.c
drivers/clk/qcom/clk-regmap-mux.h
drivers/clk/qcom/common.h

index a2495457e5647f1ca0e11c23191a9486b8f59cd0..2a7489a84e69b41007bc71d2bb99a240cd6df980 100644 (file)
@@ -25,16 +25,6 @@ struct freq_tbl {
        u16 n;
 };
 
-/**
- * struct parent_map - map table for PLL source select configuration values
- * @src: source PLL
- * @cfg: configuration value
- */
-struct parent_map {
-       u8 src;
-       u8 cfg;
-};
-
 /**
  * struct mn - M/N:D counter
  * @mnctr_en_bit: bit to enable mn counter
index cae3071f384c8131247fb047f95aa90cfd973067..0f3a1bda3e91a265fd04e8b9473507c011bd989f 100644 (file)
@@ -35,6 +35,9 @@ static u8 mux_get_parent(struct clk_hw *hw)
        val >>= mux->shift;
        val &= mask;
 
+       if (mux->parent_map)
+               return qcom_find_src_index(hw, mux->parent_map, val);
+
        return val;
 }
 
@@ -45,6 +48,9 @@ static int mux_set_parent(struct clk_hw *hw, u8 index)
        unsigned int mask = GENMASK(mux->width + mux->shift - 1, mux->shift);
        unsigned int val;
 
+       if (mux->parent_map)
+               index = mux->parent_map[index].cfg;
+
        val = index;
        val <<= mux->shift;
 
index 5cec76154fdae427573b07ea1d6480aabacb69ab..7797cddabe6b793405616aadec082e626695e37a 100644 (file)
 
 #include <linux/clk-provider.h>
 #include "clk-regmap.h"
+#include "common.h"
 
 struct clk_regmap_mux {
        u32                     reg;
        u32                     shift;
        u32                     width;
+       const struct parent_map *parent_map;
        struct clk_regmap       clkr;
 };
 
index 23c1927669bac89273c39ee1b698ddc31890e5e7..00196ee15e739155831d08c894f1f315dac1ff2e 100644 (file)
@@ -20,7 +20,6 @@ struct qcom_reset_map;
 struct regmap;
 struct freq_tbl;
 struct clk_hw;
-struct parent_map;
 
 #define PLL_LOCK_COUNT_SHIFT   8
 #define PLL_LOCK_COUNT_MASK    0x3f
@@ -39,6 +38,16 @@ struct qcom_cc_desc {
        size_t num_gdscs;
 };
 
+/**
+ * struct parent_map - map table for source select configuration values
+ * @src: source
+ * @cfg: configuration value
+ */
+struct parent_map {
+       u8 src;
+       u8 cfg;
+};
+
 extern const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f,
                                             unsigned long rate);
 extern const struct freq_tbl *qcom_find_freq_floor(const struct freq_tbl *f,