Skip to contentSkip to conversation

ARM: sunxi: Add SPDIF playback support

PATCH Superseded codekipper at gmail.com 2 participants 9 messages Feb 27, 2016 – Mar 14, 2016

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover ARM: sunxi: Add SPDIF playback support

From: Marcus Cooper <[email protected]>

Hi All,

now that the sun4i-spdif driver has made it into linux-next then this patch series completes what is needed to have SPDIF working on both A10 and A20 devices.

Enjoy,
CK

Andrea Venturi (1):
clk: sunxi: mod1 clock should modify it's parent

Marcus Cooper (4):
ARM: dts :sunxi: Add SPDIF pins to A10 and A20
ARM: dts: sunxi: Add the SPDIF to the A10 and A20
ARM: dts: sun4i: Add SPDIF to the Mele A1000
ARM: dts: sun7i: Add SPDIF to Itead Ibox

 arch/arm/boot/dts/sun4i-a10-a1000.dts      | 23 ++++++++++++++++
 arch/arm/boot/dts/sun4i-a10.dtsi           | 44 ++++++++++++++++++++++++++++++
 arch/arm/boot/dts/sun7i-a20-itead-ibox.dts | 24 ++++++++++++++++
 arch/arm/boot/dts/sun7i-a20.dtsi           | 44 ++++++++++++++++++++++++++++++
 drivers/clk/sunxi/clk-a10-mod1.c           |  2 +-
 5 files changed, 136 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.1
#1 lore raw

PATCH 1/5 clk: sunxi: mod1 clock should modify it's parent

From: Andrea Venturi <[email protected]>

add CLK_SET_RATE_PARENT to modify the rate on clk upstream

---
 drivers/clk/sunxi/clk-a10-mod1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sunxi/clk-a10-mod1.c +1 -1
index e9d870d..e2819fa 100644
@@ -62,7 +62,7 @@ static void __init sun4i_mod1_clk_setup(struct device_node *node)
 	clk = clk_register_composite(NULL, clk_name, parents, i,
 				     &mux->hw, &clk_mux_ops,
 				     NULL, NULL,
-				     &gate->hw, &clk_gate_ops, 0);
+				     &gate->hw, &clk_gate_ops, CLK_SET_RATE_PARENT);
 	if (IS_ERR(clk))
 		goto err_free_gate;
 
Signature · 1 line
2.7.1
#2 lore raw

PATCH 2/5 ARM: dts :sunxi: Add SPDIF pins to A10 and A20

In reply to codekipper at gmail.com

From: Marcus Cooper <[email protected]>

Add the SPDIF pins to the A10 and A20 dtsi.

---
 arch/arm/boot/dts/sun4i-a10.dtsi | 21 +++++++++++++++++++++
 arch/arm/boot/dts/sun7i-a20.dtsi | 21 +++++++++++++++++++++
 2 files changed, 42 insertions(+)
arch/arm/boot/dts/sun4i-a10.dtsi +21 -0
index 2c8f5e6..0483640 100644
@@ -1006,6 +1006,27 @@
 				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
 				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
 			};
+
+			spdif_tx_pins_a: spdif at 0 {
+				allwinner,pins = "PB13";
+				allwinner,function = "spdif";
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_PULL_UP>;
+			};
+
+			spdif_rx_pins_a: spdif at 1 {
+				allwinner,pins = "PB12";
+				allwinner,function = "spdif";
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+			};
+
+			spdif_mclk_pins_a: spdif at 2 {
+				allwinner,pins = "PB3";
+				allwinner,function = "spdif";
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+			};
 		};
 
 		timer at 01c20c00 {
arch/arm/boot/dts/sun7i-a20.dtsi +21 -0
index 0940a78..7264d5e 100644
@@ -1193,6 +1193,27 @@
 				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
 				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
 			};
