Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1456447 > unrolled thread

[PATCH 0/4] ASoC: da7213: Device clocking updates and fixes

Started byAdam Thomson <Adam.Thomson.Opensource@diasemi.com>
First post2016-08-04 16:50 +0200
Last post2016-08-05 12:40 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/4] ASoC: da7213: Device clocking updates and fixes Adam Thomson <Adam.Thomson.Opensource@diasemi.com> - 2016-08-04 16:50 +0200
    [PATCH 2/4] ASoC: da7213: Improve driver efficiency with regards to  MCLK usage Adam Thomson <Adam.Thomson.Opensource@diasemi.com> - 2016-08-04 16:50 +0200
      Re: [alsa-devel] [PATCH 2/4] ASoC: da7213: Improve driver efficiency  with regards to MCLK usage Peter Meerwald-Stadler <pmeerw@pmeerw.net> - 2016-08-08 09:50 +0200
    [PATCH 4/4] ASoC: da7213: Improve 32KHz mode PLL locking Adam Thomson <Adam.Thomson.Opensource@diasemi.com> - 2016-08-04 16:50 +0200
      Re: [alsa-devel] [PATCH 4/4] ASoC: da7213: Improve 32KHz mode PLL  locking Peter Meerwald-Stadler <pmeerw@pmeerw.net> - 2016-08-05 11:10 +0200
        Re: [alsa-devel] [PATCH 4/4] ASoC: da7213: Improve 32KHz mode PLL  locking Mark Brown <broonie@kernel.org> - 2016-08-05 12:40 +0200

#1456447 — [PATCH 0/4] ASoC: da7213: Device clocking updates and fixes

FromAdam Thomson <Adam.Thomson.Opensource@diasemi.com>
Date2016-08-04 16:50 +0200
Subject[PATCH 0/4] ASoC: da7213: Device clocking updates and fixes
Message-ID<s2rYt-20R-3@gated-at.bofh.it>
This patch set contains a series of patches relating to device clocking. The
changes are as follows:

 1) Set correct default BCLKs per WCLK to achieve all DAI formats. Currently
    only 16-bit formats would operate correctly.
 2) Only use MCLK as required, when an audio stream is active. Can be disabled
    all other times.
 3) Refactoring of sysclk() and pll() functions to make them cleaner, removing
    need for unnecessary private flags, and resolve incorrect 32Khz mode
    configuration.
 4) Improve 32KHz PLL locking with some small register updates when configuring
    PLL and when DAI is enabled.

Patches are based on v4.7 Linux kernel

Adam Thomson (4):
  ASoC: da7213: Default to 64 BCLKs per WCLK to support all formats
  ASoC: da7213: Improve driver efficiency with regards to MCLK usage
  ASoC: da7213: Refactor sysclk(), pll() functions to improve handling
  ASoC: da7213: Improve 32KHz mode PLL locking

 sound/soc/codecs/da7213.c | 134 +++++++++++++++++++++++++++++-----------------
 sound/soc/codecs/da7213.h |  12 +++--
 2 files changed, 94 insertions(+), 52 deletions(-)

--
1.9.3

[toc] | [next] | [standalone]


#1456448 — [PATCH 2/4] ASoC: da7213: Improve driver efficiency with regards to MCLK usage

FromAdam Thomson <Adam.Thomson.Opensource@diasemi.com>
Date2016-08-04 16:50 +0200
Subject[PATCH 2/4] ASoC: da7213: Improve driver efficiency with regards to MCLK usage
Message-ID<s2s89-24U-13@gated-at.bofh.it>
In reply to#1456447
Currently MCLK remains enabled during bias STANDBY state, and this
is not necessary. This patch updates the code to handle enabling
and disabling of MCLK, if provided, when moving between STANDBY
and PREPARE states, therefore saving power when no active streams
present.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
---
 sound/soc/codecs/da7213.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c
