Add freescale S/PDIF CPU DAI and machine drivers
Subsystems (5)
PATCH v10 1/2 ASoC: fsl: Add S/PDIF CPU DAI driver
In reply to Nicolin ChenThis patch implements a device-tree-only CPU DAI driver for Freescale S/PDIF controller that supports stereo playback and record feature.
--- .../devicetree/bindings/sound/fsl,spdif.txt | 54 + sound/soc/fsl/Kconfig | 3 + sound/soc/fsl/Makefile | 2 + sound/soc/fsl/fsl_spdif.c | 1236 ++++++++++++++++++++ sound/soc/fsl/fsl_spdif.h | 191 +++ 5 files changed, 1486 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/fsl,spdif.txt create mode 100644 sound/soc/fsl/fsl_spdif.c create mode 100644 sound/soc/fsl/fsl_spdif.h
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +54 -0
@@ -0,0 +1,54 @@ +Freescale Sony/Philips Digital Interface Format (S/PDIF) Controller + +The Freescale S/PDIF audio block is a stereo transceiver that allows the +processor to receive and transmit digital audio via an coaxial cable or +a fibre cable. + +Required properties: + + - compatible : Compatible list, must contain "fsl,imx35-spdif". + + - reg : Offset and length of the register set for the device. + + - interrupts : Contains the spdif interrupt. + + - dmas : Generic dma devicetree binding as described in + Documentation/devicetree/bindings/dma/dma.txt. + + - dma-names : Two dmas have to be defined, "tx" and "rx". + + - clocks : Contains an entry for each entry in clock-names. + + - clock-names : Includes the following entries: + "core" The core clock of spdif controller + "rxtx<0-7>" Clock source list for tx and rx clock. + This clock list should be identical to + the source list connecting to the spdif + clock mux in "SPDIF Transceiver Clock + Diagram" of SoC reference manual. It + can also be referred to TxClk_Source + bit of register SPDIF_STC. + +Example: + +spdif: spdif@02004000 { + compatible = "fsl,imx35-spdif"; + reg = <0x02004000 0x4000>; + interrupts = <0 52 0x04>; + dmas = <&sdma 14 18 0>, + <&sdma 15 18 0>; + dma-names = "rx", "tx"; + + clocks = <&clks 197>, <&clks 3>, + <&clks 197>, <&clks 107>, + <&clks 0>, <&clks 118>, + <&clks 62>, <&clks 139>, + <&clks 0>; + clock-names = "core", "rxtx0", + "rxtx1", "rxtx2", + "rxtx3", "rxtx4", + "rxtx5", "rxtx6", + "rxtx7"; + + status = "okay"; +};
sound/soc/fsl/Kconfig +3 -0
@@ -1,6 +1,9 @@ config SND_SOC_FSL_SSI tristate +config SND_SOC_FSL_SPDIF + tristate + config SND_SOC_FSL_UTILS tristate
sound/soc/fsl/Makefile +2 -0
@@ -12,9 +12,11 @@ obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o # Freescale PowerPC SSI/DMA Platform Support snd-soc-fsl-ssi-objs := fsl_ssi.o +snd-soc-fsl-spdif-objs := fsl_spdif.o snd-soc-fsl-utils-objs := fsl_utils.o snd-soc-fsl-dma-objs := fsl_dma.o obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o +obj-$(CONFIG_SND_SOC_FSL_SPDIF) += snd-soc-fsl-spdif.o obj-$(CONFIG_SND_SOC_FSL_UTILS) += snd-soc-fsl-utils.o obj-$(CONFIG_SND_SOC_POWERPC_DMA) += snd-soc-fsl-dma.o
sound/soc/fsl/fsl_spdif.c new file +1236 -0
1,236 lines not on this page · raw message
sound/soc/fsl/fsl_spdif.h new file +191 -0
191 lines not on this page · raw message
Signature · 1 line
1.7.1
v10 cover Add freescale S/PDIF CPU DAI and machine drivers
Changelog:v9->v10:
* Removed "dummy" words from binding doc in PATCH-2.v8->v9:
* Use bool instead of atomic_t.
* Use clk_prepare_enable() instead.
* Dropped dumpregs().
* Dropped unnecessary clk_round_rate().
* Dropped unused clock source enum.
* Revised dev_err() message.v7->v8:
* Revised DT binding doc.
* Revised dev_err() error msg.
* Check return value of clk_set_rate().v6->v7:
* Removed extra comma in array.
* Revised some comments.
* Added some dev_err().
* Check the return value of soft reset.
* Use bitrev8() instead of extra reverse_bits().
* Use cache_bypass as default for regmap.v5->v6:
* Sorted out rxtx clk source in DT binding.
* Use devm_xxxx() functions.
* Use platform_get_resource() instead.v4->v5:
* Dropped rx/tx-clksrc-names DT bindings.
* Use standard clock binding instead to pass the clock source list.
* Update the compatible list by using "imx35", the first SoC that has spdif.v3->v4:
* Use regmap for CPU DAI driver.
* Use individual clock source for 32KHz, 44KHz, 48KHz playback.
* Determine clock source configuration from 'clocks' entry.
* Added imx53 to compatible list, merged imx6q and imx6dl in the list.
* Improve the algorism of reverse_bits().
* Dropped the unneeded clk_put().v2->v3:
* Removed a wrong tag from the commit of patch-1.v1->v2:
* Dropped one applied patch for spdif dummy codec drivers.
* Use generic DMA DT binding.
* Let spdif controller driver calculate the clock div.
* Added one optional clock source for spdif tx.
* Reivsed documentation accordingly.
Nicolin Chen (2):
ASoC: fsl: Add S/PDIF CPU DAI driver
ASoC: fsl: Add S/PDIF machine driver
.../devicetree/bindings/sound/fsl,spdif.txt | 54 + .../devicetree/bindings/sound/imx-audio-spdif.txt | 29 + sound/soc/fsl/Kconfig | 14 + sound/soc/fsl/Makefile | 4 + sound/soc/fsl/fsl_spdif.c | 1236 ++++++++++++++++++++ sound/soc/fsl/fsl_spdif.h | 191 +++ sound/soc/fsl/imx-spdif.c | 134 +++ 7 files changed, 1662 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/fsl,spdif.txt create mode 100644 Documentation/devicetree/bindings/sound/imx-audio-spdif.txt create mode 100644 sound/soc/fsl/fsl_spdif.c create mode 100644 sound/soc/fsl/fsl_spdif.h create mode 100644 sound/soc/fsl/imx-spdif.c
PATCH v10 2/2 ASoC: fsl: Add S/PDIF machine driver
This patch implements a device-tree-only machine driver for Freescale i.MX series Soc. It works with spdif_transmitter/spdif_receiver and fsl_spdif.c drivers.
--- .../devicetree/bindings/sound/imx-audio-spdif.txt | 29 +++++ sound/soc/fsl/Kconfig | 11 ++ sound/soc/fsl/Makefile | 2 + sound/soc/fsl/imx-spdif.c | 134 ++++++++++++++++++++ 4 files changed, 176 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/imx-audio-spdif.txt create mode 100644 sound/soc/fsl/imx-spdif.c
Documentation/devicetree/bindings/sound/imx-audio-spdif.txt new file +29 -0
@@ -0,0 +1,29 @@ +Freescale i.MX audio complex with S/PDIF transceiver + +Required properties: + + - compatible : "fsl,imx-audio-spdif" + + - model : The user-visible name of this sound complex + + - spdif-controller : The phandle of the i.MX S/PDIF controller + + +Optional properties: + + - spdif-transmitter : The phandle of the spdif-transmitter codec + + - spdif-receiver : The phandle of the spdif-receiver codec + +* Note: At least one of these two properties should be set in the DT binding. + + +Example: + +sound-spdif { + compatible = "fsl,imx-audio-spdif"; + model = "imx-spdif"; + spdif-controller = <&spdif>; + spdif-transmitter = <&spdif_tx_codec>; + spdif-receiver = <&spdif_rx_codec>; +};
sound/soc/fsl/Kconfig +11 -0
@@ -193,6 +193,17 @@ config SND_SOC_IMX_SGTL5000 Say Y if you want to add support for SoC audio on an i.MX board with a sgtl5000 codec. +config SND_SOC_IMX_SPDIF + tristate "SoC Audio support for i.MX boards with S/PDIF" + select SND_SOC_IMX_PCM_DMA + select SND_SOC_FSL_SPDIF + select SND_SOC_FSL_UTILS + select SND_SOC_SPDIF + help + SoC Audio support for i.MX boards with S/PDIF + Say Y if you want to add support for SoC audio on an i.MX board with + a S/DPDIF. + config SND_SOC_IMX_MC13783 tristate "SoC Audio support for I.MX boards with mc13783" depends on MFD_MC13783 && ARM
sound/soc/fsl/Makefile +2 -0
@@ -45,6 +45,7 @@ snd-soc-mx27vis-aic32x4-objs := mx27vis-aic32x4.o snd-soc-wm1133-ev1-objs := wm1133-ev1.o snd-soc-imx-sgtl5000-objs := imx-sgtl5000.o snd-soc-imx-wm8962-objs := imx-wm8962.o +snd-soc-imx-spdif-objs :=imx-spdif.o snd-soc-imx-mc13783-objs := imx-mc13783.o obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o
@@ -53,4 +54,5 @@ obj-$(CONFIG_SND_SOC_MX27VIS_AIC32X4) += snd-soc-mx27vis-aic32x4.o obj-$(CONFIG_SND_MXC_SOC_WM1133_EV1) += snd-soc-wm1133-ev1.o obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o obj-$(CONFIG_SND_SOC_IMX_WM8962) += snd-soc-imx-wm8962.o +obj-$(CONFIG_SND_SOC_IMX_SPDIF) += snd-soc-imx-spdif.o obj-$(CONFIG_SND_SOC_IMX_MC13783) += snd-soc-imx-mc13783.o
sound/soc/fsl/imx-spdif.c new file +134 -0
134 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [PATCH v10 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
In reply to Nicolin ChenQuoted 2 lines · Nicolin Chen
This patch implements a device-tree-only CPU DAI driver for Freescale S/PDIF controller that supports stereo playback and record feature.
The DT bindings part of this patch,
Re: [PATCH v10 2/2] ASoC: fsl: Add S/PDIF machine driver
In reply to Nicolin ChenDocumentation/devicetree/bindings/sound/imx-audio-spdif.txt line 18
Quoted 13 lines · Nicolin Chen
This patch implements a device-tree-only machine driver for Freescale i.MX series Soc. It works with spdif_transmitter/spdif_receiver and
fsl_spdif.cdrivers.Documentation/devicetree/bindings/sound/imx-audio-spdif.txt +7
-0+Optional properties: + + - spdif-transmitter : The phandle of the spdif-transmitter codec + + - spdif-receiver : The phandle of the spdif-receiver codec + +* Note: At least one of these two properties should be set in the DT binding.
I still don't think those two properties are correct.
Exactly what node will those phandles point at?
There definitely should not be a DT node for any "dummy CODEC", irrespective of whether this binding calls the other node a "CODEC" or a "dummy CODEC".
If these properties are to contain phandles, it would be acceptable for the referenced node to be:
* A node representing the physical connector/jack on the board.
* A node representing some other IP block on the board, such as an HDMI encoder/display-controller
I think those options are unlikely in general, so I think instead these properties should just be Boolean indicating that "something" is connector to the S/PDIF RX/TX, without specifying what that "something" is. It doesn't matter what at least in the connector/jack case, although perhaps it does in the HDMI encoder/display-controller?
Re: [PATCH v10 2/2] ASoC: fsl: Add S/PDIF machine driver
Quoted 19 lines · On Wednesday 21 of August 2013 12:30:59 Stephen Warren wrote:
Quoted 15 lines · Nicolin Chen
This patch implements a device-tree-only machine driver for Freescale i.MX series Soc. It works with spdif_transmitter/spdif_receiver and
fsl_spdif.cdrivers.diff --git
a/Documentation/devicetree/bindings/sound/imx-audio-spdif.txtb/Documentation/devicetree/bindings/sound/imx-audio-spdif.txtDocumentation/devicetree/bindings/sound/imx-audio-spdif.txt new file +7
-0+Optional properties: + + - spdif-transmitter : The phandle of the spdif-transmitter codec + + - spdif-receiver : The phandle of the spdif-receiver codec + +* Note: At least one of these two properties should be set in the DTQuoted 1 line
binding.
I still don't think those two properties are correct.
Quoted 1 line
Exactly what node will those phandles point at?
Imagine following setup:
________ ________________
| | RX | Microphone DSP | Analog mic input | S/PDIF | <--------< |________________| <------------------- | | ________________ | DAI | >--------> | Amplifier | >------------------- |________| TX |________________| Speakers output
As you see in the diagram, the S/PDIF interface of the SoC can be connected to some external devices that can perform sound processing or simply handle the physical layer.
I'd say that normally both RX and TX lines would be connected to a single codec chip that has multiple blocks inside, like sound processing, amplifier, mixer, etc., but nothing stops you from making a crazy setup, when RX and TX lines are connected to different chips.
Quoted 3 lines
There definitely should not be a DT node for any "dummy CODEC", irrespective of whether this binding calls the other node a "CODEC" or a "dummy CODEC".
I agree. Instead if no chip connected to particular line is specified in device tree, it's responsibility of Linux sound core to handle this properly by adding a dummy codec or whatever.
Quoted 9 lines
If these properties are to contain phandles, it would be acceptable for the referenced node to be:
* A node representing the physical connector/jack on the board.
* A node representing some other IP block on the board, such as an HDMI encoder/display-controller
I think those options are unlikely in general
Why? You usually codec SoC DAIs to some external chips.
Best regards,
Tomasz
Re: [PATCH v10 2/2] ASoC: fsl: Add S/PDIF machine driver
Quoted 31 lines · Tomasz Figa
Quoted 19 lines · On Wednesday 21 of August 2013 12:30:59 Stephen Warren wrote:
Quoted 15 lines · Nicolin Chen
This patch implements a device-tree-only machine driver for Freescale i.MX series Soc. It works with spdif_transmitter/spdif_receiver and
fsl_spdif.cdrivers.diff --git
a/Documentation/devicetree/bindings/sound/imx-audio-spdif.txtb/Documentation/devicetree/bindings/sound/imx-audio-spdif.txtDocumentation/devicetree/bindings/sound/imx-audio-spdif.txt new file +7
-0+Optional properties: + + - spdif-transmitter : The phandle of the spdif-transmitter codec + + - spdif-receiver : The phandle of the spdif-receiver codec + +* Note: At least one of these two properties should be set in the DTQuoted 1 line
binding.
I still don't think those two properties are correct.
Quoted 1 line
Exactly what node will those phandles point at?
Imagine following setup:
________ ________________
| | RX | Microphone DSP | Analog mic input | S/PDIF | <--------< |________________| <------------------- | | ________________ | DAI | >--------> | Amplifier | >------------------- |________| TX |________________| Speakers output
Quoted 8 lines
As you see in the diagram, the S/PDIF interface of the SoC can be connected to some external devices that can perform sound processing or simply handle the physical layer.
I'd say that normally both RX and TX lines would be connected to a single codec chip that has multiple blocks inside, like sound processing, amplifier, mixer, etc., but nothing stops you from making a crazy setup, when RX and TX lines are connected to different chips.
That's much rarer with S/PDIF than I2S though right? Usually I'd expect the S/PDIF controller to simply be routed out to a jack/connector on the board, or perhaps to an internal HDMI encoder.
But the point of my question was more that the binding should fully describe the type of object/node that the phandle should reference. The type of the node would then imply what kind of operations could be performed on that other node's driver by this node's driver. If the set of operations is undefined, that's bad. If the set of operations is NULL, there's probably no need to reference the node.
Quoted 11 lines
Quoted 3 lines
There definitely should not be a DT node for any "dummy CODEC", irrespective of whether this binding calls the other node a "CODEC" or a "dummy CODEC".
I agree. Instead if no chip connected to particular line is specified in device tree, it's responsibility of Linux sound core to handle this properly by adding a dummy codec or whatever.
Quoted 3 lines
If these properties are to contain phandles, it would be acceptable for the referenced node to be:
Quoted 8 lines
Quoted 6 lines
* A node representing the physical connector/jack on the board.
* A node representing some other IP block on the board, such as an HDMI encoder/display-controller
I think those options are unlikely in general
Why? You usually codec SoC DAIs to some external chips.
It's unlikely the phandle would reference a connector/jack since we (thus far at least) haven't created DT nodes for them. If we do put jacks/connectors into DT, then referencing them is fine.
In the "other IP block" case, it may be worth referencing the device, although as I mentioned above, we need to describe exactly what is expected from that other device interface-wise.
Re: [PATCH v10 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver
In reply to Nicolin ChenQuoted 2 lines · Nicolin Chen
This patch implements a device-tree-only CPU DAI driver for Freescale S/PDIF controller that supports stereo playback and record feature.
Applied, thanks.
Re: [PATCH v10 2/2] ASoC: fsl: Add S/PDIF machine driver
In reply to Stephen WarrenHi Stephen,
Quoted 13 lines · Stephen Warren
I still don't think those two properties are correct.
Exactly what node will those phandles point at?
There definitely should not be a DT node for any "dummy CODEC", irrespective of whether this binding calls the other node a "CODEC" or a "dummy CODEC".
If these properties are to contain phandles, it would be acceptable for the referenced node to be:
* A node representing the physical connector/jack on the board.
Quoted 8 lines
* A node representing some other IP block on the board, such as an HDMI encoder/display-controller
I think those options are unlikely in general, so I think instead these properties should just be Boolean indicating that "something" is connector to the S/PDIF RX/TX, without specifying what that "something" is. It doesn't matter what at least in the connector/jack case, although perhaps it does in the HDMI encoder/display-controller?
Documentation/devicetree/bindings/sound/spdif-receiver.txt
If I understand correctly, this doc for the dummy codec should be invalid?
But this patch, the spdif machine driver, is based on this codec driver, pls check the following code:
164 + codec_rx_np = of_parse_phandle(np, "spdif-receiver", 0);
165 + if (codec_rx_np) {
169 + data->dai[num_links].codec_of_node = codec_rx_np;
173 + }
Accordingly, the binding I planned to add in DT:
27 + spdif_rx_codec: spdif-receiver {
28 + compatible = "linux,spdif-dir";
29 + };
30 +
31 + sound-spdif {
32 + compatible = "fsl,imx-audio-spdif",
33 + "fsl,imx-sabreauto-spdif";
34 + model = "imx-spdif"; 35 + spdif-controller = <&spdif>; 37 + spdif-receiver = <&spdif_rx_codec>;
38 + };
So if the DT can't allow me to include this codec node, how could I handle it in the current baseline.
Could you please directly provide me a nicer means? Or maybe just an eclectic way for everyone, since it doesn't look like we have a perfect solution right now.
Thank you so much.
Nicolin
Re: [PATCH v10 2/2] ASoC: fsl: Add S/PDIF machine driver
Quoted 19 lines · Nicolin Chen
Hi Stephen,
Quoted 16 lines · Stephen Warren
I still don't think those two properties are correct.
Exactly what node will those phandles point at?
There definitely should not be a DT node for any "dummy CODEC", irrespective of whether this binding calls the other node a "CODEC" or a "dummy CODEC".
If these properties are to contain phandles, it would be acceptable for the referenced node to be:
* A node representing the physical connector/jack on the board.
* A node representing some other IP block on the board, such as an HDMI encoder/display-controller
Quoted 8 lines
Quoted 5 lines
I think those options are unlikely in general, so I think instead these properties should just be Boolean indicating that "something" is connector to the S/PDIF RX/TX, without specifying what that "something" is. It doesn't matter what at least in the connector/jack case, although perhaps it does in the HDMI encoder/display-controller?
Documentation/devicetree/bindings/sound/spdif-receiver.txt
If I understand correctly, this doc for the dummy codec should be invalid?
Yes, I'm not convinced that binding is a good idea; it describes something that often doesn't actually exist in HW. (Sometimes there's a real S/PDIF receiving device on board, but sometimes there's nothing except a jack/connector).
It'd be useful if other DT binding maintainers could weigh in on this to confirm/deny my thoughts.
Quoted 17 lines
But this patch, the spdif machine driver, is based on this codec driver, pls check the following code:
164 +
codec_rx_np=of_parse_phandle(np, "spdif-receiver", 0);
165 + if (codec_rx_np) {
169 + data->dai[num_links].codec_of_node =codec_rx_np;
173 + }Accordingly, the binding I planned to add in DT:
27 +
spdif_rx_codec: spdif-receiver {
28 + compatible = "linux,spdif-dir";
29 + };
30 +
31 + sound-spdif {
32 + compatible = "fsl,imx-audio-spdif",
33 + "fsl,imx-sabreauto-spdif";
Quoted 7 lines
34 + model = "imx-spdif"; 35 + spdif-controller = <&spdif>; 37 + spdif-receiver = <&spdif_rx_codec>;38 + };
So if the DT can't allow me to include this codec node, how could I handle it in the current baseline.
I would expect the machine driver's probe routine to create the dummy S/PDIF receiver object itself, and register it by calling snd_soc_register_codec(). That way, only the machine driver code need know it (dummy CODEC) exists.
Mark Brown
maintainerRe: [PATCH v10 2/2] ASoC: fsl: Add S/PDIF machine driver
Quoted 5 lines · Stephen Warren
Quoted 2 lines · Nicolin Chen
Documentation/devicetree/bindings/sound/spdif-receiver.txt
If I understand correctly, this doc for the dummy codec should be invalid?
Quoted 7 lines
Yes, I'm not convinced that binding is a good idea; it describes something that often doesn't actually exist in HW. (Sometimes there's a real S/PDIF receiving device on board, but sometimes there's nothing except a jack/connector).
It'd be useful if other DT binding maintainers could weigh in on this to confirm/deny my thoughts.
I think the binding should be changed to replace the word "dummy" with "generic" and perhaps some verbiage about not requiring software configuration. I think given the unidirectional nature of S/PDIF it's reasonable to represent a jack like this - the hardware can't generally tell if there's anything at the other end of the link anyway, for all pratical purposes the transmit end just has to blindly send.