diff mbox series

[06/13] clk: qcom: hfpll: get parent clock names from DT

Message ID 1545039990-19984-7-git-send-email-jorge.ramirez-ortiz@linaro.org
State New
Headers show
Series Support CPU frequency scaling on QCS404 | expand

Commit Message

Jorge Ramirez-Ortiz Dec. 17, 2018, 9:46 a.m. UTC
Allow accessing the parent clock name required for the driver
operation using the device tree node.

This permits extending the driver to other platforms without having to
modify its source code.

For backwards compatibility leave the previous value as default.

Co-developed-by: Niklas Cassel <niklas.cassel@linaro.org>
Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org>

Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>

---
 drivers/clk/qcom/hfpll.c | 8 ++++++++
 1 file changed, 8 insertions(+)

-- 
2.7.4

Comments

Bjorn Andersson Jan. 17, 2019, 6:27 a.m. UTC | #1
On Mon 17 Dec 01:46 PST 2018, Jorge Ramirez-Ortiz wrote:

> Allow accessing the parent clock name required for the driver

> operation using the device tree node.

> 

> This permits extending the driver to other platforms without having to

> modify its source code.

> 

> For backwards compatibility leave the previous value as default.

> 


Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>


> Co-developed-by: Niklas Cassel <niklas.cassel@linaro.org>

> Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org>

> Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>

> ---

>  drivers/clk/qcom/hfpll.c | 8 ++++++++

>  1 file changed, 8 insertions(+)

> 

> diff --git a/drivers/clk/qcom/hfpll.c b/drivers/clk/qcom/hfpll.c

> index a6de7101..87b7f46 100644

> --- a/drivers/clk/qcom/hfpll.c

> +++ b/drivers/clk/qcom/hfpll.c

> @@ -52,6 +52,7 @@ static int qcom_hfpll_probe(struct platform_device *pdev)

>  	void __iomem *base;

>  	struct regmap *regmap;

>  	struct clk_hfpll *h;

> +	struct clk *pclk;

>  	struct clk_init_data init = {

>  		.parent_names = (const char *[]){ "xo" },

>  		.num_parents = 1,

> @@ -75,6 +76,13 @@ static int qcom_hfpll_probe(struct platform_device *pdev)

>  					  0, &init.name))

>  		return -ENODEV;

>  

> +	/* get parent clock from device tree (optional) */

> +	pclk = devm_clk_get(dev, "xo");

> +	if (!IS_ERR(pclk))

> +		init.parent_names = (const char *[]){ __clk_get_name(pclk) };

> +	else if (PTR_ERR(pclk) == -EPROBE_DEFER)

> +		return -EPROBE_DEFER;

> +

>  	h->d = &hdata;

>  	h->clkr.hw.init = &init;

>  	spin_lock_init(&h->lock);

> -- 

> 2.7.4

>
diff mbox series

Patch

diff --git a/drivers/clk/qcom/hfpll.c b/drivers/clk/qcom/hfpll.c
index a6de7101..87b7f46 100644
--- a/drivers/clk/qcom/hfpll.c
+++ b/drivers/clk/qcom/hfpll.c
@@ -52,6 +52,7 @@  static int qcom_hfpll_probe(struct platform_device *pdev)
 	void __iomem *base;
 	struct regmap *regmap;
 	struct clk_hfpll *h;
+	struct clk *pclk;
 	struct clk_init_data init = {
 		.parent_names = (const char *[]){ "xo" },
 		.num_parents = 1,
@@ -75,6 +76,13 @@  static int qcom_hfpll_probe(struct platform_device *pdev)
 					  0, &init.name))
 		return -ENODEV;
 
+	/* get parent clock from device tree (optional) */
+	pclk = devm_clk_get(dev, "xo");
+	if (!IS_ERR(pclk))
+		init.parent_names = (const char *[]){ __clk_get_name(pclk) };
+	else if (PTR_ERR(pclk) == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+
 	h->d = &hdata;
 	h->clkr.hw.init = &init;
 	spin_lock_init(&h->lock);