All of lore.kernel.org
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH V2] ASoC: fsl_esai: Add pm runtime function
@ 2019-04-19 11:01 ` S.j. Wang
  0 siblings, 0 replies; 5+ messages in thread
From: S.j. Wang @ 2019-04-19 11:01 UTC (permalink / raw)
  To: S.j. Wang, timur, nicoleotsuka, Xiubo.Lee, festevam, broonie, alsa-devel
  Cc: linuxppc-dev, linux-kernel


Hi

> 
> 
> Add pm runtime support and move clock handling there.
> fsl_esai_suspend is replaced by pm_runtime_force_suspend.
> fsl_esai_resume is replaced by pm_runtime_force_resume.
> 
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
> Changes in v2
> -refine the commit comments.
> -move regcache_mark_dirty to runtime suspend.
> 
>  sound/soc/fsl/fsl_esai.c | 141 ++++++++++++++++++++++++++--------------------
> -
>  1 file changed, 77 insertions(+), 64 deletions(-)
> 
> diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index
> bad0dfed6b68..10d2210c91ef 100644
> --- a/sound/soc/fsl/fsl_esai.c
> +++ b/sound/soc/fsl/fsl_esai.c
> @@ -9,6 +9,7 @@
>  #include <linux/module.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_platform.h>
> +#include <linux/pm_runtime.h>
>  #include <sound/dmaengine_pcm.h>
>  #include <sound/pcm_params.h>
> 
> @@ -466,30 +467,6 @@ static int fsl_esai_startup(struct
> snd_pcm_substream *substream,
>                             struct snd_soc_dai *dai)  {
>         struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai);
> -       int ret;
> -
> -       /*
> -        * Some platforms might use the same bit to gate all three or two of
> -        * clocks, so keep all clocks open/close at the same time for safety
> -        */
> -       ret = clk_prepare_enable(esai_priv->coreclk);
> -       if (ret)
> -               return ret;
> -       if (!IS_ERR(esai_priv->spbaclk)) {
> -               ret = clk_prepare_enable(esai_priv->spbaclk);
> -               if (ret)
> -                       goto err_spbaclk;
> -       }
> -       if (!IS_ERR(esai_priv->extalclk)) {
> -               ret = clk_prepare_enable(esai_priv->extalclk);
> -               if (ret)
> -                       goto err_extalck;
> -       }
> -       if (!IS_ERR(esai_priv->fsysclk)) {
> -               ret = clk_prepare_enable(esai_priv->fsysclk);
> -               if (ret)
> -                       goto err_fsysclk;
> -       }
> 
>         if (!dai->active) {
>                 /* Set synchronous mode */ @@ -506,16 +483,6 @@ static int
> fsl_esai_startup(struct snd_pcm_substream *substream,
> 
>         return 0;
> 
> -err_fsysclk:
> -       if (!IS_ERR(esai_priv->extalclk))
> -               clk_disable_unprepare(esai_priv->extalclk);
> -err_extalck:
> -       if (!IS_ERR(esai_priv->spbaclk))
> -               clk_disable_unprepare(esai_priv->spbaclk);
> -err_spbaclk:
> -       clk_disable_unprepare(esai_priv->coreclk);
> -
> -       return ret;
>  }
> 
>  static int fsl_esai_hw_params(struct snd_pcm_substream *substream, @@
> -576,20 +543,6 @@ static int fsl_esai_hw_params(struct
> snd_pcm_substream *substream,
>         return 0;
>  }
> 
> -static void fsl_esai_shutdown(struct snd_pcm_substream *substream,
> -                             struct snd_soc_dai *dai)
> -{
> -       struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai);
> -
> -       if (!IS_ERR(esai_priv->fsysclk))
> -               clk_disable_unprepare(esai_priv->fsysclk);
> -       if (!IS_ERR(esai_priv->extalclk))
> -               clk_disable_unprepare(esai_priv->extalclk);
> -       if (!IS_ERR(esai_priv->spbaclk))
> -               clk_disable_unprepare(esai_priv->spbaclk);
> -       clk_disable_unprepare(esai_priv->coreclk);
> -}
> -
>  static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd,
>                             struct snd_soc_dai *dai)  { @@ -658,7 +611,6 @@ static int
> fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd,
> 
>  static const struct snd_soc_dai_ops fsl_esai_dai_ops = {
>         .startup = fsl_esai_startup,
> -       .shutdown = fsl_esai_shutdown,
>         .trigger = fsl_esai_trigger,
>         .hw_params = fsl_esai_hw_params,
>         .set_sysclk = fsl_esai_set_dai_sysclk, @@ -947,6 +899,10 @@ static int
> fsl_esai_probe(struct platform_device *pdev)
>                 return ret;
>         }
> 
> +       pm_runtime_enable(&pdev->dev);
> +

I just have a question, do I need to add pm_runtime_idle(&pdev->dev)?

Best regards
Wang shengjiu

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

* [PATCH V2] ASoC: fsl_esai: Add pm runtime function
@ 2019-04-19 11:01 ` S.j. Wang
  0 siblings, 0 replies; 5+ messages in thread
