Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] Update cs42l43b load detection proceedure
@ 2026-11-11 17:10 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 ` [PATCH 2/2] ASoC: cs42l43: Update load detect procedure " Charles Keepax
  0 siblings, 2 replies; 6+ messages in thread
From: Charles Keepax @ 2026-11-11 17:10 UTC (permalink / raw)
  To: broonie, lee; +Cc: lgirdwood, linux-sound, linux-kernel, mfd, patches

Some updates are required to ensure proper accuracy on the cs42l43b
headphone load detection. Add the required extra register to the regmap
in the MFD and then update the proceedure in ASoC.

Charles Keepax (2):
  mfd: cs42l43: Add load detection register needed for cs42l43b
  ASoC: cs42l43: Update load detect procedure for cs42l43b

 drivers/mfd/cs42l43.c            |   1 +
 include/linux/mfd/cs42l43-regs.h |   2 +
 sound/soc/codecs/cs42l43-jack.c  | 101 ++++++++++++++++++++-----------
 3 files changed, 70 insertions(+), 34 deletions(-)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] mfd: cs42l43: Add load detection register needed for cs42l43b
  2026-11-11 17:10 [PATCH 0/2] Update cs42l43b load detection proceedure Charles Keepax
@ 2026-11-11 17:10 ` Charles Keepax
  2026-11-11 17:36   ` sashiko-bot
  2026-11-11 17:10 ` [PATCH 2/2] ASoC: cs42l43: Update load detect procedure " Charles Keepax
  1 sibling, 1 reply; 6+ messages in thread
From: Charles Keepax @ 2026-11-11 17:10 UTC (permalink / raw)
  To: broonie, lee; +Cc: lgirdwood, linux-sound, linux-kernel, mfd, patches

The headphone load detection procedure on cs42l43b is slightly different
and requires a register that wasn't used on previous versions of the
chip. Add that register into the driver.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 drivers/mfd/cs42l43.c            | 1 +
 include/linux/mfd/cs42l43-regs.h | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
index a83b62064dae6..4e5d82c355ee3 100644
--- a/drivers/mfd/cs42l43.c
+++ b/drivers/mfd/cs42l43.c
@@ -425,6 +425,7 @@ bool cs42l43_precious_register(struct device *dev, unsigned int reg)
 	case CS42L43_RX_DATA:
 	case CS42L43_DECIM_INT ... CS42L43_HPOUT_INT:
 	case CS42L43_MCU_SW_REV ... CS42L43_MCU_RAM_MAX:
+	case CS42L43B_LOAD_DET_SEL:
 		return true;
 	default:
 		return false;
diff --git a/include/linux/mfd/cs42l43-regs.h b/include/linux/mfd/cs42l43-regs.h
index 4c00ceae8b461..924438655c630 100644
--- a/include/linux/mfd/cs42l43-regs.h
+++ b/include/linux/mfd/cs42l43-regs.h
@@ -1204,6 +1204,8 @@
 #define CS42L43B_ISRC2DEC3_INPUT1				0x0000C7A0
 #define CS42L43B_ISRC2DEC4_INPUT1				0x0000C7B0
 
+#define CS42L43B_LOAD_DET_SEL					0x000170E8
+
 #define CS42L43B_FW_MISSION_CTRL_NEED_CONFIGS			0x00117E00
 #define CS42L43B_FW_MISSION_CTRL_HAVE_CONFIGS			0x00117E04
 #define CS42L43B_FW_MISSION_CTRL_PATCH_START_ADDR_REG		0x00117E08
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ASoC: cs42l43: Update load detect procedure for cs42l43b
  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
  2026-11-11 17:47   ` sashiko-bot
  1 sibling, 1 reply; 6+ messages in thread
From: Charles Keepax @ 2026-11-11 17:10 UTC (permalink / raw)
  To: broonie, lee; +Cc: lgirdwood, linux-sound, linux-kernel, mfd, patches

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] mfd: cs42l43: Add load detection register needed for cs42l43b
  2026-11-11 17:10 ` [PATCH 1/2] mfd: cs42l43: Add load detection register needed for cs42l43b Charles Keepax
@ 2026-11-11 17:36   ` sashiko-bot
  0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-11 17:36 UTC (permalink / raw)
  To: Charles Keepax; +Cc: linux-sound, mfd, lee

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mfd: cs42l43: missing CS42L43B_LOAD_DET_SEL in
  cs42l43_readable_register()
--

commit 86bb228eefe713b198f8b6a31cc740c008b39cd7
Author: Charles Keepax <ckeepax@opensource.cirrus.com>

mfd: cs42l43: Add load detection register needed for cs42l43b

This commit defines the CS42L43B_LOAD_DET_SEL register and marks it as
precious in cs42l43_precious_register().

> diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
> index a83b62064dae6..4e5d82c355ee3 100644
> --- a/drivers/mfd/cs42l43.c
> +++ b/drivers/mfd/cs42l43.c
> @@ -425,6 +425,7 @@ bool cs42l43_precious_register(struct device *dev, unsigned int reg)
>  	case CS42L43_RX_DATA:
>  	case CS42L43_DECIM_INT ... CS42L43_HPOUT_INT:
>  	case CS42L43_MCU_SW_REV ... CS42L43_MCU_RAM_MAX:
> +	case CS42L43B_LOAD_DET_SEL:
>  		return true;

[Severity: Medium]
Should CS42L43B_LOAD_DET_SEL also be added to cs42l43_readable_register()?

regmap_precious() and regmap_volatile() return false before invoking
cs42l43_precious_register() or cs42l43_volatile_register() when
cs42l43_readable_register() returns false.  As a result, writes to
CS42L43B_LOAD_DET_SEL during headphone load detection are treated as
non-volatile, cached in the maple tree regcache, and replayed to hardware on
every runtime PM resume during regcache_sync().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261111171032.1491717-1-ckeepax@opensource.cirrus.com?part=1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] ASoC: cs42l43: Update load detect procedure for cs42l43b
  2026-11-11 17:10 ` [PATCH 2/2] ASoC: cs42l43: Update load detect procedure " Charles Keepax
