Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] clk: qcom: lpasscc: Re-configure the PLL in case lost
@ 2020-10-14 15:58 Douglas Anderson
  2020-10-14 17:06 ` Stephen Boyd
  2020-10-14 17:21 ` Taniya Das
  0 siblings, 2 replies; 5+ messages in thread
From: Douglas Anderson @ 2020-10-14 15:58 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: David Brown, Rajendra Nayak, linux-soc, Taniya Das,
	Douglas Anderson, Andy Gross, Bjorn Andersson, Michael Turquette,
	linux-arm-msm, linux-clk, linux-kernel

From: Taniya Das <tdas@codeaurora.org>

In the case where the PLL configuration is lost, then the pm runtime
resume will reconfigure before usage.

Fixes: edab812d802d ("clk: qcom: lpass: Add support for LPASS clock controller for SC7180")
Signed-off-by: Taniya Das <tdas@codeaurora.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
I took the liberty of fixing my own nits that I had with Taniya's
patch, AKA:

https://lore.kernel.org/r/1602614008-2421-2-git-send-email-tdas@codeaurora.org

Changes in v2:
- Don't needlessly have a 2nd copy of dev_pm_ops and jam it in.
- Check the return value of pm_clk_resume()
- l_val should be unsigned int.

 drivers/clk/qcom/lpasscorecc-sc7180.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c
index 228d08f5d26f..ee23eb5b9bf2 100644
--- a/drivers/clk/qcom/lpasscorecc-sc7180.c
+++ b/drivers/clk/qcom/lpasscorecc-sc7180.c
@@ -356,6 +356,25 @@ static const struct qcom_cc_desc lpass_audio_hm_sc7180_desc = {
 	.num_gdscs = ARRAY_SIZE(lpass_audio_hm_sc7180_gdscs),
 };
 
