From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: broonie@kernel.org, lee@kernel.org
Cc: lgirdwood@gmail.com, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org, mfd@lists.linux.dev,
patches@opensource.cirrus.com
Subject: [PATCH 2/2] ASoC: cs42l43: Update load detect procedure for cs42l43b
Date: Wed, 11 Nov 2026 17:10:32 +0000 [thread overview]
Message-ID: <20261111171032.1491717-3-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20261111171032.1491717-1-ckeepax@opensource.cirrus.com>
The newer variants requires a slightly different process for the load
detection. It is no longer necessary to apply different tuning for 3 vs
4-pole headsets, but a new field does require updated for CTIA vs OMTP
headsets. Update the driver to follow the correct process for this
new version of the chip.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
sound/soc/codecs/cs42l43-jack.c | 101 +++++++++++++++++++++-----------
1 file changed, 67 insertions(+), 34 deletions(-)
diff --git a/sound/soc/codecs/cs42l43-jack.c b/sound/soc/codecs/cs42l43-jack.c
index a2555dd9229e3..b3f89c712ed93 100644
--- a/sound/soc/codecs/cs42l43-jack.c
+++ b/sound/soc/codecs/cs42l43-jack.c
@@ -324,6 +324,11 @@ irqreturn_t cs42l43_bias_detect_clamp(int irq, void *data)
#define CS42L43_JACK_BUTTONS (SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | \
SND_JACK_BTN_3 | SND_JACK_BTN_4 | SND_JACK_BTN_5)
+#define CS42L43_TYPE_CTIA 0x0
+#define CS42L43_TYPE_OMTP 0x1
+#define CS42L43_TYPE_3POLE 0x2
+#define CS42L43_TYPE_OPEN 0x3
+
static inline bool cs42l43_jack_present(struct cs42l43_codec *priv)
{
struct cs42l43 *cs42l43 = priv->core;
@@ -502,9 +507,11 @@ static const struct reg_sequence cs42l43_4pole_patch[] = {
{ 0x4000, 0x00000000 },
};
-static void cs42l43_start_load_detect(struct cs42l43_codec *priv, bool mic)
+static void cs42l43_start_load_detect(struct cs42l43_codec *priv, int type)
{
struct cs42l43 *cs42l43 = priv->core;
+ const struct reg_sequence *patch;
+ int size;
dev_dbg(priv->dev, "Start load detect\n");
@@ -526,14 +533,36 @@ static void cs42l43_start_load_detect(struct cs42l43_codec *priv, bool mic)
dev_err(priv->dev, "Load detect HP power down timed out\n");
}
- if (mic)
- regmap_multi_reg_write_bypassed(cs42l43->regmap,
- cs42l43_4pole_patch,
- ARRAY_SIZE(cs42l43_4pole_patch));
- else
- regmap_multi_reg_write_bypassed(cs42l43->regmap,
- cs42l43_3pole_patch,
- ARRAY_SIZE(cs42l43_3pole_patch));
+ switch (cs42l43->variant_id) {
+ case CS42L43_DEVID_VAL:
+ switch (type) {
+ case CS42L43_TYPE_3POLE:
+ case CS42L43_TYPE_OPEN:
+ patch = cs42l43_3pole_patch;
+ size = ARRAY_SIZE(cs42l43_3pole_patch);
+ break;
+ default:
+ patch = cs42l43_4pole_patch;
+ size = ARRAY_SIZE(cs42l43_4pole_patch);
+ break;
+ }
+ break;
+ default:
+ patch = cs42l43_4pole_patch;
+ size = ARRAY_SIZE(cs42l43_4pole_patch);
+
+ switch (type) {
+ case CS42L43_TYPE_OMTP:
+ regmap_write(cs42l43->regmap, CS42L43B_LOAD_DET_SEL, 0x89);
+ break;
+ default:
+ regmap_write(cs42l43->regmap, CS42L43B_LOAD_DET_SEL, 0x98);
+ break;
+ }
+ break;
+ }
+
+ regmap_multi_reg_write_bypassed(cs42l43->regmap, patch, size);
regmap_update_bits(cs42l43->regmap, CS42L43_BLOCK_EN3,
CS42L43_ADC1_EN_MASK | CS42L43_ADC2_EN_MASK, 0);
@@ -586,6 +615,14 @@ static void cs42l43_stop_load_detect(struct cs42l43_codec *priv)
CS42L43_ADC1_EN_MASK | CS42L43_ADC2_EN_MASK,
priv->adc_ena);
+ switch (cs42l43->variant_id) {
+ case CS42L43_DEVID_VAL:
+ break;
+ default:
+ regmap_write(cs42l43->regmap, CS42L43B_LOAD_DET_SEL, 0x0);
+ break;
+ }
+
if (priv->hp_ena && !priv->hp_ilimited) {
unsigned long time_left;
@@ -605,7 +642,7 @@ static void cs42l43_stop_load_detect(struct cs42l43_codec *priv)
snd_soc_dapm_mutex_unlock(snd_soc_component_to_dapm(priv->component));
}
-static int cs42l43_run_load_detect(struct cs42l43_codec *priv, bool mic)
+static int cs42l43_run_load_detect(struct cs42l43_codec *priv, int type)
{
struct cs42l43 *cs42l43 = priv->core;
unsigned int val = 0;
@@ -613,7 +650,7 @@ static int cs42l43_run_load_detect(struct cs42l43_codec *priv, bool mic)
reinit_completion(&priv->load_detect);
- cs42l43_start_load_detect(priv, mic);
+ cs42l43_start_load_detect(priv, type);
time_left = wait_for_completion_timeout(&priv->load_detect,
msecs_to_jiffies(CS42L43_LOAD_TIMEOUT_MS));
cs42l43_stop_load_detect(priv);
@@ -629,23 +666,25 @@ static int cs42l43_run_load_detect(struct cs42l43_codec *priv, bool mic)
if (!cs42l43_jack_present(priv))
return -ENODEV;
- if (mic) {
+ switch (type) {
+ case CS42L43_TYPE_3POLE:
+ case CS42L43_TYPE_OPEN:
+ switch (val & CS42L43_AMP3_RES_DET_MASK) {
+ case 0x0: // < 22 Ohm impedance
+ case 0x1: // < 150 Ohm impedance
+ case 0x2: // < 1000 Ohm impedance
+ return CS42L43_JACK_HEADPHONE;
+ case 0x3: // > 1000 Ohm impedance
+ return CS42L43_JACK_LINEOUT;
+ default:
+ return -EINVAL;
+ }
+ default:
cs42l43_start_hs_bias(priv, false);
cs42l43_start_button_detect(priv);
return CS42L43_JACK_HEADSET;
}
-
- switch (val & CS42L43_AMP3_RES_DET_MASK) {
- case 0x0: // < 22 Ohm impedance
- case 0x1: // < 150 Ohm impedance
- case 0x2: // < 1000 Ohm impedance
- return CS42L43_JACK_HEADPHONE;
- case 0x3: // > 1000 Ohm impedance
- return CS42L43_JACK_LINEOUT;
- default:
- return -EINVAL;
- }
}
static int cs42l43_run_type_detect(struct cs42l43_codec *priv)
@@ -686,18 +725,12 @@ static int cs42l43_run_type_detect(struct cs42l43_codec *priv)
if (!cs42l43_jack_present(priv))
return -ENODEV;
- switch (type & CS42L43_HSDET_TYPE_STS_MASK) {
- case 0x0: // CTIA
- case 0x1: // OMTP
- case 0x4:
- return cs42l43_run_load_detect(priv, true);
- case 0x2: // 3-pole
- return cs42l43_run_load_detect(priv, false);
- case 0x3: // Open-circuit
+ type &= CS42L43_HSDET_TYPE_STS_MASK;
+
+ if (type == CS42L43_TYPE_OPEN)
return CS42L43_JACK_EXTENSION;
- default:
- return -EINVAL;
- }
+ else
+ return cs42l43_run_load_detect(priv, type);
}
void cs42l43_clear_jack(struct cs42l43_codec *priv)
--
2.47.3
prev parent reply other threads:[~2026-11-11 17:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 17:10 [PATCH 0/2] Update cs42l43b load detection proceedure Charles Keepax
2026-11-11 17:10 ` [PATCH 1/2] mfd: cs42l43: Add load detection register needed for cs42l43b Charles Keepax
2026-11-11 17:10 ` Charles Keepax [this message]
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=20261111171032.1491717-3-ckeepax@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=patches@opensource.cirrus.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®