@ 2026-11-11 17:47   ` sashiko-bot
  2026-11-12 11:22     ` Charles Keepax
  0 siblings, 1 reply; 6+ messages in thread
From: sashiko-bot @ 2026-11-11 17:47 UTC (permalink / raw)
  To: Charles Keepax; +Cc: linux-sound, mfd, lee

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ASoC: cs42l43: cs42l43_run_type_detect() treats invalid
  status as headset
- [Medium] ASoC: cs42l43: CS42L43B_LOAD_DET_SEL cached due to unread
  regmap_write()
--

commit 2f8a25cd3cc97db982b37853fb39365ad8d29795
Author: Charles Keepax <ckeepax@opensource.cirrus.com>

ASoC: cs42l43: Update load detect procedure for cs42l43b

This commit updates the headphone load detection procedure to pass the
detected jack type into load detection and configure CS42L43B_LOAD_DET_SEL
on newer chip variants.

> 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

[ ... ]

> @@ -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;
> +	}

[Severity: Medium]
Does writing CS42L43B_LOAD_DET_SEL via regmap_write() here and in
cs42l43_stop_load_detect() cache the register in REGCACHE_MAPLE and cause
every subsequent regcache_sync() in cs42l43_runtime_resume() to re-write
it to hardware?

Commit "mfd: cs42l43: Add load detection register needed for cs42l43b"
added CS42L43B_LOAD_DET_SEL to cs42l43_precious_register() (which
cs42l43_volatile_register() also consults), but did not add it to
cs42l43_readable_register().  Because regmap_volatile() returns false for
non-readable registers when format_write is NULL, regmap treats
CS42L43B_LOAD_DET_SEL as cacheable, and with no entry in
cs42l43_reg_default[] it is synced back on every resume unless it is marked
readable or written with cache bypass.

[ ... ]

> @@ -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);
>  }

[Severity: Medium]
Does replacing the switch in cs42l43_run_type_detect() cause invalid
CS42L43_HS_STAT values (0x5..0x7) to be misclassified as a 4-pole headset
instead of returning -EINVAL?

In cs42l43_run_type_detect(), type is initialized to 0xff and
regmap_read(cs42l43->regmap, CS42L43_HS_STAT, &type) is not checked for
errors; if that read fails or hardware reports 0x5..0x7, type &
CS42L43_HSDET_TYPE_STS_MASK is passed to cs42l43_run_load_detect(), which
now hits the default branch, enables headset bias and button detection,
and reports CS42L43_JACK_HEADSET.  In addition, the CS42L43_TYPE_OPEN
cases in cs42l43_start_load_detect() and cs42l43_run_load_detect() are
unreachable because cs42l43_run_type_detect() returns
CS42L43_JACK_EXTENSION when type == CS42L43_TYPE_OPEN.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261111171032.1491717-1-ckeepax@opensource.cirrus.com?part=2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] ASoC: cs42l43: Update load detect procedure for cs42l43b
  2026-11-11 17:47   ` sashiko-bot
@ 2026-11-12 11:22     ` Charles Keepax
  0 siblings, 0 replies; 6+ messages in thread
From: Charles Keepax @ 2026-11-12 11:22 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: linux-sound, mfd, lee

On Wed, Nov 11, 2026 at 05:47:46PM +0000, sashiko-bot@kernel.org wrote:
> > +		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;
> > +	}
> 
> [Severity: Medium]
> Does writing CS42L43B_LOAD_DET_SEL via regmap_write() here and in
> cs42l43_stop_load_detect() cache the register in REGCACHE_MAPLE and cause
> every subsequent regcache_sync() in cs42l43_runtime_resume() to re-write
> it to hardware?

Yeah the register should be marked as readable missed the fact
that overrides precious. Will spin for this.

> > -	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);
> >  }
> 
> [Severity: Medium]
> Does replacing the switch in cs42l43_run_type_detect() cause invalid
> CS42L43_HS_STAT values (0x5..0x7) to be misclassified as a 4-pole headset
> instead of returning -EINVAL?
> 
> In cs42l43_run_type_detect(), type is initialized to 0xff and
> regmap_read(cs42l43->regmap, CS42L43_HS_STAT, &type) is not checked for
> errors; if that read fails or hardware reports 0x5..0x7, type &
> CS42L43_HSDET_TYPE_STS_MASK is passed to cs42l43_run_load_detect(), which
> now hits the default branch, enables headset bias and button detection,
> and reports CS42L43_JACK_HEADSET.  In addition, the CS42L43_TYPE_OPEN
> cases in cs42l43_start_load_detect() and cs42l43_run_load_detect() are
> unreachable because cs42l43_run_type_detect() returns
> CS42L43_JACK_EXTENSION when type == CS42L43_TYPE_OPEN.

I think we are happy with these, failing the headset detect is
not super useful. And it is safer to handle the open cases
even if at the moment we can't hit those in load detect, load
detect has historically been uses a couple of times to try and
detect what is/when something is connected to an extension cable,
so probably safer against future refactoring.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-12 11:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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:36   ` sashiko-bot
2026-11-11 17:10 ` [PATCH 2/2] ASoC: cs42l43: Update load detect procedure " Charles Keepax
2026-11-11 17:47   ` sashiko-bot
2026-11-12 11:22     ` Charles Keepax

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox