alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: davinci-mcasp: add support for suspend and resume
@ 2013-10-01 12:50 Daniel Mack
  2013-10-03  6:48 ` Gururaja Hebbar
  2013-10-03 13:22 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Mack @ 2013-10-01 12:50 UTC (permalink / raw)
  To: alsa-devel
  Cc: marek.belisko, s.neumann, nsekhar, Daniel Mack, broonie,
	gururaja.hebbar

When the system returns from suspend, it looses its configuration. Most
of it is restored by running a normal audio stream startup, but the DAI
format is left unset as that's configured on the audio device creation.

Hence, it suffices here to care for the registers which are touched by
davinci_mcasp_set_dai_fmt() and restore them when the system is resumed.

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
 sound/soc/davinci/davinci-mcasp.c | 39 +++++++++++++++++++++++++++++++++++++++
 sound/soc/davinci/davinci-mcasp.h | 12 ++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 591f853..5023da7 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -1272,12 +1272,51 @@ static int davinci_mcasp_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int davinci_mcasp_suspend(struct device *dev)
+{
+	struct davinci_audio_dev *a = dev_get_drvdata(dev);
+	void __iomem *base = a->base;
+
+	a->context.txfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_TXFMCTL_REG);
+	a->context.rxfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_RXFMCTL_REG);
+	a->context.txfmt = mcasp_get_reg(base + DAVINCI_MCASP_TXFMT_REG);
+	a->context.rxfmt = mcasp_get_reg(base + DAVINCI_MCASP_RXFMT_REG);
+	a->context.aclkxctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKXCTL_REG);
+	a->context.aclkrctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKRCTL_REG);
+	a->context.pdir = mcasp_get_reg(base + DAVINCI_MCASP_PDIR_REG);
+
+	return 0;
+}
+
+static int davinci_mcasp_resume(struct device *dev)
+{
+	struct davinci_audio_dev *a = dev_get_drvdata(dev);
+	void __iomem *base = a->base;
+
+	mcasp_set_reg(base + DAVINCI_MCASP_TXFMCTL_REG, a->context.txfmtctl);
+	mcasp_set_reg(base + DAVINCI_MCASP_RXFMCTL_REG, a->context.rxfmtctl);
+	mcasp_set_reg(base + DAVINCI_MCASP_TXFMT_REG, a->context.txfmt);
+	mcasp_set_reg(base + DAVINCI_MCASP_RXFMT_REG, a->context.rxfmt);
+	mcasp_set_reg(base + DAVINCI_MCASP_ACLKXCTL_REG, a->context.aclkxctl);
+	mcasp_set_reg(base + DAVINCI_MCASP_ACLKRCTL_REG, a->context.aclkrctl);
+	mcasp_set_reg(base + DAVINCI_MCASP_PDIR_REG, a->context.pdir);
+
+	return 0;
+}
+#endif
+
+SIMPLE_DEV_PM_OPS(davinci_mcasp_pm_ops,
+		  davinci_mcasp_suspend,
+		  davinci_mcasp_resume);
+
 static struct platform_driver davinci_mcasp_driver = {
 	.probe		= davinci_mcasp_probe,
 	.remove		= davinci_mcasp_remove,
 	.driver		= {
 		.name	= "davinci-mcasp",
 		.owner	= THIS_MODULE,
+		.pm	= &davinci_mcasp_pm_ops,
 		.of_match_table = mcasp_dt_ids,
 	},
 };
diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h
index a9ac0c1..a2e27e1 100644
--- a/sound/soc/davinci/davinci-mcasp.h
+++ b/sound/soc/davinci/davinci-mcasp.h
@@ -43,6 +43,18 @@ struct davinci_audio_dev {
 	/* McASP FIFO related */
 	u8	txnumevt;
 	u8	rxnumevt;
+
+#ifdef CONFIG_PM_SLEEP
+	struct {
+		u32	txfmtctl;
+		u32	rxfmtctl;
+		u32	txfmt;
+		u32	rxfmt;
+		u32	aclkxctl;
+		u32	aclkrctl;
+		u32	pdir;
+	} context;
+#endif
 };
 
 #endif	/* DAVINCI_MCASP_H */
-- 
1.8.3.1

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

* Re: [PATCH] ASoC: davinci-mcasp: add support for suspend and resume
  2013-10-01 12:50 [PATCH] ASoC: davinci-mcasp: add support for suspend and resume Daniel Mack
@ 2013-10-03  6:48 ` Gururaja Hebbar
  2013-10-03 13:22 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Gururaja Hebbar @ 2013-10-03  6:48 UTC (permalink / raw)
  To: Daniel Mack, alsa-devel; +Cc: marek.belisko, broonie, s.neumann, nsekhar

On Tuesday 01 October 2013 06:20 PM, Daniel Mack wrote:
> When the system returns from suspend, it looses its configuration. Most
> of it is restored by running a normal audio stream startup, but the DAI
> format is left unset as that's configured on the audio device creation.
> 
> Hence, it suffices here to care for the registers which are touched by
> davinci_mcasp_set_dai_fmt() and restore them when the system is resumed.


