Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH v3 00/10] sound: codecs: tlv320adcx140: assorted patches
@ 2025-12-18 18:21 Sascha Hauer
  2025-12-18 18:21 ` [PATCH v3 01/10] ASoC: tlv320adcx140: invert DRE_ENABLE Sascha Hauer
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Sascha Hauer @ 2025-12-18 18:21 UTC (permalink / raw)
  To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Andrew Davis, Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree,
	Sascha Hauer, Emil Svendsen, Dimitrios Katsaros, Emil-Juhl,
	Emil-Juhl

These are some patches for the tlv320adcx140 codec we are carrying
around for a while, time to upstream them.

First four patches are fixes. The following four add regulator support
for AVDD and IOVDD. The remaining three patches add more controls to the
driver.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Changes in v3:
- Add missing "true" for regulator
- Link to v2: https://lore.kernel.org/r/20251218-sound-soc-codecs-tvl320adcx140-v2-0-3c2270c34bac@pengutronix.de

Changes in v2:
- drop "Add kcontrols for TDM Slot assignment", wrong way to control TDM
  slot assignment
- drop overlong and unnecessary backtrace from commit message
- drop unnecessary descriptio for regulator in binding
- improve commit message for "ASoC: tlv320adcx140: implement register caching"
- change order in dt-binding patches to fixes first
- Add missing S-o-b Emil Juhl
- Link to v1: https://lore.kernel.org/r/20251217-sound-soc-codecs-tvl320adcx140-v1-0-293dea149d7b@pengutronix.de

---
Dimitrios Katsaros (1):
      ASoC: tlv320adcx140: Propagate error codes during probe

Emil Svendsen (4):
      ASoC: tlv320adcx140: invert DRE_ENABLE
      ASoC: tlv320adcx140: fix null pointer
      ASoC: tlv320adcx140: fix word length
      ASoC: tlv320adcx140: add channel sum control

Emil-Juhl (4):
      ASoC: tlv320adcx140: power on/off the device on demand
      ASoC: tlv320adcx140: add avdd and iovdd supply
      ASoC: dt-bindings: clarify areg-supply documentation
      ASoC: tlv320adcx140: add kcontrol for num biquads

Sascha Hauer (1):
      ASoC: dt-bindings: add avdd and iovdd supply

 .../bindings/sound/ti,tlv320adcx140.yaml           |   7 +-
 sound/soc/codecs/tlv320adcx140.c                   | 149 +++++++++++++++++++--
 2 files changed, 146 insertions(+), 10 deletions(-)
---
base-commit: ea1013c1539270e372fc99854bc6e4d94eaeff66
change-id: 20251217-sound-soc-codecs-tvl320adcx140-a8d2e649bf78

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>


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

* [PATCH v3 01/10] ASoC: tlv320adcx140: invert DRE_ENABLE
  2025-12-18 18:21 [PATCH v3 00/10] sound: codecs: tlv320adcx140: assorted patches Sascha Hauer
@ 2025-12-18 18:21 ` Sascha Hauer
  2025-12-18 18:21 ` [PATCH v3 02/10] ASoC: tlv320adcx140: fix null pointer Sascha Hauer
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2025-12-18 18:21 UTC (permalink / raw)
  To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Andrew Davis, Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree,
	Sascha Hauer, Emil Svendsen

From: Emil Svendsen <emas@bang-olufsen.dk>

Looking at section 8.6.1.1.69 in datasheets for both 5140 and 6140 (3140
doesn't support DRE). REG ADCX140_DSP_CFG1 BIT 3 field "DRE_AGC_SEL" it
select either DRE or AGC.
It states:
 * 0 = DRE
 * 1 = AGC

The control is called "DRE_ENABLE" and for it to be true it has to be
active low.

This commit will invert the control so "DRE_ENABLE" is active low.

Signed-off-by: Emil Svendsen <emas@bang-olufsen.dk>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 sound/soc/codecs/tlv320adcx140.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index 443cf59cb71ab3e70f47c4395159752a0331b1ef..75e1007012a48a569586bc2896400e79ddce1c71 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -338,7 +338,7 @@ static const struct snd_kcontrol_new adcx140_dapm_ch4_dre_en_switch =
 	SOC_DAPM_SINGLE("Switch", ADCX140_CH4_CFG0, 0, 1, 0);
 
 static const struct snd_kcontrol_new adcx140_dapm_dre_en_switch =
-	SOC_DAPM_SINGLE("Switch", ADCX140_DSP_CFG1, 3, 1, 0);
+	SOC_DAPM_SINGLE("Switch", ADCX140_DSP_CFG1, 3, 1, 1);
 
 /* Output Mixer */
 static const struct snd_kcontrol_new adcx140_output_mixer_controls[] = {

-- 
2.47.3


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

* [PATCH v3 02/10] ASoC: tlv320adcx140: fix null pointer
  2025-12-18 18:21 [PATCH v3 00/10] sound: codecs: tlv320adcx140: assorted patches Sascha Hauer
  2025-12-18 18:21 ` [PATCH v3 01/10] ASoC: tlv320adcx140: invert DRE_ENABLE Sascha Hauer
