All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Irestål" <andreas.irestal@axis.com>
To: lars@metafoo.de
Cc: liam.r.girdwood@linux.intel.com,
	"Andreas Irestål" <andire@axis.com>,
	alsa-devel@alsa-project.org, broonie@kernel.org
Subject: [PATCH] ASoC: adau17x1: Cache writes when core clock is disabled
Date: Thu,  4 Feb 2016 15:05:19 +0100	[thread overview]
Message-ID: <1454594719-17270-1-git-send-email-andire@axis.com> (raw)

In some configurations, the dai registers get written before the bias
level is changed in the codec driver. This leads to a situation where
an initial write to the serial port register gets ignored, and future
writes may as well, since regmap thinks that the codec already holds the
value. More specifically, configuring the codec as i2s master would in
fact result in the codec running as slave, a situation where no i2s
clocks are generated and hence no data is transferred.

This change makes sure that regmap only caches writes when the core
clock is disabled, and syncs regmap whenever enabling the core clock
again.

Signed-off-by: Andreas Irestål <andire@axis.com>
---
 sound/soc/codecs/adau1761.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sound/soc/codecs/adau1761.c b/sound/soc/codecs/adau1761.c
index 2f12477..e7136b1 100644
--- a/sound/soc/codecs/adau1761.c
+++ b/sound/soc/codecs/adau1761.c
@@ -456,13 +456,17 @@ static int adau1761_set_bias_level(struct snd_soc_codec *codec,
 	case SND_SOC_BIAS_PREPARE:
 		break;
 	case SND_SOC_BIAS_STANDBY:
+		regcache_cache_only(adau->regmap, false);
 		regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL,
 			ADAU17X1_CLOCK_CONTROL_SYSCLK_EN,
 			ADAU17X1_CLOCK_CONTROL_SYSCLK_EN);
+		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
+			regcache_sync(adau->regmap);
 		break;
 	case SND_SOC_BIAS_OFF:
 		regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL,
 			ADAU17X1_CLOCK_CONTROL_SYSCLK_EN, 0);
+		regcache_cache_only(adau->regmap, true);
 		break;
 
 	}
@@ -783,6 +787,10 @@ int adau1761_probe(struct device *dev, struct regmap *regmap,
 	if (ret)
 		return ret;
 
+	/* Enable cache only mode as we could miss writes before bias level
+	 * reaches standby and the core clock is enabled */
+	regcache_cache_only(regmap, true);
+
 	return snd_soc_register_codec(dev, &adau1761_codec_driver, dai_drv, 1);
 }
 EXPORT_SYMBOL_GPL(adau1761_probe);
-- 
2.1.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

             reply	other threads:[~2016-02-04 14:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-04 14:05 Andreas Irestål [this message]
2016-02-04 17:22 ` [PATCH] ASoC: adau17x1: Cache writes when core clock is disabled Lars-Peter Clausen
2016-02-04 17:24   ` Lars-Peter Clausen
2016-02-04 19:01     ` Andreas Irestål
2016-02-04 19:34       ` Mark Brown
2016-02-05 13:35 ` Applied "ASoC: adau17x1: Cache writes when core clock is disabled" to the asoc tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454594719-17270-1-git-send-email-andire@axis.com \
    --to=andreas.irestal@axis.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=andire@axis.com \
    --cc=broonie@kernel.org \
    --cc=lars@metafoo.de \
    --cc=liam.r.girdwood@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.