Skip to contentSkip to conversation

ASoC: Add Freescale i.MX S/PDIF controller driver

PATCH Applied Nicolin Chen 3 participants 8 messages Jul 31, 2013

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover ASoC: Add Freescale i.MX S/PDIF controller driver

* This series of patches add i.MX S/PDIF drivers, including CPU DAI, machine.
* It also add two missing sample rates support for spdif dummy codec drivers

Nicolin Chen (3):
ASoC: codec: spdif: Add S20_3LE and S24_LE support for dummy codec
drivers
ASoC: fsl: Add S/PDIF CPU DAI driver
ASoC: fsl: Add S/PDIF machine driver

 .../devicetree/bindings/sound/fsl,spdif.txt        |   63 +
 .../devicetree/bindings/sound/imx-audio-spdif.txt  |   29 +
 sound/soc/codecs/spdif_receiver.c                  |    2 +
 sound/soc/codecs/spdif_transmitter.c               |    5 +-
 sound/soc/fsl/Kconfig                              |   14 +
 sound/soc/fsl/Makefile                             |    4 +
 sound/soc/fsl/fsl_spdif.c                          | 1276 ++++++++++++++++++++
 sound/soc/fsl/fsl_spdif.h                          |  233 ++++
 sound/soc/fsl/imx-spdif.c                          |  134 ++
 9 files changed, 1758 insertions(+), 2 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 1/3 ASoC: codec: spdif: Add S20_3LE and S24_LE support for dummy codec drivers

Generally, S/PDIF supports 20bit and optional 24bit samples. Thus add these two formats for the dummy codec drivers.

If one S/PDIF controller has its own limitation, its CPU DAI driver should set the supported format by its own circumstance, since the soc-pcm driver will use the intersection of cpu_dai's formats and codec_dai's formats.

---
 sound/soc/codecs/spdif_receiver.c    |    2 ++
 sound/soc/codecs/spdif_transmitter.c |    5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)
sound/soc/codecs/spdif_receiver.c +2 -0
index e9d7881..26d3474 100644
@@ -25,6 +25,8 @@
 
 #define STUB_RATES	SNDRV_PCM_RATE_8000_192000
 #define STUB_FORMATS	(SNDRV_PCM_FMTBIT_S16_LE | \
+			SNDRV_PCM_FMTBIT_S20_3LE | \
+			SNDRV_PCM_FMTBIT_S24_LE | \
 			SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
 
 static struct snd_soc_codec_driver soc_codec_spdif_dir;
sound/soc/codecs/spdif_transmitter.c +3 -2
index 1828049..efc3d88 100644
@@ -25,8 +25,9 @@
 #define DRV_NAME "spdif-dit"
 
 #define STUB_RATES	SNDRV_PCM_RATE_8000_96000
-#define STUB_FORMATS	SNDRV_PCM_FMTBIT_S16_LE
-
+#define STUB_FORMATS	(SNDRV_PCM_FMTBIT_S16_LE | \
+			SNDRV_PCM_FMTBIT_S20_3LE | \
+			SNDRV_PCM_FMTBIT_S24_LE)
 
 static struct snd_soc_codec_driver soc_codec_spdif_dit;
 
Signature · 1 line
1.7.1
maintainer Applied
#2 lore raw

Re: [PATCH 1/3] ASoC: codec: spdif: Add S20_3LE and S24_LE support for dummy codec drivers

Quoted 2 lines · Nicolin Chen

Generally, S/PDIF supports 20bit and optional 24bit samples. Thus add these two formats for the dummy codec drivers.

Applied, thanks. Please check the mailing lists you're posting to - you've got the DT list wrong here and you shouldn't post non-binding reviews there anyway.

#3 lore raw

Re: [PATCH 1/3] ASoC: codec: spdif: Add S20_3LE and S24_LE support for dummy codec drivers

Quoted 3 lines · Mark Brown

Applied, thanks. Please check the mailing lists you're posting to - you've got the DT list wrong here and you shouldn't post non-binding reviews there anyway.

Sorry that I forgot to update the DT list addr but using an old one. I'll pay attention to it next time. Thank you.

#4 lore raw

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

In reply to Nicolin Chen

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

---
 .../devicetree/bindings/sound/fsl,spdif.txt        |   63 +
 sound/soc/fsl/Kconfig                              |    3 +
 sound/soc/fsl/Makefile                             |    2 +
 sound/soc/fsl/fsl_spdif.c                          | 1276 ++++++++++++++++++++
 sound/soc/fsl/fsl_spdif.h                          |  233 ++++
 5 files changed, 1577 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 +63 -0
new file mode 100644
index 0000000..a655800
@@ -0,0 +1,63 @@
+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,spdif".
+
+  - reg : Offset and length of the register set for the device.
+
+  - interrupts : <a b> where a is the interrupt number and b is a field that
+    represents an encoding of the sense and level information for the interrupt.
+    This should be encoded based on the information in section 2) depending on
+    the type of interrupt controller you have.
+
+  - clocks : The phandle for the clock ID number registered in clock tree.
+
+  - fsl,spdif-dma-events: The dma event ID numbers for Tx and Rx.
+
+Optional properties:
+
+  - rx-clk-source : The clock cource for Rx. Need to set this source according
+  to the SoC datasheet in SPDIF_SRPC section. If absent, the default source is
+  value 0x0 - if (DPLL Locked) SPDIF_RxClk else extal.
+
+  - tx-clk-source : The clock cources for Tx. There're three sources, each for
+  different supported sample rate, sequentially 32000Hz, 44100Hz and 48000Hz.
+  Need to set this source according to the SoC datasheet in SPDIF_STC section.
+  If absent, the default source is value 0x1 - CCM spdif0_clk_root input.
+
+  - tx-clk-div : The clock divider factor for Tx clock. There're three values,
+  each for different supported sample rate, sequentially 32000Hz 44100Hz 48000Hz.
+  Need to set this source according to the clock rate from the clock source.
+  If absent, the default divider factor is <37 23 37> by using spdif0_clk source.
+
+Example:
+
+spdif: spdif@02004000 {
+	compatible = "fsl,fsl-spdif";
+	reg = <0x02004000 0x4000>;
+	interrupts = <0 52 0x04>;
+	clocks = <&clks 197>;
+	fsl,spdif-dma-events = <15 14>;
+
+	rx-clk-source = <0x0>;
+	tx-clk-source = <
+		0x1 /* Tx clk src for 32KHz: CCM spdif0_clk_root input */
+		0x1 /* Tx clk src for 44KHz: CCM spdif0_clk_root input */
+		0x1 /* Tx clk src for 48KHz: CCM spdif0_clk_root input */
+	>;
+
+	/*
+	 * In i.MX6Q SoC, the clock rate of spdif0_clk_root will be 454.7MHz.
+	 * 32KHz:   454.7MHz / 6(ccm) / 37(spdif) = 32,003 Hz ~ 0.01% error
+	 * 44.1KHz: 454.7MHz / 7(ccm) / 23(spdif) = 44,128 Hz ~ 0.06% error
+	 * 48KHz:   454.7MHz / 4(ccm) / 37(spdif) = 48,004 Hz ~ 0.01% error
+	 */
+	tx-clk-div = <37 23 37>;
+
+	status = "okay";
+};
sound/soc/fsl/Kconfig +3 -0
index 3a79d01..156b794 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 +1276 -0

1,276 lines not on this page · raw message

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

233 lines not on this page · raw message

Signature · 1 line
1.7.1
#5 lore raw

Re: [PATCH 2/3] ASoC: fsl: Add S/PDIF CPU DAI driver

[...] a/Documentation/devicetree/bindings/sound/fsl,spdif.txt b/Documentation/devicetree/bindings/sound/fsl,spdif.txt

Quoted 5 lines

new file mode 100644
index 0000000..a655800

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

Quoted 9 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +9 -0
@@ -0,0 +1,63 @@
+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,spdif".

That's not what the driver says though.

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

Quoted 7 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +7 -0
+
+  - reg : Offset and length of the register set for the device.
+
+  - interrupts : <a b> where a is the interrupt number and b is a field that
+    represents an encoding of the sense and level information for the interrupt.
+    This should be encoded based on the information in section 2) depending on
+    the type of interrupt controller you have.