+static int lpass_core_cc_pm_clk_resume(struct device *dev)
+{
+	struct regmap *regmap = dev_get_drvdata(dev);
+	unsigned int l_val;
+	int ret;
+
+	ret = pm_clk_resume(dev);
+	if (ret)
+		return ret;
+
+	/* Read PLL_L_VAL */
+	regmap_read(regmap, 0x1004, &l_val);
+	if (!l_val)
+		clk_fabia_pll_configure(&lpass_lpaaudio_dig_pll, regmap,
+				&lpass_lpaaudio_dig_pll_config);
+
+	return 0;
+}
+
 static int lpass_core_cc_sc7180_probe(struct platform_device *pdev)
 {
 	const struct qcom_cc_desc *desc;
@@ -373,6 +392,8 @@ static int lpass_core_cc_sc7180_probe(struct platform_device *pdev)
 	if (IS_ERR(regmap))
 		return PTR_ERR(regmap);
 
+	dev_set_drvdata(&pdev->dev, regmap);
+
 	/*
 	 * Keep the CLK always-ON
 	 * LPASS_AUDIO_CORE_SYSNOC_SWAY_CORE_CLK
@@ -449,7 +470,7 @@ static int lpass_core_sc7180_probe(struct platform_device *pdev)
 }
 
 static const struct dev_pm_ops lpass_core_cc_pm_ops = {
-	SET_RUNTIME_PM_OPS(pm_clk_suspend, pm_clk_resume, NULL)
+	SET_RUNTIME_PM_OPS(pm_clk_suspend, lpass_core_cc_pm_clk_resume, NULL)
 };
 
 static struct platform_driver lpass_core_cc_sc7180_driver = {
-- 
2.28.0.1011.ga647a8990f-goog


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] clk: qcom: lpasscc: Re-configure the PLL in case lost
  2020-10-14 15:58 [PATCH v2] clk: qcom: lpasscc: Re-configure the PLL in case lost Douglas Anderson
@ 2020-10-14 17:06 ` Stephen Boyd
  2020-10-14 21:13   ` Doug Anderson
  2020-10-14 17:21 ` Taniya Das
  1 sibling, 1 reply; 5+ messages in thread
From: Stephen Boyd @ 2020-10-14 17:06 UTC (permalink / raw)
  To: Douglas Anderson
  Cc: David Brown, Rajendra Nayak, linux-soc, Taniya Das,
	Douglas Anderson, Andy Gross, Bjorn Andersson, Michael Turquette,
	linux-arm-msm, linux-clk, linux-kernel

Quoting Douglas Anderson (2020-10-14 08:58:24)
> diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c
> index 228d08f5d26f..ee23eb5b9bf2 100644
> --- a/drivers/clk/qcom/lpasscorecc-sc7180.c
> +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c
> @@ -356,6 +356,25 @@ static const struct qcom_cc_desc lpass_audio_hm_sc7180_desc = {
>         .num_gdscs = ARRAY_SIZE(lpass_audio_hm_sc7180_gdscs),
>  };
>  
> +static int lpass_core_cc_pm_clk_resume(struct device *dev)
> +{
> +       struct regmap *regmap = dev_get_drvdata(dev);

Can we use dev_get_remap(dev, NULL) instead?

> +       unsigned int l_val;
> +       int ret;
> +
> +       ret = pm_clk_resume(dev);
> +       if (ret)
> +               return ret;
> +
> +       /* Read PLL_L_VAL */

Please drop this useless comment. Replace it with something like this
(if at all):

	/* Reconfigure PLL if PLL was reset across suspend */

> +       regmap_read(regmap, 0x1004, &l_val);
> +       if (!l_val)
> +               clk_fabia_pll_configure(&lpass_lpaaudio_dig_pll, regmap,
> +                               &lpass_lpaaudio_dig_pll_config);
> +
> +       return 0;
> +}
> +
>  static int lpass_core_cc_sc7180_probe(struct platform_device *pdev)
>  {
>         const struct qcom_cc_desc *desc;
> @@ -373,6 +392,8 @@ static int lpass_core_cc_sc7180_probe(struct platform_device *pdev)
>         if (IS_ERR(regmap))
>                 return PTR_ERR(regmap);
>  
> +       dev_set_drvdata(&pdev->dev, regmap);
> +

And then this isn't needed.

>         /*
>          * Keep the CLK always-ON
>          * LPASS_AUDIO_CORE_SYSNOC_SWAY_CORE_CLK

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] clk: qcom: lpasscc: Re-configure the PLL in case lost
  2020-10-14 15:58 [PATCH v2] clk: qcom: lpasscc: Re-configure the PLL in case lost Douglas Anderson
  2020-10-14 17:06 ` Stephen Boyd
@ 2020-10-14 17:21 ` Taniya Das
  2020-10-14 21:13   ` Doug Anderson
  1 sibling, 1 reply; 5+ messages in thread
From: Taniya Das @ 2020-10-14 17:21 UTC (permalink / raw)
  To: Douglas Anderson, Stephen Boyd
  Cc: David Brown, Rajendra Nayak, linux-soc, Andy Gross,
	Bjorn Andersson, Michael Turquette, linux-arm-msm, linux-clk,
	linux-kernel

Thanks Doug for the patch.

On 10/14/2020 9:28 PM, Douglas Anderson wrote:
> From: Taniya Das <tdas@codeaurora.org>
> 
> In the case where the PLL configuration is lost, then the pm runtime
> resume will reconfigure before usage.
> 
> Fixes: edab812d802d ("clk: qcom: lpass: Add support for LPASS clock controller for SC7180")
> Signed-off-by: Taniya Das <tdas@codeaurora.org>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
> I took the liberty of fixing my own nits that I had with Taniya's
> patch, AKA:
> 
> https://lore.kernel.org/r/1602614008-2421-2-git-send-email-tdas@codeaurora.org
> 
> Changes in v2:
> - Don't needlessly have a 2nd copy of dev_pm_ops and jam it in.
> - Check the return value of pm_clk_resume()
> - l_val should be unsigned int.
> 
>   drivers/clk/qcom/lpasscorecc-sc7180.c | 23 ++++++++++++++++++++++-
>   1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c
> index 228d08f5d26f..ee23eb5b9bf2 100644
> --- a/drivers/clk/qcom/lpasscorecc-sc7180.c
> +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c
> @@ -356,6 +356,25 @@ static const struct qcom_cc_desc lpass_audio_hm_sc7180_desc = {
>   	.num_gdscs = ARRAY_SIZE(lpass_audio_hm_sc7180_gdscs),
>   };
>   
> +static int lpass_core_cc_pm_clk_resume(struct device *dev)
> +{
> +	struct regmap *regmap = dev_get_drvdata(dev);
> +	unsigned int l_val;
> +	int ret;
> +
> +	ret = pm_clk_resume(dev);
> +	if (ret)
> +		return ret;
> +
> +	/* Read PLL_L_VAL */
> +	regmap_read(regmap, 0x1004, &l_val);
> +	if (!l_val)
> +		clk_fabia_pll_configure(&lpass_lpaaudio_dig_pll, regmap,
> +				&lpass_lpaaudio_dig_pll_config);
> +
> +	return 0;
> +}
> +
>   static int lpass_core_cc_sc7180_probe(struct platform_device *pdev)
>   {
>   	const struct qcom_cc_desc *desc;
> @@ -373,6 +392,8 @@ static int lpass_core_cc_sc7180_probe(struct platform_device *pdev)
>   	if (IS_ERR(regmap))
>   		return PTR_ERR(regmap);
>   
> +	dev_set_drvdata(&pdev->dev, regmap);
> +
>   	/*
>   	 * Keep the CLK always-ON
>   	 * LPASS_AUDIO_CORE_SYSNOC_SWAY_CORE_CLK
> @@ -449,7 +470,7 @@ static int lpass_core_sc7180_probe(struct platform_device *pdev)
>   }
>   
>   static const struct dev_pm_ops lpass_core_cc_pm_ops = {
> -	SET_RUNTIME_PM_OPS(pm_clk_suspend, pm_clk_resume, NULL)
> +	SET_RUNTIME_PM_OPS(pm_clk_suspend, lpass_core_cc_pm_clk_resume, NULL)

There are two devices and "lpass_hm_core" and the PLL is not part of the 
HM_CORE, thus was the reason to separate out the pm_ops.

>   };
>   
>   static struct platform_driver lpass_core_cc_sc7180_driver = {
> 

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation.

--

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] clk: qcom: lpasscc: Re-configure the PLL in case lost
  2020-10-14 17:06 ` Stephen Boyd
@ 2020-10-14 21:13   ` Doug Anderson
  0 siblings, 0 replies; 5+ messages in thread
From: Doug Anderson @ 2020-10-14 21:13 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: David Brown, Rajendra Nayak, open list:ARM/QUALCOMM SUPPORT,
	Taniya Das, Andy Gross, Bjorn Andersson, Michael Turquette,
	linux-arm-msm, linux-clk, LKML

Hi,

On Wed, Oct 14, 2020 at 10:06 AM Stephen Boyd <sboyd@kernel.org> wrote:
>
> Quoting Douglas Anderson (2020-10-14 08:58:24)
> > diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c
> > index 228d08f5d26f..ee23eb5b9bf2 100644
> > --- a/drivers/clk/qcom/lpasscorecc-sc7180.c
> > +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c
> > @@ -356,6 +356,25 @@ static const struct qcom_cc_desc lpass_audio_hm_sc7180_desc = {
> >         .num_gdscs = ARRAY_SIZE(lpass_audio_hm_sc7180_gdscs),
> >  };
> >
> > +static int lpass_core_cc_pm_clk_resume(struct device *dev)
> > +{
> > +       struct regmap *regmap = dev_get_drvdata(dev);
>
> Can we use dev_get_remap(dev, NULL) instead?

Good idea.  ...but as far as I can tell there are two regmaps.  I'll use

dev_get_regmap(dev, "lpass_core_cc");


> > +       unsigned int l_val;
> > +       int ret;
> > +
> > +       ret = pm_clk_resume(dev);
> > +       if (ret)
> > +               return ret;
> > +
> > +       /* Read PLL_L_VAL */
>
> Please drop this useless comment. Replace it with something like this
> (if at all):
>
>         /* Reconfigure PLL if PLL was reset across suspend */

We reconfigure more than just the PLL.  I believe that the PLL being
zero is just a clue that we use to know we should re-init the whole
thing.  I've tried to convey this in a comment in the next version.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] clk: qcom: lpasscc: Re-configure the PLL in case lost
  2020-10-14 17:21 ` Taniya Das
@ 2020-10-14 21:13   ` Doug Anderson
  0 siblings, 0 replies; 5+ messages in thread
From: Doug Anderson @ 2020-10-14 21:13 UTC (permalink / raw)
  To: Taniya Das
  Cc: Stephen Boyd, David Brown, Rajendra Nayak,
	open list:ARM/QUALCOMM SUPPORT, Andy Gross, Bjorn Andersson,
	Michael Turquette, linux-arm-msm, linux-clk, LKML

Hi,

On Wed, Oct 14, 2020 at 10:21 AM Taniya Das <tdas@codeaurora.org> wrote:
>
> Thanks Doug for the patch.
>
> On 10/14/2020 9:28 PM, Douglas Anderson wrote:
> > From: Taniya Das <tdas@codeaurora.org>
> >
> > In the case where the PLL configuration is lost, then the pm runtime
> > resume will reconfigure before usage.
> >
> > Fixes: edab812d802d ("clk: qcom: lpass: Add support for LPASS clock controller for SC7180")
> > Signed-off-by: Taniya Das <tdas@codeaurora.org>
> > Signed-off-by: Douglas Anderson <dianders@chromium.org>
> > ---
> > I took the liberty of fixing my own nits that I had with Taniya's
> > patch, AKA:
> >
> > https://lore.kernel.org/r/1602614008-2421-2-git-send-email-tdas@codeaurora.org
> >
> > Changes in v2:
> > - Don't needlessly have a 2nd copy of dev_pm_ops and jam it in.
> > - Check the return value of pm_clk_resume()
> > - l_val should be unsigned int.
> >
> >   drivers/clk/qcom/lpasscorecc-sc7180.c | 23 ++++++++++++++++++++++-
> >   1 file changed, 22 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c
> > index 228d08f5d26f..ee23eb5b9bf2 100644
> > --- a/drivers/clk/qcom/lpasscorecc-sc7180.c
> > +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c
> > @@ -356,6 +356,25 @@ static const struct qcom_cc_desc lpass_audio_hm_sc7180_desc = {
> >       .num_gdscs = ARRAY_SIZE(lpass_audio_hm_sc7180_gdscs),
> >   };
> >
> > +static int lpass_core_cc_pm_clk_resume(struct device *dev)
> > +{
> > +     struct regmap *regmap = dev_get_drvdata(dev);
> > +     unsigned int l_val;
> > +     int ret;
> > +
> > +     ret = pm_clk_resume(dev);
> > +     if (ret)
> > +             return ret;
> > +
> > +     /* Read PLL_L_VAL */
> > +     regmap_read(regmap, 0x1004, &l_val);
> > +     if (!l_val)
> > +             clk_fabia_pll_configure(&lpass_lpaaudio_dig_pll, regmap,
> > +                             &lpass_lpaaudio_dig_pll_config);
> > +
> > +     return 0;
> > +}
> > +
> >   static int lpass_core_cc_sc7180_probe(struct platform_device *pdev)
> >   {
> >       const struct qcom_cc_desc *desc;
> > @@ -373,6 +392,8 @@ static int lpass_core_cc_sc7180_probe(struct platform_device *pdev)
> >       if (IS_ERR(regmap))
> >               return PTR_ERR(regmap);
> >
> > +     dev_set_drvdata(&pdev->dev, regmap);
> > +
> >       /*
> >        * Keep the CLK always-ON
> >        * LPASS_AUDIO_CORE_SYSNOC_SWAY_CORE_CLK
> > @@ -449,7 +470,7 @@ static int lpass_core_sc7180_probe(struct platform_device *pdev)
> >   }
> >
> >   static const struct dev_pm_ops lpass_core_cc_pm_ops = {
> > -     SET_RUNTIME_PM_OPS(pm_clk_suspend, pm_clk_resume, NULL)
> > +     SET_RUNTIME_PM_OPS(pm_clk_suspend, lpass_core_cc_pm_clk_resume, NULL)
>
> There are two devices and "lpass_hm_core" and the PLL is not part of the
> HM_CORE, thus was the reason to separate out the pm_ops.

Oh, that's really weird / unexpected.  I've tried to disentangle this
in a v3 patch series so I'd be curious to see what people think.
Though it's probably fine to jam the "pm" value like your v1 did I
think it violates the "principle of least surprise" a bit.

-Doug

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14 15:58 [PATCH v2] clk: qcom: lpasscc: Re-configure the PLL in case lost Douglas Anderson
2020-10-14 17:06 ` Stephen Boyd
2020-10-14 21:13   ` Doug Anderson
2020-10-14 17:21 ` Taniya Das
2020-10-14 21:13   ` Doug Anderson

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org
	public-inbox-index linux-arm-msm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git