+
+			spdif_tx_pins_a: spdif at 0 {
+				allwinner,pins = "PB13";
+				allwinner,function = "spdif";
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_PULL_UP>;
+			};
+
+			spdif_rx_pins_a: spdif at 1 {
+				allwinner,pins = "PB12";
+				allwinner,function = "spdif";
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+			};
+
+			spdif_mclk_pins_a: spdif at 2 {
+				allwinner,pins = "PB3";
+				allwinner,function = "spdif";
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+			};
 		};
 
 		timer at 01c20c00 {
Signature · 1 line
2.7.1
#3 lore raw

PATCH 3/5 ARM: dts: sunxi: Add the SPDIF to the A10 and A20

In reply to codekipper at gmail.com

From: Marcus Cooper <[email protected]>

Add the SPDIF transceiver controller and clock to the A10 and A20 dtsi.

---
 arch/arm/boot/dts/sun4i-a10.dtsi | 23 +++++++++++++++++++++++
 arch/arm/boot/dts/sun7i-a20.dtsi | 23 +++++++++++++++++++++++
 2 files changed, 46 insertions(+)
arch/arm/boot/dts/sun4i-a10.dtsi +23 -0
index 0483640..83d46b2 100644
@@ -477,6 +477,17 @@
 			clock-output-names = "ir1";
 		};
 
+		spdif_clk: clk at 01c200c0 {
+			#clock-cells = <0>;
+			compatible = "allwinner,sun4i-a10-mod1-clk";
+			reg = <0x01c200c0 0x4>;
+			clocks = <&pll2 SUN4I_A10_PLL2_8X>,
+				 <&pll2 SUN4I_A10_PLL2_4X>,
+				 <&pll2 SUN4I_A10_PLL2_2X>,
+				 <&pll2 SUN4I_A10_PLL2_1X>;
+			clock-output-names = "spdif";
+		};
+
 		usb_clk: clk at 01c200cc {
 			#clock-cells = <1>;
 			#reset-cells = <1>;
@@ -1055,6 +1066,18 @@
 			status = "disabled";
 		};
 
+		spdif: spdif at 01c21000 {
+			#sound-dai-cells = <0>;
+			compatible = "allwinner,sun4i-a10-spdif";
+			reg = <0x01c21000 0x40>;
+			interrupts = <13>;
+			clocks = <&apb0_gates 1>, <&spdif_clk>;
+			clock-names = "apb", "spdif";
+			dmas = <&dma 0 2>, <&dma 0 2>;
+			dma-names = "rx", "tx";
+			status = "disabled";
+		};
+
 		ir0: ir at 01c21800 {
 			compatible = "allwinner,sun4i-a10-ir";
 			clocks = <&apb0_gates 6>, <&ir0_clk>;
arch/arm/boot/dts/sun7i-a20.dtsi +23 -0
index 7264d5e..4631660 100644
@@ -476,6 +476,17 @@
 			clock-output-names = "ir1";
 		};
 
+		spdif_clk: clk at 01c200c0 {
+			#clock-cells = <0>;
+			compatible = "allwinner,sun4i-a10-mod1-clk";
+			reg = <0x01c200c0 0x4>;
+			clocks = <&pll2 SUN4I_A10_PLL2_8X>,
+				 <&pll2 SUN4I_A10_PLL2_4X>,
+				 <&pll2 SUN4I_A10_PLL2_2X>,
+				 <&pll2 SUN4I_A10_PLL2_1X>;
+			clock-output-names = "spdif";
+		};
+
 		keypad_clk: clk at 01c200c4 {
 			#clock-cells = <0>;
 			compatible = "allwinner,sun4i-a10-mod0-clk";
@@ -1247,6 +1258,18 @@
 			status = "disabled";
 		};
 
+		spdif: spdif at 01c21000 {
+			#sound-dai-cells = <0>;
+			compatible = "allwinner,sun4i-a10-spdif";
+			reg = <0x01c21000 0x40>;
+			interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&apb0_gates 1>, <&spdif_clk>;
+			clock-names = "apb", "spdif";
+			dmas = <&dma 0 2>, <&dma 0 2>;
+			dma-names = "rx", "tx";
+			status = "disabled";
+		};
+
 		ir0: ir at 01c21800 {
 			compatible = "allwinner,sun4i-a10-ir";
 			clocks = <&apb0_gates 6>, <&ir0_clk>;
Signature · 1 line
2.7.1
#4 lore raw

PATCH 3/5 ARM: dts: sunxi: Add the SPDIF to the A10 and A20

Hi,

Quoted 34 lines · codekipper at gmail.com

From: Marcus Cooper <[email protected]>

Add the SPDIF transceiver controller and clock to the A10 and A20 dtsi.

---
 arch/arm/boot/dts/sun4i-a10.dtsi | 23 +++++++++++++++++++++++
 arch/arm/boot/dts/sun7i-a20.dtsi | 23 +++++++++++++++++++++++
 2 files changed, 46 insertions(+)
arch/arm/boot/dts/sun4i-a10.dtsi +11 -0
index 0483640..83d46b2 100644
@@ -477,6 +477,17 @@
 			clock-output-names = "ir1";
 		};
 