@ 2025-12-18 18:21 ` Sascha Hauer
  2025-12-18 18:21 ` [PATCH v3 03/10] ASoC: tlv320adcx140: Propagate error codes during probe Sascha Hauer
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2025-12-18 18:21 UTC (permalink / raw)
  To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Andrew Davis, Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree,
	Sascha Hauer, Emil Svendsen

From: Emil Svendsen <emas@bang-olufsen.dk>

The "snd_soc_component" in "adcx140_priv" was only used once but never
set. It was only used for reaching "dev" which is already present in
"adcx140_priv".

Fixes: 4e82971f7b55 ("ASoC: tlv320adcx140: Add a new kcontrol")
Signed-off-by: Emil Svendsen <emas@bang-olufsen.dk>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 sound/soc/codecs/tlv320adcx140.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index 75e1007012a48a569586bc2896400e79ddce1c71..3fb1b6251e6f8b361e8f82ce6381a7e8cfcd1935 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -23,7 +23,6 @@
 #include "tlv320adcx140.h"
 
 struct adcx140_priv {
-	struct snd_soc_component *component;
 	struct regulator *supply_areg;
 	struct gpio_desc *gpio_reset;
 	struct regmap *regmap;
@@ -699,7 +698,6 @@ static void adcx140_pwr_ctrl(struct adcx140_priv *adcx140, bool power_state)
 {
 	int pwr_ctrl = 0;
 	int ret = 0;
-	struct snd_soc_component *component = adcx140->component;
 
 	if (power_state)
 		pwr_ctrl = ADCX140_PWR_CFG_ADC_PDZ | ADCX140_PWR_CFG_PLL_PDZ;
@@ -711,7 +709,7 @@ static void adcx140_pwr_ctrl(struct adcx140_priv *adcx140, bool power_state)
 		ret = regmap_write(adcx140->regmap, ADCX140_PHASE_CALIB,
 			adcx140->phase_calib_on ? 0x00 : 0x40);
 		if (ret)
-			dev_err(component->dev, "%s: register write error %d\n",
+			dev_err(adcx140->dev, "%s: register write error %d\n",
 				__func__, ret);
 	}
 

-- 
2.47.3


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

* [PATCH v3 03/10] ASoC: tlv320adcx140: Propagate error codes during probe
  2025-12-18 18:21 [PATCH v3 00/10] sound: codecs: tlv320adcx140: assorted patches Sascha Hauer
  2025-12-18 18:21 ` [PATCH v3 01/10] ASoC: tlv320adcx140: invert DRE_ENABLE Sascha Hauer
  2025-12-18 18:21 ` [PATCH v3 02/10] ASoC: tlv320adcx140: fix null pointer Sascha Hauer
@ 2025-12-18 18:21 ` Sascha Hauer
  2025-12-18 18:21 ` [PATCH v3 04/10] ASoC: tlv320adcx140: fix word length Sascha Hauer
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2025-12-18 18:21 UTC (permalink / raw)
  To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Andrew Davis, Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree,
	Sascha Hauer, Dimitrios Katsaros

From: Dimitrios Katsaros <patcherwork@gmail.com>

When scanning for the reset pin, we could get an -EPROBE_DEFER.
The driver would assume that no reset pin had been defined,
which would mean that the chip would never be powered.

Now we both respect any error we get from devm_gpiod_get_optional.
We also now properly report the missing GPIO definition when
'gpio_reset' is NULL.

Signed-off-by: Dimitrios Katsaros <patcherwork@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 sound/soc/codecs/tlv320adcx140.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index 3fb1b6251e6f8b361e8f82ce6381a7e8cfcd1935..58a6dfa228cc326d18b3c3f126732033749c8e49 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -1154,6 +1154,9 @@ static int adcx140_i2c_probe(struct i2c_client *i2c)
 	adcx140->gpio_reset = devm_gpiod_get_optional(adcx140->dev,
 						      "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(adcx140->gpio_reset))
+		return dev_err_probe(&i2c->dev, PTR_ERR(adcx140->gpio_reset),
+				     "Failed to get Reset GPIO\n");
+	if (!adcx140->gpio_reset)
 		dev_info(&i2c->dev, "Reset GPIO not defined\n");
 
 	adcx140->supply_areg = devm_regulator_get_optional(adcx140->dev,

-- 
2.47.3


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

* [PATCH v3 04/10] ASoC: tlv320adcx140: fix word length
  2025-12-18 18:21 [PATCH v3 00/10] sound: codecs: tlv320adcx140: assorted patches Sascha Hauer
                   ` (2 preceding siblings ...)
  2025-12-18 18:21 ` [PATCH v3 03/10] ASoC: tlv320adcx140: Propagate error codes during probe Sascha Hauer
@ 2025-12-18 18:21 ` Sascha Hauer
  2025-12-18 18:21 ` [PATCH v3 05/10] ASoC: tlv320adcx140: power on/off the device on demand Sascha Hauer
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2025-12-18 18:21 UTC (permalink / raw)
  To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Andrew Davis, Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree,
	Sascha Hauer, Emil Svendsen

From: Emil Svendsen <emas@bang-olufsen.dk>

The word length is the physical width of the channel slots. So the
hw_params would misconfigure when format width and physical width
doesn't match. Like S24_LE which has data width of 24 bits but physical
width of 32 bits. So if using asymmetric formats you will get a lot of
noise.

Fixes: 689c7655b50c5 ("ASoC: tlv320adcx140: Add the tlv320adcx140 codec driver family")
Signed-off-by: Emil Svendsen <emas@bang-olufsen.dk>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 sound/soc/codecs/tlv320adcx140.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index 58a6dfa228cc326d18b3c3f126732033749c8e49..fdf4a9add852deb5e879dba5c8a09458fc6e709d 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -725,7 +725,7 @@ static int adcx140_hw_params(struct snd_pcm_substream *substream,
 	struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component);
 	u8 data = 0;
 
-	switch (params_width(params)) {
+	switch (params_physical_width(params)) {
 	case 16:
 		data = ADCX140_16_BIT_WORD;
 		break;
@@ -740,7 +740,7 @@ static int adcx140_hw_params(struct snd_pcm_substream *substream,
 		break;
 	default:
 		dev_err(component->dev, "%s: Unsupported width %d\n",
-			__func__, params_width(params));
+			__func__, params_physical_width(params));
 		return -EINVAL;
 	}
 

-- 
2.47.3


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

* [PATCH v3 05/10] ASoC: tlv320adcx140: power on/off the device on demand
  2025-12-18 18:21 [PATCH v3 00/10] sound: codecs: tlv320adcx140: assorted patches Sascha Hauer
                   ` (3 preceding siblings ...)
  2025-12-18 18:21 ` [PATCH v3 04/10] ASoC: tlv320adcx140: fix word length Sascha Hauer
@ 2025-12-18 18:21 ` Sascha Hauer
  2025-12-18 18:22 ` [PATCH v3 06/10] ASoC: tlv320adcx140: add avdd and iovdd supply Sascha Hauer
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2025-12-18 18:21 UTC (permalink / raw)
  To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Andrew Davis, Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree,
	Sascha Hauer, Emil-Juhl

From: Emil-Juhl <emdj@bang-olufsen.dk>

The tlv320adcx140 can be connected to controllable AVDD/IOVDD regulators
which when disabled will reset the registers to their default.  In
preparation for that switch to register writes to cache only when
powered off and sync the cached values to the registers when powered
back on.

Signed-off-by: Emil-Juhl <emdj@bang-olufsen.dk>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 sound/soc/codecs/tlv320adcx140.c | 89 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 87 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index fdf4a9add852deb5e879dba5c8a09458fc6e709d..444c0e80f0907de201ed1818b5612164a48b0fca 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -121,6 +121,34 @@ static const struct reg_default adcx140_reg_defaults[] = {
 	{ ADCX140_DEV_STS1, 0x80 },
 };
 
+static const struct regmap_range adcx140_wr_ranges[] = {
+	regmap_reg_range(ADCX140_PAGE_SELECT, ADCX140_SLEEP_CFG),
+	regmap_reg_range(ADCX140_SHDN_CFG, ADCX140_SHDN_CFG),
+	regmap_reg_range(ADCX140_ASI_CFG0, ADCX140_ASI_CFG2),
+	regmap_reg_range(ADCX140_ASI_CH1, ADCX140_MST_CFG1),
+	regmap_reg_range(ADCX140_CLK_SRC, ADCX140_CLK_SRC),
+	regmap_reg_range(ADCX140_PDMCLK_CFG, ADCX140_GPO_CFG3),
+	regmap_reg_range(ADCX140_GPO_VAL, ADCX140_GPO_VAL),
+	regmap_reg_range(ADCX140_GPI_CFG0, ADCX140_GPI_CFG1),
+	regmap_reg_range(ADCX140_GPI_MON, ADCX140_GPI_MON),
+	regmap_reg_range(ADCX140_INT_CFG, ADCX140_INT_MASK0),
+	regmap_reg_range(ADCX140_BIAS_CFG, ADCX140_CH4_CFG4),
+	regmap_reg_range(ADCX140_CH5_CFG2, ADCX140_CH5_CFG4),
+	regmap_reg_range(ADCX140_CH6_CFG2, ADCX140_CH6_CFG4),
+	regmap_reg_range(ADCX140_CH7_CFG2, ADCX140_CH7_CFG4),
+	regmap_reg_range(ADCX140_CH8_CFG2, ADCX140_CH8_CFG4),
+	regmap_reg_range(ADCX140_DSP_CFG0, ADCX140_DRE_CFG0),
+	regmap_reg_range(ADCX140_AGC_CFG0, ADCX140_AGC_CFG0),
+	regmap_reg_range(ADCX140_IN_CH_EN, ADCX140_PWR_CFG),
+	regmap_reg_range(ADCX140_PHASE_CALIB, ADCX140_PHASE_CALIB),
+	regmap_reg_range(0x7e, 0x7e),
+};
+
+static const struct regmap_access_table adcx140_wr_table = {
+	.yes_ranges = adcx140_wr_ranges,
+	.n_yes_ranges = ARRAY_SIZE(adcx140_wr_ranges),
+};
+
 static const struct regmap_range_cfg adcx140_ranges[] = {
 	{
 		.range_min = 0,
@@ -156,6 +184,7 @@ static const struct regmap_config adcx140_i2c_regmap = {
 	.num_ranges = ARRAY_SIZE(adcx140_ranges),
 	.max_register = 12 * 128,
 	.volatile_reg = adcx140_volatile,
+	.wr_table = &adcx140_wr_table,
 };
 
 /* Digital Volume control. From -100 to 27 dB in 0.5 dB steps */
@@ -1073,19 +1102,73 @@ static int adcx140_codec_probe(struct snd_soc_component *component)
 	return ret;
 }
 
+static int adcx140_pwr_off(struct adcx140_priv *adcx140)
+{
+	regcache_cache_only(adcx140->regmap, true);
+	regcache_mark_dirty(adcx140->regmap);
+
+	/* Assert the reset GPIO */
+	gpiod_set_value_cansleep(adcx140->gpio_reset, 0);
+
+	/*
+	 * Datasheet - TLV320ADC3140 Rev. B, TLV320ADC5140 Rev. A,
+	 * TLV320ADC6140 Rev. A 8.4.1:
+	 * wait for hw shutdown (25ms) + >= 1ms
+	 */
+	usleep_range(30000, 100000);
+
+	return 0;
+}
+
+static int adcx140_pwr_on(struct adcx140_priv *adcx140)
+{
+	int ret;
+
+	/* De-assert the reset GPIO */
+	gpiod_set_value_cansleep(adcx140->gpio_reset, 1);
+
+	/*
+	 * Datasheet - TLV320ADC3140 Rev. B, TLV320ADC5140 Rev. A,
+	 * TLV320ADC6140 Rev. A 8.4.2:
+	 * wait >= 10 ms after entering sleep mode.
+	 */
+	usleep_range(10000, 100000);
+
+	regcache_cache_only(adcx140->regmap, false);
+
+	/* Flush the regcache */
+	ret = regcache_sync(adcx140->regmap);
+	if (ret) {
+		dev_err(adcx140->dev, "Failed to restore register map: %d\n",
+			ret);
+		return  ret;
+	}
+
+	return 0;
+}
+
 static int adcx140_set_bias_level(struct snd_soc_component *component,
 				  enum snd_soc_bias_level level)
 {
 	struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component);
+	enum snd_soc_bias_level prev_level
+		= snd_soc_component_get_bias_level(component);
 
 	switch (level) {
 	case SND_SOC_BIAS_ON:
 	case SND_SOC_BIAS_PREPARE:
+		if (prev_level == SND_SOC_BIAS_STANDBY)
+			adcx140_pwr_ctrl(adcx140, true);
+		break;
 	case SND_SOC_BIAS_STANDBY:
-		adcx140_pwr_ctrl(adcx140, true);
+		if (prev_level == SND_SOC_BIAS_PREPARE)
+			adcx140_pwr_ctrl(adcx140, false);
+		if (prev_level == SND_SOC_BIAS_OFF)
+			return adcx140_pwr_on(adcx140);
 		break;
 	case SND_SOC_BIAS_OFF:
-		adcx140_pwr_ctrl(adcx140, false);
+		if (prev_level == SND_SOC_BIAS_STANDBY)
+			return adcx140_pwr_off(adcx140);
 		break;
 	}
 
@@ -1186,6 +1269,8 @@ static int adcx140_i2c_probe(struct i2c_client *i2c)
 		return ret;
 	}
 
+	regcache_cache_only(adcx140->regmap, true);
+
 	i2c_set_clientdata(i2c, adcx140);
 
 	return devm_snd_soc_register_component(&i2c->dev,

-- 
2.47.3


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

* [PATCH v3 06/10] ASoC: tlv320adcx140: add avdd and iovdd supply
  2025-12-18 18:21 [PATCH v3 00/10] sound: codecs: tlv320adcx140: assorted patches Sascha Hauer
                   ` (4 preceding siblings ...)
  2025-12-18 18:21 ` [PATCH v3 05/10] ASoC: tlv320adcx140: power on/off the device on demand Sascha Hauer
@ 2025-12-18 18:22 ` Sascha Hauer
  2025-12-18 18:22 ` [PATCH v3 07/10] ASoC: dt-bindings: clarify areg-supply documentation Sascha Hauer
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2025-12-18 18:22 UTC (permalink / raw)
  To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Andrew Davis, Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree,
	Sascha Hauer, Emil-Juhl

From: Emil-Juhl <emdj@bang-olufsen.dk>

The datasheet, under "10 Power Supply Recommendations" section,
specifies that both the AVDD and IOVDD supplies must be up and stable
for at least 100us before the SHDNZ can be released. After that, the
chip is ready to receive commands after another 2ms.
Currently the driver doesn't contain any options to bind AVDD and IOVDD
supplies to the tlv320adcx140.

This commit adds bindings for AVDD and IOVDD supplies which the driver
will enable when used.

Signed-off-by: Emil-Juhl <emdj@bang-olufsen.dk>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 sound/soc/codecs/tlv320adcx140.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index 444c0e80f0907de201ed1818b5612164a48b0fca..a7200e149e5f40ddd61e3c0455b796c81f55e2e8 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -22,8 +22,16 @@
 
 #include "tlv320adcx140.h"
 
+static const char *const adcx140_supply_names[] = {
+	"avdd",
+	"iovdd",
+};
+
+#define ADCX140_NUM_SUPPLIES ARRAY_SIZE(adcx140_supply_names)
+
 struct adcx140_priv {
 	struct regulator *supply_areg;
+	struct regulator_bulk_data supplies[ADCX140_NUM_SUPPLIES];
 	struct gpio_desc *gpio_reset;
 	struct regmap *regmap;
 	struct device *dev;
@@ -1104,6 +1112,8 @@ static int adcx140_codec_probe(struct snd_soc_component *component)
 
 static int adcx140_pwr_off(struct adcx140_priv *adcx140)
 {
+	int ret;
+
 	regcache_cache_only(adcx140->regmap, true);
 	regcache_mark_dirty(adcx140->regmap);
 
@@ -1117,6 +1127,14 @@ static int adcx140_pwr_off(struct adcx140_priv *adcx140)
 	 */
 	usleep_range(30000, 100000);
 
+	/* Power off the regulators, `avdd` and `iovdd` */
+	ret = regulator_bulk_disable(ARRAY_SIZE(adcx140->supplies),
+				     adcx140->supplies);
+	if (ret) {
+		dev_err(adcx140->dev, "Failed to disable supplies: %d\n", ret);
+		return ret;
+	}
+
 	return 0;
 }
 
@@ -1124,6 +1142,14 @@ static int adcx140_pwr_on(struct adcx140_priv *adcx140)
 {
 	int ret;
 
+	/* Power on the regulators, `avdd` and `iovdd` */
+	ret = regulator_bulk_enable(ARRAY_SIZE(adcx140->supplies),
+					adcx140->supplies);
+	if (ret) {
+		dev_err(adcx140->dev, "Failed to enable supplies: %d\n", ret);
+		return ret;
+	}
+
 	/* De-assert the reset GPIO */
 	gpiod_set_value_cansleep(adcx140->gpio_reset, 1);
 
@@ -1234,6 +1260,16 @@ static int adcx140_i2c_probe(struct i2c_client *i2c)
 	adcx140->phase_calib_on = false;
 	adcx140->dev = &i2c->dev;
 
+	for (int i = 0; i < ADCX140_NUM_SUPPLIES; i++)
+		adcx140->supplies[i].supply = adcx140_supply_names[i];
+
+	ret = devm_regulator_bulk_get(&i2c->dev, ADCX140_NUM_SUPPLIES,
+				 adcx140->supplies);
+	if (ret) {
+		dev_err_probe(&i2c->dev, ret, "Failed to request supplies\n");
+		return ret;
+	}
+
 	adcx140->gpio_reset = devm_gpiod_get_optional(adcx140->dev,
 						      "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(adcx140->gpio_reset))

-- 
2.47.3


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

* [PATCH v3 07/10] ASoC: dt-bindings: clarify areg-supply documentation
  2025-12-18 18:21 [PATCH v3 00/10] sound: codecs: tlv320adcx140: assorted patches Sascha Hauer
                   ` (5 preceding siblings ...)
  2025-12-18 18:22 ` [PATCH v3 06/10] ASoC: tlv320adcx140: add avdd and iovdd supply Sascha Hauer
@ 2025-12-18 18:22 ` Sascha Hauer
  2025-12-18 19:57   ` Krzysztof Kozlowski
  2025-12-18 18:22 ` [PATCH v3 08/10] ASoC: dt-bindings: add avdd and iovdd supply Sascha Hauer
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Sascha Hauer @ 2025-12-18 18:22 UTC (permalink / raw)
  To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Andrew Davis, Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree,
	Sascha Hauer, Emil-Juhl, Emil-Juhl

From: Emil-Juhl <emdj@bang-olufsen.dk>

The documentation for areg-supply could cause confusion mainly in terms
of the relationship between AREG and AVDD.
According to the datasheet[1] the AREG can be one of two cases:

1) an external 1.8V supply
2) generated by an internal regulator (hence a 1.8V output)

[1] https://www.ti.com/lit/ds/symlink/tlv320adc5140.pdf

Signed-off-by: Emil-Juhl <juhl.emildahl@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml b/Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml
index 876fa97bfbcdd3b9450aa6ff57de42f1faed350d..b34ea7824360310434d8b826392864dbfa5fc369 100644
--- a/Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml
+++ b/Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml
@@ -41,8 +41,8 @@ properties:
 
   areg-supply:
     description: |
-      Regulator with AVDD at 3.3V.  If not defined then the internal regulator
-      is enabled.
+      External supply of 1.8V. If not defined then the internal regulator is
+      enabled instead.
 
   ti,mic-bias-source:
     description: |

-- 
2.47.3


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

* [PATCH v3 08/10] ASoC: dt-bindings: add avdd and iovdd supply
  2025-12-18 18:21 [PATCH v3 00/10] sound: codecs: tlv320adcx140: assorted patches Sascha Hauer
                   ` (6 preceding siblings ...)
  2025-12-18 18:22 ` [PATCH v3 07/10] ASoC: dt-bindings: clarify areg-supply documentation Sascha Hauer
@ 2025-12-18 18:22 ` Sascha Hauer
  2025-12-18 19:57   ` Krzysztof Kozlowski
  2025-12-18 18:22 ` [PATCH v3 09/10] ASoC: tlv320adcx140: add kcontrol for num biquads Sascha Hauer
  2025-12-18 18:22 ` [PATCH v3 10/10] ASoC: tlv320adcx140: add channel sum control Sascha Hauer
  9 siblings, 1 reply; 13+ messages in thread
From: Sascha Hauer @ 2025-12-18 18:22 UTC (permalink / raw)
  To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Andrew Davis, Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree,
	Sascha Hauer

Add bindings for the avdd-supply and iovdd-supply which are named after
the corresponding pins on the tlv320adcx140 chips.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml b/Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml
index b34ea7824360310434d8b826392864dbfa5fc369..a93de2debbb45a3daebb0e24397e4893262e3a11 100644
--- a/Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml
+++ b/Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml
@@ -44,6 +44,9 @@ properties:
       External supply of 1.8V. If not defined then the internal regulator is
       enabled instead.
 
+  avdd-supply: true
+  iovdd-supply: true
+
   ti,mic-bias-source:
     description: |
       Indicates the source for MIC Bias.

-- 
2.47.3


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

* [PATCH v3 09/10] ASoC: tlv320adcx140: add kcontrol for num biquads
  2025-12-18 18:21 [PATCH v3 00/10] sound: codecs: tlv320adcx140: assorted patches Sascha Hauer
                   ` (7 preceding siblings ...)
  2025-12-18 18:22 ` [PATCH v3 08/10] ASoC: dt-bindings: add avdd and iovdd supply Sascha Hauer
@ 2025-12-18 18:22 ` Sascha Hauer
  2025-12-18 18:22 ` [PATCH v3 10/10] ASoC: tlv320adcx140: add channel sum control Sascha Hauer
  9 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2025-12-18 18:22 UTC (permalink / raw)
  To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Andrew Davis, Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree,
	Sascha Hauer, Emil-Juhl

From: Emil-Juhl <emdj@bang-olufsen.dk>

The tlv320adcx140 chips have a configurable amount of biquad filters
enabled per input channel. Currently this number is always left at the
default value of 2 biquads per channel.
This commit adds a kcontrol to allow runtime configuration of the amount
of biquads per channel.

The configuration is controlled by bits [5-6] in the DSP_CFG1 register.

Signed-off-by: Emil-Juhl <emdj@bang-olufsen.dk>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 sound/soc/codecs/tlv320adcx140.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index a7200e149e5f40ddd61e3c0455b796c81f55e2e8..e7c607af642f43b2b783597f3cba3a8cbb31de4a 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -709,6 +709,8 @@ static const struct snd_kcontrol_new adcx140_snd_controls[] = {
 	SOC_SINGLE_TLV("Digital CH8 Out Volume", ADCX140_CH8_CFG2,
 			0, 0xff, 0, dig_vol_tlv),
 	ADCX140_PHASE_CALIB_SWITCH("Phase Calibration Switch"),
+
+	SOC_SINGLE("Biquads Per Channel", ADCX140_DSP_CFG1, 5, 3, 0),
 };
 
 static int adcx140_reset(struct adcx140_priv *adcx140)

-- 
2.47.3


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

* [PATCH v3 10/10] ASoC: tlv320adcx140: add channel sum control
  2025-12-18 18:21 [PATCH v3 00/10] sound: codecs: tlv320adcx140: assorted patches Sascha Hauer
                   ` (8 preceding siblings ...)
  2025-12-18 18:22 ` [PATCH v3 09/10] ASoC: tlv320adcx140: add kcontrol for num biquads Sascha Hauer
@ 2025-12-18 18:22 ` Sascha Hauer
  9 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2025-12-18 18:22 UTC (permalink / raw)
  To: Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Andrew Davis, Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree,
	Sascha Hauer, Emil Svendsen

From: Emil Svendsen <emas@bang-olufsen.dk>

Add control for channel summation.

3 modes are supported:

1. "Disabled": Normal operation

2. "2 Channel": Every two channels are summed and divided by 2

  Out 1 <- (CH1 + CH2) / 2
  Out 2 <- (CH1 + CH2) / 2
  Out 3 <- (CH3 + CH4) / 2
  Out 4 <- (CH3 + CH4) / 2

3. "4 Channel": Every four channels are summed and divided by 4

  Out 1 <- (CH1 + CH2 + CH3 + CH4) / 4
  Out 2 <- (CH1 + CH2 + CH3 + CH4) / 4
  Out 3 <- (CH1 + CH2 + CH3 + CH4) / 4
  Out 4 <- (CH1 + CH2 + CH3 + CH4) / 4

Signed-off-by: Emil Svendsen <emas@bang-olufsen.dk>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 sound/soc/codecs/tlv320adcx140.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index e7c607af642f43b2b783597f3cba3a8cbb31de4a..ac6aab8d722409b2c47b4e1df2a23760bebe795b 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -222,6 +222,13 @@ static const struct snd_kcontrol_new decimation_filter_controls[] = {
 	SOC_DAPM_ENUM("Decimation Filter", decimation_filter_enum),
 };
 
+static const char * const channel_summation_text[] = {
+	"Disabled", "2 Channel", "4 Channel"
+};
+
+static SOC_ENUM_SINGLE_DECL(channel_summation_enum, ADCX140_DSP_CFG0, 2,
+			    channel_summation_text);
+
 static const char * const pdmclk_text[] = {
 	"2.8224 MHz", "1.4112 MHz", "705.6 kHz", "5.6448 MHz"
 };
@@ -711,6 +718,8 @@ static const struct snd_kcontrol_new adcx140_snd_controls[] = {
 	ADCX140_PHASE_CALIB_SWITCH("Phase Calibration Switch"),
 
 	SOC_SINGLE("Biquads Per Channel", ADCX140_DSP_CFG1, 5, 3, 0),
+
+	SOC_ENUM("Channel Summation", channel_summation_enum),
 };
 
 static int adcx140_reset(struct adcx140_priv *adcx140)

-- 
2.47.3


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

* Re: [PATCH v3 07/10] ASoC: dt-bindings: clarify areg-supply documentation
  2025-12-18 18:22 ` [PATCH v3 07/10] ASoC: dt-bindings: clarify areg-supply documentation Sascha Hauer
@ 2025-12-18 19:57   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2025-12-18 19:57 UTC (permalink / raw)
  To: Sascha Hauer, Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood,
	Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andrew Davis,
	Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree,
	Emil-Juhl, Emil-Juhl

On 18/12/2025 19:22, Sascha Hauer wrote:
> From: Emil-Juhl <emdj@bang-olufsen.dk>
> 
> The documentation for areg-supply could cause confusion mainly in terms
> of the relationship between AREG and AVDD.
> According to the datasheet[1] the AREG can be one of two cases:
> 
> 1) an external 1.8V supply
> 2) generated by an internal regulator (hence a 1.8V output)
> 
> [1] https://www.ti.com/lit/ds/symlink/tlv320adc5140.pdf
> 
> Signed-off-by: Emil-Juhl <juhl.emildahl@gmail.com>

Does not match from. Please use consistent identities. The SoB must not
be different than From address.

> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 


Best regards,
Krzysztof

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

* Re: [PATCH v3 08/10] ASoC: dt-bindings: add avdd and iovdd supply
  2025-12-18 18:22 ` [PATCH v3 08/10] ASoC: dt-bindings: add avdd and iovdd supply Sascha Hauer
@ 2025-12-18 19:57   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2025-12-18 19:57 UTC (permalink / raw)
  To: Sascha Hauer, Shenghao Ding, Kevin Lu, Baojun Xu, Liam Girdwood,
	Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andrew Davis,
	Dan Murphy
  Cc: linux-sound, linux-kernel, Kevin Lu, linux-rt-devel, devicetree

On 18/12/2025 19:22, Sascha Hauer wrote:
> Add bindings for the avdd-supply and iovdd-supply which are named after
> the corresponding pins on the tlv320adcx140 chips.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml | 3 +++
>  1 file changed, 3 insertions(+)


Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

Best regards,
Krzysztof

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

end of thread, other threads:[~2025-12-18 19:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-18 18:21 [PATCH v3 00/10] sound: codecs: tlv320adcx140: assorted patches Sascha Hauer
2025-12-18 18:21 ` [PATCH v3 01/10] ASoC: tlv320adcx140: invert DRE_ENABLE Sascha Hauer
2025-12-18 18:21 ` [PATCH v3 02/10] ASoC: tlv320adcx140: fix null pointer Sascha Hauer
2025-12-18 18:21 ` [PATCH v3 03/10] ASoC: tlv320adcx140: Propagate error codes during probe Sascha Hauer
2025-12-18 18:21 ` [PATCH v3 04/10] ASoC: tlv320adcx140: fix word length Sascha Hauer
2025-12-18 18:21 ` [PATCH v3 05/10] ASoC: tlv320adcx140: power on/off the device on demand Sascha Hauer
2025-12-18 18:22 ` [PATCH v3 06/10] ASoC: tlv320adcx140: add avdd and iovdd supply Sascha Hauer
2025-12-18 18:22 ` [PATCH v3 07/10] ASoC: dt-bindings: clarify areg-supply documentation Sascha Hauer
2025-12-18 19:57   ` Krzysztof Kozlowski
2025-12-18 18:22 ` [PATCH v3 08/10] ASoC: dt-bindings: add avdd and iovdd supply Sascha Hauer
2025-12-18 19:57   ` Krzysztof Kozlowski
2025-12-18 18:22 ` [PATCH v3 09/10] ASoC: tlv320adcx140: add kcontrol for num biquads Sascha Hauer
2025-12-18 18:22 ` [PATCH v3 10/10] ASoC: tlv320adcx140: add channel sum control Sascha Hauer

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