Skip to contentSkip to conversation

Add freescale S/PDIF CPU DAI and machine drivers

PATCH Superseded Nicolin Chen 3 participants 11 messages Aug 12, 2013 – Aug 15, 2013

Subsystems (5)

v4 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add freescale S/PDIF CPU DAI and machine drivers

Changelog:
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        |  100 ++
 .../devicetree/bindings/sound/imx-audio-spdif.txt  |   29 +
 sound/soc/fsl/Kconfig                              |   14 +
 sound/soc/fsl/Makefile                             |    4 +
 sound/soc/fsl/fsl_spdif.c                          | 1350 ++++++++++++++++++++
 sound/soc/fsl/fsl_spdif.h                          |  223 ++++
 sound/soc/fsl/imx-spdif.c                          |  134 ++
 7 files changed, 1854 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
#1 lore raw

PATCH v4 1/2 ASoC: fsl: Add S/PDIF CPU DAI driver

This patch add S/PDIF controller driver for Freescale SoC.

---
 .../devicetree/bindings/sound/fsl,spdif.txt        |  100 ++
 sound/soc/fsl/Kconfig                              |    3 +
 sound/soc/fsl/Makefile                             |    2 +
 sound/soc/fsl/fsl_spdif.c                          | 1350 ++++++++++++++++++++
 sound/soc/fsl/fsl_spdif.h                          |  223 ++++
 5 files changed, 1678 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 +100 -0
new file mode 100644
index 0000000..e95318e
@@ -0,0 +1,100 @@
+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, contains "fsl,<chip>-spdif". Using general
+  "fsl,fsl-spdif" will get the default SoC type -- imx6q-spdif.
+
+  - reg : Offset and length of the register set for the device.
+
+  - interrupts : Contains 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:
+	name		type		comments
+	"core"		Required	The core clock of spdif controller
+	"rx"		Optional	Rx clock source for spdif record.
+					If absent, will use core clock.
+	"tx"		Optional	Tx clock source for spdif playback.
+					If absent, will use core clock.
+	"tx-32000"	Optional	Tx clock source for 32000Hz sample rate
+					playback. If absent, will use tx clock.
+	"tx-44100"	Optional	Tx clock source for 44100Hz sample rate
+					playback. If absent, will use tx clock.
+	"tx-48000"	Optional	Tx clock source for 48000Hz sample rate
+					playback. If absent, will use tx clock.
+
+  - tx-clksrc-names : The names for all available clock sources for tx, which
+  is also being listed in SoC reference manual, ClkSrc_Sel bit of SPDIF_SRPC.
+  And the name list would be different between different SoC. Use 'null' for
+  those unlisted names, and the max number of tx-clksrc-names should be 8.
+
+  - rx-clksrc-names : The names for all available clock sources for rx, which
+  is also being listed in SoC reference manual, TxClk_Source bit of SPDIF_STC.
+  And the name list would be different between different SoC. Use 'null' for
+  those unlisted names, and the max number of rx-clksrc-names should be 16.
+
+Optional properties:
+
+  - rx-clksrc-lock: This is a boolean property. If present, ClkSrc_Sel bit
+  of SPDIF_SRPC would be set a clock source that cares DPLL locked condition.
+
+Example1:
+
+spdif: spdif@02004000 {
+	compatible = "fsl,imx6q-spdif";
+	reg = <0x02004000 0x4000>;
+	interrupts = <0 52 0x04>;
+	dmas = <&sdma 14 18 0>,
+	       <&sdma 15 18 0>;
+	dma-names = "rx", "tx";
+
+	clocks = <&clks 197>;
+	clock-names = "core";
+	rx-clksrc-lock;
+	rx-clksrc-names =
+		"lock.ext", "lock.spdif", "lock.asrc",
+		"lock.spdif_ext", "lock.esai", "ext",
+		"spdif", "asrc", "spdif_ext", "esai",
+		"lock.mlb", "lock.mlb_phy", "mlb",
+		"mlb_phy";
+	tx-clksrc-names =
+		"xtal", "spdif", "asrc", "spdif_ext",
+		"esai", "ipg", "mlb", "mlb_phy";
+
+	status = "okay";
+};
+
+Example2:
+
+spdif: spdif@02004000 {
+	compatible = "fsl,imx6sl-spdif";
+	reg = <0x02004000 0x4000>;
+	interrupts = <0 52 0x04>;
+	dmas = <&sdma 14 18 0>,
+	       <&sdma 15 18 0>;
+	dma-names = "rx", "tx";
+
+	clocks = <&clks 122>;
+	clock-names = "core";
+	rx-clksrc-lock;
+	rx-clksrc-names =
+		"lock.xtal", "lock.spdif", "null", "lock.spdif_ext",
+		"null", "xtal", "spdif", "null", "spdif_ext", "null",
+		"null", "null", "mlb";
+	tx-clksrc-names =
+		"xtal", "spdif", "null", "spdif_ext",
+		"null", "ipg";
+
+	status = "okay";
+};
sound/soc/fsl/Kconfig +3 -0
index e15f771..2c518db 100644
@@ -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
index d4b4aa8..4b5970e 100644
@@ -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 +1350 -0

1,350 lines not on this page · raw message

sound/soc/fsl/fsl_spdif.h new file +223 -0

223 lines not on this page · raw message

Signature · 1 line
1.7.1
maintainer
#2 lore raw

Re: [PATCH v4 resent 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver

Quoted 61 lines · Nicolin Chen

This patch add S/PDIF controller driver for Freescale SoC.

Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +58 -0
+
+Required properties:
+
+  - compatible : Compatible list, contains "fsl,<chip>-spdif". Using general
+  "fsl,fsl-spdif" will get the default SoC type -- imx6q-spdif.
+
+  - reg : Offset and length of the register set for the device.
+
+  - interrupts : Contains 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:
+	name		type		comments
+	"core"		Required	The core clock of spdif controller
+	"rx"		Optional	Rx clock source for spdif record.
+					If absent, will use core clock.
+	"tx"		Optional	Tx clock source for spdif playback.
+					If absent, will use core clock.
+	"tx-32000"	Optional	Tx clock source for 32000Hz sample rate
+					playback. If absent, will use tx clock.
+	"tx-44100"	Optional	Tx clock source for 44100Hz sample rate
+					playback. If absent, will use tx clock.
+	"tx-48000"	Optional	Tx clock source for 48000Hz sample rate
+					playback. If absent, will use tx clock.
+
+  - tx-clksrc-names : The names for all available clock sources for tx, which
+  is also being listed in SoC reference manual, ClkSrc_Sel bit of SPDIF_SRPC.
+  And the name list would be different between different SoC. Use 'null' for
+  those unlisted names, and the max number of tx-clksrc-names should be 8.
+
+  - rx-clksrc-names : The names for all available clock sources for rx, which
+  is also being listed in SoC reference manual, TxClk_Source bit of SPDIF_STC.
+  And the name list would be different between different SoC. Use 'null' for
+  those unlisted names, and the max number of rx-clksrc-names should be 16.
+
+Optional properties:
+
+  - rx-clksrc-lock: This is a boolean property. If present, ClkSrc_Sel bit
+  of SPDIF_SRPC would be set a clock source that cares DPLL locked condition.
+
+Example1:
+
+spdif: spdif@02004000 {
+	compatible = "fsl,imx6q-spdif";
+	reg = <0x02004000 0x4000>;
+	interrupts = <0 52 0x04>;
+	dmas = <&sdma 14 18 0>,
+	       <&sdma 15 18 0>;
+	dma-names = "rx", "tx";
+
+	clocks = <&clks 197>;
+	clock-names = "core";

Documentation/devicetree/bindings/sound/fsl,spdif.txt line 73

Quoted 10 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +10 -0
+	rx-clksrc-lock;
+	rx-clksrc-names =
+		"lock.ext", "lock.spdif", "lock.asrc",
+		"lock.spdif_ext", "lock.esai", "ext",
+		"spdif", "asrc", "spdif_ext", "esai",
+		"lock.mlb", "lock.mlb_phy", "mlb",
+		"mlb_phy";
+	tx-clksrc-names =
+		"xtal", "spdif", "asrc", "spdif_ext",
+		"esai", "ipg", "mlb", "mlb_phy";

I had a hard time understanding what you are doing here.

With this the clk names in arch/arm/mach-imx/clk-imx6q.c become an API between the Kernel and the devicetree. Don't do that.

There is a standardized devicetree binding for clocks. Use it.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#3 lore raw

Re: [PATCH v4 resent 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver

Hi Sascha,

Quoted 33 lines · Sascha Hauer
Quoted 20 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +20 -0
+  - tx-clksrc-names : The names for all available clock sources for tx, which
+  is also being listed in SoC reference manual, ClkSrc_Sel bit of SPDIF_SRPC.
+  And the name list would be different between different SoC. Use 'null' for
+  those unlisted names, and the max number of tx-clksrc-names should be 8.
+
+  - rx-clksrc-names : The names for all available clock sources for rx, which
+  is also being listed in SoC reference manual, TxClk_Source bit of SPDIF_STC.
+  And the name list would be different between different SoC. Use 'null' for
+  those unlisted names, and the max number of rx-clksrc-names should be 16.
+
+Optional properties:
+
+  - rx-clksrc-lock: This is a boolean property. If present, ClkSrc_Sel bit
+  of SPDIF_SRPC would be set a clock source that cares DPLL locked condition.
+
+Example1:
+
+spdif: spdif@02004000 {
+	clocks = <&clks 197>;
+	clock-names = "core";

Documentation/devicetree/bindings/sound/fsl,spdif.txt line 73

Quoted 10 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +10 -0
+	rx-clksrc-lock;
+	rx-clksrc-names =
+		"lock.ext", "lock.spdif", "lock.asrc",
+		"lock.spdif_ext", "lock.esai", "ext",
+		"spdif", "asrc", "spdif_ext", "esai",
+		"lock.mlb", "lock.mlb_phy", "mlb",
+		"mlb_phy";
+	tx-clksrc-names =
+		"xtal", "spdif", "asrc", "spdif_ext",
+		"esai", "ipg", "mlb", "mlb_phy";

I had a hard time understanding what you are doing here.

Quoted 4 lines

With this the clk names in arch/arm/mach-imx/clk-imx6q.c become an API between the Kernel and the devicetree. Don't do that.

There is a standardized devicetree binding for clocks. Use it.

I think I should first explain to you what this part is doing:
The driver needs to set Clk_source bit for TX/RX to select the clock from a clock mux. The names listed above are those of the clocks connecting to the mux, while they are not only internal clocks which're included in clk-imx6q.c but also external ones, an on-board external osc for example.

The driver does get the clock by using the standard DT binding, see the 'clocks = <&clks 197>' above, and then compare this obtained clock->name with the name list to decide which value should be set to the Clk_source bit.

==================================================================
ClkSrc_Sel from i.MX6Q reference manual:

Clock source selection, all other settings not shown are reserved:
0000 if (DPLL Locked) SPDIF_RxClk else extal
0001 if (DPLL Locked) SPDIF_RxClk else spdif_clk
0010 if (DPLL Locked) SPDIF_RxClk else asrc_clk
0011 if (DPLL Locked) SPDIF_RxClk else spdif_extclk 0100 if (DPLL Locked) SPDIF_Rxclk else esai_hckt
0101 extal_clk
0110 spdif_clk
0111 asrc_clk
1000 spdif_extclk
1001 esai_hckt
1010 if (DPLL Locked) SPDIF_RxClk else mlb_clk
==================================================================

So the name list here basically is not being used to obtain a clock like what standardized DT binding does but to provide the driver a full list to look up which value should be exactly used according to the obtained clock.

I think I should revise the binding doc for these two lists. It might be hard to explain within that kinda short paragraph.

Surely, if I misunderstand your point, please correct me. And if you have any sage idea, please guide me.

Thank you,
Nicolin Chen

maintainer
#4 lore raw

Re: [PATCH v4 resent 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver

Quoted 75 lines · Nicolin Chen

Hi Sascha,

Quoted 33 lines · Sascha Hauer
Quoted 20 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +20 -0
+  - tx-clksrc-names : The names for all available clock sources for tx, which
+  is also being listed in SoC reference manual, ClkSrc_Sel bit of SPDIF_SRPC.
+  And the name list would be different between different SoC. Use 'null' for
+  those unlisted names, and the max number of tx-clksrc-names should be 8.
+
+  - rx-clksrc-names : The names for all available clock sources for rx, which
+  is also being listed in SoC reference manual, TxClk_Source bit of SPDIF_STC.
+  And the name list would be different between different SoC. Use 'null' for
+  those unlisted names, and the max number of rx-clksrc-names should be 16.
+
+Optional properties:
+
+  - rx-clksrc-lock: This is a boolean property. If present, ClkSrc_Sel bit
+  of SPDIF_SRPC would be set a clock source that cares DPLL locked condition.
+
+Example1:
+
+spdif: spdif@02004000 {
+	clocks = <&clks 197>;
+	clock-names = "core";

Documentation/devicetree/bindings/sound/fsl,spdif.txt line 73

Quoted 10 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +10 -0
+	rx-clksrc-lock;
+	rx-clksrc-names =
+		"lock.ext", "lock.spdif", "lock.asrc",
+		"lock.spdif_ext", "lock.esai", "ext",
+		"spdif", "asrc", "spdif_ext", "esai",
+		"lock.mlb", "lock.mlb_phy", "mlb",
+		"mlb_phy";
+	tx-clksrc-names =
+		"xtal", "spdif", "asrc", "spdif_ext",
+		"esai", "ipg", "mlb", "mlb_phy";

I had a hard time understanding what you are doing here.

Quoted 4 lines

With this the clk names in arch/arm/mach-imx/clk-imx6q.c become an API between the Kernel and the devicetree. Don't do that.

There is a standardized devicetree binding for clocks. Use it.

I think I should first explain to you what this part is doing:
The driver needs to set Clk_source bit for TX/RX to select the clock from a clock mux. The names listed above are those of the clocks connecting to the mux, while they are not only internal clocks which're included in clk-imx6q.c but also external ones, an on-board external osc for example.

The driver does get the clock by using the standard DT binding, see the 'clocks = <&clks 197>' above, and then compare this obtained clock->name with the name list to decide which value should be set to the Clk_source bit.

==================================================================
ClkSrc_Sel from i.MX6Q reference manual:

Clock source selection, all other settings not shown are reserved:
0000 if (DPLL Locked) SPDIF_RxClk else extal
0001 if (DPLL Locked) SPDIF_RxClk else spdif_clk
0010 if (DPLL Locked) SPDIF_RxClk else asrc_clk
0011 if (DPLL Locked) SPDIF_RxClk else spdif_extclk 0100 if (DPLL Locked) SPDIF_Rxclk else esai_hckt
0101 extal_clk
0110 spdif_clk
0111 asrc_clk
1000 spdif_extclk
1001 esai_hckt
1010 if (DPLL Locked) SPDIF_RxClk else mlb_clk
==================================================================

So the name list here basically is not being used to obtain a clock like what standardized DT binding does but to provide the driver a full list to look up which value should be exactly used according to the obtained clock.

Quoted 5 lines

I think I should revise the binding doc for these two lists. It might be hard to explain within that kinda short paragraph.

Surely, if I misunderstand your point, please correct me. And if you have any sage idea, please guide me.

Something like this:

clocks = <&clks 197>, <&clks 3>, <&clks 197>, <&clks 107>, <&clks SPDIF_EXT>,

         <&clks 118>, <&clks 62>, <&clks 139>, <&clks MLB_PHY>

clock-names = "core", "rxtx0", "rxtx1", "rxtx2", "rxtx3", "rxtx4", "rxtx5", "rxtx6", "rxtx7"

This describes the different input clocks to the spdif core and also gives a hint to the array index (rxtx_n_) to use.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#5 lore raw

Re: [PATCH v4 resent 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver

Hi,

Quoted 40 lines · Sascha Hauer
Quoted 34 lines

I think I should first explain to you what this part is doing:
The driver needs to set Clk_source bit for TX/RX to select the clock from a clock mux. The names listed above are those of the clocks connecting to the mux, while they are not only internal clocks which're included in clk-imx6q.c but also external ones, an on-board external osc for example.

The driver does get the clock by using the standard DT binding, see the 'clocks = <&clks 197>' above, and then compare this obtained clock->name with the name list to decide which value should be set to the Clk_source bit.

==================================================================
ClkSrc_Sel from i.MX6Q reference manual:

Clock source selection, all other settings not shown are reserved:
0000 if (DPLL Locked) SPDIF_RxClk else extal
0001 if (DPLL Locked) SPDIF_RxClk else spdif_clk
0010 if (DPLL Locked) SPDIF_RxClk else asrc_clk
0011 if (DPLL Locked) SPDIF_RxClk else spdif_extclk 0100 if (DPLL Locked) SPDIF_Rxclk else esai_hckt
0101 extal_clk
0110 spdif_clk
0111 asrc_clk
1000 spdif_extclk
1001 esai_hckt
1010 if (DPLL Locked) SPDIF_RxClk else mlb_clk
==================================================================

So the name list here basically is not being used to obtain a clock like what standardized DT binding does but to provide the driver a full list to look up which value should be exactly used according to the obtained clock.

Quoted 5 lines

I think I should revise the binding doc for these two lists. It might be hard to explain within that kinda short paragraph.

Surely, if I misunderstand your point, please correct me. And if you have any sage idea, please guide me.

Quoted 8 lines

Something like this:

clocks = <&clks 197>, <&clks 3>, <&clks 197>, <&clks 107>, <&clks SPDIF_EXT>,

         <&clks 118>, <&clks 62>, <&clks 139>, <&clks MLB_PHY>

clock-names = "core", "rxtx0", "rxtx1", "rxtx2", "rxtx3", "rxtx4", "rxtx5", "rxtx6", "rxtx7"

This describes the different input clocks to the spdif core and also gives a hint to the array index (rxtx_n_) to use.

Thank you for the idea, and..hmm..I'm a bit confused.. Is this really a nicer way?

Actually the rx clock list and tx clock list are totally different. So doing this I have to list, in the maximum case, 24 (8 + 16) clock phandles for these two lists. And plussing another 6 I've listed in this binding doc -- thus there are totally 30 clock phanldes. But the 24 of 30 are only used to get two indexes.

I think I need a little help here to understand why this is better. It looks more complicated to me.

Creating the two name lists just because I can describe them in the dtsi of SoC, since they are totally fixed and identical to the SoC reference manual, while the clocks area can be remained for users to select the actual clocks (core/rx/tx/tx-32000/tx-44100/tx-48000), so they can configure these clocks in dts file of a specific board, and they don't need to touch the name lists any more.

Thank you,
Nicolin Chen

maintainer
#6 lore raw

Re: [PATCH v4 resent 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver

Quoted 11 lines · Nicolin Chen

Hi,

Quoted 9 lines
Quoted 2 lines

Surely, if I misunderstand your point, please correct me. And if you have any sage idea, please guide me.

Something like this:

clocks = <&clks 197>, <&clks 3>, <&clks 197>, <&clks 107>, <&clks SPDIF_EXT>,

         <&clks 118>, <&clks 62>, <&clks 139>, <&clks MLB_PHY>

clock-names = "core", "rxtx0", "rxtx1", "rxtx2", "rxtx3", "rxtx4", "rxtx5", "rxtx6", "rxtx7"

Quoted 5 lines
Quoted 2 lines

This describes the different input clocks to the spdif core and also gives a hint to the array index (rxtx_n_) to use.

Thank you for the idea, and..hmm..I'm a bit confused.. Is this really a nicer way?

Yes, since the clk names are not an API. Exposing them to the devicetree is not an option. The fact that the names are defined in arch/arm/mach-imx/clk-imx6q.c and are used in the spdif driver makes this really clear.

Quoted 6 lines

Actually the rx clock list and tx clock list are totally different. So doing this I have to list, in the maximum case, 24 (8 + 16) clock phandles for these two lists. And plussing another 6 I've listed in this binding doc -- thus there are totally 30 clock phanldes. But the 24 of 30 are only used to get two indexes.

The spdif core has 8 input clocks which have to be described in the devicetree. Nobody says the mapping which clock name corresponds to which bit combination has to be in the devicetree.

Look at the possible clocks:

0000 if (DPLL Locked) SPDIF_RxClk else extal 0001 if (DPLL Locked) SPDIF_RxClk else spdif_clk 0010 if (DPLL Locked) SPDIF_RxClk else asrc_clk 0011 if (DPLL Locked) SPDIF_RxClk else spdif_extclk 0100 if (DPLL Locked) SPDIF_Rxclk else esai_hckt 0101 extal_clk
0110 spdif_clk
0111 asrc_clk
1000 spdif_extclk
1001 esai_hckt
1010 if (DPLL Locked) SPDIF_RxClk else mlb_clk 1011 if (DPLL Locked) SPDIF_RxClk else mlb_phy_clk 1100 mkb_clk
1101 mlb_phy_clk

Only half of them actually are clocks. "if (DPLL Locked) SPDIF_RxClk else ..." is not a clock. Every sane hardware developer would have introduced a mux with 8 entries and an additional "Use DPLL if possible" bit. Now this is not the case here so we have to live with it and maintain the above table in the driver. And another one for the i.MX35 and still another one for i.MX53.

Quoted 2 lines

I think I need a little help here to understand why this is better.

As said, the clock names are not an API. Nobody changing clk-imx6q.c expects to break devicetree bindings.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#7 lore raw

Re: [PATCH v4 resent 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver

Quoted 8 lines · Sascha Hauer

Yes, since the clk names are not an API. Exposing them to the devicetree is not an option. The fact that the names are defined in arch/arm/mach-imx/clk-imx6q.c and are used in the spdif driver makes this really clear.

The spdif core has 8 input clocks which have to be described in the devicetree. Nobody says the mapping which clock name corresponds to which bit combination has to be in the devicetree.

Thank you for the explain. I get your point and really appreciate it.

Quoted 17 lines

Look at the possible clocks:

0000 if (DPLL Locked) SPDIF_RxClk else extal 0001 if (DPLL Locked) SPDIF_RxClk else spdif_clk 0010 if (DPLL Locked) SPDIF_RxClk else asrc_clk 0011 if (DPLL Locked) SPDIF_RxClk else spdif_extclk 0100 if (DPLL Locked) SPDIF_Rxclk else esai_hckt 0101 extal_clk
0110 spdif_clk
0111 asrc_clk
1000 spdif_extclk
1001 esai_hckt
1010 if (DPLL Locked) SPDIF_RxClk else mlb_clk 1011 if (DPLL Locked) SPDIF_RxClk else mlb_phy_clk 1100 mkb_clk
1101 mlb_phy_clk

Quoted 6 lines

Only half of them actually are clocks. "if (DPLL Locked) SPDIF_RxClk else ..." is not a clock. Every sane hardware developer would have introduced a mux with 8 entries and an additional "Use DPLL if possible" bit. Now this is not the case here so we have to live with it and maintain the above table in the driver. And another one for the i.MX35 and still another one for i.MX53.

I think I just have an idea for the table. I'll put them into the next version. Please take a look after I send it.

Thank you,
Nicolin Chen

#8 lore raw

Re: [PATCH v4 resent 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver

In reply to Nicolin Chen

Am Mittwoch, den 14.08.2013, 16:48 +0800 schrieb Nicolin Chen:

Quoted 56 lines

Hi Sascha,

Quoted 33 lines · Sascha Hauer
Quoted 20 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +20 -0
+  - tx-clksrc-names : The names for all available clock sources for tx, which
+  is also being listed in SoC reference manual, ClkSrc_Sel bit of SPDIF_SRPC.
+  And the name list would be different between different SoC. Use 'null' for
+  those unlisted names, and the max number of tx-clksrc-names should be 8.
+
+  - rx-clksrc-names : The names for all available clock sources for rx, which
+  is also being listed in SoC reference manual, TxClk_Source bit of SPDIF_STC.
+  And the name list would be different between different SoC. Use 'null' for
+  those unlisted names, and the max number of rx-clksrc-names should be 16.
+
+Optional properties:
+
+  - rx-clksrc-lock: This is a boolean property. If present, ClkSrc_Sel bit
+  of SPDIF_SRPC would be set a clock source that cares DPLL locked condition.
+
+Example1:
+
+spdif: spdif@02004000 {
+	clocks = <&clks 197>;
+	clock-names = "core";

Documentation/devicetree/bindings/sound/fsl,spdif.txt line 73

Quoted 10 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +10 -0
+	rx-clksrc-lock;
+	rx-clksrc-names =
+		"lock.ext", "lock.spdif", "lock.asrc",
+		"lock.spdif_ext", "lock.esai", "ext",
+		"spdif", "asrc", "spdif_ext", "esai",
+		"lock.mlb", "lock.mlb_phy", "mlb",
+		"mlb_phy";
+	tx-clksrc-names =
+		"xtal", "spdif", "asrc", "spdif_ext",
+		"esai", "ipg", "mlb", "mlb_phy";

I had a hard time understanding what you are doing here.

Quoted 4 lines

With this the clk names in arch/arm/mach-imx/clk-imx6q.c become an API between the Kernel and the devicetree. Don't do that.

There is a standardized devicetree binding for clocks. Use it.

I think I should first explain to you what this part is doing:
The driver needs to set Clk_source bit for TX/RX to select the clock from a clock mux. The names listed above are those of the clocks connecting to the mux, while they are not only internal clocks which're included in clk-imx6q.c but also external ones, an on-board external osc for example.

The driver does get the clock by using the standard DT binding, see the 'clocks = <&clks 197>' above, and then compare this obtained clock->name with the name list to decide which value should be set to the Clk_source bit.

==================================================================
ClkSrc_Sel from i.MX6Q reference manual:

Quoted 13 lines

Clock source selection, all other settings not shown are reserved:
0000 if (DPLL Locked) SPDIF_RxClk else extal
0001 if (DPLL Locked) SPDIF_RxClk else spdif_clk
0010 if (DPLL Locked) SPDIF_RxClk else asrc_clk
0011 if (DPLL Locked) SPDIF_RxClk else spdif_extclk 0100 if (DPLL Locked) SPDIF_Rxclk else esai_hckt
0101 extal_clk
0110 spdif_clk
0111 asrc_clk
1000 spdif_extclk
1001 esai_hckt
1010 if (DPLL Locked) SPDIF_RxClk else mlb_clk
==================================================================

==================================================================

Quoted 1 line

From i.MX53 reference manual:

0000 if (DPLL Locked) SPDIF_RxClk else extal
0001 if (DPLL Locked) SPDIF_RxClk else spdif_clk
0011 if (DPLL Locked) SPDIF_RxClk else asrc_clk
0100 if (DPLL Locked) SPDIF_Rxclk else esai_hckt
0101 extal_clk
0110 spdif_clk
1000 asrc_clk
1001 esai_hckt
1010 if (DPLL Locked) SPDIF_RxClk else mlb_clk
1011 if (DPLL Locked) SPDIF_RxClk else camp_clk
1100 mkb_clk
1101 camp_clk
==================================================================

To me this looks like the device tree should just contain the list of unique clock inputs using phandles.

	/* for i.MX6Q: */
	clocks = <&...>;
	clock-names = "xtal", "spdif", "asrc",
	              "spdif_ext", "esai", "mlb";

	/* for i.MX53: */
	clocks = <&...>;
	clock-names = "xtal", "spdif", "asrc",
	              "esai", "mlb", "camp";

The driver could contain this list of named inputs to the multiplexer and the DPLL locking information for each SoC version. The per-clock DPLL locking bit shouldn't be in the device tree at all.

Quoted 10 lines

So the name list here basically is not being used to obtain a clock like what standardized DT binding does but to provide the driver a full list to look up which value should be exactly used according to the obtained clock.

I think I should revise the binding doc for these two lists. It might be hard to explain within that kinda short paragraph.

Surely, if I misunderstand your point, please correct me. And if you have any sage idea, please guide me.

regards
Philipp

#9 lore raw

Re: [PATCH v4 resent 1/2] ASoC: fsl: Add S/PDIF CPU DAI driver

Hi Philipp,

Thank again for the comments.

Quoted 29 lines · Philipp Zabel

==================================================================
From i.MX53 reference manual:

0000 if (DPLL Locked) SPDIF_RxClk else extal
0001 if (DPLL Locked) SPDIF_RxClk else spdif_clk
0011 if (DPLL Locked) SPDIF_RxClk else asrc_clk
0100 if (DPLL Locked) SPDIF_Rxclk else esai_hckt
0101 extal_clk
0110 spdif_clk
1000 asrc_clk
1001 esai_hckt
1010 if (DPLL Locked) SPDIF_RxClk else mlb_clk
1011 if (DPLL Locked) SPDIF_RxClk else camp_clk
1100 mkb_clk
1101 camp_clk
==================================================================

To me this looks like the device tree should just contain the list of unique clock inputs using phandles.

	/* for i.MX6Q: */
	clocks = <&...>;
	clock-names = "xtal", "spdif", "asrc",
	              "spdif_ext", "esai", "mlb";

	/* for i.MX53: */
	clocks = <&...>;
	clock-names = "xtal", "spdif", "asrc",
	              "esai", "mlb", "camp";
Quoted 3 lines

The driver could contain this list of named inputs to the multiplexer and the DPLL locking information for each SoC version. The per-clock DPLL locking bit shouldn't be in the device tree at all.

I understand your point. I'll put the DPLL-locking info to the driver. And I just found that the DPLL-lock condition seems to be fixed within the range -- {0x0 ~ 0x4, 0xa ~ 0xb} (I checked i.MX6Q/6SL/53/35, all of them are in such pattern.) So I don't need to put them into DT.

I'll revise it in next ver.

Thank you,
Nicolin Chen

#10 lore raw

PATCH v4 2/2 ASoC: fsl: Add S/PDIF machine driver

In reply to Nicolin Chen

Add S/PDIF machine driver for Freescale i.MX series SoC.

---
 .../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
new file mode 100644
index 0000000..9a3fa26
@@ -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 dummy codec
+
+  - spdif-receiver : The phandle of the spdif-receiver dummy 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
index 2c518db..4cc118c 100644
@@ -195,6 +195,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
index 4b5970e..e2aaff7 100644
@@ -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