I believe you have confirmed below are the only registers/fields which
will lose context across suspend/resume.

Regards
Gururaja


> 
> Signed-off-by: Daniel Mack <zonque@gmail.com>
> ---
>  sound/soc/davinci/davinci-mcasp.c | 39 +++++++++++++++++++++++++++++++++++++++
>  sound/soc/davinci/davinci-mcasp.h | 12 ++++++++++++
>  2 files changed, 51 insertions(+)
> 
> diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
> index 591f853..5023da7 100644
> --- a/sound/soc/davinci/davinci-mcasp.c
> +++ b/sound/soc/davinci/davinci-mcasp.c
> @@ -1272,12 +1272,51 @@ static int davinci_mcasp_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int davinci_mcasp_suspend(struct device *dev)
> +{
> +	struct davinci_audio_dev *a = dev_get_drvdata(dev);
> +	void __iomem *base = a->base;
> +
> +	a->context.txfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_TXFMCTL_REG);
> +	a->context.rxfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_RXFMCTL_REG);
> +	a->context.txfmt = mcasp_get_reg(base + DAVINCI_MCASP_TXFMT_REG);
> +	a->context.rxfmt = mcasp_get_reg(base + DAVINCI_MCASP_RXFMT_REG);
> +	a->context.aclkxctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKXCTL_REG);
> +	a->context.aclkrctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKRCTL_REG);
> +	a->context.pdir = mcasp_get_reg(base + DAVINCI_MCASP_PDIR_REG);
> +
> +	return 0;
> +}
> +
> +static int davinci_mcasp_resume(struct device *dev)
> +{
> +	struct davinci_audio_dev *a = dev_get_drvdata(dev);
> +	void __iomem *base = a->base;
> +
> +	mcasp_set_reg(base + DAVINCI_MCASP_TXFMCTL_REG, a->context.txfmtctl);
> +	mcasp_set_reg(base + DAVINCI_MCASP_RXFMCTL_REG, a->context.rxfmtctl);
> +	mcasp_set_reg(base + DAVINCI_MCASP_TXFMT_REG, a->context.txfmt);
> +	mcasp_set_reg(base + DAVINCI_MCASP_RXFMT_REG, a->context.rxfmt);
> +	mcasp_set_reg(base + DAVINCI_MCASP_ACLKXCTL_REG, a->context.aclkxctl);
> +	mcasp_set_reg(base + DAVINCI_MCASP_ACLKRCTL_REG, a->context.aclkrctl);
> +	mcasp_set_reg(base + DAVINCI_MCASP_PDIR_REG, a->context.pdir);
> +
> +	return 0;
> +}
> +#endif
> +
> +SIMPLE_DEV_PM_OPS(davinci_mcasp_pm_ops,
> +		  davinci_mcasp_suspend,
> +		  davinci_mcasp_resume);
> +
>  static struct platform_driver davinci_mcasp_driver = {
>  	.probe		= davinci_mcasp_probe,
>  	.remove		= davinci_mcasp_remove,
>  	.driver		= {
>  		.name	= "davinci-mcasp",
>  		.owner	= THIS_MODULE,
> +		.pm	= &davinci_mcasp_pm_ops,
>  		.of_match_table = mcasp_dt_ids,
>  	},
>  };
> diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h
> index a9ac0c1..a2e27e1 100644
> --- a/sound/soc/davinci/davinci-mcasp.h
> +++ b/sound/soc/davinci/davinci-mcasp.h
> @@ -43,6 +43,18 @@ struct davinci_audio_dev {
>  	/* McASP FIFO related */
>  	u8	txnumevt;
>  	u8	rxnumevt;
> +
> +#ifdef CONFIG_PM_SLEEP
> +	struct {
> +		u32	txfmtctl;
> +		u32	rxfmtctl;
> +		u32	txfmt;
> +		u32	rxfmt;
> +		u32	aclkxctl;
> +		u32	aclkrctl;
> +		u32	pdir;
> +	} context;
> +#endif
>  };
>  
>  #endif	/* DAVINCI_MCASP_H */
> 

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

* Re: [PATCH] ASoC: davinci-mcasp: add support for suspend and resume
  2013-10-01 12:50 [PATCH] ASoC: davinci-mcasp: add support for suspend and resume Daniel Mack
  2013-10-03  6:48 ` Gururaja Hebbar
@ 2013-10-03 13:22 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2013-10-03 13:22 UTC (permalink / raw)
  To: Daniel Mack
  Cc: marek.belisko, alsa-devel, s.neumann, nsekhar, gururaja.hebbar


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

On Tue, Oct 01, 2013 at 02:50:02PM +0200, Daniel Mack wrote:
> When the system returns from suspend, it looses its configuration. Most
> of it is restored by running a normal audio stream startup, but the DAI
> format is left unset as that's configured on the audio device creation.

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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



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

end of thread, other threads:[~2013-10-03 13:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-01 12:50 [PATCH] ASoC: davinci-mcasp: add support for suspend and resume Daniel Mack
2013-10-03  6:48 ` Gururaja Hebbar
2013-10-03 13:22 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).