The exact layout of the cell depends on the parent interrupt controller, so you probably shouldn't describe it here.

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

Quoted 5 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +5 -0
+
+  - clocks : The phandle for the clock ID number registered in clock tree.
+
+  - fsl,spdif-dma-events: The dma event ID numbers for Tx and Rx.
+

Use the generic DMA bindings.

Quoted 5 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +5 -0
+Optional properties:
+
+  - rx-clk-source : The clock cource for Rx. Need to set this source according
+  to the SoC datasheet in SPDIF_SRPC section. If absent, the default source is
+  value 0x0 - if (DPLL Locked) SPDIF_RxClk else extal.

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

Quoted 10 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +10 -0
+
+  - tx-clk-source : The clock cources for Tx. There're three sources, each for
+  different supported sample rate, sequentially 32000Hz, 44100Hz and 48000Hz.
+  Need to set this source according to the SoC datasheet in SPDIF_STC section.
+  If absent, the default source is value 0x1 - CCM spdif0_clk_root input.
+
+  - tx-clk-div : The clock divider factor for Tx clock. There're three values,
+  each for different supported sample rate, sequentially 32000Hz 44100Hz 48000Hz.
+  Need to set this source according to the clock rate from the clock source.
+  If absent, the default divider factor is <37 23 37> by using spdif0_clk source.

Can't the driver figure out the divider values on its own based on the input clock rate?

- Lars

#6 lore raw

Re: [PATCH 2/3] ASoC: fsl: Add S/PDIF CPU DAI driver

Hi Lars

Thank you for the sage advices.

I'll revise the patch and send the v2.
________________________________________
From: Lars-Peter Clausen [[email protected]]
Sent: Wednesday, July 31, 2013 8:16 PM
To: Chen Guangyu-B42378
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [alsa-devel] [PATCH 2/3] ASoC: fsl: Add S/PDIF CPU DAI driver

[...] a/Documentation/devicetree/bindings/sound/fsl,spdif.txt b/Documentation/devicetree/bindings/sound/fsl,spdif.txt

Quoted 5 lines

new file mode 100644
index 0000000..a655800

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

Quoted 9 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +9 -0
@@ -0,0 +1,63 @@
+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,spdif".

That's not what the driver says though.

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

Quoted 7 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +7 -0
+
+  - reg : Offset and length of the register set for the device.
+
+  - interrupts : <a b> where a is the interrupt number and b is a field that
+    represents an encoding of the sense and level information for the interrupt.
+    This should be encoded based on the information in section 2) depending on
+    the type of interrupt controller you have.

The exact layout of the cell depends on the parent interrupt controller, so you probably shouldn't describe it here.

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

Quoted 5 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +5 -0
+
+  - clocks : The phandle for the clock ID number registered in clock tree.
+
+  - fsl,spdif-dma-events: The dma event ID numbers for Tx and Rx.
+

Use the generic DMA bindings.

Quoted 5 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +5 -0
+Optional properties:
+
+  - rx-clk-source : The clock cource for Rx. Need to set this source according
+  to the SoC datasheet in SPDIF_SRPC section. If absent, the default source is
+  value 0x0 - if (DPLL Locked) SPDIF_RxClk else extal.

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

Quoted 10 lines
Documentation/devicetree/bindings/sound/fsl,spdif.txt new file +10 -0
+
+  - tx-clk-source : The clock cources for Tx. There're three sources, each for
+  different supported sample rate, sequentially 32000Hz, 44100Hz and 48000Hz.
+  Need to set this source according to the SoC datasheet in SPDIF_STC section.
+  If absent, the default source is value 0x1 - CCM spdif0_clk_root input.
+
+  - tx-clk-div : The clock divider factor for Tx clock. There're three values,
+  each for different supported sample rate, sequentially 32000Hz 44100Hz 48000Hz.
+  Need to set this source according to the clock rate from the clock source.
+  If absent, the default divider factor is <37 23 37> by using spdif0_clk source.

Can't the driver figure out the divider values on its own based on the input clock rate?

- Lars

#7 lore raw

PATCH 3/3 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 156b794..ba0c7ff 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 && ARCH_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