Add driver for SAMA7G5's PDMC
Subsystems (7)
v2 cover Add driver for SAMA7G5's PDMC
This patch series adds support for Pulse Density Microphone Controller (PDMC), present on Microchip's SAMA7G5.
The PDMC interfaces up to 4 digital microphones having Pulse Density Modulated (PDM) outputs. It generates a single clock line and samples 1 or 2 data lines. The signal path includes an audio grade programmable decimation filter and outputs 24-bit audio words.
The source of each channel can be independently defined as PDMC_DS0 or PDMC_DS1, sampled at the rising or falling edge of PDMC_CLK.
The patch series starts with a fix on the ASoC DMA engine support. Then continues with the bindings and the driver of PDMC. It is followed by the DT nodes for SAMA7G5 and SAMA7G5-EK. In the end, the drivers for PDMC and PDM microphones are enabled in sama7_defconfig.
Changes in v2:
- addressed comments from Krzysztof Kozlowski
Codrin Ciubotariu (6):
ASoC: dmaengine: do not use a NULL prepare_slave_config() callback
ASoC: dt-bindings: Document Microchip's PDMC
ASoC: atmel: mchp-pdmc: add PDMC driver
ARM: dts: at91: sama7g5: add nodes for PDMC
ARM: dts: at91: sama7g5ek: add node for PDMC0
ARM: configs: at91: sama7_defconfig: add MCHP PDMC and DMIC drivers
.../bindings/sound/microchip,pdmc.yaml | 99 ++ arch/arm/boot/dts/at91-sama7g5ek.dts | 21 +- arch/arm/boot/dts/sama7g5.dtsi | 24 + arch/arm/configs/sama7_defconfig | 2 + include/dt-bindings/sound/microchip,pdmc.h | 13 + sound/soc/atmel/Kconfig | 16 + sound/soc/atmel/Makefile | 2 + sound/soc/atmel/mchp-pdmc.c | 1084 +++++++++++++++++ sound/soc/soc-generic-dmaengine-pcm.c | 6 +- 9 files changed, 1263 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/microchip,pdmc.yaml create mode 100644 include/dt-bindings/sound/microchip,pdmc.h create mode 100644 sound/soc/atmel/mchp-pdmc.c
Signature · 1 line
2.32.0
PATCH v2 1/6 ASoC: dmaengine: do not use a NULL prepare_slave_config() callback
Even if struct snd_dmaengine_pcm_config is used, prepare_slave_config() callback might not be set. Check if this callback is set before using it.
---
Changes in v2:
- none
sound/soc/soc-generic-dmaengine-pcm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/soc-generic-dmaengine-pcm.c +3 -3
@@ -86,10 +86,10 @@ static int dmaengine_pcm_hw_params(struct snd_soc_component *component,memset (&slave_config,0 ,sizeof (slave_config)); -if (!pcm->config) - prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config; -else +if (pcm->config && pcm->config->prepare_slave_config) prepare_slave_config = pcm->config->prepare_slave_config; +else + prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;if (prepare_slave_config) {int ret =prepare_slave_config (substream, params, &slave_config);
Signature · 7 lines
2.32.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 2/6 ASoC: dt-bindings: Document Microchip's PDMC
In reply to Codrin CiubotariuAdd DT bindings for the new Microchip PDMC embedded in sama7g5 SoCs.
---
Changes in v2:
- renamed patch from 'ASoC: add DT bindings for Microchip PDMC' to 'ASoC: dt-bindings: Document Microchip's PDMC';
- renamed yaml file from 'mchp,pdmc.yaml' to 'microchip,pdmc.yaml';
- used imperative mode in commit description;
- renamed mchp,pdmc.h to microchip,pdmc.h;
- fixed 'title' to represent HW;
- made 'compatible' first property;
- s/microhpone/microphone;
- none name in example set to 'sound';
.../bindings/sound/microchip,pdmc.yaml | 99 +++++++++++++++++++ include/dt-bindings/sound/microchip,pdmc.h | 13 +++ 2 files changed, 112 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/microchip,pdmc.yaml create mode 100644 include/dt-bindings/sound/microchip,pdmc.h
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml new file +99 -0
@@ -0,0 +1,99 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/microchip,pdmc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip Pulse Density Microphone Controller + +maintainers: + - Codrin Ciubotariu <[email protected]> + +description: + The Microchip Pulse Density Microphone Controller (PDMC) interfaces up to 4 digital microphones + having Pulse Density Modulated (PDM) outputs. + +properties: + compatible: + const: microchip,sama7g5-pdmc + + "#sound-dai-cells": + const: 0 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: Peripheral Bus Clock + - description: Generic Clock + + clock-names: + items: + - const: pclk + - const: gclk + + dmas: + description: RX DMA Channel + maxItems: 1 + + dma-names: + const: rx + + microchip,mic-pos: + description: | + Position of PDM microphones on the DS line and the sampling edge (rising or falling) of the + CLK line. A microphone is represented as a pair of DS line and the sampling edge. The first + microphone is mapped to channel 0, the second to channel 1, etc. + $ref: /schemas/types.yaml#/definitions/uint32-matrix + items: + items: + - description: value for DS line + - description: value for sampling edge + anyOf: + - enum: + - [0, 0] + - [0, 1] + - [1, 0] + - [1, 1] + minItems: 1 + maxItems: 4 + uniqueItems: true + +required: + - compatible + - "#sound-dai-cells" + - reg + - interrupts + - clocks + - clock-names + - dmas + - dma-names + - microchip,mic-pos + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/at91.h> + #include <dt-bindings/dma/at91.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/sound/microchip,pdmc.h> + + pdmc: sound@e1608000 { + compatible = "microchip,sama7g5-pdmc"; + #sound-dai-cells = <0>; + reg = <0xe1608000 0x4000>; + interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>; + dmas = <&dma0 AT91_XDMAC_DT_PERID(37)>; + dma-names = "rx"; + clocks = <&pmc PMC_TYPE_PERIPHERAL 68>, <&pmc PMC_TYPE_GCK 68>; + clock-names = "pclk", "gclk"; + microchip,mic-pos = <MCHP_PDMC_DS0 MCHP_PDMC_CLK_POSITIVE>, + <MCHP_PDMC_DS0 MCHP_PDMC_CLK_NEGATIVE>, + <MCHP_PDMC_DS1 MCHP_PDMC_CLK_POSITIVE>, + <MCHP_PDMC_DS1 MCHP_PDMC_CLK_NEGATIVE>; + };
include/dt-bindings/sound/microchip,pdmc.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DT_BINDINGS_MICROCHIP_PDMC_H__ +#define __DT_BINDINGS_MICROCHIP_PDMC_H__ + +/* PDM microphone's pin placement */ +#define MCHP_PDMC_DS0 0 +#define MCHP_PDMC_DS1 1 + +/* PDM microphone clock edge sampling */ +#define MCHP_PDMC_CLK_POSITIVE 0 +#define MCHP_PDMC_CLK_NEGATIVE 1 + +#endif /* __DT_BINDINGS_MICROCHIP_PDMC_H__ */
Signature · 1 line
2.32.0
Re: [PATCH v2 2/6] ASoC: dt-bindings: Document Microchip's PDMC
Quoted 32 lines · Codrin Ciubotariu
Add DT bindings for the new Microchip PDMC embedded in sama7g5 SoCs.
Signed-off-by Codrin Ciubotariu <[email protected]>---
Changes in v2:
- renamed patch from 'ASoC: add DT bindings for Microchip PDMC' to 'ASoC: dt-bindings: Document Microchip's PDMC';
- renamed yaml file from 'mchp,pdmc.yaml' to 'microchip,pdmc.yaml';
- used imperative mode in commit description;
- renamed mchp,pdmc.h to microchip,pdmc.h;
- fixed 'title' to represent HW;
- made 'compatible' first property;
- s/microhpone/microphone;
- none name in example set to 'sound';.../bindings/sound/microchip,pdmc.yaml | 99 +++++++++++++++++++ include/dt-bindings/sound/microchip,pdmc.h | 13 +++ 2 files changed, 112 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/microchip,pdmc.yaml create mode 100644 include/dt-bindings/sound/microchip,pdmc.hDocumentation/devicetree/bindings/sound/microchip,pdmc.yaml new file +4
-0@@ -0,0 +1,99 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/microchip,pdmc.yaml#
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml line 14
Quoted 10 lines
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml new file +10
-0+$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip Pulse Density Microphone Controller + +maintainers: + - Codrin Ciubotariu <[email protected]> + +description: + The Microchip Pulse Density Microphone Controller (PDMC) interfaces up to 4 digital microphones + having Pulse Density Modulated (PDM) outputs.
This exceeds 80 characters.
Quoted 26 lines
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml new file +26
-0+ +properties: + compatible: + const: microchip,sama7g5-pdmc + + "#sound-dai-cells": + const: 0 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: Peripheral Bus Clock + - description: Generic Clock + + clock-names: + items: + - const: pclk + - const: gclk + + dmas: + description: RX DMA Channel
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml line 50
Quoted 10 lines
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml new file +10
-0+ maxItems: 1 + + dma-names: + const: rx + + microchip,mic-pos: + description: | + Position of PDM microphones on the DS line and the sampling edge (rising or falling) of the + CLK line. A microphone is represented as a pair of DS line and the sampling edge. The first + microphone is mapped to channel 0, the second to channel 1, etc.
This is also too long, wrap at 80.
Quoted 29 lines
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml new file +29
-0+ $ref: /schemas/types.yaml#/definitions/uint32-matrix + items: + items: + - description: value for DS line + - description: value for sampling edge + anyOf: + - enum: + - [0, 0] + - [0, 1] + - [1, 0] + - [1, 1] + minItems: 1 + maxItems: 4 + uniqueItems: true + +required: + - compatible + - "#sound-dai-cells" + - reg + - interrupts + - clocks + - clock-names + - dmas + - dma-names + - microchip,mic-pos + +additionalProperties: false + +examples:
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml line 89
Quoted 10 lines
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml new file +10
-0+ - | + #include <dt-bindings/clock/at91.h> + #include <dt-bindings/dma/at91.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/sound/microchip,pdmc.h> + + pdmc: sound@e1608000 { + compatible = "microchip,sama7g5-pdmc"; + #sound-dai-cells = <0>; + reg = <0xe1608000 0x4000>;
In DTS sources: compatible then reg. I mentioned it in previous version.
Best regards,
Krzysztof
Re: [PATCH v2 2/6] ASoC: dt-bindings: Document Microchip's PDMC
Quoted 6 lines · Krzysztof Kozlowski
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml line 14
Quoted 3 lines · Codrin Ciubotariu
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml new file +3
-0+description: + The Microchip Pulse Density Microphone Controller (PDMC) interfaces up to 4 digital microphones + having Pulse Density Modulated (PDM) outputs.This exceeds 80 characters.
I thought it was raised to 100. checkpatch doesn't report anything also.
Quoted 7 lines
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml line 50
Quoted 5 lines
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml new file +5
-0+ microchip,mic-pos: + description: | + Position of PDM microphones on the DS line and the sampling edge (rising or falling) of the + CLK line. A microphone is represented as a pair of DS line and the sampling edge. The first + microphone is mapped to channel 0, the second to channel 1, etc.This is also too long, wrap at 80.
ok...
Quoted 6 lines
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml line 89
Quoted 4 lines
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml new file +4
-0+ pdmc: sound@e1608000 { + compatible = "microchip,sama7g5-pdmc"; + #sound-dai-cells = <0>; + reg = <0xe1608000 0x4000>;In DTS sources: compatible then reg. I mentioned it in previous version.
right, forgot about reg, sorry.
Quoted 2 lines
Best regards,
Krzysztof
Will send v3, thanks again for your review.
Best regards,
Codrin
Re: [PATCH v2 2/6] ASoC: dt-bindings: Document Microchip's PDMC
Quoted 9 lines · On 07/03/2022 12:34, [email protected] wrote:
Quoted 6 lines · Krzysztof Kozlowski
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml line 14
Quoted 3 lines · Codrin Ciubotariu
Documentation/devicetree/bindings/sound/microchip,pdmc.yaml new file +3
-0+description: + The Microchip Pulse Density Microphone Controller (PDMC) interfaces up to 4 digital microphones + having Pulse Density Modulated (PDM) outputs.This exceeds 80 characters.
I thought it was raised to 100. checkpatch doesn't report anything also.
https://elixir.bootlin.com/linux/v5.17-rc7/source/Documentation/process/coding-style.rst#L104
The hard-constraint was lifted, but still 80 is preferred, unless readability is increased with 100. That's not the case - readability is the same, so keep 80.
Best regards,
Krzysztof
PATCH v2 3/6 ASoC: atmel: mchp-pdmc: add PDMC driver
In reply to Codrin CiubotariuThe Pulse Density Microphone Controller (PDMC) interfaces up to 4 digital microphones having Pulse Density Modulated (PDM) outputs. It generates a single clock line and samples 1 or 2 data lines. The signal path includes an audio grade programmable decimation filter and outputs 24-bit audio words on the APB bus.
---
Changes in v2:
- replaced included file dt-bindings/sound/mchp,pdmc.h wih dt-bindings/sound/microchip,pdmc.h
sound/soc/atmel/Kconfig | 16 + sound/soc/atmel/Makefile | 2 + sound/soc/atmel/mchp-pdmc.c | 1084 +++++++++++++++++++++++++++++++++++ 3 files changed, 1102 insertions(+) create mode 100644 sound/soc/atmel/mchp-pdmc.c
sound/soc/atmel/Kconfig +16 -0
@@ -160,4 +160,20 @@ config SND_MCHP_SOC_SPDIFRX This S/PDIF RX driver is compliant with IEC-60958 standard and includes programmable User Data and Channel Status fields. + +config SND_MCHP_SOC_PDMC + tristate "Microchip ASoC driver for boards using PDMC" + depends on OF && (ARCH_AT91 || COMPILE_TEST) + select SND_SOC_GENERIC_DMAENGINE_PCM + select REGMAP_MMIO + help + Say Y or M if you want to add support for Microchip ASoC PDMC driver on the + following Microchip platforms: + - sama7g5 + + The Pulse Density Microphone Controller (PDMC) interfaces up to 4 digital + microphones PDM outputs. It generates a single clock line and samples 1 or + 2 data lines. The signal path includes an audio grade programmable + decimation filter and outputs 24-bit audio words. + endif
sound/soc/atmel/Makefile +2 -0
@@ -7,6 +7,7 @@ snd-soc-atmel-i2s-objs := atmel-i2s.o snd-soc-mchp-i2s-mcc-objs := mchp-i2s-mcc.o snd-soc-mchp-spdiftx-objs := mchp-spdiftx.o snd-soc-mchp-spdifrx-objs := mchp-spdifrx.o +snd-soc-mchp-pdmc-objs := mchp-pdmc.o # pdc and dma need to both be built-in if any user of # ssc is built-in.
@@ -21,6 +22,7 @@ obj-$(CONFIG_SND_ATMEL_SOC_I2S) += snd-soc-atmel-i2s.o obj-$(CONFIG_SND_MCHP_SOC_I2S_MCC) += snd-soc-mchp-i2s-mcc.o obj-$(CONFIG_SND_MCHP_SOC_SPDIFTX) += snd-soc-mchp-spdiftx.o obj-$(CONFIG_SND_MCHP_SOC_SPDIFRX) += snd-soc-mchp-spdifrx.o +obj-$(CONFIG_SND_MCHP_SOC_PDMC) += snd-soc-mchp-pdmc.o # AT91 Machine Support snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o
sound/soc/atmel/mchp-pdmc.c new file +1084 -0
1,084 lines not on this page · raw message
Signature · 1 line
2.32.0
PATCH v2 4/6 ARM: dts: at91: sama7g5: add nodes for PDMC
In reply to Codrin CiubotariuMicrochip's SAMA7G5 embeds two PDMCs. The PDMCs can be used to connect 2x4 PDM microphones.
---
Changes in v2:
- set 'sound' as nodes' name
arch/arm/boot/dts/sama7g5.dtsi | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/arm/boot/dts/sama7g5.dtsi +24 -0
@@ -275,6 +275,30 @@ pwm: pwm@e1604000 { status = "disabled"; }; + pdmc0: sound@e1608000 { + compatible = "microchip,sama7g5-pdmc"; + reg = <0xe1608000 0x1000>; + interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>; + #sound-dai-cells = <0>; + dmas = <&dma0 AT91_XDMAC_DT_PERID(37)>; + dma-names = "rx"; + clocks = <&pmc PMC_TYPE_PERIPHERAL 68>, <&pmc PMC_TYPE_GCK 68>; + clock-names = "pclk", "gclk"; + status = "disabled"; + }; + + pdmc1: sound@e160c000 { + compatible = "microchip,sama7g5-pdmc"; + reg = <0xe160c000 0x1000>; + interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>; + #sound-dai-cells = <0>; + dmas = <&dma0 AT91_XDMAC_DT_PERID(38)>; + dma-names = "rx"; + clocks = <&pmc PMC_TYPE_PERIPHERAL 69>, <&pmc PMC_TYPE_GCK 69>; + clock-names = "pclk", "gclk"; + status = "disabled"; + }; + spdifrx: spdifrx@e1614000 { #sound-dai-cells = <0>; compatible = "microchip,sama7g5-spdifrx";
Signature · 1 line
2.32.0
PATCH v2 5/6 ARM: dts: at91: sama7g5ek: add node for PDMC0
In reply to Codrin CiubotariuSAMA7G5-EK has 4 PDM microphones connected to PDMC0. PDMC0 pinmux is in conflict with gmac1, gmac1 being enabled by default.
---
Changes in v2:
- replaced included file dt-bindings/sound/mchp,pdmc.h wih dt-bindings/sound/microchip,pdmc.h
arch/arm/boot/dts/at91-sama7g5ek.dts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
arch/arm/boot/dts/at91-sama7g5ek.dts +20 -1
@@ -14,6 +14,7 @@ #include <dt-bindings/mfd/atmel-flexcom.h> #include <dt-bindings/input/input.h> #include <dt-bindings/pinctrl/at91.h> +#include <dt-bindings/sound/microchip,pdmc.h> / { model = "Microchip SAMA7G5-EK";
@@ -439,7 +440,7 @@ &gmac1 { &pinctrl_gmac1_mdio_default &pinctrl_gmac1_phy_irq>; phy-mode = "rmii"; - status = "okay"; + status = "okay"; /* Conflict with pdmc0. */ ethernet-phy@0 { reg = <0x0>;
@@ -453,6 +454,17 @@ &i2s0 { pinctrl-0 = <&pinctrl_i2s0_default>; }; +&pdmc0 { + #sound-dai-cells = <0>; + microchip,mic-pos = <MCHP_PDMC_DS0 MCHP_PDMC_CLK_NEGATIVE>, /* MIC 1 */ + <MCHP_PDMC_DS1 MCHP_PDMC_CLK_NEGATIVE>, /* MIC 2 */ + <MCHP_PDMC_DS0 MCHP_PDMC_CLK_POSITIVE>, /* MIC 3 */ + <MCHP_PDMC_DS1 MCHP_PDMC_CLK_POSITIVE>; /* MIC 4 */ + status = "disabled"; /* Conflict with gmac1. */ + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pdmc0_default>; +}; + &pioA { pinctrl_flx0_default: flx0_default { pinmux = <PIN_PE3__FLEXCOM0_IO0>,
@@ -609,6 +621,13 @@ pinctrl_mikrobus1_spi: mikrobus1_spi { bias-disable; }; + pinctrl_pdmc0_default: pdmc0_default { + pinmux = <PIN_PD23__PDMC0_DS0>, + <PIN_PD24__PDMC0_DS1>, + <PIN_PD22__PDMC0_CLK>; + bias_disable; + }; + pinctrl_qspi: qspi { pinmux = <PIN_PB12__QSPI0_IO0>, <PIN_PB11__QSPI0_IO1>,
Signature · 1 line
2.32.0
PATCH v2 6/6 ARM: configs: at91: sama7_defconfig: add MCHP PDMC and DMIC drivers
In reply to Codrin CiubotariuEnable drivers needed for Microchip's PDMC and PDM microphones.
---
Changes in v2:
- none;
arch/arm/configs/sama7_defconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/configs/sama7_defconfig +2 -0
@@ -138,6 +138,8 @@ CONFIG_SND_SOC_MIKROE_PROTO=m CONFIG_SND_MCHP_SOC_I2S_MCC=y CONFIG_SND_MCHP_SOC_SPDIFTX=y CONFIG_SND_MCHP_SOC_SPDIFRX=y +CONFIG_SND_MCHP_SOC_PDMC=y +CONFIG_SND_SOC_DMIC=y CONFIG_SND_SOC_PCM5102A=y CONFIG_SND_SOC_SPDIF=y CONFIG_SND_SIMPLE_CARD=y
Signature · 1 line
2.32.0