* use dmaengine for atmel ssc/pcm dai drivers
@ 2011-06-29 18:00 Nicolas Ferre
2011-06-29 18:00 ` [PATCH 1/5] ASoC: wm8731: rework power management Nicolas Ferre
` (4 more replies)
0 siblings, 5 replies; 23+ messages in thread
From: Nicolas Ferre @ 2011-06-29 18:00 UTC (permalink / raw)
To: linux-arm-kernel
This patch series is built on top of ASoC git tree for-3.1 branch.
It will add the DMA use through dmaengine to the SSC/PCM Atmel drivers. These
drivers are curently using the PDC DMA feature which has been replaced by a DMA
controller in some chips. The dmaengine driver curently used is at_hdmac.
The first patch is a little update to wm8731 codec driver.
Nicolas Ferre (5):
ASoC: wm8731: rework power management
ASoC: atmel-ssc: add phybase in device structure
ASoC: atmel-ssc: dmaengine usage switch depending on cpu
ASoC: atmel_ssc_dai/atmel-pcm: adapt to dmaengine usage
ASoC: atmel_ssc_dai: PM: actually stopping clock on suspend/resume
drivers/misc/atmel-ssc.c | 1 +
include/linux/atmel-ssc.h | 4 +
sound/soc/atmel/atmel-pcm.c | 382 +++++++++++++++++++++++++++++++++++---
sound/soc/atmel/atmel-pcm.h | 4 +-
sound/soc/atmel/atmel_ssc_dai.c | 53 ++++--
sound/soc/codecs/wm8731.c | 5 +-
6 files changed, 395 insertions(+), 54 deletions(-)
^ permalink raw reply [flat|nested] 23+ messages in thread* [PATCH 1/5] ASoC: wm8731: rework power management 2011-06-29 18:00 use dmaengine for atmel ssc/pcm dai drivers Nicolas Ferre @ 2011-06-29 18:00 ` Nicolas Ferre 2011-06-29 17:11 ` Mark Brown 2011-07-01 10:43 ` [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered Nicolas Ferre 2011-06-29 18:00 ` [PATCH 2/5] ASoC: atmel-ssc: add phybase in device structure Nicolas Ferre ` (3 subsequent siblings) 4 siblings, 2 replies; 23+ messages in thread From: Nicolas Ferre @ 2011-06-29 18:00 UTC (permalink / raw) To: linux-arm-kernel - preserve crystal oscillator across suspend/resume sequence: enabled by default, it should be kept enabled on resume. - if codec is in active state: set the active bit at resume time. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> --- sound/soc/codecs/wm8731.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 2dc964b..e65af3d 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -481,7 +481,8 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: snd_soc_write(codec, WM8731_ACTIVE, 0x0); - snd_soc_write(codec, WM8731_PWR, 0xffff); + /* standby: keep crystal oscillator enabled */ + snd_soc_write(codec, WM8731_PWR, 0x00df); regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); break; @@ -533,6 +534,8 @@ static int wm8731_suspend(struct snd_soc_codec *codec, pm_message_t state) static int wm8731_resume(struct snd_soc_codec *codec) { wm8731_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + if (codec->active) + snd_soc_write(codec, WM8731_ACTIVE, 0x0001); return 0; } -- 1.7.3 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 1/5] ASoC: wm8731: rework power management 2011-06-29 18:00 ` [PATCH 1/5] ASoC: wm8731: rework power management Nicolas Ferre @ 2011-06-29 17:11 ` Mark Brown 2011-06-30 13:57 ` Nicolas Ferre 2011-07-01 10:43 ` [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered Nicolas Ferre 1 sibling, 1 reply; 23+ messages in thread From: Mark Brown @ 2011-06-29 17:11 UTC (permalink / raw) To: linux-arm-kernel On Wed, Jun 29, 2011 at 08:00:15PM +0200, Nicolas Ferre wrote: Don't mix multiple changes into a single patch! There's no perceptible code overlap between these so I don't understand why you've merged them, it just makes review harder and the changelog less descriptive. > - preserve crystal oscillator across suspend/resume sequence: > enabled by default, it should be kept enabled on resume. This isn't what your code does... > - if codec is in active state: set the active bit at resume time. Your changelog doesn't explain what the actual problem is here... I can see it by studying the diff but the changelog makes me think the change is bad as the subsystem shuts everything down before it enters CODEC suspend... > snd_soc_write(codec, WM8731_ACTIVE, 0x0); > - snd_soc_write(codec, WM8731_PWR, 0xffff); > + /* standby: keep crystal oscillator enabled */ > + snd_soc_write(codec, WM8731_PWR, 0x00df); This doesn't keep the crystal oscillator enabled, this forces it on in suspend (and without looking at the datasheet it also changes way more than the one register bit I'd expect to be changed). If the system isn't using the oscillator then that's not good. I'd expect to see a change to using snd_soc_update_bits() based on your description, or more likely something more involved. > @@ -533,6 +534,8 @@ static int wm8731_suspend(struct snd_soc_codec *codec, pm_message_t state) > static int wm8731_resume(struct snd_soc_codec *codec) > { > wm8731_set_bias_level(codec, SND_SOC_BIAS_STANDBY); > + if (codec->active) > + snd_soc_write(codec, WM8731_ACTIVE, 0x0001); This should be handled as part of the bias level managemnent and cache sync, if the disable happens in bias level management so should the restore. ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 1/5] ASoC: wm8731: rework power management 2011-06-29 17:11 ` Mark Brown @ 2011-06-30 13:57 ` Nicolas Ferre 2011-06-30 15:04 ` [alsa-devel] " Nicolas Ferre 2011-06-30 15:22 ` Mark Brown 0 siblings, 2 replies; 23+ messages in thread From: Nicolas Ferre @ 2011-06-30 13:57 UTC (permalink / raw) To: linux-arm-kernel Le 29/06/2011 19:11, Mark Brown : > On Wed, Jun 29, 2011 at 08:00:15PM +0200, Nicolas Ferre wrote: > > Don't mix multiple changes into a single patch! There's no perceptible > code overlap between these so I don't understand why you've merged them, > it just makes review harder and the changelog less descriptive. Ok. >> - preserve crystal oscillator across suspend/resume sequence: >> enabled by default, it should be kept enabled on resume. > > This isn't what your code does... > >> snd_soc_write(codec, WM8731_ACTIVE, 0x0); >> - snd_soc_write(codec, WM8731_PWR, 0xffff); >> + /* standby: keep crystal oscillator enabled */ >> + snd_soc_write(codec, WM8731_PWR, 0x00df); > > This doesn't keep the crystal oscillator enabled, this forces it on in > suspend (and without looking at the datasheet it also changes way more > than the one register bit I'd expect to be changed). If the system > isn't using the oscillator then that's not good. > > I'd expect to see a change to using snd_soc_update_bits() based on your > description, or more likely something more involved. First of all, I experienced issues while not having OSC enabled during suspend/resume cycle. Am I right supposing that, if using oscillator to clock the codec, I have to keep it running during a suspend/resume cycle? Is something like this sounds like an acceptable option or we need something more sophisticated? @@ -481,7 +481,10 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: snd_soc_write(codec, WM8731_ACTIVE, 0x0); - snd_soc_write(codec, WM8731_PWR, 0xffff); + reg = 0xdf; + if (wm8731->sysclk_type == WM8731_SYSCLK_XTAL) + reg |= 1 << 0x5; + snd_soc_update_bits(codec, WM8731_PWR, 0x00ff, reg); regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); break; And, yes, there is only 8 bits dedicated to power down control in this register. Best regards, -- Nicolas Ferre ^ permalink raw reply [flat|nested] 23+ messages in thread
* [alsa-devel] [PATCH 1/5] ASoC: wm8731: rework power management 2011-06-30 13:57 ` Nicolas Ferre @ 2011-06-30 15:04 ` Nicolas Ferre 2011-06-30 15:22 ` Mark Brown 1 sibling, 0 replies; 23+ messages in thread From: Nicolas Ferre @ 2011-06-30 15:04 UTC (permalink / raw) To: linux-arm-kernel Le 30/06/2011 15:57, Nicolas Ferre : > Le 29/06/2011 19:11, Mark Brown : >> On Wed, Jun 29, 2011 at 08:00:15PM +0200, Nicolas Ferre wrote: >> >> Don't mix multiple changes into a single patch! There's no perceptible >> code overlap between these so I don't understand why you've merged them, >> it just makes review harder and the changelog less descriptive. > > Ok. > >>> - preserve crystal oscillator across suspend/resume sequence: >>> enabled by default, it should be kept enabled on resume. >> >> This isn't what your code does... >> >>> snd_soc_write(codec, WM8731_ACTIVE, 0x0); >>> - snd_soc_write(codec, WM8731_PWR, 0xffff); >>> + /* standby: keep crystal oscillator enabled */ >>> + snd_soc_write(codec, WM8731_PWR, 0x00df); >> >> This doesn't keep the crystal oscillator enabled, this forces it on in >> suspend (and without looking at the datasheet it also changes way more >> than the one register bit I'd expect to be changed). If the system >> isn't using the oscillator then that's not good. >> >> I'd expect to see a change to using snd_soc_update_bits() based on your >> description, or more likely something more involved. > > First of all, I experienced issues while not having OSC enabled during suspend/resume cycle. Am I right supposing that, if using oscillator to clock the codec, I have to keep it running during a suspend/resume cycle? > > Is something like this sounds like an acceptable option or we need something more sophisticated? > > @@ -481,7 +481,10 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, > break; > case SND_SOC_BIAS_OFF: > snd_soc_write(codec, WM8731_ACTIVE, 0x0); > - snd_soc_write(codec, WM8731_PWR, 0xffff); > + reg = 0xdf; > + if (wm8731->sysclk_type == WM8731_SYSCLK_XTAL) Actually it is: if... != WM8731_SYSCLK_XTAL > + reg |= 1 << 0x5; > + snd_soc_update_bits(codec, WM8731_PWR, 0x00ff, reg); And maybe here a simple snd_soc_write() is sufficient... > regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), > wm8731->supplies); > break; > > And, yes, there is only 8 bits dedicated to power down control in this register. > > Best regards, -- Nicolas Ferre ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 1/5] ASoC: wm8731: rework power management 2011-06-30 13:57 ` Nicolas Ferre 2011-06-30 15:04 ` [alsa-devel] " Nicolas Ferre @ 2011-06-30 15:22 ` Mark Brown 2011-07-01 9:31 ` Nicolas Ferre 1 sibling, 1 reply; 23+ messages in thread From: Mark Brown @ 2011-06-30 15:22 UTC (permalink / raw) To: linux-arm-kernel On Thu, Jun 30, 2011 at 03:57:12PM +0200, Nicolas Ferre wrote: Please fix your mailer to line wrap within paragraphs. > First of all, I experienced issues while not having OSC enabled during > suspend/resume cycle. Am I right supposing that, if using oscillator > to clock the codec, I have to keep it running during a suspend/resume > cycle? No, not at all. What makes you believe that you would you need to do that? ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 1/5] ASoC: wm8731: rework power management 2011-06-30 15:22 ` Mark Brown @ 2011-07-01 9:31 ` Nicolas Ferre 0 siblings, 0 replies; 23+ messages in thread From: Nicolas Ferre @ 2011-07-01 9:31 UTC (permalink / raw) To: linux-arm-kernel Le 30/06/2011 17:22, Mark Brown : > On Thu, Jun 30, 2011 at 03:57:12PM +0200, Nicolas Ferre wrote: > > Please fix your mailer to line wrap within paragraphs. > >> First of all, I experienced issues while not having OSC enabled during >> suspend/resume cycle. Am I right supposing that, if using oscillator >> to clock the codec, I have to keep it running during a suspend/resume >> cycle? > > No, not at all. What makes you believe that you would you need to do > that? Ok, I re-tested and for sure I was totally wrong! So we forget this part of the patch. I guess that this belief may come from my first implementation on 2.6.35 where OSC was not part of the DAPM... Sory for the noise. I repost the "active bit" part real-soon-now. Thanks for your help, best regards, -- Nicolas Ferre ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered 2011-06-29 18:00 ` [PATCH 1/5] ASoC: wm8731: rework power management Nicolas Ferre 2011-06-29 17:11 ` Mark Brown @ 2011-07-01 10:43 ` Nicolas Ferre 2011-07-01 14:18 ` Liam Girdwood 2011-07-01 16:15 ` Mark Brown 1 sibling, 2 replies; 23+ messages in thread From: Nicolas Ferre @ 2011-07-01 10:43 UTC (permalink / raw) To: linux-arm-kernel Resuming from a suspend/resume cycle, the ACTIVE bit was not set even if a stream had actually been processing. Setting this bit at entering SND_SOC_BIAS_ON level will ensure this. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> --- Supersed the wrong patch: "[PATCH 1/5] ASoC: wm8731: rework power management" now based on broonie/sound-2.6 git tree branch: for-3.1. sound/soc/codecs/wm8731.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 2dc964b..ee4ec31 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -453,6 +453,7 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, switch (level) { case SND_SOC_BIAS_ON: + snd_soc_write(codec, WM8731_ACTIVE, 0x0001); break; case SND_SOC_BIAS_PREPARE: break; -- 1.7.3 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered 2011-07-01 10:43 ` [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered Nicolas Ferre @ 2011-07-01 14:18 ` Liam Girdwood 2011-07-01 16:15 ` Mark Brown 1 sibling, 0 replies; 23+ messages in thread From: Liam Girdwood @ 2011-07-01 14:18 UTC (permalink / raw) To: linux-arm-kernel On 01/07/11 11:43, Nicolas Ferre wrote: > Resuming from a suspend/resume cycle, the ACTIVE bit was not set even if a > stream had actually been processing. > Setting this bit at entering SND_SOC_BIAS_ON level will ensure this. > > Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> > --- > Supersed the wrong patch: > "[PATCH 1/5] ASoC: wm8731: rework power management" > > now based on broonie/sound-2.6 git tree branch: for-3.1. > > sound/soc/codecs/wm8731.c | 1 + > 1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c > index 2dc964b..ee4ec31 100644 > --- a/sound/soc/codecs/wm8731.c > +++ b/sound/soc/codecs/wm8731.c > @@ -453,6 +453,7 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, > > switch (level) { > case SND_SOC_BIAS_ON: > + snd_soc_write(codec, WM8731_ACTIVE, 0x0001); > break; > case SND_SOC_BIAS_PREPARE: > break; Acked-by: Liam Girdwood <lrg@ti.com> ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered 2011-07-01 10:43 ` [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered Nicolas Ferre 2011-07-01 14:18 ` Liam Girdwood @ 2011-07-01 16:15 ` Mark Brown 2011-07-04 9:46 ` Nicolas Ferre 1 sibling, 1 reply; 23+ messages in thread From: Mark Brown @ 2011-07-01 16:15 UTC (permalink / raw) To: linux-arm-kernel On Fri, Jul 01, 2011 at 12:43:54PM +0200, Nicolas Ferre wrote: > Resuming from a suspend/resume cycle, the ACTIVE bit was not set even if a > stream had actually been processing. > Setting this bit at entering SND_SOC_BIAS_ON level will ensure this. This will set the bit even for analogue bypass paths which don't need it. I'd suggest making the active bit a supply widget supplying the DAC and ADC rather than something open coded, that should do the right thing I think. ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered 2011-07-01 16:15 ` Mark Brown @ 2011-07-04 9:46 ` Nicolas Ferre 2011-07-04 17:29 ` Mark Brown 0 siblings, 1 reply; 23+ messages in thread From: Nicolas Ferre @ 2011-07-04 9:46 UTC (permalink / raw) To: linux-arm-kernel Le 01/07/2011 18:15, Mark Brown : > On Fri, Jul 01, 2011 at 12:43:54PM +0200, Nicolas Ferre wrote: >> Resuming from a suspend/resume cycle, the ACTIVE bit was not set even if a >> stream had actually been processing. >> Setting this bit at entering SND_SOC_BIAS_ON level will ensure this. > > This will set the bit even for analogue bypass paths which don't need > it. I'd suggest making the active bit a supply widget supplying the DAC > and ADC rather than something open coded, that should do the right thing > I think. Ah, ok... but I fear that I do not know the whole system enough for this addition ;-( Do you think you can code this modification, I will be happy to test it, if you want... Best regards, -- Nicolas Ferre ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered 2011-07-04 9:46 ` Nicolas Ferre @ 2011-07-04 17:29 ` Mark Brown 2011-07-04 17:34 ` Liam Girdwood 2011-07-05 7:58 ` Nicolas Ferre 0 siblings, 2 replies; 23+ messages in thread From: Mark Brown @ 2011-07-04 17:29 UTC (permalink / raw) To: linux-arm-kernel On Mon, Jul 04, 2011 at 11:46:30AM +0200, Nicolas Ferre wrote: > Ah, ok... but I fear that I do not know the whole system enough for this > addition ;-( > Do you think you can code this modification, I will be happy to test it, > if you want... It's pretty trivial - try the below (Liam, are you OK with this if it tests OK?): ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered 2011-07-04 17:29 ` Mark Brown @ 2011-07-04 17:34 ` Liam Girdwood 2011-07-05 7:58 ` Nicolas Ferre 1 sibling, 0 replies; 23+ messages in thread From: Liam Girdwood @ 2011-07-04 17:34 UTC (permalink / raw) To: linux-arm-kernel On 04/07/11 18:29, Mark Brown wrote: > On Mon, Jul 04, 2011 at 11:46:30AM +0200, Nicolas Ferre wrote: > >> Ah, ok... but I fear that I do not know the whole system enough for this >> addition ;-( >> Do you think you can code this modification, I will be happy to test it, >> if you want... > > It's pretty trivial - try the below (Liam, are you OK with this if it > tests OK?): > All fine by me, It's been so long I've forgotten most things about the WM8731 now ;) ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered 2011-07-04 17:29 ` Mark Brown 2011-07-04 17:34 ` Liam Girdwood @ 2011-07-05 7:58 ` Nicolas Ferre 2011-07-05 20:27 ` [alsa-devel] " Mark Brown 1 sibling, 1 reply; 23+ messages in thread From: Nicolas Ferre @ 2011-07-05 7:58 UTC (permalink / raw) To: linux-arm-kernel Le 04/07/2011 19:29, Mark Brown : > On Mon, Jul 04, 2011 at 11:46:30AM +0200, Nicolas Ferre wrote: > >> Ah, ok... but I fear that I do not know the whole system enough for this >> addition ;-( >> Do you think you can code this modification, I will be happy to test it, >> if you want... > > It's pretty trivial - try the below (Liam, are you OK with this if it > tests OK?): > >>From 1dd054eb530641dadbf71525ee517c847f19e161 Mon Sep 17 00:00:00 2001 > From: Mark Brown <broonie@opensource.wolfsonmicro.com> > Date: Mon, 4 Jul 2011 10:27:51 -0700 > Subject: [PATCH] ASoC: Manage WM8731 ACTIVE bit as a supply widget > > Now we have supply widgets there's no need to open code the handling of > the ACTIVE bit. > > Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> > --- > sound/soc/codecs/wm8731.c | 29 +++-------------------------- > 1 files changed, 3 insertions(+), 26 deletions(-) > > diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c > index 2dc964b..59d9e59 100644 > --- a/sound/soc/codecs/wm8731.c > +++ b/sound/soc/codecs/wm8731.c > @@ -175,6 +175,7 @@ static const struct snd_kcontrol_new wm8731_input_mux_controls = > SOC_DAPM_ENUM("Input Select", wm8731_insel_enum); > > static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = { > +SND_SOC_DAPM_SUPPLY("Active",WM8731_ACTIVE, 0, 0, NULL, 0), ------------------------^^^^^^^ I have replaced this with ACTIVE to match the route declaration. *With this modification* it works, so you can add my: Tested-by: Nicolas Ferre <nicolas.ferre@atmel.com> > SND_SOC_DAPM_SUPPLY("OSC", WM8731_PWR, 5, 1, NULL, 0), > SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, > &wm8731_output_mixer_controls[0], > @@ -204,6 +205,8 @@ static int wm8731_check_osc(struct snd_soc_dapm_widget *source, > static const struct snd_soc_dapm_route wm8731_intercon[] = { > {"DAC", NULL, "OSC", wm8731_check_osc}, > {"ADC", NULL, "OSC", wm8731_check_osc}, > + {"DAC", NULL, "ACTIVE"}, > + {"ADC", NULL, "ACTIVE"}, > > /* output mixer */ > {"Output Mixer", "Line Bypass Switch", "Line Input"}, > @@ -315,29 +318,6 @@ static int wm8731_hw_params(struct snd_pcm_substream *substream, > return 0; > } > > -static int wm8731_pcm_prepare(struct snd_pcm_substream *substream, > - struct snd_soc_dai *dai) > -{ > - struct snd_soc_codec *codec = dai->codec; > - > - /* set active */ > - snd_soc_write(codec, WM8731_ACTIVE, 0x0001); > - > - return 0; > -} > - > -static void wm8731_shutdown(struct snd_pcm_substream *substream, > - struct snd_soc_dai *dai) > -{ > - struct snd_soc_codec *codec = dai->codec; > - > - /* deactivate */ > - if (!codec->active) { > - udelay(50); > - snd_soc_write(codec, WM8731_ACTIVE, 0x0); > - } > -} > - > static int wm8731_mute(struct snd_soc_dai *dai, int mute) > { > struct snd_soc_codec *codec = dai->codec; > @@ -480,7 +460,6 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, > snd_soc_write(codec, WM8731_PWR, reg | 0x0040); > break; > case SND_SOC_BIAS_OFF: > - snd_soc_write(codec, WM8731_ACTIVE, 0x0); > snd_soc_write(codec, WM8731_PWR, 0xffff); > regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), > wm8731->supplies); > @@ -496,9 +475,7 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, > SNDRV_PCM_FMTBIT_S24_LE) > > static struct snd_soc_dai_ops wm8731_dai_ops = { > - .prepare = wm8731_pcm_prepare, > .hw_params = wm8731_hw_params, > - .shutdown = wm8731_shutdown, > .digital_mute = wm8731_mute, > .set_sysclk = wm8731_set_dai_sysclk, > .set_fmt = wm8731_set_dai_fmt, -- Nicolas Ferre ^ permalink raw reply [flat|nested] 23+ messages in thread
* [alsa-devel] [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered 2011-07-05 7:58 ` Nicolas Ferre @ 2011-07-05 20:27 ` Mark Brown 0 siblings, 0 replies; 23+ messages in thread From: Mark Brown @ 2011-07-05 20:27 UTC (permalink / raw) To: linux-arm-kernel On Tue, Jul 05, 2011 at 09:58:30AM +0200, Nicolas Ferre wrote: > I have replaced this with ACTIVE to match the route declaration. > *With this modification* it works, so you can add my: > Tested-by: Nicolas Ferre <nicolas.ferre@atmel.com> Great, thanks. ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 2/5] ASoC: atmel-ssc: add phybase in device structure 2011-06-29 18:00 use dmaengine for atmel ssc/pcm dai drivers Nicolas Ferre 2011-06-29 18:00 ` [PATCH 1/5] ASoC: wm8731: rework power management Nicolas Ferre @ 2011-06-29 18:00 ` Nicolas Ferre 2011-06-29 17:48 ` Mark Brown 2011-06-29 18:00 ` [PATCH 3/5] ASoC: atmel-ssc: dmaengine usage switch depending on cpu Nicolas Ferre ` (2 subsequent siblings) 4 siblings, 1 reply; 23+ messages in thread From: Nicolas Ferre @ 2011-06-29 18:00 UTC (permalink / raw) To: linux-arm-kernel Useful for future dmaengine use. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> --- drivers/misc/atmel-ssc.c | 1 + include/linux/atmel-ssc.h | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index 4afffe6..27c9ffa 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c @@ -101,6 +101,7 @@ static int __init ssc_probe(struct platform_device *pdev) retval = -EINVAL; goto out_clk; } + ssc->phybase = regs->start; /* disable all interrupts */ clk_enable(ssc->clk); diff --git a/include/linux/atmel-ssc.h b/include/linux/atmel-ssc.h index 0602339..2bab4b4 100644 --- a/include/linux/atmel-ssc.h +++ b/include/linux/atmel-ssc.h @@ -6,6 +6,7 @@ struct ssc_device { struct list_head list; + resource_size_t phybase; void __iomem *regs; struct platform_device *pdev; struct clk *clk; -- 1.7.3 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 2/5] ASoC: atmel-ssc: add phybase in device structure 2011-06-29 18:00 ` [PATCH 2/5] ASoC: atmel-ssc: add phybase in device structure Nicolas Ferre @ 2011-06-29 17:48 ` Mark Brown 2011-07-01 14:46 ` [PATCH V2 " Nicolas Ferre 0 siblings, 1 reply; 23+ messages in thread From: Mark Brown @ 2011-06-29 17:48 UTC (permalink / raw) To: linux-arm-kernel On Wed, Jun 29, 2011 at 08:00:16PM +0200, Nicolas Ferre wrote: > struct ssc_device { > struct list_head list; > + resource_size_t phybase; The type here looks rather wrong? ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH V2 2/5] ASoC: atmel-ssc: add phybase in device structure 2011-06-29 17:48 ` Mark Brown @ 2011-07-01 14:46 ` Nicolas Ferre 0 siblings, 0 replies; 23+ messages in thread From: Nicolas Ferre @ 2011-07-01 14:46 UTC (permalink / raw) To: linux-arm-kernel Useful for future dmaengine use. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> --- V2: change type to phys_addr_t. drivers/misc/atmel-ssc.c | 1 + include/linux/atmel-ssc.h | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index 4afffe6..27c9ffa 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c @@ -101,6 +101,7 @@ static int __init ssc_probe(struct platform_device *pdev) retval = -EINVAL; goto out_clk; } + ssc->phybase = regs->start; /* disable all interrupts */ clk_enable(ssc->clk); diff --git a/include/linux/atmel-ssc.h b/include/linux/atmel-ssc.h index 0602339..6ff634e 100644 --- a/include/linux/atmel-ssc.h +++ b/include/linux/atmel-ssc.h @@ -6,6 +6,7 @@ struct ssc_device { struct list_head list; + phys_addr_t phybase; void __iomem *regs; struct platform_device *pdev; struct clk *clk; -- 1.7.3 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 3/5] ASoC: atmel-ssc: dmaengine usage switch depending on cpu 2011-06-29 18:00 use dmaengine for atmel ssc/pcm dai drivers Nicolas Ferre 2011-06-29 18:00 ` [PATCH 1/5] ASoC: wm8731: rework power management Nicolas Ferre 2011-06-29 18:00 ` [PATCH 2/5] ASoC: atmel-ssc: add phybase in device structure Nicolas Ferre @ 2011-06-29 18:00 ` Nicolas Ferre 2011-06-29 18:00 ` [PATCH 4/5] ASoC: atmel_ssc_dai/atmel-pcm: adapt to dmaengine usage Nicolas Ferre 2011-06-29 18:00 ` [PATCH 5/5] ASoC: atmel_ssc_dai: PM: actually stopping clock on suspend/resume Nicolas Ferre 4 siblings, 0 replies; 23+ messages in thread From: Nicolas Ferre @ 2011-06-29 18:00 UTC (permalink / raw) To: linux-arm-kernel Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> --- include/linux/atmel-ssc.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/include/linux/atmel-ssc.h b/include/linux/atmel-ssc.h index 2bab4b4..52b4c20 100644 --- a/include/linux/atmel-ssc.h +++ b/include/linux/atmel-ssc.h @@ -3,6 +3,7 @@ #include <linux/platform_device.h> #include <linux/list.h> +#include <mach/cpu.h> struct ssc_device { struct list_head list; @@ -310,4 +311,6 @@ void ssc_free(struct ssc_device *ssc); #define ssc_readl(base, reg) __raw_readl(base + SSC_##reg) #define ssc_writel(base, reg, value) __raw_writel((value), base + SSC_##reg) +#define ssc_use_dmaengine() cpu_is_at91sam9x5() + #endif /* __INCLUDE_ATMEL_SSC_H */ -- 1.7.3 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 4/5] ASoC: atmel_ssc_dai/atmel-pcm: adapt to dmaengine usage 2011-06-29 18:00 use dmaengine for atmel ssc/pcm dai drivers Nicolas Ferre ` (2 preceding siblings ...) 2011-06-29 18:00 ` [PATCH 3/5] ASoC: atmel-ssc: dmaengine usage switch depending on cpu Nicolas Ferre @ 2011-06-29 18:00 ` Nicolas Ferre 2011-06-29 17:59 ` Mark Brown 2011-06-30 0:54 ` Koul, Vinod 2011-06-29 18:00 ` [PATCH 5/5] ASoC: atmel_ssc_dai: PM: actually stopping clock on suspend/resume Nicolas Ferre 4 siblings, 2 replies; 23+ messages in thread From: Nicolas Ferre @ 2011-06-29 18:00 UTC (permalink / raw) To: linux-arm-kernel Change xfer_size name to apply to PDC and DMA aswell. Specify overrun bit in interrupt mask. Add dmaengine specific routines and replace PDC ones in pcm_ops if appropriate. Uses cyclic DMA API for queuing samples. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> --- sound/soc/atmel/atmel-pcm.c | 382 +++++++++++++++++++++++++++++++++++--- sound/soc/atmel/atmel-pcm.h | 4 +- sound/soc/atmel/atmel_ssc_dai.c | 33 ++-- 3 files changed, 373 insertions(+), 46 deletions(-) diff --git a/sound/soc/atmel/atmel-pcm.c b/sound/soc/atmel/atmel-pcm.c index 51dde4e..fee6696 100644 --- a/sound/soc/atmel/atmel-pcm.c +++ b/sound/soc/atmel/atmel-pcm.c @@ -37,6 +37,7 @@ #include <linux/slab.h> #include <linux/dma-mapping.h> #include <linux/atmel_pdc.h> +#include <linux/dmaengine.h> #include <linux/atmel-ssc.h> #include <sound/core.h> @@ -44,6 +45,8 @@ #include <sound/pcm_params.h> #include <sound/soc.h> +#include <mach/at_hdmac.h> + #include "atmel-pcm.h" @@ -53,7 +56,7 @@ /* TODO: These values were taken from the AT91 platform driver, check * them against real values for AT32 */ -static const struct snd_pcm_hardware atmel_pcm_hardware = { +static const struct snd_pcm_hardware atmel_pcm_pdc_hardware = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -66,6 +69,22 @@ static const struct snd_pcm_hardware atmel_pcm_hardware = { .buffer_bytes_max = 32 * 1024, }; +static const struct snd_pcm_hardware atmel_pcm_dma_hardware = { + .info = SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_RESUME | + SNDRV_PCM_INFO_PAUSE, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .period_bytes_min = 256, /* not too low to absorb DMA programming overhead */ + .period_bytes_max = 2 * 0xffff, /* if 2 bytes format */ + .periods_min = 8, + .periods_max = 1024, /* no limit */ + .buffer_bytes_max = 64 * 1024, /* 64KiB */ +}; + +static const struct snd_pcm_hardware *atmel_pcm_hardware; + /*--------------------------------------------------------------------------*\ * Data types @@ -77,12 +96,19 @@ struct atmel_runtime_data { size_t period_size; dma_addr_t period_ptr; /* physical address of next period */ + int periods; /* period index of period_ptr */ /* PDC register save */ u32 pdc_xpr_save; u32 pdc_xcr_save; u32 pdc_xnpr_save; u32 pdc_xncr_save; + + /* dmaengine data */ + struct at_dma_slave atslave; + struct dma_async_tx_descriptor *desc; + dma_cookie_t cookie; + struct dma_chan *dma_chan; }; @@ -94,7 +120,7 @@ static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, { struct snd_pcm_substream *substream = pcm->streams[stream].substream; struct snd_dma_buffer *buf = &substream->dma_buffer; - size_t size = atmel_pcm_hardware.buffer_bytes_max; + size_t size = atmel_pcm_hardware->buffer_bytes_max; buf->dev.type = SNDRV_DMA_TYPE_DEV; buf->dev.dev = pcm->card->dev; @@ -116,7 +142,7 @@ static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, /*--------------------------------------------------------------------------*\ * ISR \*--------------------------------------------------------------------------*/ -static void atmel_pcm_dma_irq(u32 ssc_sr, +static void atmel_pcm_pdc_irq(u32 ssc_sr, struct snd_pcm_substream *substream) { struct atmel_runtime_data *prtd = substream->runtime->private_data; @@ -142,7 +168,7 @@ static void atmel_pcm_dma_irq(u32 ssc_sr, ssc_writex(params->ssc->regs, params->pdc->xpr, prtd->period_ptr); ssc_writex(params->ssc->regs, params->pdc->xcr, - prtd->period_size / params->pdc_xfer_size); + prtd->period_size / params->data_xfer_size); ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR, params->mask->pdc_enable); } @@ -156,12 +182,163 @@ static void atmel_pcm_dma_irq(u32 ssc_sr, ssc_writex(params->ssc->regs, params->pdc->xnpr, prtd->period_ptr); ssc_writex(params->ssc->regs, params->pdc->xncr, - prtd->period_size / params->pdc_xfer_size); + prtd->period_size / params->data_xfer_size); } snd_pcm_period_elapsed(substream); } +/** + * atmel_pcm_dma_irq: SSC interrupt handler for DMAENGINE enabled SSC + * + * We use DMAENGINE to send/receive data to/from SSC so this ISR is only to + * check if any overrun occured. + */ +static void atmel_pcm_dma_irq(u32 ssc_sr, + struct snd_pcm_substream *substream) +{ + struct atmel_runtime_data *prtd = substream->runtime->private_data; + struct atmel_pcm_dma_params *params = prtd->params; + + if (ssc_sr & params->mask->ssc_error) { + if (snd_pcm_running(substream)) + pr_warning("atmel-pcm: buffer %s on %s" + " (SSC_SR=%#x)\n", + substream->stream == SNDRV_PCM_STREAM_PLAYBACK + ? "underrun" : "overrun", + params->name, ssc_sr); + + /* stop RX and capture stream: will be enabled again at restart */ + ssc_writex(params->ssc->regs, SSC_CR, params->mask->ssc_disable); + snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); + + /* now drain RHR and read status to remove xrun condition */ + ssc_readx(params->ssc->regs, SSC_RHR); + ssc_readx(params->ssc->regs, SSC_SR); + } +} + +/*--------------------------------------------------------------------------*\ + * DMAENGINE operations +\*--------------------------------------------------------------------------*/ +static bool filter(struct dma_chan *chan, void *slave) +{ + struct at_dma_slave *sl = slave; + + if (sl->dma_dev == chan->device->dev) { + chan->private = sl; + return true; + } else { + return false; + } +} + +static int atmel_pcm_dma_alloc(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct atmel_runtime_data *prtd = runtime->private_data; + struct ssc_device *ssc = prtd->params->ssc; + struct at_dma_slave *sdata = NULL; + + if (ssc->pdev) + sdata = ssc->pdev->dev.platform_data; + + if (sdata && sdata->dma_dev) { + dma_cap_mask_t mask; + + /* setup DMA addresses */ + sdata->rx_reg = (dma_addr_t)ssc->phybase + SSC_RHR; + sdata->tx_reg = (dma_addr_t)ssc->phybase + SSC_THR; + + /* Try to grab a DMA channel */ + dma_cap_zero(mask); + dma_cap_set(DMA_CYCLIC, mask); + prtd->dma_chan = dma_request_channel(mask, filter, sdata); + } + if (!prtd->dma_chan) { + pr_err("atmel-pcm: " + "DMA channel not available, unable to use SSC-audio\n"); + return -EBUSY; + } + + return 0; +} + +static void audio_dma_irq(void *data) +{ + struct snd_pcm_substream *substream = (struct snd_pcm_substream *)data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct atmel_runtime_data *prtd = runtime->private_data; + + prtd->period_ptr += prtd->period_size; + if (prtd->period_ptr >= prtd->dma_buffer_end) + prtd->period_ptr = prtd->dma_buffer; + + snd_pcm_period_elapsed(substream); +} + +static void atmel_pcm_dma_slave_config(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct atmel_runtime_data *prtd = runtime->private_data; + struct dma_chan *chan = prtd->dma_chan; + struct dma_slave_config slave_config; + enum dma_slave_buswidth buswidth; + + switch (prtd->params->data_xfer_size) { + case 1: + buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; + break; + case 2: + buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; + break; + case 4: + buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; + break; + default: + return; + } + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + slave_config.direction = DMA_TO_DEVICE; + slave_config.dst_addr_width = buswidth; + } else { + slave_config.direction = DMA_FROM_DEVICE; + slave_config.src_addr_width = buswidth; + } + + dmaengine_slave_config(chan, &slave_config); +} + +static int atmel_pcm_dma_prep(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct atmel_runtime_data *prtd = runtime->private_data; + struct dma_chan *chan = prtd->dma_chan; + + if (prtd->desc) + /* already been there: redo the prep job */ + dmaengine_terminate_all(chan); + + /* setup dma configuration */ + atmel_pcm_dma_slave_config(substream); + + prtd->desc = chan->device->device_prep_dma_cyclic(chan, prtd->dma_buffer, + prtd->period_size * prtd->periods, + prtd->period_size, + substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? + DMA_TO_DEVICE : DMA_FROM_DEVICE); + if (!prtd->desc) { + dev_err(&chan->dev->device, "cannot prepare slave dma\n"); + return -EINVAL; + } + + prtd->desc->callback = audio_dma_irq; + prtd->desc->callback_param = substream; + + return 0; +} /*--------------------------------------------------------------------------*\ * PCM operations @@ -172,6 +349,7 @@ static int atmel_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; struct atmel_runtime_data *prtd = runtime->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data; + int ret; /* this may get called several times by oss emulation * with different params */ @@ -180,15 +358,35 @@ static int atmel_pcm_hw_params(struct snd_pcm_substream *substream, runtime->dma_bytes = params_buffer_bytes(params); prtd->params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - prtd->params->dma_intr_handler = atmel_pcm_dma_irq; prtd->dma_buffer = runtime->dma_addr; prtd->dma_buffer_end = runtime->dma_addr + runtime->dma_bytes; prtd->period_size = params_period_bytes(params); + prtd->periods = params_periods(params); + + if (ssc_use_dmaengine()) { + if (prtd->dma_chan == NULL) { + ret = atmel_pcm_dma_alloc(substream, params); + if (ret) + return ret; + } + ret = atmel_pcm_dma_prep(substream); + if (ret) { + dma_release_channel(prtd->dma_chan); + prtd->dma_chan = NULL; + return ret; + } + + prtd->params->dma_intr_handler = atmel_pcm_dma_irq; + } else { + prtd->params->dma_intr_handler = atmel_pcm_pdc_irq; + } pr_debug("atmel-pcm: " - "hw_params: DMA for %s initialized " + "hw_params: %s%s for %s initialized " "(dma_bytes=%u, period_size=%u)\n", + prtd->dma_chan ? "DMA " : "PDC", + prtd->dma_chan ? dma_chan_name(prtd->dma_chan): "", prtd->params->name, runtime->dma_bytes, prtd->period_size); @@ -201,15 +399,30 @@ static int atmel_pcm_hw_free(struct snd_pcm_substream *substream) struct atmel_pcm_dma_params *params = prtd->params; if (params != NULL) { - ssc_writex(params->ssc->regs, SSC_PDC_PTCR, - params->mask->pdc_disable); + if (ssc_use_dmaengine()) { + struct dma_chan *chan = prtd->dma_chan; + + if (chan) { + dmaengine_terminate_all(chan); + prtd->cookie = 0; + prtd->desc = NULL; + dma_release_channel(chan); + prtd->dma_chan = NULL; + } + } else { + ssc_writex(params->ssc->regs, SSC_PDC_PTCR, + params->mask->pdc_disable); + } prtd->params->dma_intr_handler = NULL; } return 0; } -static int atmel_pcm_prepare(struct snd_pcm_substream *substream) +/*--------------------------------------------------------------------------*\ + * PCM callbacks using PDC +\*--------------------------------------------------------------------------*/ +static int atmel_pcm_pdc_prepare(struct snd_pcm_substream *substream) { struct atmel_runtime_data *prtd = substream->runtime->private_data; struct atmel_pcm_dma_params *params = prtd->params; @@ -221,7 +434,7 @@ static int atmel_pcm_prepare(struct snd_pcm_substream *substream) return 0; } -static int atmel_pcm_trigger(struct snd_pcm_substream *substream, +static int atmel_pcm_pdc_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_pcm_runtime *rtd = substream->runtime; @@ -240,13 +453,13 @@ static int atmel_pcm_trigger(struct snd_pcm_substream *substream, ssc_writex(params->ssc->regs, params->pdc->xpr, prtd->period_ptr); ssc_writex(params->ssc->regs, params->pdc->xcr, - prtd->period_size / params->pdc_xfer_size); + prtd->period_size / params->data_xfer_size); prtd->period_ptr += prtd->period_size; ssc_writex(params->ssc->regs, params->pdc->xnpr, prtd->period_ptr); ssc_writex(params->ssc->regs, params->pdc->xncr, - prtd->period_size / params->pdc_xfer_size); + prtd->period_size / params->data_xfer_size); pr_debug("atmel-pcm: trigger: " "period_ptr=%lx, xpr=%u, " @@ -264,7 +477,7 @@ static int atmel_pcm_trigger(struct snd_pcm_substream *substream, pr_debug("sr=%u imr=%u\n", ssc_readx(params->ssc->regs, SSC_SR), - ssc_readx(params->ssc->regs, SSC_IER)); + ssc_readx(params->ssc->regs, SSC_IMR)); break; /* SNDRV_PCM_TRIGGER_START */ case SNDRV_PCM_TRIGGER_STOP: @@ -287,7 +500,7 @@ static int atmel_pcm_trigger(struct snd_pcm_substream *substream, return ret; } -static snd_pcm_uframes_t atmel_pcm_pointer( +static snd_pcm_uframes_t atmel_pcm_pdc_pointer( struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -305,13 +518,107 @@ static snd_pcm_uframes_t atmel_pcm_pointer( return x; } +/*--------------------------------------------------------------------------*\ + * PCM callbacks using DMAENGINE +\*--------------------------------------------------------------------------*/ +static int atmel_pcm_dma_prepare(struct snd_pcm_substream *substream) +{ + struct atmel_runtime_data *prtd = substream->runtime->private_data; + struct atmel_pcm_dma_params *params = prtd->params; + + ssc_writex(params->ssc->regs, SSC_IDR, params->mask->ssc_error); + return 0; +} + +static int atmel_pcm_dma_trigger(struct snd_pcm_substream *substream, + int cmd) +{ + struct snd_pcm_runtime *rtd = substream->runtime; + struct atmel_runtime_data *prtd = rtd->private_data; + struct atmel_pcm_dma_params *params = prtd->params; + dma_cookie_t cookie; + int ret = 0; + + pr_debug("atmel-pcm: trigger %d: buffer_size = %ld," + " dma_area = %p, dma_bytes = %u\n", + cmd, rtd->buffer_size, rtd->dma_area, rtd->dma_bytes); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + + if (prtd->cookie < DMA_MIN_COOKIE) { + cookie = dmaengine_submit(prtd->desc); + if (dma_submit_error(cookie)) { + ret = -EINVAL; + break; + } + prtd->cookie = cookie; + prtd->period_ptr = prtd->dma_buffer; + } + + + pr_debug("atmel-pcm: trigger: start sr=0x%08x imr=0x%08u\n", + ssc_readx(params->ssc->regs, SSC_SR), + ssc_readx(params->ssc->regs, SSC_IMR)); + + /* fallback */ + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_RESUME: + dmaengine_resume(prtd->dma_chan); + + /* It not already done or comming from xrun state */ + ssc_readx(params->ssc->regs, SSC_SR); + ssc_writex(params->ssc->regs, SSC_IER, params->mask->ssc_error); + ssc_writex(params->ssc->regs, SSC_CR, params->mask->ssc_enable); + + break; + case SNDRV_PCM_TRIGGER_STOP: + pr_debug("atmel-pcm: trigger: stop cmd = %d\n", cmd); + + ssc_writex(params->ssc->regs, SSC_IDR, params->mask->ssc_error); + + /* fallback */ + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_SUSPEND: + dmaengine_pause(prtd->dma_chan); + break; + default: + ret = -EINVAL; + } + + return ret; +} + +static snd_pcm_uframes_t atmel_pcm_dma_pointer( + struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct atmel_runtime_data *prtd = runtime->private_data; + snd_pcm_uframes_t x; + + dev_vdbg(substream->pcm->card->dev, "%s: 0x%08x %ld\n", + __func__, prtd->period_ptr, + bytes_to_frames(runtime, prtd->period_ptr - prtd->dma_buffer)); + + x = bytes_to_frames(runtime, prtd->period_ptr - prtd->dma_buffer); + + if (x >= runtime->buffer_size) + x = 0; + + return x; +} + + +/*--------------------------------------------------------------------------*\ + * PCM open/close/mmap +\*--------------------------------------------------------------------------*/ static int atmel_pcm_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct atmel_runtime_data *prtd; int ret = 0; - snd_soc_set_runtime_hwparams(substream, &atmel_pcm_hardware); + snd_soc_set_runtime_hwparams(substream, atmel_pcm_hardware); /* ensure that buffer size is a multiple of period size */ ret = snd_pcm_hw_constraint_integer(runtime, @@ -352,9 +659,9 @@ static struct snd_pcm_ops atmel_pcm_ops = { .ioctl = snd_pcm_lib_ioctl, .hw_params = atmel_pcm_hw_params, .hw_free = atmel_pcm_hw_free, - .prepare = atmel_pcm_prepare, - .trigger = atmel_pcm_trigger, - .pointer = atmel_pcm_pointer, + .prepare = atmel_pcm_pdc_prepare, + .trigger = atmel_pcm_pdc_trigger, + .pointer = atmel_pcm_pdc_pointer, .mmap = atmel_pcm_mmap, }; @@ -426,14 +733,16 @@ static int atmel_pcm_suspend(struct snd_soc_dai *dai) prtd = runtime->private_data; params = prtd->params; - /* disable the PDC and save the PDC registers */ + if (!ssc_use_dmaengine()) { + /* disable the PDC and save the PDC registers */ - ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_disable); + ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_disable); - prtd->pdc_xpr_save = ssc_readx(params->ssc->regs, params->pdc->xpr); - prtd->pdc_xcr_save = ssc_readx(params->ssc->regs, params->pdc->xcr); - prtd->pdc_xnpr_save = ssc_readx(params->ssc->regs, params->pdc->xnpr); - prtd->pdc_xncr_save = ssc_readx(params->ssc->regs, params->pdc->xncr); + prtd->pdc_xpr_save = ssc_readx(params->ssc->regs, params->pdc->xpr); + prtd->pdc_xcr_save = ssc_readx(params->ssc->regs, params->pdc->xcr); + prtd->pdc_xnpr_save = ssc_readx(params->ssc->regs, params->pdc->xnpr); + prtd->pdc_xncr_save = ssc_readx(params->ssc->regs, params->pdc->xncr); + } return 0; } @@ -450,13 +759,15 @@ static int atmel_pcm_resume(struct snd_soc_dai *dai) prtd = runtime->private_data; params = prtd->params; - /* restore the PDC registers and enable the PDC */ - ssc_writex(params->ssc->regs, params->pdc->xpr, prtd->pdc_xpr_save); - ssc_writex(params->ssc->regs, params->pdc->xcr, prtd->pdc_xcr_save); - ssc_writex(params->ssc->regs, params->pdc->xnpr, prtd->pdc_xnpr_save); - ssc_writex(params->ssc->regs, params->pdc->xncr, prtd->pdc_xncr_save); + if (!ssc_use_dmaengine()) { + /* restore the PDC registers and enable the PDC */ + ssc_writex(params->ssc->regs, params->pdc->xpr, prtd->pdc_xpr_save); + ssc_writex(params->ssc->regs, params->pdc->xcr, prtd->pdc_xcr_save); + ssc_writex(params->ssc->regs, params->pdc->xnpr, prtd->pdc_xnpr_save); + ssc_writex(params->ssc->regs, params->pdc->xncr, prtd->pdc_xncr_save); - ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_enable); + ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_enable); + } return 0; } #else @@ -495,6 +806,15 @@ static struct platform_driver atmel_pcm_driver = { static int __init snd_atmel_pcm_init(void) { + if (ssc_use_dmaengine()) { + atmel_pcm_ops.prepare = atmel_pcm_dma_prepare; + atmel_pcm_ops.trigger = atmel_pcm_dma_trigger; + atmel_pcm_ops.pointer = atmel_pcm_dma_pointer; + + atmel_pcm_hardware = &atmel_pcm_dma_hardware; + } else { + atmel_pcm_hardware = &atmel_pcm_pdc_hardware; + } return platform_driver_register(&atmel_pcm_driver); } module_init(snd_atmel_pcm_init); diff --git a/sound/soc/atmel/atmel-pcm.h b/sound/soc/atmel/atmel-pcm.h index 5e0a95e..b007376 100644 --- a/sound/soc/atmel/atmel-pcm.h +++ b/sound/soc/atmel/atmel-pcm.h @@ -50,6 +50,7 @@ struct atmel_pdc_regs { struct atmel_ssc_mask { u32 ssc_enable; /* SSC recv/trans enable */ u32 ssc_disable; /* SSC recv/trans disable */ + u32 ssc_error; /* SSC error conditions */ u32 ssc_endx; /* SSC ENDTX or ENDRX */ u32 ssc_endbuf; /* SSC TXBUFE or RXBUFF */ u32 pdc_enable; /* PDC recv/trans enable */ @@ -66,7 +67,8 @@ struct atmel_ssc_mask { */ struct atmel_pcm_dma_params { char *name; /* stream identifier */ - int pdc_xfer_size; /* PDC counter increment in bytes */ + int data_xfer_size; /* PDC counter increment in bytes, + DMA data transfer size in bytes */ struct ssc_device *ssc; /* SSC device for stream */ struct atmel_pdc_regs *pdc; /* PDC receive or transmit registers */ struct atmel_ssc_mask *mask; /* SSC & PDC status bits */ diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index a7a7bbc..9412fc3 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -48,7 +48,8 @@ #include "atmel_ssc_dai.h" -#if defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9G20) +#if defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9G20) \ + || defined(CONFIG_ARCH_AT91SAM9X5) #define NUM_SSC_DEVICES 1 #else #define NUM_SSC_DEVICES 3 @@ -86,6 +87,7 @@ static struct atmel_ssc_mask ssc_tx_mask = { static struct atmel_ssc_mask ssc_rx_mask = { .ssc_enable = SSC_BIT(CR_RXEN), .ssc_disable = SSC_BIT(CR_RXDIS), + .ssc_error = SSC_BIT(SR_OVRUN), .ssc_endx = SSC_BIT(SR_ENDRX), .ssc_endbuf = SSC_BIT(SR_RXBUFF), .pdc_enable = ATMEL_PDC_RXTEN, @@ -183,7 +185,8 @@ static irqreturn_t atmel_ssc_interrupt(int irq, void *dev_id) if ((dma_params != NULL) && (dma_params->dma_intr_handler != NULL)) { ssc_substream_mask = (dma_params->mask->ssc_endx | - dma_params->mask->ssc_endbuf); + dma_params->mask->ssc_endbuf | + dma_params->mask->ssc_error); if (ssc_sr & ssc_substream_mask) { dma_params->dma_intr_handler(ssc_sr, dma_params-> @@ -376,19 +379,19 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, switch (params_format(params)) { case SNDRV_PCM_FORMAT_S8: bits = 8; - dma_params->pdc_xfer_size = 1; + dma_params->data_xfer_size = 1; break; case SNDRV_PCM_FORMAT_S16_LE: bits = 16; - dma_params->pdc_xfer_size = 2; + dma_params->data_xfer_size = 2; break; case SNDRV_PCM_FORMAT_S24_LE: bits = 24; - dma_params->pdc_xfer_size = 4; + dma_params->data_xfer_size = 4; break; case SNDRV_PCM_FORMAT_S32_LE: bits = 32; - dma_params->pdc_xfer_size = 4; + dma_params->data_xfer_size = 4; break; default: printk(KERN_WARNING "atmel_ssc_dai: unsupported PCM format"); @@ -561,15 +564,17 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, /* Reset the SSC and its PDC registers */ ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); - ssc_writel(ssc_p->ssc->regs, PDC_RPR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_RCR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_RNPR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_RNCR, 0); + if (!ssc_use_dmaengine()) { + ssc_writel(ssc_p->ssc->regs, PDC_RPR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_RCR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_RNPR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_RNCR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_TPR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_TCR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_TNPR, 0); - ssc_writel(ssc_p->ssc->regs, PDC_TNCR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_TPR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_TCR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_TNPR, 0); + ssc_writel(ssc_p->ssc->regs, PDC_TNCR, 0); + } ret = request_irq(ssc_p->ssc->irq, atmel_ssc_interrupt, 0, ssc_p->name, ssc_p); -- 1.7.3 ^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 4/5] ASoC: atmel_ssc_dai/atmel-pcm: adapt to dmaengine usage 2011-06-29 18:00 ` [PATCH 4/5] ASoC: atmel_ssc_dai/atmel-pcm: adapt to dmaengine usage Nicolas Ferre @ 2011-06-29 17:59 ` Mark Brown 2011-06-30 0:54 ` Koul, Vinod 1 sibling, 0 replies; 23+ messages in thread From: Mark Brown @ 2011-06-29 17:59 UTC (permalink / raw) To: linux-arm-kernel On Wed, Jun 29, 2011 at 08:00:18PM +0200, Nicolas Ferre wrote: > +static const struct snd_pcm_hardware atmel_pcm_dma_hardware = { > + .info = SNDRV_PCM_INFO_MMAP | > + SNDRV_PCM_INFO_MMAP_VALID | The naming here looks a bit undescriptive but I'm not sure what a better name would be - obviously both DMA controllers are DMA controllers. It feels like it would be more sensible to just write a separate DMA driver as I'm not sure how much code actually ends up being shared here but it looks pretty small from the diff... > +static bool filter(struct dma_chan *chan, void *slave) > +{ > + struct at_dma_slave *sl = slave; > + Odd whitespace here. > +static int atmel_pcm_dma_alloc(struct snd_pcm_substream *substream, > + struct snd_pcm_hw_params *params) > +{ > + struct snd_pcm_runtime *runtime = substream->runtime; > + struct atmel_runtime_data *prtd = runtime->private_data; > + struct ssc_device *ssc = prtd->params->ssc; > + struct at_dma_slave *sdata = NULL; > + > + if (ssc->pdev) > + sdata = ssc->pdev->dev.platform_data; Why wouldn't we have a device, and why is there a separate copy of the device? > + if (!prtd->dma_chan) { > + pr_err("atmel-pcm: " > + "DMA channel not available, unable to use SSC-audio\n"); > + return -EBUSY; dev_err() and don't split strings over lines. > + switch (prtd->params->data_xfer_size) { > + case 1: > + buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; > + break; > + case 2: > + buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; > + break; > + case 4: > + buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; > + break; > + default: > + return; > + } It strikes me that this mapping of bytes to DMA_SLAVE_ is likely to be quite common and might be nice as a helper in dmaengine. I'd also expect to see something complain (even if just with BUG()) if we hit the default case. ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 4/5] ASoC: atmel_ssc_dai/atmel-pcm: adapt to dmaengine usage 2011-06-29 18:00 ` [PATCH 4/5] ASoC: atmel_ssc_dai/atmel-pcm: adapt to dmaengine usage Nicolas Ferre 2011-06-29 17:59 ` Mark Brown @ 2011-06-30 0:54 ` Koul, Vinod 1 sibling, 0 replies; 23+ messages in thread From: Koul, Vinod @ 2011-06-30 0:54 UTC (permalink / raw) To: linux-arm-kernel On Wed, 2011-06-29 at 20:00 +0200, Nicolas Ferre wrote: > Change xfer_size name to apply to PDC and DMA aswell. > Specify overrun bit in interrupt mask. > Add dmaengine specific routines and replace PDC ones in > pcm_ops if appropriate. > Uses cyclic DMA API for queuing samples. > > Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> > Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> > --- > sound/soc/atmel/atmel-pcm.c | 382 +++++++++++++++++++++++++++++++++++--- > sound/soc/atmel/atmel-pcm.h | 4 +- > sound/soc/atmel/atmel_ssc_dai.c | 33 ++-- > 3 files changed, 373 insertions(+), 46 deletions(-) > > diff --git a/sound/soc/atmel/atmel-pcm.c b/sound/soc/atmel/atmel-pcm.c > index 51dde4e..fee6696 100644 > --- a/sound/soc/atmel/atmel-pcm.c > +++ b/sound/soc/atmel/atmel-pcm.c > @@ -37,6 +37,7 @@ > #include <linux/slab.h> > #include <linux/dma-mapping.h> > #include <linux/atmel_pdc.h> > +#include <linux/dmaengine.h> > #include <linux/atmel-ssc.h> > > #include <sound/core.h> > @@ -44,6 +45,8 @@ > #include <sound/pcm_params.h> > #include <sound/soc.h> > > +#include <mach/at_hdmac.h> > + > #include "atmel-pcm.h" > > > @@ -53,7 +56,7 @@ > /* TODO: These values were taken from the AT91 platform driver, check > * them against real values for AT32 > */ > -static const struct snd_pcm_hardware atmel_pcm_hardware = { > +static const struct snd_pcm_hardware atmel_pcm_pdc_hardware = { > .info = SNDRV_PCM_INFO_MMAP | > SNDRV_PCM_INFO_MMAP_VALID | > SNDRV_PCM_INFO_INTERLEAVED | > @@ -66,6 +69,22 @@ static const struct snd_pcm_hardware atmel_pcm_hardware = { > .buffer_bytes_max = 32 * 1024, > }; > > +static const struct snd_pcm_hardware atmel_pcm_dma_hardware = { > + .info = SNDRV_PCM_INFO_MMAP | > + SNDRV_PCM_INFO_MMAP_VALID | > + SNDRV_PCM_INFO_INTERLEAVED | > + SNDRV_PCM_INFO_RESUME | > + SNDRV_PCM_INFO_PAUSE, > + .formats = SNDRV_PCM_FMTBIT_S16_LE, > + .period_bytes_min = 256, /* not too low to absorb DMA programming overhead */ > + .period_bytes_max = 2 * 0xffff, /* if 2 bytes format */ > + .periods_min = 8, > + .periods_max = 1024, /* no limit */ > + .buffer_bytes_max = 64 * 1024, /* 64KiB */ > +}; > + > +static const struct snd_pcm_hardware *atmel_pcm_hardware; > + > > /*--------------------------------------------------------------------------*\ > * Data types > @@ -77,12 +96,19 @@ struct atmel_runtime_data { > size_t period_size; > > dma_addr_t period_ptr; /* physical address of next period */ > + int periods; /* period index of period_ptr */ > > /* PDC register save */ > u32 pdc_xpr_save; > u32 pdc_xcr_save; > u32 pdc_xnpr_save; > u32 pdc_xncr_save; > + > + /* dmaengine data */ > + struct at_dma_slave atslave; > + struct dma_async_tx_descriptor *desc; > + dma_cookie_t cookie; > + struct dma_chan *dma_chan; > }; > > > @@ -94,7 +120,7 @@ static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, > { > struct snd_pcm_substream *substream = pcm->streams[stream].substream; > struct snd_dma_buffer *buf = &substream->dma_buffer; > - size_t size = atmel_pcm_hardware.buffer_bytes_max; > + size_t size = atmel_pcm_hardware->buffer_bytes_max; > > buf->dev.type = SNDRV_DMA_TYPE_DEV; > buf->dev.dev = pcm->card->dev; > @@ -116,7 +142,7 @@ static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, > /*--------------------------------------------------------------------------*\ > * ISR > \*--------------------------------------------------------------------------*/ > -static void atmel_pcm_dma_irq(u32 ssc_sr, > +static void atmel_pcm_pdc_irq(u32 ssc_sr, > struct snd_pcm_substream *substream) > { > struct atmel_runtime_data *prtd = substream->runtime->private_data; > @@ -142,7 +168,7 @@ static void atmel_pcm_dma_irq(u32 ssc_sr, > ssc_writex(params->ssc->regs, params->pdc->xpr, > prtd->period_ptr); > ssc_writex(params->ssc->regs, params->pdc->xcr, > - prtd->period_size / params->pdc_xfer_size); > + prtd->period_size / params->data_xfer_size); > ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR, > params->mask->pdc_enable); > } > @@ -156,12 +182,163 @@ static void atmel_pcm_dma_irq(u32 ssc_sr, > ssc_writex(params->ssc->regs, params->pdc->xnpr, > prtd->period_ptr); > ssc_writex(params->ssc->regs, params->pdc->xncr, > - prtd->period_size / params->pdc_xfer_size); > + prtd->period_size / params->data_xfer_size); > } > > snd_pcm_period_elapsed(substream); > } > > +/** > + * atmel_pcm_dma_irq: SSC interrupt handler for DMAENGINE enabled SSC > + * > + * We use DMAENGINE to send/receive data to/from SSC so this ISR is only to > + * check if any overrun occured. > + */ > +static void atmel_pcm_dma_irq(u32 ssc_sr, > + struct snd_pcm_substream *substream) > +{ > + struct atmel_runtime_data *prtd = substream->runtime->private_data; > + struct atmel_pcm_dma_params *params = prtd->params; > + > + if (ssc_sr & params->mask->ssc_error) { > + if (snd_pcm_running(substream)) > + pr_warning("atmel-pcm: buffer %s on %s" > + " (SSC_SR=%#x)\n", > + substream->stream == SNDRV_PCM_STREAM_PLAYBACK > + ? "underrun" : "overrun", > + params->name, ssc_sr); > + > + /* stop RX and capture stream: will be enabled again at restart */ > + ssc_writex(params->ssc->regs, SSC_CR, params->mask->ssc_disable); > + snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); > + > + /* now drain RHR and read status to remove xrun condition */ > + ssc_readx(params->ssc->regs, SSC_RHR); > + ssc_readx(params->ssc->regs, SSC_SR); > + } > +} > + > +/*--------------------------------------------------------------------------*\ > + * DMAENGINE operations > +\*--------------------------------------------------------------------------*/ > +static bool filter(struct dma_chan *chan, void *slave) > +{ > + struct at_dma_slave *sl = slave; > + > + if (sl->dma_dev == chan->device->dev) { > + chan->private = sl; Nope you dont want to do that, pls use dmaengine_slave_config() API for setting this > + return true; > + } else { > + return false; > + } > +} > + > +static int atmel_pcm_dma_alloc(struct snd_pcm_substream *substream, > + struct snd_pcm_hw_params *params) > +{ > + struct snd_pcm_runtime *runtime = substream->runtime; > + struct atmel_runtime_data *prtd = runtime->private_data; > + struct ssc_device *ssc = prtd->params->ssc; > + struct at_dma_slave *sdata = NULL; > + > + if (ssc->pdev) > + sdata = ssc->pdev->dev.platform_data; > + > + if (sdata && sdata->dma_dev) { > + dma_cap_mask_t mask; > + > + /* setup DMA addresses */ > + sdata->rx_reg = (dma_addr_t)ssc->phybase + SSC_RHR; > + sdata->tx_reg = (dma_addr_t)ssc->phybase + SSC_THR; > + > + /* Try to grab a DMA channel */ > + dma_cap_zero(mask); > + dma_cap_set(DMA_CYCLIC, mask); > + prtd->dma_chan = dma_request_channel(mask, filter, sdata); > + } > + if (!prtd->dma_chan) { > + pr_err("atmel-pcm: " > + "DMA channel not available, unable to use SSC-audio\n"); > + return -EBUSY; > + } > + > + return 0; > +} > + > +static void audio_dma_irq(void *data) > +{ > + struct snd_pcm_substream *substream = (struct snd_pcm_substream *)data; > + struct snd_pcm_runtime *runtime = substream->runtime; > + struct atmel_runtime_data *prtd = runtime->private_data; > + > + prtd->period_ptr += prtd->period_size; > + if (prtd->period_ptr >= prtd->dma_buffer_end) > + prtd->period_ptr = prtd->dma_buffer; > + > + snd_pcm_period_elapsed(substream); > +} > + > +static void atmel_pcm_dma_slave_config(struct snd_pcm_substream *substream) > +{ > + struct snd_pcm_runtime *runtime = substream->runtime; > + struct atmel_runtime_data *prtd = runtime->private_data; > + struct dma_chan *chan = prtd->dma_chan; > + struct dma_slave_config slave_config; > + enum dma_slave_buswidth buswidth; > + > + switch (prtd->params->data_xfer_size) { > + case 1: > + buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; > + break; > + case 2: > + buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; > + break; > + case 4: > + buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; > + break; > + default: > + return; > + } > + > + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { > + slave_config.direction = DMA_TO_DEVICE; > + slave_config.dst_addr_width = buswidth; > + } else { > + slave_config.direction = DMA_FROM_DEVICE; > + slave_config.src_addr_width = buswidth; > + } > + > + dmaengine_slave_config(chan, &slave_config); okay, you seem to be doing right thing, then why are you setting the chan->slave pointer?? > +} > + > +static int atmel_pcm_dma_prep(struct snd_pcm_substream *substream) > +{ > + struct snd_pcm_runtime *runtime = substream->runtime; > + struct atmel_runtime_data *prtd = runtime->private_data; > + struct dma_chan *chan = prtd->dma_chan; > + > + if (prtd->desc) > + /* already been there: redo the prep job */ > + dmaengine_terminate_all(chan); > + > + /* setup dma configuration */ > + atmel_pcm_dma_slave_config(substream); Nope, this is channel config. As long as you retain the channel you shouldn't be required to set this again. > + > + prtd->desc = chan->device->device_prep_dma_cyclic(chan, prtd->dma_buffer, > + prtd->period_size * prtd->periods, > + prtd->period_size, > + substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? > + DMA_TO_DEVICE : DMA_FROM_DEVICE); > + if (!prtd->desc) { > + dev_err(&chan->dev->device, "cannot prepare slave dma\n"); > + return -EINVAL; > + } > + > + prtd->desc->callback = audio_dma_irq; > + prtd->desc->callback_param = substream; > + > + return 0; > +} > > /*--------------------------------------------------------------------------*\ > * PCM operations > @@ -172,6 +349,7 @@ static int atmel_pcm_hw_params(struct snd_pcm_substream *substream, > struct snd_pcm_runtime *runtime = substream->runtime; > struct atmel_runtime_data *prtd = runtime->private_data; > struct snd_soc_pcm_runtime *rtd = substream->private_data; > + int ret; > > /* this may get called several times by oss emulation > * with different params */ > @@ -180,15 +358,35 @@ static int atmel_pcm_hw_params(struct snd_pcm_substream *substream, > runtime->dma_bytes = params_buffer_bytes(params); > > prtd->params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); > - prtd->params->dma_intr_handler = atmel_pcm_dma_irq; > > prtd->dma_buffer = runtime->dma_addr; > prtd->dma_buffer_end = runtime->dma_addr + runtime->dma_bytes; > prtd->period_size = params_period_bytes(params); > + prtd->periods = params_periods(params); > + > + if (ssc_use_dmaengine()) { > + if (prtd->dma_chan == NULL) { > + ret = atmel_pcm_dma_alloc(substream, params); > + if (ret) > + return ret; > + } > + ret = atmel_pcm_dma_prep(substream); > + if (ret) { > + dma_release_channel(prtd->dma_chan); > + prtd->dma_chan = NULL; > + return ret; > + } > + > + prtd->params->dma_intr_handler = atmel_pcm_dma_irq; > + } else { > + prtd->params->dma_intr_handler = atmel_pcm_pdc_irq; > + } > > pr_debug("atmel-pcm: " > - "hw_params: DMA for %s initialized " > + "hw_params: %s%s for %s initialized " > "(dma_bytes=%u, period_size=%u)\n", > + prtd->dma_chan ? "DMA " : "PDC", > + prtd->dma_chan ? dma_chan_name(prtd->dma_chan): "", > prtd->params->name, > runtime->dma_bytes, > prtd->period_size); > @@ -201,15 +399,30 @@ static int atmel_pcm_hw_free(struct snd_pcm_substream *substream) > struct atmel_pcm_dma_params *params = prtd->params; > > if (params != NULL) { > - ssc_writex(params->ssc->regs, SSC_PDC_PTCR, > - params->mask->pdc_disable); > + if (ssc_use_dmaengine()) { > + struct dma_chan *chan = prtd->dma_chan; > + > + if (chan) { > + dmaengine_terminate_all(chan); > + prtd->cookie = 0; > + prtd->desc = NULL; > + dma_release_channel(chan); > + prtd->dma_chan = NULL; > + } > + } else { > + ssc_writex(params->ssc->regs, SSC_PDC_PTCR, > + params->mask->pdc_disable); > + } > prtd->params->dma_intr_handler = NULL; > } > > return 0; > } > > -static int atmel_pcm_prepare(struct snd_pcm_substream *substream) > +/*--------------------------------------------------------------------------*\ > + * PCM callbacks using PDC > +\*--------------------------------------------------------------------------*/ > +static int atmel_pcm_pdc_prepare(struct snd_pcm_substream *substream) > { > struct atmel_runtime_data *prtd = substream->runtime->private_data; > struct atmel_pcm_dma_params *params = prtd->params; > @@ -221,7 +434,7 @@ static int atmel_pcm_prepare(struct snd_pcm_substream *substream) > return 0; > } > > -static int atmel_pcm_trigger(struct snd_pcm_substream *substream, > +static int atmel_pcm_pdc_trigger(struct snd_pcm_substream *substream, > int cmd) > { > struct snd_pcm_runtime *rtd = substream->runtime; > @@ -240,13 +453,13 @@ static int atmel_pcm_trigger(struct snd_pcm_substream *substream, > ssc_writex(params->ssc->regs, params->pdc->xpr, > prtd->period_ptr); > ssc_writex(params->ssc->regs, params->pdc->xcr, > - prtd->period_size / params->pdc_xfer_size); > + prtd->period_size / params->data_xfer_size); > > prtd->period_ptr += prtd->period_size; > ssc_writex(params->ssc->regs, params->pdc->xnpr, > prtd->period_ptr); > ssc_writex(params->ssc->regs, params->pdc->xncr, > - prtd->period_size / params->pdc_xfer_size); > + prtd->period_size / params->data_xfer_size); > > pr_debug("atmel-pcm: trigger: " > "period_ptr=%lx, xpr=%u, " > @@ -264,7 +477,7 @@ static int atmel_pcm_trigger(struct snd_pcm_substream *substream, > > pr_debug("sr=%u imr=%u\n", > ssc_readx(params->ssc->regs, SSC_SR), > - ssc_readx(params->ssc->regs, SSC_IER)); > + ssc_readx(params->ssc->regs, SSC_IMR)); > break; /* SNDRV_PCM_TRIGGER_START */ > > case SNDRV_PCM_TRIGGER_STOP: > @@ -287,7 +500,7 @@ static int atmel_pcm_trigger(struct snd_pcm_substream *substream, > return ret; > } > > -static snd_pcm_uframes_t atmel_pcm_pointer( > +static snd_pcm_uframes_t atmel_pcm_pdc_pointer( > struct snd_pcm_substream *substream) > { > struct snd_pcm_runtime *runtime = substream->runtime; > @@ -305,13 +518,107 @@ static snd_pcm_uframes_t atmel_pcm_pointer( > return x; > } > > +/*--------------------------------------------------------------------------*\ > + * PCM callbacks using DMAENGINE > +\*--------------------------------------------------------------------------*/ > +static int atmel_pcm_dma_prepare(struct snd_pcm_substream *substream) > +{ > + struct atmel_runtime_data *prtd = substream->runtime->private_data; > + struct atmel_pcm_dma_params *params = prtd->params; > + > + ssc_writex(params->ssc->regs, SSC_IDR, params->mask->ssc_error); > + return 0; > +} > + > +static int atmel_pcm_dma_trigger(struct snd_pcm_substream *substream, > + int cmd) > +{ > + struct snd_pcm_runtime *rtd = substream->runtime; > + struct atmel_runtime_data *prtd = rtd->private_data; > + struct atmel_pcm_dma_params *params = prtd->params; > + dma_cookie_t cookie; > + int ret = 0; > + > + pr_debug("atmel-pcm: trigger %d: buffer_size = %ld," > + " dma_area = %p, dma_bytes = %u\n", > + cmd, rtd->buffer_size, rtd->dma_area, rtd->dma_bytes); > + > + switch (cmd) { > + case SNDRV_PCM_TRIGGER_START: > + > + if (prtd->cookie < DMA_MIN_COOKIE) { > + cookie = dmaengine_submit(prtd->desc); submit and issue_pending as well... > + if (dma_submit_error(cookie)) { > + ret = -EINVAL; > + break; > + } > + prtd->cookie = cookie; > + prtd->period_ptr = prtd->dma_buffer; > + } > + > + > + pr_debug("atmel-pcm: trigger: start sr=0x%08x imr=0x%08u\n", > + ssc_readx(params->ssc->regs, SSC_SR), > + ssc_readx(params->ssc->regs, SSC_IMR)); > + > + /* fallback */ > + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: > + case SNDRV_PCM_TRIGGER_RESUME: > + dmaengine_resume(prtd->dma_chan); > + > + /* It not already done or comming from xrun state */ > + ssc_readx(params->ssc->regs, SSC_SR); > + ssc_writex(params->ssc->regs, SSC_IER, params->mask->ssc_error); > + ssc_writex(params->ssc->regs, SSC_CR, params->mask->ssc_enable); > + > + break; > + case SNDRV_PCM_TRIGGER_STOP: > + pr_debug("atmel-pcm: trigger: stop cmd = %d\n", cmd); > + > + ssc_writex(params->ssc->regs, SSC_IDR, params->mask->ssc_error); > + > + /* fallback */ > + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: > + case SNDRV_PCM_TRIGGER_SUSPEND: > + dmaengine_pause(prtd->dma_chan); > + break; > + default: > + ret = -EINVAL; > + } > + > + return ret; > +} > + > +static snd_pcm_uframes_t atmel_pcm_dma_pointer( > + struct snd_pcm_substream *substream) > +{ > + struct snd_pcm_runtime *runtime = substream->runtime; > + struct atmel_runtime_data *prtd = runtime->private_data; > + snd_pcm_uframes_t x; > + > + dev_vdbg(substream->pcm->card->dev, "%s: 0x%08x %ld\n", > + __func__, prtd->period_ptr, > + bytes_to_frames(runtime, prtd->period_ptr - prtd->dma_buffer)); > + > + x = bytes_to_frames(runtime, prtd->period_ptr - prtd->dma_buffer); > + > + if (x >= runtime->buffer_size) > + x = 0; > + > + return x; > +} > + > + > +/*--------------------------------------------------------------------------*\ > + * PCM open/close/mmap > +\*--------------------------------------------------------------------------*/ > static int atmel_pcm_open(struct snd_pcm_substream *substream) > { > struct snd_pcm_runtime *runtime = substream->runtime; > struct atmel_runtime_data *prtd; > int ret = 0; > > - snd_soc_set_runtime_hwparams(substream, &atmel_pcm_hardware); > + snd_soc_set_runtime_hwparams(substream, atmel_pcm_hardware); > > /* ensure that buffer size is a multiple of period size */ > ret = snd_pcm_hw_constraint_integer(runtime, > @@ -352,9 +659,9 @@ static struct snd_pcm_ops atmel_pcm_ops = { > .ioctl = snd_pcm_lib_ioctl, > .hw_params = atmel_pcm_hw_params, > .hw_free = atmel_pcm_hw_free, > - .prepare = atmel_pcm_prepare, > - .trigger = atmel_pcm_trigger, > - .pointer = atmel_pcm_pointer, > + .prepare = atmel_pcm_pdc_prepare, > + .trigger = atmel_pcm_pdc_trigger, > + .pointer = atmel_pcm_pdc_pointer, > .mmap = atmel_pcm_mmap, > }; > > @@ -426,14 +733,16 @@ static int atmel_pcm_suspend(struct snd_soc_dai *dai) > prtd = runtime->private_data; > params = prtd->params; > > - /* disable the PDC and save the PDC registers */ > + if (!ssc_use_dmaengine()) { > + /* disable the PDC and save the PDC registers */ > > - ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_disable); > + ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_disable); > > - prtd->pdc_xpr_save = ssc_readx(params->ssc->regs, params->pdc->xpr); > - prtd->pdc_xcr_save = ssc_readx(params->ssc->regs, params->pdc->xcr); > - prtd->pdc_xnpr_save = ssc_readx(params->ssc->regs, params->pdc->xnpr); > - prtd->pdc_xncr_save = ssc_readx(params->ssc->regs, params->pdc->xncr); > + prtd->pdc_xpr_save = ssc_readx(params->ssc->regs, params->pdc->xpr); > + prtd->pdc_xcr_save = ssc_readx(params->ssc->regs, params->pdc->xcr); > + prtd->pdc_xnpr_save = ssc_readx(params->ssc->regs, params->pdc->xnpr); > + prtd->pdc_xncr_save = ssc_readx(params->ssc->regs, params->pdc->xncr); > + } > > return 0; > } > @@ -450,13 +759,15 @@ static int atmel_pcm_resume(struct snd_soc_dai *dai) > prtd = runtime->private_data; > params = prtd->params; > > - /* restore the PDC registers and enable the PDC */ > - ssc_writex(params->ssc->regs, params->pdc->xpr, prtd->pdc_xpr_save); > - ssc_writex(params->ssc->regs, params->pdc->xcr, prtd->pdc_xcr_save); > - ssc_writex(params->ssc->regs, params->pdc->xnpr, prtd->pdc_xnpr_save); > - ssc_writex(params->ssc->regs, params->pdc->xncr, prtd->pdc_xncr_save); > + if (!ssc_use_dmaengine()) { > + /* restore the PDC registers and enable the PDC */ > + ssc_writex(params->ssc->regs, params->pdc->xpr, prtd->pdc_xpr_save); > + ssc_writex(params->ssc->regs, params->pdc->xcr, prtd->pdc_xcr_save); > + ssc_writex(params->ssc->regs, params->pdc->xnpr, prtd->pdc_xnpr_save); > + ssc_writex(params->ssc->regs, params->pdc->xncr, prtd->pdc_xncr_save); > > - ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_enable); > + ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_enable); > + } > return 0; > } > #else > @@ -495,6 +806,15 @@ static struct platform_driver atmel_pcm_driver = { > > static int __init snd_atmel_pcm_init(void) > { > + if (ssc_use_dmaengine()) { > + atmel_pcm_ops.prepare = atmel_pcm_dma_prepare; > + atmel_pcm_ops.trigger = atmel_pcm_dma_trigger; > + atmel_pcm_ops.pointer = atmel_pcm_dma_pointer; > + > + atmel_pcm_hardware = &atmel_pcm_dma_hardware; > + } else { > + atmel_pcm_hardware = &atmel_pcm_pdc_hardware; > + } > return platform_driver_register(&atmel_pcm_driver); > } > module_init(snd_atmel_pcm_init); > diff --git a/sound/soc/atmel/atmel-pcm.h b/sound/soc/atmel/atmel-pcm.h > index 5e0a95e..b007376 100644 > --- a/sound/soc/atmel/atmel-pcm.h > +++ b/sound/soc/atmel/atmel-pcm.h > @@ -50,6 +50,7 @@ struct atmel_pdc_regs { > struct atmel_ssc_mask { > u32 ssc_enable; /* SSC recv/trans enable */ > u32 ssc_disable; /* SSC recv/trans disable */ > + u32 ssc_error; /* SSC error conditions */ > u32 ssc_endx; /* SSC ENDTX or ENDRX */ > u32 ssc_endbuf; /* SSC TXBUFE or RXBUFF */ > u32 pdc_enable; /* PDC recv/trans enable */ > @@ -66,7 +67,8 @@ struct atmel_ssc_mask { > */ > struct atmel_pcm_dma_params { > char *name; /* stream identifier */ > - int pdc_xfer_size; /* PDC counter increment in bytes */ > + int data_xfer_size; /* PDC counter increment in bytes, > + DMA data transfer size in bytes */ > struct ssc_device *ssc; /* SSC device for stream */ > struct atmel_pdc_regs *pdc; /* PDC receive or transmit registers */ > struct atmel_ssc_mask *mask; /* SSC & PDC status bits */ > diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c > index a7a7bbc..9412fc3 100644 > --- a/sound/soc/atmel/atmel_ssc_dai.c > +++ b/sound/soc/atmel/atmel_ssc_dai.c > @@ -48,7 +48,8 @@ > #include "atmel_ssc_dai.h" > > > -#if defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9G20) > +#if defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9G20) \ > + || defined(CONFIG_ARCH_AT91SAM9X5) > #define NUM_SSC_DEVICES 1 > #else > #define NUM_SSC_DEVICES 3 > @@ -86,6 +87,7 @@ static struct atmel_ssc_mask ssc_tx_mask = { > static struct atmel_ssc_mask ssc_rx_mask = { > .ssc_enable = SSC_BIT(CR_RXEN), > .ssc_disable = SSC_BIT(CR_RXDIS), > + .ssc_error = SSC_BIT(SR_OVRUN), > .ssc_endx = SSC_BIT(SR_ENDRX), > .ssc_endbuf = SSC_BIT(SR_RXBUFF), > .pdc_enable = ATMEL_PDC_RXTEN, > @@ -183,7 +185,8 @@ static irqreturn_t atmel_ssc_interrupt(int irq, void *dev_id) > if ((dma_params != NULL) && > (dma_params->dma_intr_handler != NULL)) { > ssc_substream_mask = (dma_params->mask->ssc_endx | > - dma_params->mask->ssc_endbuf); > + dma_params->mask->ssc_endbuf | > + dma_params->mask->ssc_error); > if (ssc_sr & ssc_substream_mask) { > dma_params->dma_intr_handler(ssc_sr, > dma_params-> > @@ -376,19 +379,19 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, > switch (params_format(params)) { > case SNDRV_PCM_FORMAT_S8: > bits = 8; > - dma_params->pdc_xfer_size = 1; > + dma_params->data_xfer_size = 1; > break; > case SNDRV_PCM_FORMAT_S16_LE: > bits = 16; > - dma_params->pdc_xfer_size = 2; > + dma_params->data_xfer_size = 2; > break; > case SNDRV_PCM_FORMAT_S24_LE: > bits = 24; > - dma_params->pdc_xfer_size = 4; > + dma_params->data_xfer_size = 4; > break; > case SNDRV_PCM_FORMAT_S32_LE: > bits = 32; > - dma_params->pdc_xfer_size = 4; > + dma_params->data_xfer_size = 4; > break; > default: > printk(KERN_WARNING "atmel_ssc_dai: unsupported PCM format"); > @@ -561,15 +564,17 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, > /* Reset the SSC and its PDC registers */ > ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); > > - ssc_writel(ssc_p->ssc->regs, PDC_RPR, 0); > - ssc_writel(ssc_p->ssc->regs, PDC_RCR, 0); > - ssc_writel(ssc_p->ssc->regs, PDC_RNPR, 0); > - ssc_writel(ssc_p->ssc->regs, PDC_RNCR, 0); > + if (!ssc_use_dmaengine()) { > + ssc_writel(ssc_p->ssc->regs, PDC_RPR, 0); > + ssc_writel(ssc_p->ssc->regs, PDC_RCR, 0); > + ssc_writel(ssc_p->ssc->regs, PDC_RNPR, 0); > + ssc_writel(ssc_p->ssc->regs, PDC_RNCR, 0); > > - ssc_writel(ssc_p->ssc->regs, PDC_TPR, 0); > - ssc_writel(ssc_p->ssc->regs, PDC_TCR, 0); > - ssc_writel(ssc_p->ssc->regs, PDC_TNPR, 0); > - ssc_writel(ssc_p->ssc->regs, PDC_TNCR, 0); > + ssc_writel(ssc_p->ssc->regs, PDC_TPR, 0); > + ssc_writel(ssc_p->ssc->regs, PDC_TCR, 0); > + ssc_writel(ssc_p->ssc->regs, PDC_TNPR, 0); > + ssc_writel(ssc_p->ssc->regs, PDC_TNCR, 0); > + } > > ret = request_irq(ssc_p->ssc->irq, atmel_ssc_interrupt, 0, > ssc_p->name, ssc_p); -- ~Vinod ^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 5/5] ASoC: atmel_ssc_dai: PM: actually stopping clock on suspend/resume 2011-06-29 18:00 use dmaengine for atmel ssc/pcm dai drivers Nicolas Ferre ` (3 preceding siblings ...) 2011-06-29 18:00 ` [PATCH 4/5] ASoC: atmel_ssc_dai/atmel-pcm: adapt to dmaengine usage Nicolas Ferre @ 2011-06-29 18:00 ` Nicolas Ferre 4 siblings, 0 replies; 23+ messages in thread From: Nicolas Ferre @ 2011-06-29 18:00 UTC (permalink / raw) To: linux-arm-kernel Stop SSC clock on suspend/resume cycle checking if the controller is actually initialized. This will save power while sleeping. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> --- sound/soc/atmel/atmel_ssc_dai.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 9412fc3..43cce80 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -631,12 +631,10 @@ static int atmel_ssc_prepare(struct snd_pcm_substream *substream, #ifdef CONFIG_PM static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai) { - struct atmel_ssc_info *ssc_p; + struct atmel_ssc_info *ssc_p = &ssc_info[cpu_dai->id]; if (!cpu_dai->active) - return 0; - - ssc_p = &ssc_info[cpu_dai->id]; + goto out; /* Save the status register before disabling transmit and receive */ ssc_p->ssc_state.ssc_sr = ssc_readl(ssc_p->ssc->regs, SR); @@ -652,6 +650,11 @@ static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai) ssc_p->ssc_state.ssc_tcmr = ssc_readl(ssc_p->ssc->regs, TCMR); ssc_p->ssc_state.ssc_tfmr = ssc_readl(ssc_p->ssc->regs, TFMR); +out: + if (ssc_p->initialized) { + pr_debug("atmel_ssc_dai: suspend - stop clock\n"); + clk_disable(ssc_p->ssc->clk); + } return 0; } @@ -659,14 +662,17 @@ static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai) static int atmel_ssc_resume(struct snd_soc_dai *cpu_dai) { - struct atmel_ssc_info *ssc_p; + struct atmel_ssc_info *ssc_p = &ssc_info[cpu_dai->id]; u32 cr; + if (ssc_p->initialized) { + pr_debug("atmel_ssc_dai: resume - restart clock\n"); + clk_enable(ssc_p->ssc->clk); + } + if (!cpu_dai->active) return 0; - ssc_p = &ssc_info[cpu_dai->id]; - /* restore SSC register settings */ ssc_writel(ssc_p->ssc->regs, TFMR, ssc_p->ssc_state.ssc_tfmr); ssc_writel(ssc_p->ssc->regs, TCMR, ssc_p->ssc_state.ssc_tcmr); -- 1.7.3 ^ permalink raw reply related [flat|nested] 23+ messages in thread
end of thread, other threads:[~2011-07-05 20:27 UTC | newest] Thread overview: 23+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-06-29 18:00 use dmaengine for atmel ssc/pcm dai drivers Nicolas Ferre 2011-06-29 18:00 ` [PATCH 1/5] ASoC: wm8731: rework power management Nicolas Ferre 2011-06-29 17:11 ` Mark Brown 2011-06-30 13:57 ` Nicolas Ferre 2011-06-30 15:04 ` [alsa-devel] " Nicolas Ferre 2011-06-30 15:22 ` Mark Brown 2011-07-01 9:31 ` Nicolas Ferre 2011-07-01 10:43 ` [PATCH] ASoC: wm8731: set the ACTIVE bit if bias ON entered Nicolas Ferre 2011-07-01 14:18 ` Liam Girdwood 2011-07-01 16:15 ` Mark Brown 2011-07-04 9:46 ` Nicolas Ferre 2011-07-04 17:29 ` Mark Brown 2011-07-04 17:34 ` Liam Girdwood 2011-07-05 7:58 ` Nicolas Ferre 2011-07-05 20:27 ` [alsa-devel] " Mark Brown 2011-06-29 18:00 ` [PATCH 2/5] ASoC: atmel-ssc: add phybase in device structure Nicolas Ferre 2011-06-29 17:48 ` Mark Brown 2011-07-01 14:46 ` [PATCH V2 " Nicolas Ferre 2011-06-29 18:00 ` [PATCH 3/5] ASoC: atmel-ssc: dmaengine usage switch depending on cpu Nicolas Ferre 2011-06-29 18:00 ` [PATCH 4/5] ASoC: atmel_ssc_dai/atmel-pcm: adapt to dmaengine usage Nicolas Ferre 2011-06-29 17:59 ` Mark Brown 2011-06-30 0:54 ` Koul, Vinod 2011-06-29 18:00 ` [PATCH 5/5] ASoC: atmel_ssc_dai: PM: actually stopping clock on suspend/resume Nicolas Ferre
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).