Skip to contentSkip to conversation

dt-bindings: sound: Add TLV320ADCx140 dt bindings

PATCH Superseded Dan Murphy 2 participants 4 messages Feb 7, 2020 – Feb 11, 2020

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
author
#1 lore raw

PATCH 2/2 ASoC: tlv320adcx140: Add the tlv320adcx140 codec driver family

In reply to Dan Murphy

Add the tlv320adcx140 codec driver family.

The TLV320ADCx140 is a Burr-Brown™ highperformance, audio analog-to-digital converter (ADC) that supports simultaneous sampling of up to four analog channels or eight digital channels for the pulse density modulation (PDM)
microphone input. The device supports line and microphone inputs, and
allows for both single-ended and differential input configurations.

---
 sound/soc/codecs/Kconfig         |   9 +
 sound/soc/codecs/Makefile        |   2 +
 sound/soc/codecs/tlv320adcx140.c | 783 +++++++++++++++++++++++++++++++
 sound/soc/codecs/tlv320adcx140.h | 123 +++++
 4 files changed, 917 insertions(+)
 create mode 100644 sound/soc/codecs/tlv320adcx140.c
 create mode 100644 sound/soc/codecs/tlv320adcx140.h
sound/soc/codecs/Kconfig +9 -0
index 7e90f5d83097..69019402c21a 100644
@@ -205,6 +205,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_TLV320AIC3X if I2C
 	select SND_SOC_TPA6130A2 if I2C
 	select SND_SOC_TLV320DAC33 if I2C
+	select SND_SOC_TLV320ADCX140 if I2C
 	select SND_SOC_TSCS42XX if I2C
 	select SND_SOC_TSCS454 if I2C
 	select SND_SOC_TS3A227E if I2C
@@ -1282,6 +1283,14 @@ config SND_SOC_TLV320AIC3X
 config SND_SOC_TLV320DAC33
 	tristate
 
+config SND_SOC_TLV320ADCX140
+	tristate "Texas Instruments TLV320ADCX140 CODEC family"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Add support for Texas Instruments tlv320adc3140, tlv320adc5140 and
+	  tlv320adc6140 quad channel ADCs.
+
 config SND_SOC_TS3A227E
 	tristate "TI Headset/Mic detect and keypress chip"
 	depends on I2C
sound/soc/codecs/Makefile +2 -0
index ba1b4b3fa2da..943ebc93fbc1 100644
@@ -218,6 +218,7 @@ snd-soc-tlv320aic32x4-i2c-objs := tlv320aic32x4-i2c.o
 snd-soc-tlv320aic32x4-spi-objs := tlv320aic32x4-spi.o
 snd-soc-tlv320aic3x-objs := tlv320aic3x.o
 snd-soc-tlv320dac33-objs := tlv320dac33.o
+snd-soc-tlv320adcx140-objs := tlv320adcx140.o
 snd-soc-tscs42xx-objs := tscs42xx.o
 snd-soc-tscs454-objs := tscs454.o
 snd-soc-ts3a227e-objs := ts3a227e.o
@@ -516,6 +517,7 @@ obj-$(CONFIG_SND_SOC_TLV320AIC32X4_I2C)	+= snd-soc-tlv320aic32x4-i2c.o
 obj-$(CONFIG_SND_SOC_TLV320AIC32X4_SPI)	+= snd-soc-tlv320aic32x4-spi.o
 obj-$(CONFIG_SND_SOC_TLV320AIC3X)	+= snd-soc-tlv320aic3x.o
 obj-$(CONFIG_SND_SOC_TLV320DAC33)	+= snd-soc-tlv320dac33.o
+obj-$(CONFIG_SND_SOC_TLV320ADCX140)	+= snd-soc-tlv320adcx140.o
 obj-$(CONFIG_SND_SOC_TSCS42XX)	+= snd-soc-tscs42xx.o
 obj-$(CONFIG_SND_SOC_TSCS454)	+= snd-soc-tscs454.o
 obj-$(CONFIG_SND_SOC_TS3A227E)	+= snd-soc-ts3a227e.o
sound/soc/codecs/tlv320adcx140.c new file +783 -0

783 lines not on this page · raw message

sound/soc/codecs/tlv320adcx140.h new file +123 -0

123 lines not on this page · raw message

Signature · 1 line
2.25.0

Dan Murphy

author
#0 lore raw

PATCH 1/2 dt-bindings: sound: Add TLV320ADCx140 dt bindings

Add dt bindings for the TLV320ADCx140 Burr-Brown ADC. The initial support is for the following:

TLV320ADC3140 - http://www.ti.com/lit/gpn/tlv320adc3140
TLV320ADC5140 - http://www.ti.com/lit/gpn/tlv320adc5140
TLV320ADC6140 - http://www.ti.com/lit/gpn/tlv320adc6140

---
 .../bindings/sound/tlv320adcx140.yaml         | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
Documentation/devicetree/bindings/sound/tlv320adcx140.yaml new file +73 -0
new file mode 100644
index 000000000000..84c407fae21e
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0+ OR BSD-2-Clause)
+# Copyright (C) 2019 Texas Instruments Incorporated
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/tlv320adcx140.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments TLV320ADCX140 Quad Channel Analog-to-Digital Converter
+
+maintainers:
+  - Dan Murphy <[email protected]>
+
+description: |
+  The TLV320ADCX140 are multichannel (4-ch analog recording or 8-ch digital
+  PDM microphones recording), high-performance audio, analog-to-digital
+  converter (ADC) with analog inputs supporting up to 2V RMS. The TLV320ADCX140
+  family supports line and  microphone Inputs, and offers a programmable
+  microphone bias or supply voltage generation.
+
+  Specifications can be found at:
+    http://www.ti.com/lit/ds/symlink/tlv320adc3140.pdf
+    http://www.ti.com/lit/ds/symlink/tlv320adc5140.pdf
+    http://www.ti.com/lit/ds/symlink/tlv320adc6140.pdf
+
+properties:
+  compatible:
+    oneOf:
+      - const: ti,tlv320adc3140
+      - const: ti,tlv320adc5140
+      - const: ti,tlv320adc6140
+
+  reg:
+    maxItems: 1
+    description: |
+       I2C addresss of the device can be one of these 0x4c, 0x4d, 0x4e or 0x4f
+
+  reset-gpios:
+    description: |
+       GPIO used for hardware reset.
+
+  ti,use-internal-areg:
+    type: boolean
+    description: |
+       Internal Regulator with AVDD at 3.3V.
+
+  ti,mic-bias-source:
+    description: |
+       Indicates the source for MIC Bias.
+       0 - Mic bias is set to VREF
+       1 - Mic bias is set to VREF × 1.096
+       6 - Mic bias is set to AVDD
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+      - enum: [0, 1, 6]
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c0 {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      codec: codec@4c {
+        compatible = "ti,tlv320adc5140";
+        reg = <0x4c>;
+        ti,use-internal-areg;
+        ti,mic-bias-source = <6>;
+        reset-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
+      };
+    };
Signature · 1 line
2.25.0
maintainer
#2 lore raw

Re: [PATCH 2/2] ASoC: tlv320adcx140: Add the tlv320adcx140 codec driver family

In reply to Dan Murphy

sound/soc/codecs/tlv320adcx140.c line 572

Quoted 11 lines · Dan Murphy
sound/soc/codecs/tlv320adcx140.c new file +11 -0
+	/* interface format */
+	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+	case SND_SOC_DAIFMT_I2S:
+		iface_reg1 |= ADCX140_I2S_MODE_BIT;
+		break;
+	case SND_SOC_DAIFMT_LEFT_J:
+		iface_reg1 |= ADCX140_LEFT_JUST_BIT;
+		break;
+	case SND_SOC_DAIFMT_DSP_A:
+	case SND_SOC_DAIFMT_DSP_B:
+		break;

_DSP_A and _DSP_B are two different format so I'd expect the device to be configured differently for them, or for only one to be supported.

sound/soc/codecs/tlv320adcx140.c line 600

Quoted 13 lines
sound/soc/codecs/tlv320adcx140.c new file +13 -0
+static int adcx140_mute(struct snd_soc_dai *codec_dai, int mute)
+{
+	struct snd_soc_component *component = codec_dai->component;
+	int config_reg;
+	int mic_enable;
+	int i;
+
+	/* There is not a single register to mute.  Each enabled path has to be
+	 * muted individually.  Read which path is enabled and mute it.
+	 */
+	snd_soc_component_read(component, ADCX140_IN_CH_EN, &mic_enable);
+	if (!mic_enable)
+		return 0;

You could also just offer this control to userspace, it's not *essential* to have this operation though it can help with glitching during stream startup.

sound/soc/codecs/tlv320adcx140.c line 609

Quoted 9 lines
sound/soc/codecs/tlv320adcx140.c new file +9 -0
+
+	for (i = 0; i < ADCX140_MAX_CHANNELS; i++) {
+		config_reg = ADCX140_CH8_CFG2 - (5 * i);
+		if (!(mic_enable & BIT(i)))
+			continue;
+
+		if (mute)
+			snd_soc_component_write(component, config_reg, 0);
+	}

How does the unmute work?

sound/soc/codecs/tlv320adcx140.c line 631

Quoted 5 lines
sound/soc/codecs/tlv320adcx140.c new file +5 -0
+	internal_reg = device_property_present(adcx140->dev,
+					       "ti,use-internal-areg");
+
+	if (internal_reg)
+		sleep_cfg_val |= ADCX140_AREG_INTERNAL;

Does this actually need a specific property or could you support the regulator API and then use regulator_get_optional() to figure out if an external AVDD is attached?

sound/soc/codecs/tlv320adcx140.c line 671

Quoted 6 lines
sound/soc/codecs/tlv320adcx140.c new file +6 -0
+static int adcx140_codec_probe(struct snd_soc_component *component)
+{
+	struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component);
+
+	return adc5410_init(adcx140);
+}