+		spdif_clk: clk at 01c200c0 {
+			#clock-cells = <0>;
+			compatible = "allwinner,sun4i-a10-mod1-clk";
+			reg = <0x01c200c0 0x4>;
+			clocks = <&pll2 SUN4I_A10_PLL2_8X>,
+				 <&pll2 SUN4I_A10_PLL2_4X>,
+				 <&pll2 SUN4I_A10_PLL2_2X>,
+				 <&pll2 SUN4I_A10_PLL2_1X>;
+			clock-output-names = "spdif";
+		};
+
 		usb_clk: clk at 01c200cc {
 			#clock-cells = <1>;
 			#reset-cells = <1>;

arch/arm/boot/dts/sun4i-a10.dtsi line 1072

Quoted 7 lines
arch/arm/boot/dts/sun4i-a10.dtsi +4 -0
@@ -1055,6 +1066,18 @@
 			status = "disabled";
 		};
 
+		spdif: spdif at 01c21000 {
+			#sound-dai-cells = <0>;
+			compatible = "allwinner,sun4i-a10-spdif";
+			reg = <0x01c21000 0x40>;

It only takes 64 bytes?

arch/arm/boot/dts/sun4i-a10.dtsi line 1076

Quoted 4 lines
arch/arm/boot/dts/sun4i-a10.dtsi +4 -0
+			interrupts = <13>;
+			clocks = <&apb0_gates 1>, <&spdif_clk>;
+			clock-names = "apb", "spdif";
+			dmas = <&dma 0 2>, <&dma 0 2>;

Please use the defines here.

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160313/1fc0332b/attachment-0001.sig>
#5 lore raw

PATCH 3/5 ARM: dts: sunxi: Add the SPDIF to the A10 and A20

Quoted 40 lines · Maxime Ripard

Hi,

Quoted 37 lines · codekipper at gmail.com

From: Marcus Cooper <[email protected]>

Add the SPDIF transceiver controller and clock to the A10 and A20 dtsi.

---
 arch/arm/boot/dts/sun4i-a10.dtsi | 23 +++++++++++++++++++++++
 arch/arm/boot/dts/sun7i-a20.dtsi | 23 +++++++++++++++++++++++
 2 files changed, 46 insertions(+)
arch/arm/boot/dts/sun4i-a10.dtsi +11 -0
index 0483640..83d46b2 100644
@@ -477,6 +477,17 @@
                      clock-output-names = "ir1";
              };
 
+             spdif_clk: clk at 01c200c0 {
+                     #clock-cells = <0>;
+                     compatible = "allwinner,sun4i-a10-mod1-clk";
+                     reg = <0x01c200c0 0x4>;
+                     clocks = <&pll2 SUN4I_A10_PLL2_8X>,
+                              <&pll2 SUN4I_A10_PLL2_4X>,
+                              <&pll2 SUN4I_A10_PLL2_2X>,
+                              <&pll2 SUN4I_A10_PLL2_1X>;
+                     clock-output-names = "spdif";
+             };
+
              usb_clk: clk at 01c200cc {
                      #clock-cells = <1>;
                      #reset-cells = <1>;
@@ -1055,6 +1066,18 @@
                      status = "disabled";
              };
 
Quoted 6 lines

arch/arm/boot/dts/sun4i-a10.dtsi line 1072

