@@ -28,6 +28,7 @@ static u8 mux_get_parent(struct clk_hw *hw)
struct clk_regmap_mux *mux = to_clk_regmap_mux(hw);
struct clk_regmap *clkr = to_clk_regmap(hw);
unsigned int mask = GENMASK(mux->width - 1, 0);
+ int num_parents = clk_hw_get_num_parents(hw);
unsigned int val;
regmap_read(clkr->regmap, mux->reg, &val);
@@ -35,6 +36,15 @@ static u8 mux_get_parent(struct clk_hw *hw)
val >>= mux->shift;
val &= mask;
+ if (mux->table) {
+ int i;
+
+ for (i = 0; i < num_parents; i++)
+ if (mux->table[i] == val)
+ return i;
+ return -EINVAL;
+ }
+
return val;
}
@@ -45,6 +55,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->table)
+ index = mux->table[index];
+
val = index;
val <<= mux->shift;
@@ -21,6 +21,7 @@ struct clk_regmap_mux {
u32 reg;
u32 shift;
u32 width;
+ u32 *table;
struct clk_regmap clkr;
};
Add support to pass a table of values for parent selection similar to whats done in clk-mux Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org> --- drivers/clk/qcom/clk-regmap-mux.c | 13 +++++++++++++ drivers/clk/qcom/clk-regmap-mux.h | 1 + 2 files changed, 14 insertions(+)