Skip to contentSkip to conversation

ASoC: meson: add axg audio subsystem support

PATCH RESEND In review Jerome Brunet 3 participants 19 messages Jul 17, 2018 – Jul 19, 2018

Subsystems (5)
lore
Share & tools
lore

Jerome Brunet

author maintainer
#0 lore raw

cover ASoC: meson: add axg audio subsystem support

This patchset adds support for the audio subsystem found on Amlogic's axg SoC family. The first SoC of this family is the A113D/X targeted at smart speaker application. The G12a SoC family, Amlogic next-gen STB chipset, will reuse this audio subsystem with a few changes.

This patchset implements the DPCM machine driver and the different components it made of. Several components are still missing, such spdif input and pdm, and will submitted later on.

The fancier part of this patchset is probably around the TDM. Properly modeling the SoC architecture and its capatilities made things a little more complex than usual (details in the related commit descriptions)

If necessary, this patchset could broken into smaller series. For the intial submission, I wanted to give a global view of the subsystem. Hopefully, it will make it a bit easier to understand.

Jerome Brunet (15):
ASoC: meson: add axg fifos DT binding documentation
ASoC: meson: add axg fifo base driver
ASoC: meson: add axg frddr driver
ASoC: meson: add axg toddr driver
ASoC: meson: add axg spdif output DT bindings documentation
ASoC: meson: add axg spdif output
ASoC: meson: add axg tdm formatters DT bindings documentation
ASoC: meson: add axg tdm interface DT bindings documentation
ASoC: meson: add tdm formatter base driver
ASoC: meson: add tdm interface driver
ASoC: meson: add tdm output driver
ASoC: meson: add tdm input driver
ASoC: export snd_soc_of_get_slot_mask
ASoC: meson: add axg sound card DT bindings documentation
ASoC: meson: add axg sound card support

 .../devicetree/bindings/sound/amlogic,axg-fifo.txt |  23 +
 .../bindings/sound/amlogic,axg-sound-card.txt      | 124 ++++
 .../bindings/sound/amlogic,axg-spdifout.txt        |  20 +
 .../bindings/sound/amlogic,axg-tdm-formatters.txt  |  28 +
 .../bindings/sound/amlogic,axg-tdm-iface.txt       |  22 +
 include/sound/soc.h                                |   3 +
 sound/soc/Kconfig                                  |   1 +
 sound/soc/Makefile                                 |   1 +
 sound/soc/meson/Kconfig                            |  64 ++
 sound/soc/meson/Makefile                           |  21 +
 sound/soc/meson/axg-card.c                         | 671 +++++++++++++++++++++
 sound/soc/meson/axg-fifo.c                         | 341 +++++++++++
 sound/soc/meson/axg-fifo.h                         |  80 +++
 sound/soc/meson/axg-frddr.c                        | 141 +++++
 sound/soc/meson/axg-spdifout.c                     | 456 ++++++++++++++
 sound/soc/meson/axg-tdm-formatter.c                | 381 ++++++++++++
 sound/soc/meson/axg-tdm-formatter.h                |  39 ++
 sound/soc/meson/axg-tdm-interface.c                | 542 +++++++++++++++++
 sound/soc/meson/axg-tdm.h                          |  78 +++
 sound/soc/meson/axg-tdmin.c                        | 229 +++++++
 sound/soc/meson/axg-tdmout.c                       | 259 ++++++++
 sound/soc/meson/axg-toddr.c                        | 199 ++++++
 sound/soc/soc-core.c                               |   7 +-
 23 files changed, 3727 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-fifo.txt
 create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-sound-card.txt
 create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-spdifout.txt
 create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-tdm-formatters.txt
 create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-tdm-iface.txt
 create mode 100644 sound/soc/meson/Kconfig
 create mode 100644 sound/soc/meson/Makefile
 create mode 100644 sound/soc/meson/axg-card.c
 create mode 100644 sound/soc/meson/axg-fifo.c
 create mode 100644 sound/soc/meson/axg-fifo.h
 create mode 100644 sound/soc/meson/axg-frddr.c
 create mode 100644 sound/soc/meson/axg-spdifout.c
 create mode 100644 sound/soc/meson/axg-tdm-formatter.c
 create mode 100644 sound/soc/meson/axg-tdm-formatter.h
 create mode 100644 sound/soc/meson/axg-tdm-interface.c
 create mode 100644 sound/soc/meson/axg-tdm.h
 create mode 100644 sound/soc/meson/axg-tdmin.c
 create mode 100644 sound/soc/meson/axg-tdmout.c
 create mode 100644 sound/soc/meson/axg-toddr.c
Signature · 1 line
2.14.4
author maintainer
#1 lore raw

PATCH RESEND 1/15 ASoC: meson: add axg fifos DT binding documentation

Add the DT bindings documentation for axg's FIFOs: TODDR and FRDDR.

---
 .../devicetree/bindings/sound/amlogic,axg-fifo.txt | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-fifo.txt
Documentation/devicetree/bindings/sound/amlogic,axg-fifo.txt new file +23 -0
new file mode 100644
index 000000000000..3dfc2515e5c6
@@ -0,0 +1,23 @@
+* Amlogic Audio FIFO controllers
+
+Required properties:
+- compatible: 'amlogic,axg-toddr' or
+	      'amlogic,axg-frddr'
+- reg: physical base address of the controller and length of memory
+       mapped region.
+- interrupts: interrupt specifier for the fifo.
+- clocks: phandle to the fifo peripheral clock provided by the audio
+	  clock controller.
+- resets: phandle to memory ARB line provided by the arb reset controller.
+- #sound-dai-cells: must be 0.
+
+Example of FRDDR A on the A113 SoC:
+
+frddr_a: audio-controller@1c0 {
+	compatible = "amlogic,axg-frddr";
+	reg = <0x0 0x1c0 0x0 0x1c>;
+	#sound-dai-cells = <0>;
+	interrupts = <GIC_SPI 88 IRQ_TYPE_EDGE_RISING>;
+	clocks = <&clkc_audio AUD_CLKID_FRDDR_A>;
+	resets = <&arb AXG_ARB_FRDDR_A>;
+};
Signature · 1 line
2.14.4
author maintainer
#2 lore raw