Quoted 4 lines
arch/arm/boot/dts/sun4i-a10.dtsi +4 -0
+             spdif: spdif at 01c21000 {
+                     #sound-dai-cells = <0>;
+                     compatible = "allwinner,sun4i-a10-spdif";
+                     reg = <0x01c21000 0x40>;

It only takes 64 bytes?

Yep(just like the audio codec!)
http://linux-sunxi.org/SPDIF#SUNXI_SPDIF_DEFAULT_VALUES

Quoted 7 lines

arch/arm/boot/dts/sun4i-a10.dtsi line 1076

Quoted 5 lines
arch/arm/boot/dts/sun4i-a10.dtsi +4 -0
+                     interrupts = <13>;
+                     clocks = <&apb0_gates 1>, <&spdif_clk>;
+                     clock-names = "apb", "spdif";
+                     dmas = <&dma 0 2>, <&dma 0 2>;

Please use the defines here.

ACK...will resend.
Thanks,
CK

Quoted 8 lines

Thanks!
Maxime

--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

#6 lore raw

PATCH 3/5 ARM: dts: sunxi: Add the SPDIF to the A10 and A20

Quoted 9 lines · Code Kipper
Quoted 6 lines

arch/arm/boot/dts/sun4i-a10.dtsi line 1072

Quoted 4 lines
arch/arm/boot/dts/sun4i-a10.dtsi +4 -0
+             spdif: spdif at 01c21000 {
+                     #sound-dai-cells = <0>;
+                     compatible = "allwinner,sun4i-a10-spdif";
+                     reg = <0x01c21000 0x40>;

It only takes 64 bytes?

Yep(just like the audio codec!)
http://linux-sunxi.org/SPDIF#SUNXI_SPDIF_DEFAULT_VALUES

Yet the datasheet says it takes 1k in the memory map.

Please use that value instead.

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160314/8ce1a327/attachment.sig>
#7 lore raw

PATCH 4/5 ARM: dts: sun4i: Add SPDIF to the Mele A1000

In reply to codekipper at gmail.com

From: Marcus Cooper <[email protected]>

Enable the S/PDIF transmitter that is present on the A1000.

---
 arch/arm/boot/dts/sun4i-a10-a1000.dts | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
arch/arm/boot/dts/sun4i-a10-a1000.dts +23 -0
index 97570cb..aaf5605 100644
@@ -87,6 +87,23 @@
 		enable-active-high;
 		gpio = <&pio 7 15 GPIO_ACTIVE_HIGH>;
 	};
+
+	sound {
+		compatible = "simple-audio-card";
+		simple-audio-card,name = "On-board SPDIF";
+		simple-audio-card,cpu {
+			sound-dai = <&spdif>;
+		};
+
+		simple-audio-card,codec {
+			sound-dai = <&spdif_out>;
+		};
+	};
+
+	spdif_out: spdif-out {
+		#sound-dai-cells = <0>;
+		compatible = "linux,spdif-dit";
+	};
 };
 
 &ahci {
@@ -188,6 +205,12 @@
 	status = "okay";
 };
 
+&spdif {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spdif_tx_pins_a>;
+	status = "okay";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_pins_a>;
Signature · 1 line
2.7.1
#8 lore raw

PATCH 5/5 ARM: dts: sun7i: Add SPDIF to Itead Ibox

In reply to codekipper at gmail.com

From: Marcus Cooper <[email protected]>

Enable the S/PDIF transmitter that is present on the Itead Ibox.

---
 arch/arm/boot/dts/sun7i-a20-itead-ibox.dts | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
arch/arm/boot/dts/sun7i-a20-itead-ibox.dts +24 -0
index a512581..df76b74 100644
@@ -65,6 +65,23 @@
 			default-state = "on";
 		};
 	};
+
+	sound {
+		compatible = "simple-audio-card";
+		simple-audio-card,name = "On-board SPDIF";
+		simple-audio-card,cpu {
+			sound-dai = <&spdif>;
+		};
+
+		simple-audio-card,codec {
+			sound-dai = <&spdif_out>;
+		};
+	};
+
+	spdif_out: spdif-out {
+		#sound-dai-cells = <0>;
+		compatible = "linux,spdif-dit";
+	};
 };
 
 &ahci {
@@ -131,6 +148,13 @@
 	status = "okay";
 };
 
+
+&spdif {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spdif_tx_pins_a>;
+	status = "okay";
+};
+
 &usbphy {
 	pinctrl-names = "default";
 	pinctrl-0 = <&usb0_id_detect_pin>;
Signature · 1 line
2.7.1