clk: qcom: common: Add API to register board clocks backwards compatibly
Subsystems (3)
PATCH 1/2 clk: qcom: common: Add API to register board clocks backwards compatibly
We want to put the XO board clocks into the dt files. Add an API to do this generically. This also makes a place for us to handle the case where the RPM driver is enabled or disabled.
---
I'm also thinking that maybe we should register the board clock if it isn't there in DT and then we'll either register the pass through or we'll skip it depending on if the RPM driver is enabled. That way the RPM driver doesn't need to know anything, just register the clock with parent as the board clock.
drivers/clk/qcom/common.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/clk/qcom/common.h | 3 +++ 2 files changed, 50 insertions(+)
drivers/clk/qcom/common.c +47 -0
@@ -88,6 +88,53 @@ static void qcom_cc_gdsc_unregister(void *data)gdsc_unregister (data); } +int qcom_cc_register_board_clk (struct device *dev,const char *path, +const char *name,unsigned long rate) +{ +struct device_node *node =NULL ; +struct device_node *clocks_node; +struct clk_fixed_factor *factor; +struct clk_fixed_rate *fixed; +struct clk_hw *hw; +struct clk_init_data init_data = { .name = name }; + + clocks_node =of_find_node_by_path ("/clocks" ); +if (clocks_node) + node =of_find_node_by_name (clocks_node, path); +of_node_put (clocks_node); + +if (node) { + factor =devm_kzalloc (dev,sizeof (*factor),GFP_KERNEL ); +if (!factor) +return -EINVAL ; + + factor->mult = factor->div =1 ; + factor->hw.init = &init_data; + + init_data.parent_names = &path; + init_data.num_parents =1 ; + init_data.ops = &clk_fixed_factor_ops; + + hw = &factor->hw; + }else { + fixed =devm_kzalloc (dev,sizeof (*fixed),GFP_KERNEL ); +if (!fixed) +return -EINVAL ; + + fixed->fixed_rate = rate; + fixed->hw.init = &init_data; + + init_data.flags =CLK_IS_ROOT ; + init_data.ops = &clk_fixed_rate_ops; + + hw = &fixed->hw; + } +of_node_put (node); + +return PTR_ERR_OR_ZERO (devm_clk_register (dev, hw)); +} +EXPORT_SYMBOL (qcom_cc_register_board_clk); +int qcom_cc_really_probe (struct platform_device *pdev,const struct qcom_cc_desc *desc,struct regmap *regmap) {
drivers/clk/qcom/common.h +3 -0
@@ -37,6 +37,9 @@ extern const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f,extern int qcom_find_src_index (struct clk_hw *hw,const struct parent_map *map,u8 src); +extern int qcom_cc_register_board_clk (struct device *dev,const char *path, +const char *name,unsigned long rate); +extern struct regmap *qcom_cc_map (struct platform_device *pdev,const struct qcom_cc_desc *desc); extern int qcom_cc_really_probe(struct platform_device *pdev,
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 2/2 clk: qcom: msm8960: Move cxo/pxo into dt files
Put the cxo and pxo clocks into the dt files as 'cxo_board' and 'pxo_board'. This provides a few benefits. It allows us to specify the frequency of these clocks at the board level instead of hard-coding them in the driver. It allows us to insert an RPM clock in between the consumers of the crystals and the actual clock if desired. And finally, it helps us transition the GCC driver to use RPM clocks when the configuration is enabled.
--- drivers/clk/qcom/gcc-msm8960.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/clk/qcom/gcc-msm8960.c +11 -8
@@ -3503,7 +3503,6 @@ MODULE_DEVICE_TABLE(of, gcc_msm8960_match_table);static int gcc_msm8960_probe (struct platform_device *pdev) { -struct clk *clk;struct device *dev = &pdev->dev;const struct of_device_id *match;struct platform_device *tsens;
@@ -3513,14 +3512,18 @@ static int gcc_msm8960_probe(struct platform_device *pdev)if (!match)return -EINVAL ; -/* Temporary until RPM clocks supported */ - clk =clk_register_fixed_rate (dev,"cxo" ,NULL ,CLK_IS_ROOT ,19200000 ); -if (IS_ERR (clk)) -return PTR_ERR (clk); +/* +* Backwards compatibility with old DTs. Register a pass-through +* factor 1/1 clock to translate cxo_board into cxo and pxo_board +* into pxo. +*/ + ret =qcom_cc_register_board_clk (dev,"cxo_board" ,"cxo" ,19200000 ); +if (ret) +return ret; - clk =clk_register_fixed_rate (dev,"pxo" ,NULL ,CLK_IS_ROOT ,27000000 ); -if (IS_ERR (clk)) -return PTR_ERR (clk); + ret =qcom_cc_register_board_clk (dev,"pxo_board" ,"pxo" ,27000000 ); +if (ret) +return ret; ret =qcom_cc_probe (pdev, match->data);if (ret)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 6 lines · Stephen Boyd
We want to put the XO board clocks into the dt files. Add an API to do this generically. This also makes a place for us to handle the case where the RPM driver is enabled or disabled.
Cc Georgi Djakov <[email protected]>Signed-off-by Stephen Boyd <[email protected]>
Quoted 7 lines
---
I'm also thinking that maybe we should register the board clock if it isn't there in DT and then we'll either register the pass through or we'll skip it depending on if the RPM driver is enabled. That way the RPM driver doesn't need to know anything, just register the clock with parent as the board clock.
That seems like a better idea. v2 coming with that change and a sleep_clk specific API, plus all the armv7 platforms converted.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project