Skip to content

Commit 9a61f81

Browse files
lumagbebarino
authored andcommitted
clk: qcom: regmap-mux: fix parent clock lookup
The function mux_get_parent() uses qcom_find_src_index() to find the parent clock index, which is incorrect: qcom_find_src_index() uses src enum for the lookup, while mux_get_parent() should use cfg field (which corresponds to the register value). Add qcom_find_cfg_index() function doing this kind of lookup and use it for mux parent lookup. Fixes: df96401 ("clk: qcom: add parent map for regmap mux") Cc: [email protected] Signed-off-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent fa55b7d commit 9a61f81

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

drivers/clk/qcom/clk-regmap-mux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static u8 mux_get_parent(struct clk_hw *hw)
2828
val &= mask;
2929

3030
if (mux->parent_map)
31-
return qcom_find_src_index(hw, mux->parent_map, val);
31+
return qcom_find_cfg_index(hw, mux->parent_map, val);
3232

3333
return val;
3434
}

drivers/clk/qcom/common.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map, u8 src)
6969
}
7070
EXPORT_SYMBOL_GPL(qcom_find_src_index);
7171

72+
int qcom_find_cfg_index(struct clk_hw *hw, const struct parent_map *map, u8 cfg)
73+
{
74+
int i, num_parents = clk_hw_get_num_parents(hw);
75+
76+
for (i = 0; i < num_parents; i++)
77+
if (cfg == map[i].cfg)
78+
return i;
79+
80+
return -ENOENT;
81+
}
82+
EXPORT_SYMBOL_GPL(qcom_find_cfg_index);
83+
7284
struct regmap *
7385
qcom_cc_map(struct platform_device *pdev, const struct qcom_cc_desc *desc)
7486
{

drivers/clk/qcom/common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ extern void
4949
qcom_pll_set_fsm_mode(struct regmap *m, u32 reg, u8 bias_count, u8 lock_count);
5050
extern int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map,
5151
u8 src);
52+
extern int qcom_find_cfg_index(struct clk_hw *hw, const struct parent_map *map,
53+
u8 cfg);
5254

5355
extern int qcom_cc_register_board_clk(struct device *dev, const char *path,
5456
const char *name, unsigned long rate);

0 commit comments

Comments
 (0)