PATCH RESEND 2/15 ASoC: meson: add axg fifo base driver

In reply to Jerome Brunet

Amlogic's axg SoCs have two types of fifos which are the memory interfaces of the audio subsystem. FRDDR provides the playback interface while TODDR provides the capture interface.

The way these fifos operate is very similar. Only a few settings are specific to each.

They implement the same pcm driver here and the specifics of each will be dealt with the related DAI driver.

---
 sound/soc/Kconfig          |   1 +
 sound/soc/Makefile         |   1 +
 sound/soc/meson/Kconfig    |   8 ++
 sound/soc/meson/Makefile   |   5 +
 sound/soc/meson/axg-fifo.c | 341 +++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/meson/axg-fifo.h |  80 +++++++++++
 6 files changed, 436 insertions(+)
 create mode 100644 sound/soc/meson/Kconfig
 create mode 100644 sound/soc/meson/Makefile
 create mode 100644 sound/soc/meson/axg-fifo.c
 create mode 100644 sound/soc/meson/axg-fifo.h
sound/soc/Kconfig +1 -0
index 41af6b9cc350..1cf11cf51e1d 100644
@@ -57,6 +57,7 @@ source "sound/soc/kirkwood/Kconfig"
 source "sound/soc/img/Kconfig"
 source "sound/soc/intel/Kconfig"
 source "sound/soc/mediatek/Kconfig"
+source "sound/soc/meson/Kconfig"
 source "sound/soc/mxs/Kconfig"
 source "sound/soc/pxa/Kconfig"
 source "sound/soc/qcom/Kconfig"
sound/soc/Makefile +1 -0
index 06389a5385d7..62a5f87c3cfc 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_SND_SOC)	+= jz4740/
 obj-$(CONFIG_SND_SOC)	+= img/
 obj-$(CONFIG_SND_SOC)	+= intel/
 obj-$(CONFIG_SND_SOC)	+= mediatek/
+obj-$(CONFIG_SND_SOC)	+= meson/
 obj-$(CONFIG_SND_SOC)	+= mxs/
 obj-$(CONFIG_SND_SOC)	+= nuc900/
 obj-$(CONFIG_SND_SOC)	+= omap/
sound/soc/meson/Kconfig new file +8 -0
new file mode 100644
index 000000000000..c3eb5e050308
@@ -0,0 +1,8 @@
+menu "ASoC support for Amlogic platforms"
+	depends on ARCH_MESON || COMPILE_TEST
+
+config SND_MESON_AXG_FIFO
+	tristate
+	select REGMAP_MMIO
+
+endmenu
sound/soc/meson/Makefile new file +5 -0
new file mode 100644
index 000000000000..75289b6b3ade
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: (GPL-2.0 OR MIT)
+
+snd-soc-meson-axg-fifo-objs := axg-fifo.o
+
+obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o
sound/soc/meson/axg-fifo.c new file +341 -0

341 lines not on this page · raw message

sound/soc/meson/axg-fifo.h new file +80 -0

80 lines not on this page · raw message

Signature · 1 line
2.14.4
maintainer
#3 lore raw

Re: [PATCH RESEND 02/15] ASoC: meson: add axg fifo base driver

sound/soc/meson/axg-fifo.c line 177

Quoted 1 line · Jerome Brunet
sound/soc/meson/axg-fifo.c new file +1 -0
+	return !status ? IRQ_NONE : IRQ_HANDLED;