index bcf1834..7701f4e 100644
--- a/sound/soc/codecs/da7213.c
+++ b/sound/soc/codecs/da7213.c
@@ -1454,11 +1454,10 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec,
 
 	switch (level) {
 	case SND_SOC_BIAS_ON:
-	case SND_SOC_BIAS_PREPARE:
 		break;
-	case SND_SOC_BIAS_STANDBY:
-		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
-			/* MCLK */
+	case SND_SOC_BIAS_PREPARE:
+		/* Enable MCLK for transition to ON state */
+		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) {
 			if (da7213->mclk) {
 				ret = clk_prepare_enable(da7213->mclk);
 				if (ret) {
@@ -1467,21 +1466,24 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec,
 					return ret;
 				}
 			}
-
+		}
+		break;
+	case SND_SOC_BIAS_STANDBY:
+		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
 			/* Enable VMID reference & master bias */
 			snd_soc_update_bits(codec, DA7213_REFERENCES,
 					    DA7213_VMID_EN | DA7213_BIAS_EN,
 					    DA7213_VMID_EN | DA7213_BIAS_EN);
+		} else {
+			/* Remove MCLK */
+			if (da7213->mclk)
+				clk_disable_unprepare(da7213->mclk);
 		}
 		break;
 	case SND_SOC_BIAS_OFF:
 		/* Disable VMID reference & master bias */
 		snd_soc_update_bits(codec, DA7213_REFERENCES,
 				    DA7213_VMID_EN | DA7213_BIAS_EN, 0);
-
-		/* MCLK */
-		if (da7213->mclk)
-			clk_disable_unprepare(da7213->mclk);
 		break;
 	}
 	return 0;
-- 
1.9.3

[toc] | [prev] | [next] | [standalone]


#1457594 — Re: [alsa-devel] [PATCH 2/4] ASoC: da7213: Improve driver efficiency with regards to MCLK usage

FromPeter Meerwald-Stadler <pmeerw@pmeerw.net>
Date2016-08-08 09:50 +0200
SubjectRe: [alsa-devel] [PATCH 2/4] ASoC: da7213: Improve driver efficiency with regards to MCLK usage
Message-ID<s3NtU-6TB-17@gated-at.bofh.it>
In reply to#1456448
> Currently MCLK remains enabled during bias STANDBY state, and this
> is not necessary. This patch updates the code to handle enabling
> and disabling of MCLK, if provided, when moving between STANDBY
> and PREPARE states, therefore saving power when no active streams
> present.
> 
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>

Tested-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>

> ---
>  sound/soc/codecs/da7213.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c
> index bcf1834..7701f4e 100644
> --- a/sound/soc/codecs/da7213.c
> +++ b/sound/soc/codecs/da7213.c
> @@ -1454,11 +1454,10 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec,
>  
>  	switch (level) {
>  	case SND_SOC_BIAS_ON:
> -	case SND_SOC_BIAS_PREPARE:
>  		break;
> -	case SND_SOC_BIAS_STANDBY:
> -		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
> -			/* MCLK */
> +	case SND_SOC_BIAS_PREPARE:
> +		/* Enable MCLK for transition to ON state */
> +		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) {
>  			if (da7213->mclk) {
>  				ret = clk_prepare_enable(da7213->mclk);
>  				if (ret) {
> @@ -1467,21 +1466,24 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec,
>  					return ret;
>  				}
>  			}
> -
> +		}
> +		break;
> +	case SND_SOC_BIAS_STANDBY:
> +		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
>  			/* Enable VMID reference & master bias */
>  			snd_soc_update_bits(codec, DA7213_REFERENCES,
>  					    DA7213_VMID_EN | DA7213_BIAS_EN,
>  					    DA7213_VMID_EN | DA7213_BIAS_EN);
> +		} else {
> +			/* Remove MCLK */
> +			if (da7213->mclk)
> +				clk_disable_unprepare(da7213->mclk);
>  		}
>  		break;
>  	case SND_SOC_BIAS_OFF:
>  		/* Disable VMID reference & master bias */
>  		snd_soc_update_bits(codec, DA7213_REFERENCES,
>  				    DA7213_VMID_EN | DA7213_BIAS_EN, 0);
> -
> -		/* MCLK */
> -		if (da7213->mclk)
> -			clk_disable_unprepare(da7213->mclk);
>  		break;
>  	}
>  	return 0;
> 

-- 

Peter Meerwald-Stadler
+43-664-2444418 (mobile)

[toc] | [prev] | [next] | [standalone]


#1456450 — [PATCH 4/4] ASoC: da7213: Improve 32KHz mode PLL locking

FromAdam Thomson <Adam.Thomson.Opensource@diasemi.com>
Date2016-08-04 16:50 +0200
Subject[PATCH 4/4] ASoC: da7213: Improve 32KHz mode PLL locking
Message-ID<s2s8a-24U-17@gated-at.bofh.it>
In reply to#1456447
To aid PLL in locking on to a 32KHz MCLK, some register mods
are made during PLL configuration, and when enabling the DAI,
to achieve the full range of sample rates.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
---
 sound/soc/codecs/da7213.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c
index 79b8324..095fe40 100644
--- a/sound/soc/codecs/da7213.c
+++ b/sound/soc/codecs/da7213.c
@@ -750,11 +750,18 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w,
 		snd_soc_update_bits(codec, DA7213_PC_COUNT,
 				    DA7213_PC_FREERUN_MASK, 0);

-		/* Slave mode, if SRM not enabled no need for status checks */
+		/* If SRM not enabled then nothing more to do */
 		pll_ctrl = snd_soc_read(codec, DA7213_PLL_CTRL);
 		if (!(pll_ctrl & DA7213_PLL_SRM_EN))
 			return 0;

+		/* Assist 32KHz mode PLL lock */
+		if (pll_ctrl & DA7213_PLL_32K_MODE) {
+			snd_soc_write(codec, 0xF0, 0x8B);
+			snd_soc_write(codec, 0xF2, 0x03);
+			snd_soc_write(codec, 0xF0, 0x00);
+		}
+
 		/* Check SRM has locked */
 		do {
 			pll_status = snd_soc_read(codec, DA7213_PLL_STATUS);
@@ -771,6 +778,14 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w,

 		return 0;
 	case SND_SOC_DAPM_POST_PMD:
+		/* Revert 32KHz PLL lock udpates if applied previously */
+		pll_ctrl = snd_soc_read(codec, DA7213_PLL_CTRL);
+		if (pll_ctrl & DA7213_PLL_32K_MODE) {
+			snd_soc_write(codec, 0xF0, 0x8B);
+			snd_soc_write(codec, 0xF2, 0x01);
+			snd_soc_write(codec, 0xF0, 0x00);
+		}
+
 		/* PC free-running */
 		snd_soc_update_bits(codec, DA7213_PC_COUNT,
 				    DA7213_PC_FREERUN_MASK,
@@ -1428,6 +1443,14 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
 			    DA7213_PLL_INDIV_MASK | DA7213_PLL_MODE_MASK,
 			    pll_ctrl);

+	/* Assist 32KHz mode PLL lock */
+	if (source == DA7213_SYSCLK_PLL_32KHZ) {
+		snd_soc_write(codec, 0xF0, 0x8B);
+		snd_soc_write(codec, 0xF1, 0x03);
+		snd_soc_write(codec, 0xF1, 0x01);
+		snd_soc_write(codec, 0xF0, 0x00);
+	}
+
 	return 0;
 }

--
1.9.3

[toc] | [prev] | [next] | [standalone]


#1456960 — Re: [alsa-devel] [PATCH 4/4] ASoC: da7213: Improve 32KHz mode PLL locking

FromPeter Meerwald-Stadler <pmeerw@pmeerw.net>
Date2016-08-05 11:10 +0200
SubjectRe: [alsa-devel] [PATCH 4/4] ASoC: da7213: Improve 32KHz mode PLL locking
Message-ID<s2JiF-5uW-19@gated-at.bofh.it>
In reply to#1456450
> To aid PLL in locking on to a 32KHz MCLK, some register mods
> are made during PLL configuration, and when enabling the DAI,
> to achieve the full range of sample rates.

thanks for the patch series; we are about to test...

some comments below
 
> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
> ---
>  sound/soc/codecs/da7213.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c
> index 79b8324..095fe40 100644
> --- a/sound/soc/codecs/da7213.c
> +++ b/sound/soc/codecs/da7213.c
> @@ -750,11 +750,18 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w,
>  		snd_soc_update_bits(codec, DA7213_PC_COUNT,
>  				    DA7213_PC_FREERUN_MASK, 0);
> 
> -		/* Slave mode, if SRM not enabled no need for status checks */
> +		/* If SRM not enabled then nothing more to do */
>  		pll_ctrl = snd_soc_read(codec, DA7213_PLL_CTRL);
>  		if (!(pll_ctrl & DA7213_PLL_SRM_EN))
>  			return 0;
> 
> +		/* Assist 32KHz mode PLL lock */
> +		if (pll_ctrl & DA7213_PLL_32K_MODE) {

these registers cannot not found in the datasheet;
maybe add descriptive #defines in da7213.h

> +			snd_soc_write(codec, 0xF0, 0x8B);
> +			snd_soc_write(codec, 0xF2, 0x03);
> +			snd_soc_write(codec, 0xF0, 0x00);
> +		}
> +
>  		/* Check SRM has locked */
>  		do {
>  			pll_status = snd_soc_read(codec, DA7213_PLL_STATUS);
> @@ -771,6 +778,14 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w,
> 
>  		return 0;
>  	case SND_SOC_DAPM_POST_PMD:
> +		/* Revert 32KHz PLL lock udpates if applied previously */
> +		pll_ctrl = snd_soc_read(codec, DA7213_PLL_CTRL);
> +		if (pll_ctrl & DA7213_PLL_32K_MODE) {
> +			snd_soc_write(codec, 0xF0, 0x8B);
> +			snd_soc_write(codec, 0xF2, 0x01);
> +			snd_soc_write(codec, 0xF0, 0x00);
> +		}
> +
>  		/* PC free-running */
>  		snd_soc_update_bits(codec, DA7213_PC_COUNT,
>  				    DA7213_PC_FREERUN_MASK,
> @@ -1428,6 +1443,14 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
>  			    DA7213_PLL_INDIV_MASK | DA7213_PLL_MODE_MASK,
>  			    pll_ctrl);
> 
> +	/* Assist 32KHz mode PLL lock */
> +	if (source == DA7213_SYSCLK_PLL_32KHZ) {
> +		snd_soc_write(codec, 0xF0, 0x8B);
> +		snd_soc_write(codec, 0xF1, 0x03);
> +		snd_soc_write(codec, 0xF1, 0x01);
> +		snd_soc_write(codec, 0xF0, 0x00);
> +	}
> +
>  	return 0;
>  }

-- 

Peter Meerwald-Stadler
+43-664-2444418 (mobile)

[toc] | [prev] | [next] | [standalone]


#1457010 — Re: [alsa-devel] [PATCH 4/4] ASoC: da7213: Improve 32KHz mode PLL locking

FromMark Brown <broonie@kernel.org>
Date2016-08-05 12:40 +0200
SubjectRe: [alsa-devel] [PATCH 4/4] ASoC: da7213: Improve 32KHz mode PLL locking
Message-ID<s2KHM-6gz-9@gated-at.bofh.it>
In reply to#1456960

[Multipart message — attachments visible in raw view] — view raw

On Fri, Aug 05, 2016 at 11:04:51AM +0200, Peter Meerwald-Stadler wrote:

> these registers cannot not found in the datasheet;
> maybe add descriptive #defines in da7213.h

> > +			snd_soc_write(codec, 0xF0, 0x8B);
> > +			snd_soc_write(codec, 0xF2, 0x03);
> > +			snd_soc_write(codec, 0xF0, 0x00);

It is very common for chips to have undocumented write sequences that
make tweaks based on test registers that are deliberately not
documented.  This looks like such a case, I'd imagine that register 0xf0
is a test key and 0xf2 contains a value being tweaked.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web