mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paweł Anikiel" <pan@semihalf.com>
To: alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, lgirdwood@gmail.com,
	broonie@kernel.org
Cc: perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, dinguyen@kernel.org,
	lars@metafoo.de, nuno.sa@analog.com, upstream@semihalf.com,
	"Paweł Anikiel" <pan@semihalf.com>
Subject: [PATCH 5/9] ASoC: ssm2602: Add workaround for playback with external MCLK
Date: Fri, 14 Apr 2023 16:01:59 +0200	[thread overview]
Message-ID: <20230414140203.707729-6-pan@semihalf.com> (raw)
In-Reply-To: <20230414140203.707729-1-pan@semihalf.com>

Apply a workaround for what seems to be a hardware quirk: when using
an external MCLK signal, powering on Output and DAC for the first time
produces output distortions unless they're powered together with whole
chip power.

The workaround powers them on in probe for the first time, as doing it
later may be impossible (e.g. when starting playback while recording,
whole chip power will already be on).

Here are some initialization sequences run after all other control
registers were set (`ssmset reg val` sets the value of a register
via i2c):

  ssmset 0x09 0x01 # core
  ssmset 0x06 0x07 # chip, out
  OK

  ssmset 0x09 0x01 # core
  ssmset 0x06 0x87 # out, dac
  ssmset 0x06 0x07 # chip
  OK

  (disable MCLK)
  ssmset 0x09 0x01 # core
  ssmset 0x06 0x1f # chip
  ssmset 0x06 0x07 # out, dac
  (enable MCLK)
  OK

  ssmset 0x09 0x01 # core
  ssmset 0x06 0x1f # chip
  ssmset 0x06 0x07 # out, dac
  NOT OK

  ssmset 0x06 0x1f # chip
  ssmset 0x09 0x01 # core
  ssmset 0x06 0x07 # out, dac
  NOT OK

  ssmset 0x09 0x01 # core
  ssmset 0x06 0x0f # chip, out
  ssmset 0x06 0x07 # dac
  NOT OK

  ssmset 0x09 0x01 # core
  ssmset 0x06 0x17 # chip, dac
  ssmset 0x06 0x07 # out
  NOT OK

Here are some sequences run at the very start before a sw reset (and
later using one of the NOT OK sequences from above):

  ssmset 0x09 0x01 # core
  ssmset 0x06 0x07 # chip, out, dac
  OK

  (disable MCLK)
  ssmset 0x09 0x01 # core
  ssmset 0x06 0x07 # chip, out, dac
  (enable MCLK after reset)
  NOT OK

  ssmset 0x09 0x01 # core
  ssmset 0x06 0x17 # chip, dac
  NOT OK

  ssmset 0x09 0x01 # core
  ssmset 0x06 0x0f # chip, out
  NOT OK

  ssmset 0x06 0x07 # chip, out, dac
  NOT OK

This was tested on a Google Chameleon v3 board using an SSM2603 with an
external MCLK. This doesn't seem to just be a PCB issue, as this was
also observed on a ZYBO Z7-10:
https://ez.analog.com/audio/f/q-a/543726/solved-ssm2603-right-output-offset-issue/480229

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
---
 sound/soc/codecs/ssm2602.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c
index cbbe83b85ada..021e0c860fa1 100644
--- a/sound/soc/codecs/ssm2602.c
+++ b/sound/soc/codecs/ssm2602.c
@@ -589,6 +589,17 @@ static int ssm260x_component_probe(struct snd_soc_component *component)
 		return ret;
 	}
 
+	/* Workaround for what seems to be a hardware quirk: when using an
+	 * external MCLK signal, powering on Output and DAC for the first
+	 * time produces output distortions unless they're powered together
+	 * with whole chip power. We power them here for the first time,
+	 * as doing it later may be impossible (e.g. when starting playback
+	 * while recording, whole chip power will already be on)
+	 */
+	regmap_write(ssm2602->regmap, SSM2602_ACTIVE, 0x01);
+	regmap_write(ssm2602->regmap, SSM2602_PWR,    0x07);
+	regmap_write(ssm2602->regmap, SSM2602_RESET,  0x00);
+
 	/* set the update bits */
 	regmap_update_bits(ssm2602->regmap, SSM2602_LINVOL,
 			    LINVOL_LRIN_BOTH, LINVOL_LRIN_BOTH);
-- 
2.40.0.634.g4ca3ef3211-goog


  parent reply	other threads:[~2023-04-14 14:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14 14:01 [PATCH 0/9] Add Chameleon v3 ASoC audio Paweł Anikiel
2023-04-14 14:01 ` [PATCH 1/9] ASoC: Add Chameleon v3 audio Paweł Anikiel
2023-04-14 16:57   ` Krzysztof Kozlowski
2023-04-14 17:19   ` Mark Brown
2023-04-25 15:59     ` Paweł Anikiel
2023-04-25 16:27       ` Mark Brown
2023-04-14 14:01 ` [PATCH 2/9] dt-bindings: ASoC: Add chv3-i2s Paweł Anikiel
2023-04-14 17:00   ` Krzysztof Kozlowski
2023-04-25 16:01     ` Paweł Anikiel
2023-04-26 13:15       ` Krzysztof Kozlowski
2023-04-14 14:01 ` [PATCH 3/9] dt-bindings: ASoC: Add chv3-audio Paweł Anikiel
2023-04-14 18:37   ` Rob Herring
2023-04-17 20:41   ` Rob Herring
2023-04-25 16:01     ` Paweł Anikiel
2023-04-14 14:01 ` [PATCH 4/9] dt-bindings: ASoC: Add it68051 Paweł Anikiel
2023-04-14 17:01   ` Krzysztof Kozlowski
2023-04-14 18:37   ` Rob Herring
2023-04-14 14:01 ` Paweł Anikiel [this message]
2023-04-14 17:35   ` [PATCH 5/9] ASoC: ssm2602: Add workaround for playback with external MCLK Mark Brown
2023-04-25 16:02     ` Paweł Anikiel
2023-04-25 16:42       ` Mark Brown
2023-04-14 14:02 ` [PATCH 6/9] ASoC: ssm2602: Add support for CLKDIV2 Paweł Anikiel
2023-04-14 14:02 ` [PATCH 7/9] ASoC: ssm2602: Add mute gpio Paweł Anikiel
2023-04-14 17:47   ` Mark Brown
2023-04-14 14:02 ` [PATCH 8/9] dt-bindings: ASoC: Add mute-gpio to ssm2602 Paweł Anikiel
2023-04-14 14:02 ` [PATCH 9/9] ARM: dts: chameleonv3: Add ssm2603 mute gpio Paweł Anikiel
2023-04-14 16:47 ` [PATCH 0/9] Add Chameleon v3 ASoC audio Mark Brown
2023-04-25 15:58   ` Paweł Anikiel
2023-04-25 17:06     ` Mark Brown
2023-04-17 19:28 ` (subset) " 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=20230414140203.707729-6-pan@semihalf.com \
    --to=pan@semihalf.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dinguyen@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=tiwai@suse.com \
    --cc=upstream@semihalf.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®