Please just write normal conditional statements, it makes things a lot
easier to read (the ! isn't helping either here).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-amlogic/attachments/20180718/88f02bc3/attachment.sig>

#4 lore raw

Re: [alsa-devel] [PATCH RESEND 02/15] ASoC: meson: add axg fifo base driver

Quoted 7 lines · Mark Brown

sound/soc/meson/axg-fifo.c line 177

Quoted 1 line · Jerome Brunet
sound/soc/meson/axg-fifo.c new file +1 -0
+	return !status ? IRQ_NONE : IRQ_HANDLED;

Please just write normal conditional statements, it makes things a lot easier to read (the ! isn't helping either here).

... and there is the standard IRQ_RETVAL() macro for this purpose.

Takashi

author maintainer
#5 lore raw

Re: [alsa-devel] [PATCH RESEND 02/15] ASoC: meson: add axg fifo base driver

Quoted 9 lines · Takashi Iwai
Quoted 7 lines · Mark Brown

sound/soc/meson/axg-fifo.c line 177

Quoted 1 line · Jerome Brunet
sound/soc/meson/axg-fifo.c new file +1 -0
+	return !status ? IRQ_NONE : IRQ_HANDLED;

Please just write normal conditional statements, it makes things a lot easier to read (the ! isn't helping either here).

Indeed. I'll correct this in a follow up patch

Quoted 2 lines

... and there is the standard IRQ_RETVAL() macro for this purpose.

I was not aware of it. Thanks for the tip Takashi

Quoted 3 lines

Takashi

author maintainer
#6 lore raw

PATCH RESEND 3/15 ASoC: meson: add axg frddr driver

In reply to Jerome Brunet

Add the playback memory interface of Amlogic's axg SoCs. This device pulls data from DDR to an internal FIFO. This FIFO is then used to feed TDM and SPDIF Output devices.

---
 sound/soc/meson/Kconfig     |   7 +++
 sound/soc/meson/Makefile    |   2 +
 sound/soc/meson/axg-frddr.c | 141 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 150 insertions(+)
 create mode 100644 sound/soc/meson/axg-frddr.c
sound/soc/meson/Kconfig +7 -0
index c3eb5e050308..cdd78f62e8d7 100644
@@ -5,4 +5,11 @@ config SND_MESON_AXG_FIFO
 	tristate
 	select REGMAP_MMIO
 
+config SND_MESON_AXG_FRDDR
+	tristate "Amlogic AXG Playback FIFO support"
+	select SND_MESON_AXG_FIFO
+	help
+	  Select Y or M to add support for the frontend playback interfaces
+	  embedded in the Amlogic AXG SoC family
+
 endmenu
sound/soc/meson/Makefile +2 -0
index 75289b6b3ade..9c5d7d4a8e33 100644
@@ -1,5 +1,7 @@
 # SPDX-License-Identifier: (GPL-2.0 OR MIT)
 
 snd-soc-meson-axg-fifo-objs := axg-fifo.o
+snd-soc-meson-axg-frddr-objs := axg-frddr.o
 
 obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o
+obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o
sound/soc/meson/axg-frddr.c new file +141 -0

141 lines not on this page · raw message

Signature · 1 line
2.14.4
author maintainer
#7 lore raw

PATCH RESEND 4/15 ASoC: meson: add axg toddr driver

In reply to Jerome Brunet

Add the capture memory interface of Amlogic's axg SoCs. TDM, SPDIF or PDM input devices place audio samples inside this FIFO. The FIFO content is then pushed to DDR

---
 sound/soc/meson/Kconfig     |   7 ++
 sound/soc/meson/Makefile    |   2 +
 sound/soc/meson/axg-toddr.c | 199 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 208 insertions(+)
 create mode 100644 sound/soc/meson/axg-toddr.c
sound/soc/meson/Kconfig +7 -0
index cdd78f62e8d7..3916060edcae 100644
@@ -12,4 +12,11 @@ config SND_MESON_AXG_FRDDR
 	  Select Y or M to add support for the frontend playback interfaces
 	  embedded in the Amlogic AXG SoC family
 
+config SND_MESON_AXG_TODDR
+	tristate "Amlogic AXG Capture FIFO support"
+	select SND_MESON_AXG_FIFO
+	help
+	  Select Y or M to add support for the frontend capture interfaces
+	  embedded in the Amlogic AXG SoC family
+
 endmenu
sound/soc/meson/Makefile +2 -0
index 9c5d7d4a8e33..12edf2db2a24 100644
@@ -2,6 +2,8 @@
 
 snd-soc-meson-axg-fifo-objs := axg-fifo.o
 snd-soc-meson-axg-frddr-objs := axg-frddr.o
+snd-soc-meson-axg-toddr-objs := axg-toddr.o
 
 obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o
 obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o
+obj-$(CONFIG_SND_MESON_AXG_TODDR) += snd-soc-meson-axg-toddr.o
sound/soc/meson/axg-toddr.c new file +199 -0

199 lines not on this page · raw message

Signature · 1 line
2.14.4
author maintainer
#8 lore raw

PATCH RESEND 5/15 ASoC: meson: add axg spdif output DT bindings documentation

In reply to Jerome Brunet

Add the DT bindings documentation for axg's SPDIF output.

---
 .../bindings/sound/amlogic,axg-spdifout.txt          | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-spdifout.txt
Documentation/devicetree/bindings/sound/amlogic,axg-spdifout.txt new file +20 -0
new file mode 100644
index 000000000000..521c38ad89e7
@@ -0,0 +1,20 @@
+* Amlogic Audio SPDIF Output
+
+Required properties:
+- compatible: 'amlogic,axg-spdifout'
+- clocks: list of clock phandle, one for each entry clock-names.
+- clock-names: should contain the following:
+  * "pclk" : peripheral clock.
+  * "mclk" : master clock
+- #sound-dai-cells: must be 0.
+
+Example on the A113 SoC:
+
+spdifout: audio-controller@480 {
+	compatible = "amlogic,axg-spdifout";
+	reg = <0x0 0x480 0x0 0x50>;
+	#sound-dai-cells = <0>;
+	clocks = <&clkc_audio AUD_CLKID_SPDIFOUT>,
+		 <&clkc_audio AUD_CLKID_SPDIFOUT_CLK>;
+	clock-names = "pclk", "mclk";
+};
Signature · 1 line
2.14.4
author maintainer
#9 lore raw

PATCH RESEND 6/15 ASoC: meson: add axg spdif output

In reply to Jerome Brunet

Add support for the spdif output serializer of the axg SoC family

---
 sound/soc/meson/Kconfig        |   7 +
 sound/soc/meson/Makefile       |   2 +
 sound/soc/meson/axg-spdifout.c | 456 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 465 insertions(+)
 create mode 100644 sound/soc/meson/axg-spdifout.c
sound/soc/meson/Kconfig +7 -0
index 3916060edcae..9408214b5854 100644
@@ -19,4 +19,11 @@ config SND_MESON_AXG_TODDR
 	  Select Y or M to add support for the frontend capture interfaces
 	  embedded in the Amlogic AXG SoC family
 
+config SND_MESON_AXG_SPDIFOUT
+	tristate "Amlogic AXG SPDIF Output Support"
+	imply SND_SOC_SPDIF
+	help
+	  Select Y or M to add support for SPDIF output serializer embedded
+	  in the Amlogic AXG SoC family
+
 endmenu
sound/soc/meson/Makefile +2 -0
index 12edf2db2a24..d51ae045ef08 100644
@@ -3,7 +3,9 @@
 snd-soc-meson-axg-fifo-objs := axg-fifo.o
 snd-soc-meson-axg-frddr-objs := axg-frddr.o
 snd-soc-meson-axg-toddr-objs := axg-toddr.o
+snd-soc-meson-axg-spdifout-objs := axg-spdifout.o
 
 obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o
 obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o
 obj-$(CONFIG_SND_MESON_AXG_TODDR) += snd-soc-meson-axg-toddr.o
+obj-$(CONFIG_SND_MESON_AXG_SPDIFOUT) += snd-soc-meson-axg-spdifout.o
sound/soc/meson/axg-spdifout.c new file +456 -0

456 lines not on this page · raw message

Signature · 1 line
2.14.4
author maintainer
#10 lore raw

PATCH RESEND 7/15 ASoC: meson: add axg tdm formatters DT bindings documentation

In reply to Jerome Brunet

Add the DT bindings documentation for axg's TDM formatters: TDMIN and TDMOUT.

---
 .../bindings/sound/amlogic,axg-tdm-formatters.txt  | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-tdm-formatters.txt
Documentation/devicetree/bindings/sound/amlogic,axg-tdm-formatters.txt new file +28 -0
new file mode 100644
index 000000000000..1c1b7490554e
@@ -0,0 +1,28 @@
+* Amlogic Audio TDM formatters
+
+Required properties:
+- compatible: 'amlogic,axg-tdmin' or
+	      'amlogic,axg-tdmout'
+- reg: physical base address of the controller and length of memory
+       mapped region.
+- clocks: list of clock phandle, one for each entry clock-names.
+- clock-names: should contain the following:
+  * "pclk"     : peripheral clock.
+  * "sclk"     : bit clock.
+  * "sclk_sel" : bit clock input multiplexer.
+  * "lrclk"    : sample clock
+  * "lrclk_sel": sample clock input multiplexer
+
+Example of TDMOUT_A on the A113 SoC:
+
+tdmout_a: audio-controller@500 {
+	compatible = "amlogic,axg-tdmout";
+	reg = <0x0 0x500 0x0 0x40>;
+	clocks = <&clkc_audio AUD_CLKID_TDMOUT_A>,
+		 <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK>,
+		 <&clkc_audio AUD_CLKID_TDMOUT_A_SCLK_SEL>,
+		 <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>,
+		 <&clkc_audio AUD_CLKID_TDMOUT_A_LRCLK>;
+	clock-names = "pclk", "sclk", "sclk_sel",
+		      "lrclk", "lrclk_sel";
+};
Signature · 1 line
2.14.4
author maintainer
#11 lore raw

PATCH RESEND 8/15 ASoC: meson: add axg tdm interface DT bindings documentation

In reply to Jerome Brunet

Add the DT bindings documentation for axg's TDM interfaces

---
 .../bindings/sound/amlogic,axg-tdm-iface.txt       | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-tdm-iface.txt
Documentation/devicetree/bindings/sound/amlogic,axg-tdm-iface.txt new file +22 -0
new file mode 100644
index 000000000000..cabfb26a5f22
@@ -0,0 +1,22 @@
+* Amlogic Audio TDM Interfaces
+
+Required properties:
+- compatible: 'amlogic,axg-tdm-iface'
+- clocks: list of clock phandle, one for each entry clock-names.
+- clock-names: should contain the following:
+  * "sclk" : bit clock.
+  * "lrclk": sample clock
+  * "mclk" : master clock
+	     -> optional if the interface is in clock slave mode.
+- #sound-dai-cells: must be 0.
+
+Example of TDM_A on the A113 SoC:
+
+tdmif_a: audio-controller@0 {
+	compatible = "amlogic,axg-tdm-iface";
+	#sound-dai-cells = <0>;
+	clocks = <&clkc_audio AUD_CLKID_MST_A_MCLK>,
+		 <&clkc_audio AUD_CLKID_MST_A_SCLK>,
+		 <&clkc_audio AUD_CLKID_MST_A_LRCLK>;
+	clock-names = "mclk", "sclk", "lrclk";
+};
Signature · 1 line
2.14.4
author maintainer
#12 lore raw

PATCH RESEND 9/15 ASoC: meson: add tdm formatter base driver

In reply to Jerome Brunet

Add Amlogic's axg TDM core driver. On this SoC, tdm is bit more complex than usual, mainly because the different TDM input decoders can be attached to any of TDM pad interface, including the output pads.

For the this, TDM on this SoC is modeled like this:
- TDM interface provides the DAIs the codecs will be attached to. The main responsibility of this driver is to manage the pad format and the TDM clock rates.
- TDM Formatters: These are the entities which are actually dealing with the TDM signal. TDMOUT produce a TDM signal from the audio sample provided by FRDDR using the clocks provided the TDM interface. TDMIN feeds TODDR with audio sample using the clocks and TDM signal provided by the TDM Interface.
- TDM Streams: This provides the link between 1 DAI stream of the TDM interface and one (or more) TDM formatters.

This driver provides the TDM formatter and TDM stream operations.

---
 sound/soc/meson/Kconfig             |   4 +
 sound/soc/meson/Makefile            |   2 +
 sound/soc/meson/axg-tdm-formatter.c | 381 ++++++++++++++++++++++++++++++++++++
 sound/soc/meson/axg-tdm-formatter.h |  39 ++++
 sound/soc/meson/axg-tdm.h           |  74 +++++++
 5 files changed, 500 insertions(+)
 create mode 100644 sound/soc/meson/axg-tdm-formatter.c
 create mode 100644 sound/soc/meson/axg-tdm-formatter.h
 create mode 100644 sound/soc/meson/axg-tdm.h
sound/soc/meson/Kconfig +4 -0
index 9408214b5854..80a88689491f 100644
@@ -19,6 +19,10 @@ config SND_MESON_AXG_TODDR
 	  Select Y or M to add support for the frontend capture interfaces
 	  embedded in the Amlogic AXG SoC family
 
+config SND_MESON_AXG_TDM_FORMATTER
+	tristate
+	select REGMAP_MMIO
+
 config SND_MESON_AXG_SPDIFOUT
 	tristate "Amlogic AXG SPDIF Output Support"
 	imply SND_SOC_SPDIF
sound/soc/meson/Makefile +2 -0
index d51ae045ef08..a06b56a1c995 100644
@@ -3,9 +3,11 @@
 snd-soc-meson-axg-fifo-objs := axg-fifo.o
 snd-soc-meson-axg-frddr-objs := axg-frddr.o
 snd-soc-meson-axg-toddr-objs := axg-toddr.o
+snd-soc-meson-axg-tdm-formatter-objs := axg-tdm-formatter.o
 snd-soc-meson-axg-spdifout-objs := axg-spdifout.o
 
 obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o
 obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o
 obj-$(CONFIG_SND_MESON_AXG_TODDR) += snd-soc-meson-axg-toddr.o
+obj-$(CONFIG_SND_MESON_AXG_TDM_FORMATTER) += snd-soc-meson-axg-tdm-formatter.o
 obj-$(CONFIG_SND_MESON_AXG_SPDIFOUT) += snd-soc-meson-axg-spdifout.o
sound/soc/meson/axg-tdm-formatter.c new file +381 -0

381 lines not on this page · raw message

sound/soc/meson/axg-tdm-formatter.h new file +39 -0
new file mode 100644
index 000000000000..cf947caf3cb1
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT)
+ *
+ * Copyright (c) 2018 Baylibre SAS.
+ * Author: Jerome Brunet <[email protected]>
+ */
+
+#ifndef _MESON_AXG_TDM_FORMATTER_H
+#define _MESON_AXG_TDM_FORMATTER_H
+
+#include "axg-tdm.h"
+
+struct platform_device;
+struct regmap;
+struct snd_soc_dapm_widget;
+struct snd_kcontrol;
+
+struct axg_tdm_formatter_ops {
+	struct axg_tdm_stream *(*get_stream)(struct snd_soc_dapm_widget *w);
+	void (*enable)(struct regmap *map);
+	void (*disable)(struct regmap *map);
+	int (*prepare)(struct regmap *map, struct axg_tdm_stream *ts);
+};
+
+struct axg_tdm_formatter_driver {
+	const struct snd_soc_component_driver *component_drv;
+	const struct regmap_config *regmap_cfg;
+	const struct axg_tdm_formatter_ops *ops;
+	bool invert_sclk;
+};
+
+int axg_tdm_formatter_set_channel_masks(struct regmap *map,
+					struct axg_tdm_stream *ts,
+					unsigned int offset);
+int axg_tdm_formatter_event(struct snd_soc_dapm_widget *w,
+			    struct snd_kcontrol *control,
+			    int event);
+int axg_tdm_formatter_probe(struct platform_device *pdev);
+
+#endif /* _MESON_AXG_TDM_FORMATTER_H */
sound/soc/meson/axg-tdm.h new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
2.14.4
author maintainer
#13 lore raw

PATCH RESEND 10/15 ASoC: meson: add tdm interface driver

In reply to Jerome Brunet

Add Amlogic's axg TDM interface driver. This driver manages the format and clocks provided on the pads.

On this SoC, each stream direction provides 4 serial lanes. This makes a maximum of 8 channels in i2s modes and 128 channels in DSP modes.

While each lanes operate on the same slot number (same bit clock), they may have different TDM masks. This requires to provide a function to let the card set the 4 masks, in lieu of the usual set_tdm_slots() callback of the dai driver.

---
 sound/soc/meson/Kconfig             |   4 +
 sound/soc/meson/Makefile            |   2 +
 sound/soc/meson/axg-tdm-interface.c | 542 ++++++++++++++++++++++++++++++++++++
 sound/soc/meson/axg-tdm.h           |   4 +
 4 files changed, 552 insertions(+)
 create mode 100644 sound/soc/meson/axg-tdm-interface.c
sound/soc/meson/Kconfig +4 -0
index 80a88689491f..869b359c2ce7 100644
@@ -23,6 +23,10 @@ config SND_MESON_AXG_TDM_FORMATTER
 	tristate
 	select REGMAP_MMIO
 
+config SND_MESON_AXG_TDM_INTERFACE
+	tristate
+	select SND_MESON_AXG_TDM_FORMATTER
+
 config SND_MESON_AXG_SPDIFOUT
 	tristate "Amlogic AXG SPDIF Output Support"
 	imply SND_SOC_SPDIF
sound/soc/meson/Makefile +2 -0
index a06b56a1c995..1a8eb77402e3 100644
@@ -4,10 +4,12 @@ snd-soc-meson-axg-fifo-objs := axg-fifo.o
 snd-soc-meson-axg-frddr-objs := axg-frddr.o
 snd-soc-meson-axg-toddr-objs := axg-toddr.o
 snd-soc-meson-axg-tdm-formatter-objs := axg-tdm-formatter.o
+snd-soc-meson-axg-tdm-interface-objs := axg-tdm-interface.o
 snd-soc-meson-axg-spdifout-objs := axg-spdifout.o
 
 obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o
 obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o
 obj-$(CONFIG_SND_MESON_AXG_TODDR) += snd-soc-meson-axg-toddr.o
 obj-$(CONFIG_SND_MESON_AXG_TDM_FORMATTER) += snd-soc-meson-axg-tdm-formatter.o
+obj-$(CONFIG_SND_MESON_AXG_TDM_INTERFACE) += snd-soc-meson-axg-tdm-interface.o
 obj-$(CONFIG_SND_MESON_AXG_SPDIFOUT) += snd-soc-meson-axg-spdifout.o
sound/soc/meson/axg-tdm-interface.c new file +542 -0

542 lines not on this page · raw message

sound/soc/meson/axg-tdm.h +4 -0
index 435d95b86457..e578b6f40a07 100644
@@ -71,4 +71,8 @@ static inline int axg_tdm_stream_reset(struct axg_tdm_stream *ts)
 	return axg_tdm_stream_start(ts);
 }
 
+int axg_tdm_set_tdm_slots(struct snd_soc_dai *dai, u32 *tx_mask,
+			  u32 *rx_mask, unsigned int slots,
+			  unsigned int slot_width);
+
 #endif /* _MESON_AXG_TDM_H */
Signature · 1 line
2.14.4
author maintainer
#14 lore raw

PATCH RESEND 11/15 ASoC: meson: add tdm output driver

In reply to Jerome Brunet

Add Amlogic's axg tdm output driver which pulls data from FRDDR fifo and produce the TDM signals for 4 output lanes.

---
 sound/soc/meson/Kconfig      |   8 ++
 sound/soc/meson/Makefile     |   2 +
 sound/soc/meson/axg-tdmout.c | 259 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 269 insertions(+)
 create mode 100644 sound/soc/meson/axg-tdmout.c
sound/soc/meson/Kconfig +8 -0
index 869b359c2ce7..08a522b77749 100644
@@ -27,6 +27,14 @@ config SND_MESON_AXG_TDM_INTERFACE
 	tristate
 	select SND_MESON_AXG_TDM_FORMATTER
 
+config SND_MESON_AXG_TDMOUT
+	tristate "Amlogic AXG TDM Output Support"
+	select SND_MESON_AXG_TDM_FORMATTER
+	select SND_MESON_AXG_TDM_INTERFACE
+	help
+	  Select Y or M to add support for TDM output formatter embedded
+	  in the Amlogic AXG SoC family
+
 config SND_MESON_AXG_SPDIFOUT
 	tristate "Amlogic AXG SPDIF Output Support"
 	imply SND_SOC_SPDIF
sound/soc/meson/Makefile +2 -0
index 1a8eb77402e3..a665c6b76a95 100644
@@ -5,6 +5,7 @@ snd-soc-meson-axg-frddr-objs := axg-frddr.o
 snd-soc-meson-axg-toddr-objs := axg-toddr.o
 snd-soc-meson-axg-tdm-formatter-objs := axg-tdm-formatter.o
 snd-soc-meson-axg-tdm-interface-objs := axg-tdm-interface.o
+snd-soc-meson-axg-tdmout-objs := axg-tdmout.o
 snd-soc-meson-axg-spdifout-objs := axg-spdifout.o
 
 obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o
@@ -12,4 +13,5 @@ obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o
 obj-$(CONFIG_SND_MESON_AXG_TODDR) += snd-soc-meson-axg-toddr.o
 obj-$(CONFIG_SND_MESON_AXG_TDM_FORMATTER) += snd-soc-meson-axg-tdm-formatter.o
 obj-$(CONFIG_SND_MESON_AXG_TDM_INTERFACE) += snd-soc-meson-axg-tdm-interface.o
+obj-$(CONFIG_SND_MESON_AXG_TDMOUT) += snd-soc-meson-axg-tdmout.o
 obj-$(CONFIG_SND_MESON_AXG_SPDIFOUT) += snd-soc-meson-axg-spdifout.o
sound/soc/meson/axg-tdmout.c new file +259 -0

259 lines not on this page · raw message

Signature · 1 line
2.14.4
author maintainer
#15 lore raw

PATCH RESEND 12/15 ASoC: meson: add tdm input driver

In reply to Jerome Brunet

Add Amlogic's axg TDM input driver which take the TDM signal of 4 input lanes and push the decoded audio samples to TODDR fifo

---
 sound/soc/meson/Kconfig     |   8 ++
 sound/soc/meson/Makefile    |   2 +
 sound/soc/meson/axg-tdmin.c | 229 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 239 insertions(+)
 create mode 100644 sound/soc/meson/axg-tdmin.c
sound/soc/meson/Kconfig +8 -0
index 08a522b77749..00d05df67b52 100644
@@ -27,6 +27,14 @@ config SND_MESON_AXG_TDM_INTERFACE
 	tristate
 	select SND_MESON_AXG_TDM_FORMATTER
 
+config SND_MESON_AXG_TDMIN
+	tristate "Amlogic AXG TDM Input Support"
+	select SND_MESON_AXG_TDM_FORMATTER
+	select SND_MESON_AXG_TDM_INTERFACE
+	help
+	  Select Y or M to add support for TDM input formatter embedded
+	  in the Amlogic AXG SoC family
+
 config SND_MESON_AXG_TDMOUT
 	tristate "Amlogic AXG TDM Output Support"
 	select SND_MESON_AXG_TDM_FORMATTER
sound/soc/meson/Makefile +2 -0
index a665c6b76a95..f62833fb44d8 100644
@@ -5,6 +5,7 @@ snd-soc-meson-axg-frddr-objs := axg-frddr.o
 snd-soc-meson-axg-toddr-objs := axg-toddr.o
 snd-soc-meson-axg-tdm-formatter-objs := axg-tdm-formatter.o
 snd-soc-meson-axg-tdm-interface-objs := axg-tdm-interface.o
+snd-soc-meson-axg-tdmin-objs := axg-tdmin.o
 snd-soc-meson-axg-tdmout-objs := axg-tdmout.o
 snd-soc-meson-axg-spdifout-objs := axg-spdifout.o
 
@@ -13,5 +14,6 @@ obj-$(CONFIG_SND_MESON_AXG_FRDDR) += snd-soc-meson-axg-frddr.o
 obj-$(CONFIG_SND_MESON_AXG_TODDR) += snd-soc-meson-axg-toddr.o
 obj-$(CONFIG_SND_MESON_AXG_TDM_FORMATTER) += snd-soc-meson-axg-tdm-formatter.o
 obj-$(CONFIG_SND_MESON_AXG_TDM_INTERFACE) += snd-soc-meson-axg-tdm-interface.o
+obj-$(CONFIG_SND_MESON_AXG_TDMIN) += snd-soc-meson-axg-tdmin.o
 obj-$(CONFIG_SND_MESON_AXG_TDMOUT) += snd-soc-meson-axg-tdmout.o
 obj-$(CONFIG_SND_MESON_AXG_SPDIFOUT) += snd-soc-meson-axg-spdifout.o
sound/soc/meson/axg-tdmin.c new file +229 -0

229 lines not on this page · raw message

Signature · 1 line
2.14.4
author maintainer
#16 lore raw

PATCH RESEND 13/15 ASoC: export snd_soc_of_get_slot_mask

In reply to Jerome Brunet

Amlogic's axg card driver can't use snd_soc_of_parse_tdm_slot() directly because it needs to handle 4 mask for each direction. Yet the parsing of each mask is the same, so export snd_soc_of_get_slot_mask() to reuse the the existing code.

---
 include/sound/soc.h  | 3 +++
 sound/soc/soc-core.c | 7 ++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
include/sound/soc.h +3 -0
index a4915148f739..41cec42fb456 100644
@@ -1426,6 +1426,9 @@ int snd_soc_of_parse_card_name(struct snd_soc_card *card,
 			       const char *propname);
 int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
 					  const char *propname);