Does the separate init function buy us anything?

author
#3 lore raw

Re: [PATCH 2/2] ASoC: tlv320adcx140: Add the tlv320adcx140 codec driver family

Mark

Thanks for the review

Quoted 15 lines · Mark Brown

sound/soc/codecs/tlv320adcx140.c line 572

Quoted 11 lines · Dan Murphy
sound/soc/codecs/tlv320adcx140.c new file +11 -0
+	/* interface format */
+	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+	case SND_SOC_DAIFMT_I2S:
+		iface_reg1 |= ADCX140_I2S_MODE_BIT;
+		break;
+	case SND_SOC_DAIFMT_LEFT_J:
+		iface_reg1 |= ADCX140_LEFT_JUST_BIT;
+		break;
+	case SND_SOC_DAIFMT_DSP_A:
+	case SND_SOC_DAIFMT_DSP_B:
+		break;

_DSP_A and _DSP_B are two different format so I'd expect the device to be configured differently for them, or for only one to be supported.

Ack.  I will need to adjust the TX offset for these.  I will do add a prepare call back and set the offset there.  These can fall through since TDM is default.

Quoted 18 lines
Quoted 4 lines
sound/soc/codecs/tlv320adcx140.c new file +3 -0
+static int adcx140_mute(struct snd_soc_dai *codec_dai, int mute)
+{
+	struct snd_soc_component *component = codec_dai->component;

sound/soc/codecs/tlv320adcx140.c line 600

Quoted 10 lines
sound/soc/codecs/tlv320adcx140.c new file +10 -0
+	int config_reg;
+	int mic_enable;
+	int i;
+
+	/* There is not a single register to mute.  Each enabled path has to be
+	 * muted individually.  Read which path is enabled and mute it.
+	 */
+	snd_soc_component_read(component, ADCX140_IN_CH_EN, &mic_enable);
+	if (!mic_enable)
+		return 0;

You could also just offer this control to userspace, it's not *essential* to have this operation though it can help with glitching during stream startup.

Quoted 10 lines

sound/soc/codecs/tlv320adcx140.c line 609

Quoted 9 lines
sound/soc/codecs/tlv320adcx140.c new file +9 -0
+
+	for (i = 0; i < ADCX140_MAX_CHANNELS; i++) {
+		config_reg = ADCX140_CH8_CFG2 - (5 * i);
+		if (!(mic_enable & BIT(i)))
+			continue;
+
+		if (mute)
+			snd_soc_component_write(component, config_reg, 0);
+	}

How does the unmute work?

This is unmuted through volume control.  I can remove this as the device is muted when the volume register is set to 0.  That will force the user to have to set a volume.

Quoted 9 lines

sound/soc/codecs/tlv320adcx140.c line 631

Quoted 6 lines
sound/soc/codecs/tlv320adcx140.c new file +5 -0
+	internal_reg = device_property_present(adcx140->dev,
+					       "ti,use-internal-areg");
+
+	if (internal_reg)
+		sleep_cfg_val |= ADCX140_AREG_INTERNAL;

Does this actually need a specific property or could you support the regulator API and then use regulator_get_optional() to figure out if an external AVDD is attached?

Yes we could set internal AREG bit if no supply is given.

Quoted 8 lines

sound/soc/codecs/tlv320adcx140.c line 671

Quoted 7 lines
sound/soc/codecs/tlv320adcx140.c new file +6 -0
+static int adcx140_codec_probe(struct snd_soc_component *component)
+{
+	struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component);
+
+	return adc5410_init(adcx140);
+}

Does the separate init function buy us anything?

No that is an artifact of my development I can move everything to codec_probe

Dan