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.
Signed-off-by: Dan Murphy <[email protected]>
---
sound/soc/codecs/tlv320adcx140.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index 0f713efde046..97634e0ca0ba 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -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"},
--
2.26.2
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(+)
diff --git a/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml b/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
index ab2268c0ee67..55668c7d261d 100644
--- a/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
+++ b/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
@@ -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>;
};
};
--
2.26.2
Configure the PDM sampling edges based on the values from the firmware.
Signed-off-by: Dan Murphy <[email protected]>
---
sound/soc/codecs/tlv320adcx140.c | 22 ++++++++++++++++++++++
sound/soc/codecs/tlv320adcx140.h | 3 +++
2 files changed, 25 insertions(+)
diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index 97634e0ca0ba..140a5802a9a9 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -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;
diff --git a/sound/soc/codecs/tlv320adcx140.h b/sound/soc/codecs/tlv320adcx140.h
index 6d055e55909e..432eaf25d1a7 100644
--- a/sound/soc/codecs/tlv320adcx140.h
+++ b/sound/soc/codecs/tlv320adcx140.h
@@ -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_ */
--
2.26.2
On Wed, 13 May 2020, Dan Murphy wrote:
> 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(+)
>
> diff --git a/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
> b/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
> index ab2268c0ee67..55668c7d261d 100644
> --- a/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
> +++ b/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
> @@ -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.
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.
> +??? 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>;
Should there really be a space between < and 0 ?
/Ricard
--
Ricard Wolf Wanderlof ricardw(at)axis.com
Axis Communications AB, Lund, Sweden http://www.axis.com
Phone +46 46 272 2016 Fax +46 46 13 61 30
Richard
On 5/14/20 3:09 AM, Ricard Wanderlof wrote:
> On Wed, 13 May 2020, Dan Murphy wrote:
>
>> 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(+)
>>
>> diff --git a/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
>> b/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
>> index ab2268c0ee67..55668c7d261d 100644
>> --- a/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
>> +++ b/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml
>> @@ -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.
> 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.
>> + 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>;
> Should there really be a space between < and 0 ?
I will remove the space
Dan
>
> /Ricard
On Wed, 13 May 2020 15:05:47 -0500, Dan Murphy wrote:
> 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: 79fc48e41e39d7a98c5f8ae37f613d7ff9953c86
All 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