ASOC: Add ADAU7118 8 Channel PDM-to-I2S/TDM Converter driver
Subsystems (4)
Nuno Sá
maintainerPATCH v3 1/2 ASOC: Add ADAU7118 8 Channel PDM-to-I2S/TDM Converter driver
This patch adds support for the 8 channel PDM-to-I2S/TDM converter. The ADAU7118 converts four stereo pulse density modulation (PDM) bitstreams into one pulse code modulation (PCM) output stream. The source for the PDM data can be eight microphones or other PDM sources. The PCM audio data is output on a serial audio interface port in either inter-IC serial (I2S) or time domain multiplexed (TDM) format.
---
Changes in v2:
* Use C++ coment style on the entire comment in the .c files;
* Do not use ternery operator;
* Do not use devm_regulator_get_optional as the device always requires power;
* Let DAPM suspend/resume the device.
Changes in v3:
* no changes.
MAINTAINERS | 1 + sound/soc/codecs/Kconfig | 28 ++ sound/soc/codecs/Makefile | 6 + sound/soc/codecs/adau7118-hw.c | 43 +++ sound/soc/codecs/adau7118-i2c.c | 82 +++++ sound/soc/codecs/adau7118.c | 586 ++++++++++++++++++++++++++++++++ sound/soc/codecs/adau7118.h | 24 ++ 7 files changed, 770 insertions(+) create mode 100644 sound/soc/codecs/adau7118-hw.c create mode 100644 sound/soc/codecs/adau7118-i2c.c create mode 100644 sound/soc/codecs/adau7118.c create mode 100644 sound/soc/codecs/adau7118.h
MAINTAINERS +1 -0
@@ -1002,6 +1002,7 @@ F: drivers/media/i2c/adv7842* ANALOG DEVICES INC ASOC CODEC DRIVERS M: Lars-Peter Clausen <[email protected]> +M: Nuno Sá <[email protected]> L: [email protected] (moderated for non-subscribers) W: http://wiki.analog.com/ W: http://ez.analog.com/community/linux-device-drivers
sound/soc/codecs/Kconfig +28 -0
@@ -34,6 +34,8 @@ config SND_SOC_ALL_CODECS select SND_SOC_ADAU1977_I2C if I2C select SND_SOC_ADAU1701 if I2C select SND_SOC_ADAU7002 + select SND_SOC_ADAU7118_I2C if I2C + select SND_SOC_ADAU7118_HW select SND_SOC_ADS117X select SND_SOC_AK4104 if SPI_MASTER select SND_SOC_AK4118 if I2C
@@ -396,6 +398,32 @@ config SND_SOC_ADAU1977_I2C config SND_SOC_ADAU7002 tristate "Analog Devices ADAU7002 Stereo PDM-to-I2S/TDM Converter" +config SND_SOC_ADAU7118 + tristate + +config SND_SOC_ADAU7118_HW + tristate "Analog Devices ADAU7118 8 Channel PDM-to-I2S/TDM Converter - HW Mode" + select SND_SOC_ADAU7118 + help + Enable support for the Analog Devices ADAU7118 8 Channel PDM-to-I2S/TDM + Converter. In this mode, the device works in standalone mode which + means that there is no bus to comunicate with it. Stereo mode is not + supported in this mode. + + To compile this driver as a module, choose M here: the module + will be called snd-soc-adau7118-hw. + +config SND_SOC_ADAU7118_I2C + tristate "Analog Devices ADAU7118 8 Channel PDM-to-I2S/TDM Converter - I2C" + select SND_SOC_ADAU7118 + select REGMAP_I2C + help + Enable support for the Analog Devices ADAU7118 8 Channel PDM-to-I2S/TDM + Converter over I2C. This gives full support over the device. + + To compile this driver as a module, choose M here: the module + will be called snd-soc-adau7118-i2c. + config SND_SOC_ADAV80X tristate
sound/soc/codecs/Makefile +6 -0
@@ -22,6 +22,9 @@ snd-soc-adau1977-objs := adau1977.o snd-soc-adau1977-spi-objs := adau1977-spi.o snd-soc-adau1977-i2c-objs := adau1977-i2c.o snd-soc-adau7002-objs := adau7002.o +snd-soc-adau7118-objs := adau7118.o +snd-soc-adau7118-i2c-objs := adau7118-i2c.o +snd-soc-adau7118-hw-objs := adau7118-hw.o snd-soc-adav80x-objs := adav80x.o snd-soc-adav801-objs := adav801.o snd-soc-adav803-objs := adav803.o
@@ -305,6 +308,9 @@ obj-$(CONFIG_SND_SOC_ADAU1977) += snd-soc-adau1977.o obj-$(CONFIG_SND_SOC_ADAU1977_SPI) += snd-soc-adau1977-spi.o obj-$(CONFIG_SND_SOC_ADAU1977_I2C) += snd-soc-adau1977-i2c.o obj-$(CONFIG_SND_SOC_ADAU7002) += snd-soc-adau7002.o +obj-$(CONFIG_SND_SOC_ADAU7118) += snd-soc-adau7118.o +obj-$(CONFIG_SND_SOC_ADAU7118_I2C) += snd-soc-adau7118-i2c.o +obj-$(CONFIG_SND_SOC_ADAU7118_HW) += snd-soc-adau7118-hw.o obj-$(CONFIG_SND_SOC_ADAV80X) += snd-soc-adav80x.o obj-$(CONFIG_SND_SOC_ADAV801) += snd-soc-adav801.o obj-$(CONFIG_SND_SOC_ADAV803) += snd-soc-adav803.o
sound/soc/codecs/adau7118-hw.c new file +43 -0
43 lines not on this page · raw message
sound/soc/codecs/adau7118-i2c.c new file +82 -0
82 lines not on this page · raw message
sound/soc/codecs/adau7118.c new file +586 -0
586 lines not on this page · raw message
sound/soc/codecs/adau7118.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_ADAU7118_H +#define _LINUX_ADAU7118_H + +struct regmap ; +struct device ; + +/* register map */ +#define ADAU7118_REG_VENDOR_ID 0x00 +#define ADAU7118_REG_DEVICE_ID1 0x01 +#define ADAU7118_REG_DEVICE_ID2 0x02 +#define ADAU7118_REG_REVISION_ID 0x03 +#define ADAU7118_REG_ENABLES 0x04 +#define ADAU7118_REG_DEC_RATIO_CLK_MAP 0x05 +#define ADAU7118_REG_HPF_CONTROL 0x06 +#define ADAU7118_REG_SPT_CTRL1 0x07 +#define ADAU7118_REG_SPT_CTRL2 0x08 +#define ADAU7118_REG_SPT_CX (num) (0x09 + (num)) +#define ADAU7118_REG_DRIVE_STRENGTH 0x11 +#define ADAU7118_REG_RESET 0x12 + +int adau7118_probe (struct device *dev,struct regmap *map,bool hw_mode); + +#endif
Signature · 6 lines
2.23.0 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Nuno Sá
maintainerPATCH v3 2/2 dt-bindings: asoc: Add ADAU7118 documentation
Document the ADAU7118 8 channel PDM to I2S/TDM converter devicetree bindings.
---
Changes in v2:
* List regulators as required;
Changes in v3:
* Set the correct license for new bindings.
.../bindings/sound/adi,adau7118.yaml | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/adi,adau7118.yaml
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +90 -0
@@ -0,0 +1,90 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/adi,adau7118.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + + +title: Analog Devices ADAU7118 8 Channel PDM to I2S/TDM Converter + +maintainers: + - Nuno Sá <[email protected]> + +description: | + Analog Devices ADAU7118 8 Channel PDM to I2S/TDM Converter over I2C or HW + standalone mode. + https://www.analog.com/media/en/technical-documentation/data-sheets/ADAU7118.pdf + +properties: + compatible: + enum: + - adi,adau7118 + + reg: + maxItems: 1 + + "#sound-dai-cells": + const: 0 + + IOVDD-supply: + description: Digital Input/Output Power Supply. + $ref: "/schemas/types.yaml#/definitions/phandle" + + DVDD-supply: + description: Internal Core Digital Power Supply. + $ref: "/schemas/types.yaml#/definitions/phandle" + + adi,decimation-ratio: + description: | + This property set's the decimation ratio of PDM to PCM audio data. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - enum: [64, 32, 16] + default: 64 + + adi,pdm-clk-map: + description: | + The ADAU7118 has two PDM clocks for the four Inputs. Each input must be + assigned to one of these two clocks. This property set's the mapping + between the clocks and the inputs. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - minItems: 4 + maxItems: 4 + items: + maximum: 1 + default: [0, 0, 1, 1] + +required: + - "#sound-dai-cells" + - compatible + - IOVDD-supply + - DVDD-supply + +examples: + - | + i2c0 { + /* example with i2c support */ + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + adau7118_codec: adau7118-codec@14 { + compatible = "adi,adau7118"; + reg = <14>; + #sound-dai-cells = <0>; + status = "okay"; + IOVDD-supply = <&supply>; + DVDD-supply = <&supply>; + adi,pdm-clk-map = <1 1 0 0>; + adi,decimation-ratio = <16>; + }; + }; + + /* example with hw standalone mode */ + adau7118_codec_hw: adau7118-codec-hw { + compatible = "adi,adau7118"; + #sound-dai-cells = <0>; + status = "okay"; + IOVDD-supply = <&supply>; + DVDD-supply = <&supply>; + };
Signature · 6 lines
2.23.0 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Mark Brown
maintainersound/soc/codecs/adau7118.c line 352
Quoted 11 lines · Nuno Sá
sound/soc/codecs/adau7118.c new file +11
-0+/* power on */ + ret =regulator_enable (st->iovdd); +if (ret) +return ret; + +/* there's no timing constraints before enabling dvdd */ + ret =regulator_enable (st->dvdd); +if (ret) { +regulator_disable (st->iovdd); +return ret; + }
You could use regulator_bulk_enable() here (and similarly on disable) but it doesn't fundamentally matter - they do guarantee that they'll do things in sequence, though they don't wait for the ramp to complete before kicking off the next enable in the sequence which can be an issue for some hardware.
Sa, Nuno
maintainerQuoted 13 lines · Mark Brown
Quoted 10 lines · Nuno Sá
sound/soc/codecs/adau7118.c new file +6
-0+/* power on */ + ret =regulator_enable (st->iovdd); +if (ret) +return ret; + +/* there's no timing constraints before enabling dvdd */
sound/soc/codecs/adau7118.c new file +3
-0+ ret =regulator_enable (st->dvdd); +if (ret) { +regulator_disable (st->iovdd);
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ return ret; + }You could use
regulator_bulk_enable()here (and similarly on disable) but it doesn't fundamentally matter - they do guarantee that they'll do things in sequence, though they don't wait for the ramp to complete before kicking off the next enable in the sequence which can be an issue for some hardware.
Yes, regulator_bulk_enable() could fit. The only thing that worries me is that we only check for errors returned from regulator_enable() after all async work is done (which is probably what you mean by "they don't wait for the ramp to complete before kicking off the next enable...") which could leave us with DVDD applied without IOVDD for a short amount of time. I'm not sure this would be a really issue and that would damage the HW, but from what I can tell from the datasheet, It's not advised to apply DVDD without IOVDD.
Nuno Sá
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Mark Brown
maintainerQuoted 8 lines · Nuno
Quoted 5 lines · Mark Brown
You could use
regulator_bulk_enable()here (and similarly on disable) but it doesn't fundamentally matter - they do guarantee that they'll do things in sequence, though they don't wait for the ramp to complete before kicking off the next enable in the sequence which can be an issue for some hardware.
Quoted 8 lines
Yes,
regulator_bulk_enable()could fit. The only thing that worries me is that we only check for errors returned fromregulator_enable()after all async work is done (which is probably what you mean by "they don't wait for the ramp to complete before kicking off the next enable...") which could leave us with DVDD applied without IOVDD for a short amount of time. I'm not sure this would be a really issue and that would damage the HW, but from what I can tell from the datasheet, It's not advised to apply DVDD without IOVDD.
Yeah, exactly. OTOH things like that (especially for brief time periods) are much more likely to result in the chip being in some weird state on init which won't matter if we immediately power off than anything else. Like I say it's not a requirement to use bulk operations.
Rob Herring
maintainerRe: [alsa-devel] [PATCH v3 2/2] dt-bindings: asoc: Add ADAU7118 documentation
In reply to Nuno SáQuoted 40 lines · Nuno Sá
Document the ADAU7118 8 channel PDM to I2S/TDM converter devicetree bindings.
Signed-off-by Nuno Sá <[email protected]>---
Changes in v2:
* List regulators as required;Changes in v3:
* Set the correct license for new bindings..../bindings/sound/adi,adau7118.yaml | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/adi,adau7118.yamlDocumentation/devicetree/bindings/sound/adi,adau7118.yaml new file +19
-0@@ -0,0 +1,90 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/adi,adau7118.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + + +title: Analog Devices ADAU7118 8 Channel PDM to I2S/TDM Converter + +maintainers: + - Nuno Sá <[email protected]> + +description: | + Analog Devices ADAU7118 8 Channel PDM to I2S/TDM Converter over I2C or HW + standalone mode. + https://www.analog.com/media/en/technical-documentation/data-sheets/ADAU7118.pdf + +properties: + compatible:
Documentation/devicetree/bindings/sound/adi,adau7118.yaml line 29
Quoted 10 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +10
-0+ enum: + - adi,adau7118 + + reg: + maxItems: 1 + + "#sound-dai-cells": + const: 0 + + IOVDD-supply:
Use lowercase please.
Documentation/devicetree/bindings/sound/adi,adau7118.yaml line 31
Quoted 2 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +2
-0+ description: Digital Input/Output Power Supply. + $ref: "/schemas/types.yaml#/definitions/phandle"
*-supply already has a type, so just a description is enough.
Documentation/devicetree/bindings/sound/adi,adau7118.yaml line 35
Quoted 4 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +4
-0+ + DVDD-supply: + description: Internal Core Digital Power Supply. + $ref: "/schemas/types.yaml#/definitions/phandle"
Same here.
Quoted 21 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +21
-0+ + adi,decimation-ratio: + description: | + This property set's the decimation ratio of PDM to PCM audio data. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - enum: [64, 32, 16] + default: 64 + + adi,pdm-clk-map: + description: | + The ADAU7118 has two PDM clocks for the four Inputs. Each input must be + assigned to one of these two clocks. This property set's the mapping + between the clocks and the inputs. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - minItems: 4 + maxItems: 4 + items: + maximum: 1 + default: [0, 0, 1, 1]
Documentation/devicetree/bindings/sound/adi,adau7118.yaml line 66
Quoted 10 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +10
-0+ +required: + - "#sound-dai-cells" + - compatible + - IOVDD-supply + - DVDD-supply + +examples: + - | + i2c0 {
i2c {
Documentation/devicetree/bindings/sound/adi,adau7118.yaml line 70
Quoted 4 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +4
-0+ /* example with i2c support */ + #address-cells = <1>; + #size-cells = <0>; + status = "okay";
Don't show status in examples.
Documentation/devicetree/bindings/sound/adi,adau7118.yaml line 71
Quoted 1 line
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +1
-0+ adau7118_codec: adau7118-codec@14 {
audio-codec@14
Quoted 22 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +19
-0+ compatible = "adi,adau7118"; + reg = <14>; + #sound-dai-cells = <0>; + status = "okay"; + IOVDD-supply = <&supply>; + DVDD-supply = <&supply>; + adi,pdm-clk-map = <1 1 0 0>; + adi,decimation-ratio = <16>; + }; + }; + + /* example with hw standalone mode */ + adau7118_codec_hw: adau7118-codec-hw { + compatible = "adi,adau7118"; + #sound-dai-cells = <0>; + status = "okay"; + IOVDD-supply = <&supply>; + DVDD-supply = <&supply>; + };Signature · 1 line
2.23.0
Sa, Nuno
maintainerQuoted 23 lines · Mark Brown
Quoted 6 lines · Nuno
Quoted 5 lines · Mark Brown
You could use
regulator_bulk_enable()here (and similarly on disable) but it doesn't fundamentally matter - they do guarantee that they'll do things in sequence, though they don't wait for the ramp to complete before kicking off the next enable in the sequence which can be an issue for some hardware.Quoted 14 lines
Yes,
regulator_bulk_enable()could fit. The only thing that worries me
is that we only check for errors returned fromregulator_enable()after
all async work is done (which is probably what you mean by "they don't
wait for the ramp to complete before kicking off the next enable...")
which could leave us with DVDD applied without IOVDD for a short amount
of time. I'm not sure this would be a really issue and that would damage the HW, but from what I can tell from the datasheet, It's not
advised to apply DVDD without IOVDD.
Quoted 5 lines
Yeah, exactly. OTOH things like that (especially for brief time periods) are much more likely to result in the chip being in some weird state on init which won't matter if we immediately power off than anything else. Like I say it's not a requirement to use bulk operations.
Yeah, that's probably right. I can also do some internal querying to understand if this could really damage the part. If not and since I have to prepare a v4 either way (for dt bindings), I will use regulator_bulk_enable().
Nuno Sá
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Rob Herring
maintainerRe: [alsa-devel] [PATCH v3 2/2] dt-bindings: asoc: Add ADAU7118 documentation
In reply to Rob HerringQuoted 10 lines · Rob Herring
Quoted 8 lines · Nuno Sá
Document the ADAU7118 8 channel PDM to I2S/TDM converter devicetree bindings.
Signed-off-by Nuno Sá <[email protected]>---
Changes in v2:
* List regulators as required;
Quoted 6 lines
Quoted 6 lines
Changes in v3:
* Set the correct license for new bindings..../bindings/sound/adi,adau7118.yaml | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/adi,adau7118.yaml
Looks like Mark already applied this. Please send a follow-up patch addressing my comments.
Quoted 90 lines
Quoted 26 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +19
-0@@ -0,0 +1,90 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/adi,adau7118.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + + +title: Analog Devices ADAU7118 8 Channel PDM to I2S/TDM Converter + +maintainers: + - Nuno Sá <[email protected]> + +description: | + Analog Devices ADAU7118 8 Channel PDM to I2S/TDM Converter over I2C or HW + standalone mode. + https://www.analog.com/media/en/technical-documentation/data-sheets/ADAU7118.pdf + +properties: + compatible:Documentation/devicetree/bindings/sound/adi,adau7118.yaml line 29
Quoted 10 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +10
-0+ enum: + - adi,adau7118 + + reg: + maxItems: 1 + + "#sound-dai-cells": + const: 0 + + IOVDD-supply:Use lowercase please.
Documentation/devicetree/bindings/sound/adi,adau7118.yaml line 31
Quoted 2 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +2
-0+ description: Digital Input/Output Power Supply. + $ref: "/schemas/types.yaml#/definitions/phandle"*-supply already has a type, so just a description is enough.
Documentation/devicetree/bindings/sound/adi,adau7118.yaml line 35
Quoted 4 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +4
-0+ + DVDD-supply: + description: Internal Core Digital Power Supply. + $ref: "/schemas/types.yaml#/definitions/phandle"Same here.
Quoted 21 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +21
-0+ + adi,decimation-ratio: + description: | + This property set's the decimation ratio of PDM to PCM audio data. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - enum: [64, 32, 16] + default: 64 + + adi,pdm-clk-map: + description: | + The ADAU7118 has two PDM clocks for the four Inputs. Each input must be + assigned to one of these two clocks. This property set's the mapping + between the clocks and the inputs. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - minItems: 4 + maxItems: 4 + items: + maximum: 1 + default: [0, 0, 1, 1]Documentation/devicetree/bindings/sound/adi,adau7118.yaml line 66
Quoted 10 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +10
-0+ +required: + - "#sound-dai-cells" + - compatible + - IOVDD-supply + - DVDD-supply + +examples: + - | + i2c0 {i2c {
Documentation/devicetree/bindings/sound/adi,adau7118.yaml line 70
Quoted 4 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +4
-0+ /* example with i2c support */ + #address-cells = <1>; + #size-cells = <0>; + status = "okay";
Quoted 28 lines
Don't show status in examples.
Documentation/devicetree/bindings/sound/adi,adau7118.yaml line 71
Quoted 1 line
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +1
-0+ adau7118_codec: adau7118-codec@14 {audio-codec@14
Quoted 22 lines
Documentation/devicetree/bindings/sound/adi,adau7118.yaml new file +19
-1+ compatible = "adi,adau7118"; + reg = <14>; + #sound-dai-cells = <0>; + status = "okay"; + IOVDD-supply = <&supply>; + DVDD-supply = <&supply>; + adi,pdm-clk-map = <1 1 0 0>; + adi,decimation-ratio = <16>; + }; + }; + + /* example with hw standalone mode */ + adau7118_codec_hw: adau7118-codec-hw { + compatible = "adi,adau7118"; + #sound-dai-cells = <0>; + status = "okay"; + IOVDD-supply = <&supply>; + DVDD-supply = <&supply>; + }; --2.23.0
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel