Introduce the TLV320ADCx140 codec family
v3 cover Introduce the TLV320ADCx140 codec family
Hello
Introducing the Texas Instruments TLV320ADCx140 quad channel audio ADC. This device supports 4 analog inputs, 8 digital inputs or a combination of analog and digital microphones.
TLV320ADC3140 - http://www.ti.com/lit/gpn/tlv320adc3140
TLV320ADC5140 - http://www.ti.com/lit/gpn/tlv320adc5140
TLV320ADC6140 - http://www.ti.com/lit/gpn/tlv320adc6140
Dan Murphy (2):
dt-bindings: sound: Add TLV320ADCx140 dt bindings
ASoC: tlv320adcx140: Add the tlv320adcx140 codec driver family
.../bindings/sound/tlv320adcx140.yaml | 83 ++ sound/soc/codecs/Kconfig | 9 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tlv320adcx140.c | 849 ++++++++++++++++++ sound/soc/codecs/tlv320adcx140.h | 130 +++ 5 files changed, 1073 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/tlv320adcx140.yaml create mode 100644 sound/soc/codecs/tlv320adcx140.c create mode 100644 sound/soc/codecs/tlv320adcx140.h
Signature · 1 line
2.25.0
PATCH v3 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
---
v3 - No changes
.../bindings/sound/tlv320adcx140.yaml | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
Documentation/devicetree/bindings/sound/tlv320adcx140.yaml new file +83 -0
@@ -0,0 +1,83 @@ +# 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. + + areg-supply: + description: | + Regulator with AVDD at 3.3V. If not defined then the internal regulator + is enabled. + + 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] + + ti,vref-source: + description: | + Indicates the source for MIC Bias. + 0 - Set VREF to 2.75V + 1 - Set VREF to 2.5V + 2 - Set VREF to 1.375V + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - enum: [0, 1, 2] + +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
PATCH v3 2/2 ASoC: tlv320adcx140: Add the tlv320adcx140 codec driver family
In reply to Dan MurphyAdd 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.
---
v3 - Moved regulator get to i2c probe and removed unlikely check in tdm_slot
sound/soc/codecs/Kconfig | 9 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tlv320adcx140.c | 849 +++++++++++++++++++++++++++++++ sound/soc/codecs/tlv320adcx140.h | 130 +++++ 4 files changed, 990 insertions(+) create mode 100644 sound/soc/codecs/tlv320adcx140.c create mode 100644 sound/soc/codecs/tlv320adcx140.h
sound/soc/codecs/Kconfig +9 -0
@@ -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
@@ -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 +849 -0
849 lines not on this page · raw message
sound/soc/codecs/tlv320adcx140.h new file +130 -0
130 lines not on this page · raw message
Signature · 1 line
2.25.0
Mark Brown
maintainerRe: [PATCH v3 2/2] ASoC: tlv320adcx140: Add the tlv320adcx140 codec driver family
Quoted 5 lines · 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)
This doesn't apply against current code, please check and resend.
Re: [PATCH v3 2/2] ASoC: tlv320adcx140: Add the tlv320adcx140 codec driver family
Mark
Quoted 7 lines · Mark Brown
Quoted 5 lines · 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)
This doesn't apply against current code, please check and resend.
Ok this is against linux master should this be against your for-next branch?
Dan
Mark Brown
maintainerRe: [PATCH v3 2/2] ASoC: tlv320adcx140: Add the tlv320adcx140 codec driver family
Quoted 5 lines · Dan Murphy
Quoted 1 line · Mark Brown
This doesn't apply against current code, please check and resend.
Ok this is against linux master should this be against your for-next branch?
Yes, everything except bugfixes should be against the current development tree (in general things should apply on the tree they're targetting).
Re: [PATCH v3 2/2] ASoC: tlv320adcx140: Add the tlv320adcx140 codec driver family
In reply to Dan MurphyQuoted 2 lines · Dan Murphy
Add the tlv320adcx140 codec driver family.
...
Quoted 6 lines
sound/soc/codecs/tlv320adcx140.c new file +6
-0+ +static int adcx140_set_dai_fmt (struct snd_soc_dai *codec_dai, + unsigned int fmt) +{ + struct snd_soc_component *component = codec_dai->component; + struct adcx140_priv *adcx140 =
Quoted 8 lines
snd_soc_component_get_drvdata(component);
+ u8iface_reg1= 0;
+ u8iface_reg2= 0;
+
+ /* set master/slave audio interface */ + switch (fmt &SND_SOC_DAIFMT_MASTER_MASK) { + caseSND_SOC_DAIFMT_CBM_CFM:
+iface_reg2|=ADCX140_BCLK_FSYNC_MASTER;
Although this sets up the codec to be I2S master, there doesn't seem to be a way of actually configuring the master clock frequency in master mode, as there is no .set_sysclk member in adcx140_dai_ops (and the corresponding register field appears never to be touched by the driver).
Quoted 9 lines
+ break;
+ caseSND_SOC_DAIFMT_CBS_CFS:
+ break;
+ caseSND_SOC_DAIFMT_CBS_CFM:
+ caseSND_SOC_DAIFMT_CBM_CFS:
+ default:
+dev_err(component->dev, "Invalid DAI master/slave interface\n"); + return-EINVAL;
+ }
...
Quoted 20 lines
sound/soc/codecs/tlv320adcx140.c new file +4
-0+ +static int adcx140_codec_probe (struct snd_soc_component *component) +{ + struct adcx140_priv *adcx140 =
snd_soc_component_get_drvdata(component);
+ intsleep_cfg_val=ADCX140_WAKE_DEV;
+ u8bias_source;
+ u8vref_source;
+ int ret;sound/soc/codecs/tlv320adcx140.c new file +11
-0+ + ret = device_property_read_u8(adcx140->dev, "ti,mic-bias-source", + &bias_source); + if (ret) + bias_source = ADCX140_MIC_BIAS_VAL_VREF; + + if (bias_source != ADCX140_MIC_BIAS_VAL_VREF && + bias_source != ADCX140_MIC_BIAS_VAL_VREF_1096 && + bias_source != ADCX140_MIC_BIAS_VAL_AVDD) { + dev_err(adcx140->dev, "Mic Bias source value is invalid\n"); + return -EINVAL;
sound/soc/codecs/tlv320adcx140.c line 692
Quoted 10 lines
sound/soc/codecs/tlv320adcx140.c new file +10
-0+ } + + ret = device_property_read_u8(adcx140->dev, "ti,vref-source", + &vref_source); + if (ret) + vref_source = ADCX140_MIC_BIAS_VREF_275V; + + if (vref_source != ADCX140_MIC_BIAS_VREF_275V && + vref_source != ADCX140_MIC_BIAS_VREF_25V && + vref_source != ADCX140_MIC_BIAS_VREF_1375V) {
According to the data sheet, this setting controls the ADC full scale setting and has nothing to do with the mic bias voltage, hence using MIC_BIAS as part of the macro name is misleaading.
Quoted 1 line
+
dev_err(adcx140->dev, "Mic Bias source value is invalid\n");
Error text does not reflect the actual error, suggest "VREF value is invalid".
Quoted 13 lines
+ return
-EINVAL;
+ }sound/soc/codecs/tlv320adcx140.c new file +11
-0+ + bias_source |= vref_source; + + ret = adcx140_reset(adcx140); + if (ret) + goto out; + + if(adcx140->supply_areg == NULL) + sleep_cfg_val |= ADCX140_AREG_INTERNAL; + + ret = regmap_write(adcx140->regmap, ADCX140_SLEEP_CFG,
Quoted 11 lines
sleep_cfg_val);
+ if (ret) {
+dev_err(adcx140->dev, "setting sleep config failed %d\n", ret);
+ goto out;
+ }
--
2.25.0
/Ricard
Signature · 3 lines
Ricard Wolf Wanderlof ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30
Re: [PATCH v3 2/2] ASoC: tlv320adcx140: Add the tlv320adcx140 codec driver family
Richard
Quoted 16 lines · Ricard Wanderlof
Quoted 2 lines · Dan Murphy
Add the tlv320adcx140 codec driver family.
...
Quoted 10 lines
sound/soc/codecs/tlv320adcx140.c new file +6
-0+ +static int adcx140_set_dai_fmt (struct snd_soc_dai *codec_dai, + unsigned int fmt) +{ + struct snd_soc_component *component = codec_dai->component; + struct adcx140_priv *adcx140 =
snd_soc_component_get_drvdata(component);
+ u8iface_reg1= 0;
+ u8iface_reg2= 0;
+
Quoted 8 lines
Quoted 4 lines
+ /* set master/slave audio interface */ + switch (fmt &
SND_SOC_DAIFMT_MASTER_MASK) { + caseSND_SOC_DAIFMT_CBM_CFM:
+iface_reg2|=ADCX140_BCLK_FSYNC_MASTER;Although this sets up the codec to be I2S master, there doesn't seem to be a way of actually configuring the master clock frequency in master mode, as there is no .set_sysclk member in
adcx140_dai_ops(and the corresponding register field appears never to be touched by the driver).
Thanks for the comments. The driver was written for the device to be in slave mode with auto clock configuration set.
I will look into adding the master mode clock settings.
Quoted 37 lines
Quoted 10 lines
+ break;
+ caseSND_SOC_DAIFMT_CBS_CFS:
+ break;
+ caseSND_SOC_DAIFMT_CBS_CFM:
+ caseSND_SOC_DAIFMT_CBM_CFS:
+ default:
+dev_err(component->dev, "Invalid DAI master/slave interface\n"); + return-EINVAL;
+ }...
Quoted 25 lines
sound/soc/codecs/tlv320adcx140.c new file +4
-0+ +static int adcx140_codec_probe (struct snd_soc_component *component) +{ + struct adcx140_priv *adcx140 =
snd_soc_component_get_drvdata(component);
+ intsleep_cfg_val=ADCX140_WAKE_DEV;
+ u8bias_source;
+ u8vref_source;
+ int ret;sound/soc/codecs/tlv320adcx140.c new file +16
-0+ + ret = device_property_read_u8(adcx140->dev, "ti,mic-bias-source", + &bias_source); + if (ret) + bias_source = ADCX140_MIC_BIAS_VAL_VREF; + + if (bias_source != ADCX140_MIC_BIAS_VAL_VREF && + bias_source != ADCX140_MIC_BIAS_VAL_VREF_1096 && + bias_source != ADCX140_MIC_BIAS_VAL_AVDD) { + dev_err(adcx140->dev, "Mic Bias source value is invalid\n"); + return -EINVAL; + } + + ret = device_property_read_u8(adcx140->dev, "ti,vref-source", + &vref_source); + if (ret)
Quoted 9 lines
Quoted 5 lines
+
vref_source=ADCX140_MIC_BIAS_VREF_275V; +
+ if (vref_source!=ADCX140_MIC_BIAS_VREF_275V&& +vref_source!=ADCX140_MIC_BIAS_VREF_25V&& +vref_source!=ADCX140_MIC_BIAS_VREF_1375V) {According to the data sheet, this setting controls the ADC full scale setting and has nothing to do with the mic bias voltage, hence using
MIC_BIASas part of the macro name is misleaading.
These are not macros they are #defines but in any event I can change the names as they are all local to the c and h files.
Quoted 3 lines
Quoted 1 line
+
dev_err(adcx140->dev, "Mic Bias source value is invalid\n");Error text does not reflect the actual error, suggest "VREF value is invalid".
Ack
Dan
Hello
Quoted 9 lines · Dan Murphy
Hello
Introducing the Texas Instruments TLV320ADCx140 quad channel audio ADC. This device supports 4 analog inputs, 8 digital inputs or a combination of analog and digital microphones.
TLV320ADC3140 - http://www.ti.com/lit/gpn/tlv320adc3140
TLV320ADC5140 - http://www.ti.com/lit/gpn/tlv320adc5140
TLV320ADC6140 - http://www.ti.com/lit/gpn/tlv320adc6140
Please let me know if there are any additional review comments on this code I have 2 more feature add patches on top of this patch that I developed a couple days ago and don't want to submit them for review until this driver is integrated.
Dan
Mark Brown
maintainerQuoted 10 lines · Dan Murphy
Quoted 3 lines · Dan Murphy
TLV320ADC3140 - http://www.ti.com/lit/gpn/tlv320adc3140
TLV320ADC5140 - http://www.ti.com/lit/gpn/tlv320adc5140
TLV320ADC6140 - http://www.ti.com/lit/gpn/tlv320adc6140Please let me know if there are any additional review comments on this code I have 2 more feature add patches on top of this patch that I developed a couple days ago and don't want to submit them for review until this driver is integrated.
You posted this just a bit over 24 hours ago...