Re: [PATCH v3 7/7] clk: qcom: apcs-msm8916: use clk_parent_data to specify the parent

From: Bjorn Andersson
Date: Fri Dec 20 2019 - 12:22:19 EST


On Wed 18 Dec 22:23 PST 2019, Stephen Boyd wrote:

> Quoting Niklas Cassel (2019-11-25 05:59:09)
> > diff --git a/drivers/clk/qcom/apcs-msm8916.c b/drivers/clk/qcom/apcs-msm8916.c
> > index 46061b3d230e..bb91644edc00 100644
> > --- a/drivers/clk/qcom/apcs-msm8916.c
> > +++ b/drivers/clk/qcom/apcs-msm8916.c
> > @@ -51,6 +51,19 @@ static int qcom_apcs_msm8916_clk_probe(struct platform_device *pdev)
> > struct clk_init_data init = { };
> > int ret = -ENODEV;
> >
> > + /*
> > + * This driver is defined by the devicetree binding
> > + * Documentation/devicetree/bindings/mailbox/qcom,apcs-kpss-global.txt,
> > + * however, this driver is registered as a platform device by
> > + * qcom-apcs-ipc-mailbox.c. Because of this, when this driver
> > + * uses dev_get_regmap() and devm_clk_get(), it has to send the parent
> > + * device as argument.
> > + * When registering with the clock framework, we cannot use this trick,
> > + * since the clock framework always looks at dev->of_node when it tries
> > + * to find parent clock names using clk_parent_data.
> > + */
> > + dev->of_node = parent->of_node;
>
> This is odd. The clks could be registered with of_clk_hw_register() but
> then we lose the device provider information. Maybe we should search up
> one level to the parent node and if that has a DT node but the
> clk controller device doesn't we should use that instead?
>

Yeah, we shouldn't have two struct device with the same of_node in the
system, and your suggestion looks quite reasonable. Do you mind spinning
a patch out of it and we can drop above chunk from Niklas' patch - and
afaict merge all the remaining patches to enable CPR on our first
target!

Thanks,
Bjorn

> ----8<-----
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index b68e200829f2..c8745c415c04 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -3669,7 +3669,7 @@ __clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw)
> if (dev && pm_runtime_enabled(dev))
> core->rpm_enabled = true;
> core->dev = dev;
> - core->of_node = np;
> + core->of_node = np ? : dev_of_node(dev->parent);
> if (dev && dev->driver)
> core->owner = dev->driver->owner;
> core->hw = hw;