+int snd_soc_of_get_slot_mask(struct device_node *np,
+			     const char *prop_name,
+			     unsigned int *mask);
 int snd_soc_of_parse_tdm_slot(struct device_node *np,
 			      unsigned int *tx_mask,
 			      unsigned int *rx_mask,
sound/soc/soc-core.c +4 -3
index 3be0310d5c81..1344e8e602fd 100644
@@ -3366,9 +3366,9 @@ int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_simple_widgets);
 
-static int snd_soc_of_get_slot_mask(struct device_node *np,
-				    const char *prop_name,
-				    unsigned int *mask)
+int snd_soc_of_get_slot_mask(struct device_node *np,
+			     const char *prop_name,
+			     unsigned int *mask)
 {
 	u32 val;
 	const __be32 *of_slot_mask = of_get_property(np, prop_name, &val);
@@ -3383,6 +3383,7 @@ static int snd_soc_of_get_slot_mask(struct device_node *np,
 
 	return val;
 }
+EXPORT_SYMBOL_GPL(snd_soc_of_get_slot_mask);
 
 int snd_soc_of_parse_tdm_slot(struct device_node *np,
 			      unsigned int *tx_mask,
Signature · 1 line
2.14.4
author maintainer
#17 lore raw

PATCH RESEND 14/15 ASoC: meson: add axg sound card DT bindings documentation

In reply to Jerome Brunet

Add the DT bindings documentation for axg sound card

---
 .../bindings/sound/amlogic,axg-sound-card.txt      | 124 +++++++++++++++++++++
 1 file changed, 124 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/amlogic,axg-sound-card.txt
Documentation/devicetree/bindings/sound/amlogic,axg-sound-card.txt new file +124 -0
new file mode 100644
index 000000000000..39e005da0407
@@ -0,0 +1,124 @@
+Amlogic AXG sound card:
+
+Required properties:
+
+- compatible: "amlogic,axg-sound-card"
+- amlogic,name : User specified audio sound card name, one string
+
+Optional properties:
+
+- amlogic,aux-devs : List of phandles pointing to auxiliary devices
+- amlogic,widgets : Please refer to widgets.txt.
+- amlogic,routing : A list of the connections between audio components.
+
+Subnodes:
+
+- amlogic,dai-link: Container for dai-link level properties and the
+		    CODEC sub-nodes. There should be at least one (and
+		    probably) subnode of this type.
+
+Required dai-link properties:
+
+- sound-dai: phandle and port of the CPU DAI.
+
+Required TDM Backend dai-link properties:
+- dai-format : CPU/CODEC common audio format
+
+Optional TDM Backend dai-link properties:
+- dai-tdm-slot-rx-mask-{0,1,2,3}: Receive direction slot masks
+- dai-tdm-slot-tx-mask-{0,1,2,3}: Transmit direction slot masks
+				  When omitted, mask is assumed to have to no
+				  slots. A valid must have at one slot, so at
+				  least one these mask should be provided with
+				  an enabled slot.
+- dai-tdm-slot-num : Please refer to tdm-slot.txt.
+		     If omitted, slot number is set to accommodate the largest
+		     mask provided.
+- dai-tdm-slot-width : Please refer to tdm-slot.txt. default to 32 if omitted.
+- mclk-fs : Multiplication factor between stream rate and mclk
+
+Backend dai-link subnodes:
+
+- codec: dai-link representing backend links should have at least one subnode.
+	 One subnode for each codec of the dai-link.
+	 dai-link representing frontend links have no codec, therefore have no
+	 subnodes
+
+Required codec subnodes properties:
+
+- sound-dai: phandle and port of the CODEC DAI.
+
+Optional codec subnodes properties:
+
+- dai-tdm-slot-tx-mask : Please refer to tdm-slot.txt.
+- dai-tdm-slot-rx-mask : Please refer to tdm-slot.txt.
+
+Example:
+
+sound {
+	compatible = "amlogic,axg-sound-card";
+	amlogic,name = "AXG-S420";
+	amlogic,aux-devs = <&tdmin_a>, <&tdmout_c>;
+	amlogic,widgets = "Line", "Lineout",
+			  "Line", "Linein",
+			  "Speaker", "Speaker1 Left",
+			  "Speaker", "Speaker1 Right";
+			  "Speaker", "Speaker2 Left",
+			  "Speaker", "Speaker2 Right";
+	amlogic,routing = "TDMOUT_C IN 0", "FRDDR_A OUT 2",
+			  "SPDIFOUT IN 0", "FRDDR_A OUT 3",
+			  "TDM_C Playback", "TDMOUT_C OUT",
+			  "TDMIN_A IN 2", "TDM_C Capture",
+			  "TDMIN_A IN 5", "TDM_C Loopback",
+			  "TODDR_A IN 0", "TDMIN_A OUT",
+			  "Lineout", "Lineout AOUTL",
+			  "Lineout", "Lineout AOUTR",
+			  "Speaker1 Left", "SPK1 OUT_A",
+			  "Speaker2 Left", "SPK2 OUT_A",
+			  "Speaker1 Right", "SPK1 OUT_B",
+			  "Speaker2 Right", "SPK2 OUT_B",
+			  "Linein AINL", "Linein",
+			  "Linein AINR", "Linein";
+
+	amlogic,dai-link@0 {
+		sound-dai = <&frddr_a>;
+	};
+
+	amlogic,dai-link@1 {
+		sound-dai = <&toddr_a>;
+	};
+
+	amlogic,dai-link@2 {
+		sound-dai = <&tdmif_c>;
+		dai-format = "i2s";
+		dai-tdm-slot-tx-mask-2 = <1 1>;
+		dai-tdm-slot-tx-mask-3 = <1 1>;
+		dai-tdm-slot-rx-mask-1 = <1 1>;
+		mclk-fs = <256>;
+
+		codec@0 {
+			sound-dai = <&lineout>;
+		};
+
+		codec@1 {
+			sound-dai = <&speaker_amp1>;
+		};
+
+		codec@2 {
+			sound-dai = <&speaker_amp2>;
+		};
+
+		codec@3 {
+			sound-dai = <&linein>;
+		};
+
+	};
+
+	amlogic,dai-link@4 {
+		sound-dai = <&spdifout>;
+
+		codec {
+			sound-dai = <&spdif_dit>;
+		};
+	};
+};
Signature · 1 line
2.14.4
author maintainer
#18 lore raw

PATCH RESEND 15/15 ASoC: meson: add axg sound card support

In reply to Jerome Brunet

Add the axg sound card to handle the specifities of the axg audio sub system.

This card is required to:
* setup the dpcm links specific to the AXG (with a cpu sound dai)
* handle the 4 lanes masks of the tdm interfaces
* add the loopback link when a tdm pad interface has a playback stream
* handle multi-codec links

---
 sound/soc/meson/Kconfig    |  11 +
 sound/soc/meson/Makefile   |   2 +
 sound/soc/meson/axg-card.c | 671 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 684 insertions(+)
 create mode 100644 sound/soc/meson/axg-card.c
sound/soc/meson/Kconfig +11 -0
index 00d05df67b52..4cf93c05a982 100644
@@ -43,6 +43,17 @@ config SND_MESON_AXG_TDMOUT
 	  Select Y or M to add support for TDM output formatter embedded
 	  in the Amlogic AXG SoC family
 
+config SND_MESON_AXG_SOUND_CARD
+	tristate "Amlogic AXG Sound Card Support"
+	select SND_MESON_AXG_TDM_INTERFACE
+	imply SND_MESON_AXG_FRDDR
+	imply SND_MESON_AXG_TODDR
+	imply SND_MESON_AXG_TDMIN
+	imply SND_MESON_AXG_TDMOUT
+	imply SND_MESON_AXG_SPDIFOUT
+	help
+	  Select Y or M to add support for the AXG SoC sound card
+
 config SND_MESON_AXG_SPDIFOUT
 	tristate "Amlogic AXG SPDIF Output Support"
 	imply SND_SOC_SPDIF
sound/soc/meson/Makefile +2 -0
index f62833fb44d8..c5e003b093db 100644
@@ -7,6 +7,7 @@ snd-soc-meson-axg-tdm-formatter-objs := axg-tdm-formatter.o
 snd-soc-meson-axg-tdm-interface-objs := axg-tdm-interface.o
 snd-soc-meson-axg-tdmin-objs := axg-tdmin.o
 snd-soc-meson-axg-tdmout-objs := axg-tdmout.o
+snd-soc-meson-axg-sound-card-objs := axg-card.o
 snd-soc-meson-axg-spdifout-objs := axg-spdifout.o
 
 obj-$(CONFIG_SND_MESON_AXG_FIFO) += snd-soc-meson-axg-fifo.o
@@ -16,4 +17,5 @@ obj-$(CONFIG_SND_MESON_AXG_TDM_FORMATTER) += snd-soc-meson-axg-tdm-formatter.o
 obj-$(CONFIG_SND_MESON_AXG_TDM_INTERFACE) += snd-soc-meson-axg-tdm-interface.o
 obj-$(CONFIG_SND_MESON_AXG_TDMIN) += snd-soc-meson-axg-tdmin.o
 obj-$(CONFIG_SND_MESON_AXG_TDMOUT) += snd-soc-meson-axg-tdmout.o
+obj-$(CONFIG_SND_MESON_AXG_SOUND_CARD) += snd-soc-meson-axg-sound-card.o
 obj-$(CONFIG_SND_MESON_AXG_SPDIFOUT) += snd-soc-meson-axg-spdifout.o
sound/soc/meson/axg-card.c new file +671 -0

671 lines not on this page · raw message

Signature · 1 line
2.14.4