ASoC: tlv320adcx140: Add controls for PDM clk
PATCH v2 1/3 ASoC: tlv320adcx140: Add controls for PDM clk
Add ALSA controls to configure the PDM clocks.
The clocks need to be configurable to accommodate various microphones that use clocks for low power/low resolution modes to high power/high resolution modes.
--- sound/soc/codecs/tlv320adcx140.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
sound/soc/codecs/tlv320adcx140.c +19 -0
@@ -180,6 +180,17 @@ static const struct snd_kcontrol_new decimation_filter_controls[] = { SOC_DAPM_ENUM("Decimation Filter", decimation_filter_enum), }; +static const char *const pdmclk_text[] = { +"2.8224 MHz" ,"1.4112 MHz" ,"705.6 kHz" ,"5.6448 MHz" +}; + +static SOC_ENUM_SINGLE_DECL(pdmclk_select_enum, ADCX140_PDMCLK_CFG, 0, + pdmclk_text); + +static const struct snd_kcontrol_new pdmclk_div_controls[] = { +SOC_DAPM_ENUM ("PDM Clk Divider Select" , pdmclk_select_enum), +}; +static const char *const resistor_text[] = {"2.5 kOhm" ,"10 kOhm" ,"20 kOhm" };
@@ -416,6 +427,9 @@ static const struct snd_soc_dapm_widget adcx140_dapm_widgets[] = {SND_SOC_DAPM_MUX ("IN4 Analog Mic Resistor" ,SND_SOC_NOPM ,0 ,0 , in4_resistor_controls), +SND_SOC_DAPM_MUX ("PDM Clk Div Select" ,SND_SOC_NOPM ,0 ,0 , + pdmclk_div_controls), +SND_SOC_DAPM_MUX ("Decimation Filter" ,SND_SOC_NOPM ,0 ,0 , decimation_filter_controls), };
@@ -493,6 +507,11 @@ static const struct snd_soc_dapm_route adcx140_audio_map[] = { {"IN4 Analog Mic Resistor", "10 kOhm", "MIC4M Input Mux"}, {"IN4 Analog Mic Resistor", "20 kOhm", "MIC4M Input Mux"}, + {"PDM Clk Div Select", "2.8224 MHz", "MIC1P Input Mux"}, + {"PDM Clk Div Select", "1.4112 MHz", "MIC1P Input Mux"}, + {"PDM Clk Div Select", "705.6 kHz", "MIC1P Input Mux"}, + {"PDM Clk Div Select", "5.6448 MHz", "MIC1P Input Mux"}, + {"MIC1 Analog Mux", "Line In", "MIC1P"}, {"MIC2 Analog Mux", "Line In", "MIC2P"}, {"MIC3 Analog Mux", "Line In", "MIC3P"},
Signature · 1 line
2.26.2
PATCH v2 2/3 ASoC: tlv320adcx140: Add device tree property for PDM edges
Add a device tree property to configure the PDM sampling edge for each digital microphone.
--- .../devicetree/bindings/sound/tlv320adcx140.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/sound/tlv320adcx140.yaml +14 -0
@@ -63,6 +63,19 @@ properties: - $ref: /schemas/types.yaml#/definitions/uint32 - enum: [0, 1, 2] + ti,pdm-edge-select: + description: | + Defines the sampling edge configuration for the PDM inputs. This is an + array defined as <PDMIN1 PDMIN2 PDMIN3 PDMIN4>. 0 (default) is negative + sampling edge and 1 is positive sampling edge. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - minItems: 1 + maxItems: 4 + items: + maximum: 1 + default: [0, 0, 0, 0] + required: - compatible - reg
@@ -77,6 +90,7 @@ examples: compatible = "ti,tlv320adc5140"; reg = <0x4c>; ti,mic-bias-source = <6>; + ti,pdm-edge-select = < 0 1 0 1>; reset-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>; }; };
Signature · 1 line
2.26.2
PATCH v2 3/3 ASoC: tlv320adcx140: Configure PDM sampling edge
In reply to Dan MurphyConfigure the PDM sampling edges based on the values from the firmware.
--- sound/soc/codecs/tlv320adcx140.c | 22 ++++++++++++++++++++++ sound/soc/codecs/tlv320adcx140.h | 3 +++ 2 files changed, 25 insertions(+)
sound/soc/codecs/tlv320adcx140.c +22 -0
@@ -760,6 +760,10 @@ static int adcx140_codec_probe(struct snd_soc_component *component)int sleep_cfg_val =ADCX140_WAKE_DEV ;u8 bias_source;u8 vref_source; +int pdm_count; +u32 pdm_edges[ADCX140_NUM_PDM_EDGES ]; +u32 pdm_edge_val =0 ; +int i;int ret; ret = device_property_read_u8(adcx140->dev, "ti,mic-bias-source",
@@ -786,6 +790,24 @@ static int adcx140_codec_probe(struct snd_soc_component *component) bias_source |= vref_source; + pdm_count =device_property_count_u32 (adcx140->dev, +"ti,pdm-edge-select" ); +if (pdm_count <=ADCX140_NUM_PDM_EDGES && pdm_count >0 ) { + ret =device_property_read_u32_array (adcx140->dev, +"ti,pdm-edge-select" , + pdm_edges, pdm_count); +if (ret) +return ret; + +for (i =0 ; i < pdm_count; i++) + pdm_edge_val |= pdm_edges[i] << (ADCX140_PDM_EDGE_SHIFT - i); + + ret =regmap_write (adcx140->regmap,ADCX140_PDM_CFG , + pdm_edge_val); +if (ret) +return ret; + } + ret =adcx140_reset (adcx140);if (ret) goto out;
sound/soc/codecs/tlv320adcx140.h +3 -0
@@ -128,4 +128,7 @@#define ADCX140_TX_OFFSET_MASK GENMASK(4, 0) +#define ADCX140_NUM_PDM_EDGES 4 +#define ADCX140_PDM_EDGE_SHIFT 7 +#endif /* _TLV320ADCX140_ */
Signature · 1 line
2.26.2
Re: [PATCH v2 2/3] ASoC: tlv320adcx140: Add device tree property for PDM edges
In reply to Dan MurphyQuoted 17 lines · Dan Murphy
Add a device tree property to configure the PDM sampling edge for each digital microphone.
CC Rob Herring <[email protected]>Signed-off-by Dan Murphy <[email protected]>---
.../devicetree/bindings/sound/tlv320adcx140.yaml | 14 ++++++++++++++1 file changed, 14 insertions(+)Documentation/devicetree/bindings/sound/tlv320adcx140.yaml +0
-0@@ -63,6 +63,19 @@ properties:- $ref: /schemas/types.yaml#/definitions/uint32
- enum: [0, 1, 2]
Quoted 8 lines
+ ti,pdm-edge-select:
+ description: |
+ Defines the sampling edge configuration for the PDM inputs. This is an
+ array defined as <PDMIN1 PDMIN2 PDMIN3 PDMIN4>. 0 (default) is negative
+ sampling edge and 1 is positive sampling edge.
A bit of a nitpick, but I would think of the edges as negative-going/positive-going, or rising/falling. Not sure if anyone would misunderstand 'negative edge' in practice though.
Quoted 12 lines
+ allOf:
+ - $ref: /schemas/types.yaml#/definitions/uint32-array + - minItems: 1
+ maxItems: 4
+ items:
+ maximum: 1
+ default: [0, 0, 0, 0]
+
required:
- compatible
- reg
Documentation/devicetree/bindings/sound/tlv320adcx140.yaml examples: · line 93
Quoted 4 lines
Documentation/devicetree/bindings/sound/tlv320adcx140.yaml +1
-0@@ -77,6 +90,7 @@ examples: compatible = "ti,tlv320adc5140"; reg = <0x4c>; ti,mic-bias-source = <6>; + ti,pdm-edge-select = < 0 1 0 1>;
Should there really be a space between < and 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 v2 2/3] ASoC: tlv320adcx140: Add device tree property for PDM edges
Richard
Quoted 20 lines · Ricard Wanderlof
Quoted 18 lines · Dan Murphy
Add a device tree property to configure the PDM sampling edge for each digital microphone.
CC Rob Herring <[email protected]>Signed-off-by Dan Murphy <[email protected]>--- .../devicetree/bindings/sound/tlv320adcx140.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+)Documentation/devicetree/bindings/sound/tlv320adcx140.yaml +0
-0@@ -63,6 +63,19 @@ properties: - $ref: /schemas/types.yaml#/definitions/uint32 - enum: [0, 1, 2]
Quoted 10 lines
Quoted 7 lines
Documentation/devicetree/bindings/sound/tlv320adcx140.yaml +3
-0+ ti,pdm-edge-select: + description: | + Defines the sampling edge configuration for the PDM inputs. This isan
+ array defined as <PDMIN1 PDMIN2 PDMIN3 PDMIN4>. 0 (default) is negative
+ sampling edge and 1 is positive sampling edge.A bit of a nitpick, but I would think of the edges as negative-going/positive-going, or rising/falling. Not sure if anyone would misunderstand 'negative edge' in practice though.
I will re-write the description to be more descriptive.
Quoted 9 lines
Quoted 9 lines
+ allOf:
+ - $ref: /schemas/types.yaml#/definitions/uint32-array + - minItems: 1
+ maxItems: 4
+ items:
+ maximum: 1
+ default: [0, 0, 0, 0]
+
required:
Quoted 8 lines
Documentation/devicetree/bindings/sound/tlv320adcx140.yaml examples: · line 93
Quoted 7 lines
- compatible
- regDocumentation/devicetree/bindings/sound/tlv320adcx140.yaml +1
-0@@ -77,6 +90,7 @@ examples: compatible = "ti,tlv320adc5140"; reg = <0x4c>; ti,mic-bias-source = <6>; + ti,pdm-edge-select = < 0 1 0 1>;Should there really be a space between < and 0 ?
I will remove the space
Dan
Quoted 2 lines
/Ricard
Mark Brown
maintainerQuoted 4 lines · Dan Murphy
Add ALSA controls to configure the PDM clocks.
The clocks need to be configurable to accommodate various microphones that use clocks for low power/low resolution modes to high power/high resolution modes.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.8
Thanks!
[1/3] ASoC: tlv320adcx140: Add controls for PDM clk
commit: 7cfa610205d95357f9eface292dc70fce7571f65
[2/3] ASoC: tlv320adcx140: Add device tree property for PDM edges
commit: 75b0adbb0806a141b0b5f074cd6bd58bb9870c0d
[3/3] ASoC: tlv320adcx140: Configure PDM sampling edge
commit: 79fc48e41e39d7a98c5f8ae37f613d7ff9953c86All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark