Define a parent_map struct to describe the relations between PLL source index and register configuration value. Add a qcom_find_src_index() function for finding the index of a clock matching the specific PLL configuration Signed-off-by: Georgi Djakov <georgi.djakov@xxxxxxxxxx> --- drivers/clk/qcom/clk-rcg.h | 11 +++++++++++ drivers/clk/qcom/common.c | 17 +++++++++++++++++ drivers/clk/qcom/common.h | 2 ++ 3 files changed, 30 insertions(+) diff --git a/drivers/clk/qcom/clk-rcg.h b/drivers/clk/qcom/clk-rcg.h index d09d06ba278e..6d94d5300e9e 100644 --- a/drivers/clk/qcom/clk-rcg.h +++ b/drivers/clk/qcom/clk-rcg.h @@ -26,6 +26,17 @@ struct freq_tbl { }; /** + * 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 * @mnctr_reset_bit: bit to assert mn counter reset diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index e20d947db3e5..a946b48f2d82 100644 --- a/drivers/clk/qcom/common.c +++ b/drivers/clk/qcom/common.c @@ -43,6 +43,23 @@ struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, unsigned long rate) } EXPORT_SYMBOL_GPL(qcom_find_freq); +int qcom_find_src_index(const struct parent_map *map, u8 src) +{ + int i = 0; + + if (!map) + return -EINVAL; + + do { + if (src == map->src) + return i; + i++; + } while (map++); + + return -ENOENT; +} +EXPORT_SYMBOL_GPL(qcom_find_src_index); + struct regmap * qcom_cc_map(struct platform_device *pdev, const struct qcom_cc_desc *desc) { diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h index f519322acdf3..b3d7e5716f5e 100644 --- a/drivers/clk/qcom/common.h +++ b/drivers/clk/qcom/common.h @@ -19,6 +19,7 @@ struct clk_regmap; struct qcom_reset_map; struct regmap; struct freq_tbl; +struct parent_map; struct qcom_cc_desc { const struct regmap_config *config; @@ -30,6 +31,7 @@ struct qcom_cc_desc { extern const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, unsigned long rate); +extern int qcom_find_src_index(const struct parent_map *map, u8 src); extern struct regmap *qcom_cc_map(struct platform_device *pdev, const struct qcom_cc_desc *desc); -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html