From: S.j. Wang @ 2019-04-19 11:01 UTC (permalink / raw)
  To: S.j. Wang, timur, nicoleotsuka, Xiubo.Lee, festevam, broonie, alsa-devel
  Cc: linuxppc-dev, linux-kernel


Hi

> 
> 
> Add pm runtime support and move clock handling there.
> fsl_esai_suspend is replaced by pm_runtime_force_suspend.
> fsl_esai_resume is replaced by pm_runtime_force_resume.
> 
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
> Changes in v2
> -refine the commit comments.
> -move regcache_mark_dirty to runtime suspend.
> 
>  sound/soc/fsl/fsl_esai.c | 141 ++++++++++++++++++++++++++--------------------
> -
>  1 file changed, 77 insertions(+), 64 deletions(-)
> 
> diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index
> bad0dfed6b68..10d2210c91ef 100644
> --- a/sound/soc/fsl/fsl_esai.c
> +++ b/sound/soc/fsl/fsl_esai.c
> @@ -9,6 +9,7 @@
>  #include <linux/module.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_platform.h>
> +#include <linux/pm_runtime.h>
>  #include <sound/dmaengine_pcm.h>
>  #include <sound/pcm_params.h>
> 
> @@ -466,30 +467,6 @@ static int fsl_esai_startup(struct
> snd_pcm_substream *substream,
>                             struct snd_soc_dai *dai)  {
>         struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai);
> -       int ret;
> -
> -       /*
> -        * Some platforms might use the same bit to gate all three or two of
> -        * clocks, so keep all clocks open/close at the same time for safety
> -        */
> -       ret = clk_prepare_enable(esai_priv->coreclk);
> -       if (ret)
> -               return ret;
> -       if (!IS_ERR(esai_priv->spbaclk)) {
> -               ret = clk_prepare_enable(esai_priv->spbaclk);
> -               if (ret)
> -                       goto err_spbaclk;
> -       }
> -       if (!IS_ERR(esai_priv->extalclk)) {
> -               ret = clk_prepare_enable(esai_priv->extalclk);
> -               if (ret)
> -                       goto err_extalck;
> -       }
> -       if (!IS_ERR(esai_priv->fsysclk)) {
> -               ret = clk_prepare_enable(esai_priv->fsysclk);
> -               if (ret)
> -                       goto err_fsysclk;
> -       }
> 
>         if (!dai->active) {
>                 /* Set synchronous mode */ @@ -506,16 +483,6 @@ static int
> fsl_esai_startup(struct snd_pcm_substream *substream,
> 
>         return 0;
> 
> -err_fsysclk:
> -       if (!IS_ERR(esai_priv->extalclk))
> -               clk_disable_unprepare(esai_priv->extalclk);
> -err_extalck:
> -       if (!IS_ERR(esai_priv->spbaclk))
> -               clk_disable_unprepare(esai_priv->spbaclk);
> -err_spbaclk:
> -       clk_disable_unprepare(esai_priv->coreclk);
> -
> -       return ret;
>  }
> 
>  static int fsl_esai_hw_params(struct snd_pcm_substream *substream, @@
> -576,20 +543,6 @@ static int fsl_esai_hw_params(struct
> snd_pcm_substream *substream,
>         return 0;
>  }
> 
> -static void fsl_esai_shutdown(struct snd_pcm_substream *substream,
> -                             struct snd_soc_dai *dai)
> -{
> -       struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai);
> -
> -       if (!IS_ERR(esai_priv->fsysclk))
> -               clk_disable_unprepare(esai_priv->fsysclk);
> -       if (!IS_ERR(esai_priv->extalclk))
> -               clk_disable_unprepare(esai_priv->extalclk);
> -       if (!IS_ERR(esai_priv->spbaclk))
> -               clk_disable_unprepare(esai_priv->spbaclk);
> -       clk_disable_unprepare(esai_priv->coreclk);
> -}
> -
>  static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd,
>                             struct snd_soc_dai *dai)  { @@ -658,7 +611,6 @@ static int
> fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd,
> 
>  static const struct snd_soc_dai_ops fsl_esai_dai_ops = {
>         .startup = fsl_esai_startup,
> -       .shutdown = fsl_esai_shutdown,
>         .trigger = fsl_esai_trigger,
>         .hw_params = fsl_esai_hw_params,
>         .set_sysclk = fsl_esai_set_dai_sysclk, @@ -947,6 +899,10 @@ static int
> fsl_esai_probe(struct platform_device *pdev)
>                 return ret;
>         }
> 
> +       pm_runtime_enable(&pdev->dev);
> +

I just have a question, do I need to add pm_runtime_idle(&pdev->dev)?

Best regards
Wang shengjiu

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

* Re: [alsa-devel] [PATCH V2] ASoC: fsl_esai: Add pm runtime function
  2019-04-19 11:01 ` S.j. Wang
  (?)
@ 2019-04-19 15:25   ` Mark Brown
  -1 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2019-04-19 15:25 UTC (permalink / raw)
  To: S.j. Wang
  Cc: timur, nicoleotsuka, Xiubo.Lee, festevam, alsa-devel,
	linuxppc-dev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 422 bytes --]

On Fri, Apr 19, 2019 at 11:01:21AM +0000, S.j. Wang wrote:

> > fsl_esai_probe(struct platform_device *pdev)
> >                 return ret;
> >         }
> > 
> > +       pm_runtime_enable(&pdev->dev);
> > +

> I just have a question, do I need to add pm_runtime_idle(&pdev->dev)?

It gets used to help drivers get into the correct state on startup, if
you're unsure if it's 100% required it shouldn't hurt.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH V2] ASoC: fsl_esai: Add pm runtime function
@ 2019-04-19 15:25   ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2019-04-19 15:25 UTC (permalink / raw)
  To: S.j. Wang
  Cc: alsa-devel, timur, Xiubo.Lee, festevam, linux-kernel,
	nicoleotsuka, linuxppc-dev


[-- Attachment #1.1: Type: text/plain, Size: 422 bytes --]

On Fri, Apr 19, 2019 at 11:01:21AM +0000, S.j. Wang wrote:

> > fsl_esai_probe(struct platform_device *pdev)
> >                 return ret;
> >         }
> > 
> > +       pm_runtime_enable(&pdev->dev);
> > +

> I just have a question, do I need to add pm_runtime_idle(&pdev->dev)?

It gets used to help drivers get into the correct state on startup, if
you're unsure if it's 100% required it shouldn't hurt.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [alsa-devel] [PATCH V2] ASoC: fsl_esai: Add pm runtime function
@ 2019-04-19 15:25   ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2019-04-19 15:25 UTC (permalink / raw)
  To: S.j. Wang
  Cc: alsa-devel, timur, Xiubo.Lee, festevam, linux-kernel,
	nicoleotsuka, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 422 bytes --]

On Fri, Apr 19, 2019 at 11:01:21AM +0000, S.j. Wang wrote:

> > fsl_esai_probe(struct platform_device *pdev)
> >                 return ret;
> >         }
> > 
> > +       pm_runtime_enable(&pdev->dev);
> > +

> I just have a question, do I need to add pm_runtime_idle(&pdev->dev)?

It gets used to help drivers get into the correct state on startup, if
you're unsure if it's 100% required it shouldn't hurt.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2019-04-19 18:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-19 11:01 [alsa-devel] [PATCH V2] ASoC: fsl_esai: Add pm runtime function S.j. Wang
2019-04-19 11:01 ` S.j. Wang
2019-04-19 15:25 ` [alsa-devel] " Mark Brown
2019-04-19 15:25   ` Mark Brown
2019-04-19 15:25   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.