Skip to contentSkip to conversation

Allwinner H6 SPDIF support

PATCH Superseded Clément Péron 3 participants 12 messages Apr 19, 2019 – May 3, 2019

Subsystems (4)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Allwinner H6 SPDIF support

*H6 DMA support IS REQUIRED*

Allwinner H6 SoC has a SPDIF controller called One Wire Audio (OWA) which is different from the previous H3 generation and not compatible.

Difference are an increase of fifo sizes, some memory mapping are different and there is now the possibility to output the master clock on a pin.

Also this series require the DMA working on H6, a first version has been submitted by Jernej Škrabec but is not yet accepted (as this moment):
https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=89011

This series has been tested on Beelink GS1 on top of sunxi/for-next with Jernej DMA support patch.

Clément Péron (5):
dt-bindings: sound: sun4i-spdif: Add Allwinner H6 compatible
ASoC: sun4i-spdif: Add support for H6 SoC
arm64: dts: allwinner: Add SPDIF node for Allwinner H6
arm64: dts: allwinner: h6: Enable SPDIF for Beelink GS1
arm64: defconfig: Enable Sun4i SPDIF module

 .../bindings/sound/sunxi,sun4i-spdif.txt      |  3 +-
 .../dts/allwinner/sun50i-h6-beelink-gs1.dts   |  4 ++
 arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi  | 38 +++++++++++++++++
 arch/arm64/configs/defconfig                  |  1 +
 sound/soc/sunxi/sun4i-spdif.c                 | 42 ++++++++++++++++---
 5 files changed, 81 insertions(+), 7 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/5 dt-bindings: sound: sun4i-spdif: Add Allwinner H6 compatible

Allwinner H6 has a SPDIF controller with an increase of the fifo size and a sligher difference in memory mapping compare which make it not compatible with the previous generation H3/A64.

---
 Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt +2 -1
index 0c64a209c2e9..c0fbb50a4df9 100644
@@ -7,10 +7,11 @@ For now only playback is supported.
 
 Required properties:
 
-  - compatible		: should be one of the following:
+  - compatible		: Should be one of the following:
     - "allwinner,sun4i-a10-spdif": for the Allwinner A10 SoC
     - "allwinner,sun6i-a31-spdif": for the Allwinner A31 SoC
     - "allwinner,sun8i-h3-spdif": for the Allwinner H3 SoC
+    - "allwinner,sun50i-h6-spdif": for the allwinner H6 SoC
 
   - reg			: Offset and length of the register set for the device.
 
Signature · 1 line
2.17.1
maintainer Reviewed-by on v2 1/5
#2 lore raw

Re: [PATCH v2 1/5] dt-bindings: sound: sun4i-spdif: Add Allwinner H6 compatible

Quoted 9 lines · On Fri, 19 Apr 2019 21:17:26 +0200, =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= wrote:

Allwinner H6 has a SPDIF controller with an increase of the fifo size and a sligher difference in memory mapping compare which make it not compatible with the previous generation H3/A64.

---
 Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
maintainer Reviewed-by on v2 1/5
#3 lore raw

Re: [PATCH v2 1/5] dt-bindings: sound: sun4i-spdif: Add Allwinner H6 compatible

In reply to Clément Péron
Quoted 9 lines · On Fri, 19 Apr 2019 21:17:26 +0200, =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= wrote:

Allwinner H6 has a SPDIF controller with an increase of the fifo size and a sligher difference in memory mapping compare which make it not compatible with the previous generation H3/A64.

---
 Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Acked-by on v2 1/5
#4 lore raw

Re: [PATCH v2 1/5] dt-bindings: sound: sun4i-spdif: Add Allwinner H6 compatible

In reply to Clément Péron
Quoted 5 lines · Clément Péron

Allwinner H6 has a SPDIF controller with an increase of the fifo size and a sligher difference in memory mapping compare which make it not compatible with the previous generation H3/A64.

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#5 lore raw

PATCH v2 2/5 ASoC: sun4i-spdif: Add support for H6 SoC

In reply to Clément Péron

Allwinner H6 has a different mapping for the fifo register controller.

Actually only the fifo tx flush bit is used.

Add a new quirk to know the correct fifo tx flush bit.

---
 sound/soc/sunxi/sun4i-spdif.c | 42 ++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 6 deletions(-)
sound/soc/sunxi/sun4i-spdif.c +36 -6
index b4af4aabead1..19e4bf9caa24 100644
@@ -75,6 +75,18 @@
 	#define SUN4I_SPDIF_FCTL_RXOM(v)		((v) << 0)
 	#define SUN4I_SPDIF_FCTL_RXOM_MASK		GENMASK(1, 0)
 
+#define SUN50I_H6_SPDIF_FCTL (0x14)
+	#define SUN50I_H6_SPDIF_FCTL_HUB_EN		BIT(31)
+	#define SUN50I_H6_SPDIF_FCTL_FTX		BIT(30)
+	#define SUN50I_H6_SPDIF_FCTL_FRX		BIT(29)
+	#define SUN50I_H6_SPDIF_FCTL_TXTL(v)		((v) << 12)
+	#define SUN50I_H6_SPDIF_FCTL_TXTL_MASK		GENMASK(19, 12)
+	#define SUN50I_H6_SPDIF_FCTL_RXTL(v)		((v) << 4)
+	#define SUN50I_H6_SPDIF_FCTL_RXTL_MASK		GENMASK(10, 4)
+	#define SUN50I_H6_SPDIF_FCTL_TXIM		BIT(2)
+	#define SUN50I_H6_SPDIF_FCTL_RXOM(v)		((v) << 0)
+	#define SUN50I_H6_SPDIF_FCTL_RXOM_MASK		GENMASK(1, 0)
+
 #define SUN4I_SPDIF_FSTA	(0x18)
 	#define SUN4I_SPDIF_FSTA_TXE			BIT(14)
 	#define SUN4I_SPDIF_FSTA_TXECNTSHT		(8)
@@ -169,16 +181,25 @@ struct sun4i_spdif_dev {
 	struct snd_soc_dai_driver cpu_dai_drv;
 	struct regmap *regmap;
 	struct snd_dmaengine_dai_dma_data dma_params_tx;
+	const struct sun4i_spdif_quirks *quirks;
+};
+
+struct sun4i_spdif_quirks {
+	unsigned int reg_dac_txdata;	/* TX FIFO offset for DMA config */
+	unsigned int reg_fctl_ftx;	/* TX FIFO flush bitmask */
+	bool has_reset;
 };
 
 static void sun4i_spdif_configure(struct sun4i_spdif_dev *host)
 {
+	const struct sun4i_spdif_quirks *quirks = host->quirks;
+
 	/* soft reset SPDIF */
 	regmap_write(host->regmap, SUN4I_SPDIF_CTL, SUN4I_SPDIF_CTL_RESET);
 
 	/* flush TX FIFO */
 	regmap_update_bits(host->regmap, SUN4I_SPDIF_FCTL,
-			   SUN4I_SPDIF_FCTL_FTX, SUN4I_SPDIF_FCTL_FTX);
+			   quirks->reg_fctl_ftx, quirks->reg_fctl_ftx);
 
 	/* clear TX counter */
 	regmap_write(host->regmap, SUN4I_SPDIF_TXCNT, 0);
@@ -405,22 +426,26 @@ static struct snd_soc_dai_driver sun4i_spdif_dai = {
 	.name = "spdif",
 };
 
-struct sun4i_spdif_quirks {
-	unsigned int reg_dac_txdata;	/* TX FIFO offset for DMA config */
-	bool has_reset;
-};
-
 static const struct sun4i_spdif_quirks sun4i_a10_spdif_quirks = {
 	.reg_dac_txdata	= SUN4I_SPDIF_TXFIFO,
+	.reg_fctl_ftx   = SUN4I_SPDIF_FCTL_FTX,
 };
 
 static const struct sun4i_spdif_quirks sun6i_a31_spdif_quirks = {
 	.reg_dac_txdata	= SUN4I_SPDIF_TXFIFO,
+	.reg_fctl_ftx   = SUN4I_SPDIF_FCTL_FTX,
 	.has_reset	= true,
 };
 
 static const struct sun4i_spdif_quirks sun8i_h3_spdif_quirks = {
 	.reg_dac_txdata	= SUN8I_SPDIF_TXFIFO,
+	.reg_fctl_ftx   = SUN4I_SPDIF_FCTL_FTX,
+	.has_reset	= true,
+};
+
+static const struct sun4i_spdif_quirks sun50i_h6_spdif_quirks = {
+	.reg_dac_txdata	= SUN8I_SPDIF_TXFIFO,
+	.reg_fctl_ftx   = SUN50I_H6_SPDIF_FCTL_FTX,
 	.has_reset	= true,
 };
 
@@ -437,6 +462,10 @@ static const struct of_device_id sun4i_spdif_of_match[] = {
 		.compatible = "allwinner,sun8i-h3-spdif",
 		.data = &sun8i_h3_spdif_quirks,
 	},
+	{
+		.compatible = "allwinner,sun50i-h6-spdif",
+		.data = &sun50i_h6_spdif_quirks,
+	},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, sun4i_spdif_of_match);
@@ -501,6 +530,7 @@ static int sun4i_spdif_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "Failed to determine the quirks to use\n");
 		return -ENODEV;
 	}
+	host->quirks = quirks;
 
 	host->regmap = devm_regmap_init_mmio(&pdev->dev, base,
 						&sun4i_spdif_regmap_config);
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#6 lore raw

Re: [PATCH v2 2/5] ASoC: sun4i-spdif: Add support for H6 SoC

Quoted 35 lines · Clément Péron

Allwinner H6 has a different mapping for the fifo register controller.

Actually only the fifo tx flush bit is used.

Add a new quirk to know the correct fifo tx flush bit.

---
 sound/soc/sunxi/sun4i-spdif.c | 42 ++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 6 deletions(-)
sound/soc/sunxi/sun4i-spdif.c +12 -0
index b4af4aabead1..19e4bf9caa24 100644
@@ -75,6 +75,18 @@
 	#define SUN4I_SPDIF_FCTL_RXOM(v)		((v) << 0)
 	#define SUN4I_SPDIF_FCTL_RXOM_MASK		GENMASK(1, 0)
 
+#define SUN50I_H6_SPDIF_FCTL (0x14)
+	#define SUN50I_H6_SPDIF_FCTL_HUB_EN		BIT(31)
+	#define SUN50I_H6_SPDIF_FCTL_FTX		BIT(30)
+	#define SUN50I_H6_SPDIF_FCTL_FRX		BIT(29)
+	#define SUN50I_H6_SPDIF_FCTL_TXTL(v)		((v) << 12)
+	#define SUN50I_H6_SPDIF_FCTL_TXTL_MASK		GENMASK(19, 12)
+	#define SUN50I_H6_SPDIF_FCTL_RXTL(v)		((v) << 4)
+	#define SUN50I_H6_SPDIF_FCTL_RXTL_MASK		GENMASK(10, 4)
+	#define SUN50I_H6_SPDIF_FCTL_TXIM		BIT(2)
+	#define SUN50I_H6_SPDIF_FCTL_RXOM(v)		((v) << 0)
+	#define SUN50I_H6_SPDIF_FCTL_RXOM_MASK		GENMASK(1, 0)
+
 #define SUN4I_SPDIF_FSTA	(0x18)
 	#define SUN4I_SPDIF_FSTA_TXE			BIT(14)
 	#define SUN4I_SPDIF_FSTA_TXECNTSHT		(8)

sound/soc/sunxi/sun4i-spdif.c struct sun4i_spdif_dev { · line 184

Quoted 4 lines
sound/soc/sunxi/sun4i-spdif.c +1 -0
@@ -169,16 +181,25 @@ struct sun4i_spdif_dev {
 	struct snd_soc_dai_driver cpu_dai_drv;
 	struct regmap *regmap;
 	struct snd_dmaengine_dai_dma_data dma_params_tx;
+	const struct sun4i_spdif_quirks *quirks;

I guess this will generate a warning since the structure hasn't been defined yet?

sound/soc/sunxi/sun4i-spdif.c struct sun4i_spdif_dev { · line 190

Quoted 6 lines
sound/soc/sunxi/sun4i-spdif.c +6 -0
+};
+
+struct sun4i_spdif_quirks {
+	unsigned int reg_dac_txdata;	/* TX FIFO offset for DMA config */
+	unsigned int reg_fctl_ftx;	/* TX FIFO flush bitmask */
+	bool has_reset;

You don't really need to move it around, you can just add the structure prototype.

If you do want to move it around, then please do so in a separate patch

Quoted 36 lines
sound/soc/sunxi/sun4i-spdif.c +5 -6
 };
 
 static void sun4i_spdif_configure(struct sun4i_spdif_dev *host)
 {
+	const struct sun4i_spdif_quirks *quirks = host->quirks;
+
 	/* soft reset SPDIF */
 	regmap_write(host->regmap, SUN4I_SPDIF_CTL, SUN4I_SPDIF_CTL_RESET);
 
 	/* flush TX FIFO */
 	regmap_update_bits(host->regmap, SUN4I_SPDIF_FCTL,
-			   SUN4I_SPDIF_FCTL_FTX, SUN4I_SPDIF_FCTL_FTX);
+			   quirks->reg_fctl_ftx, quirks->reg_fctl_ftx);
 
 	/* clear TX counter */
 	regmap_write(host->regmap, SUN4I_SPDIF_TXCNT, 0);
@@ -405,22 +426,26 @@ static struct snd_soc_dai_driver sun4i_spdif_dai = {
 	.name = "spdif",
 };
 
-struct sun4i_spdif_quirks {
-	unsigned int reg_dac_txdata;	/* TX FIFO offset for DMA config */
-	bool has_reset;
-};
-
 static const struct sun4i_spdif_quirks sun4i_a10_spdif_quirks = {
 	.reg_dac_txdata	= SUN4I_SPDIF_TXFIFO,
+	.reg_fctl_ftx   = SUN4I_SPDIF_FCTL_FTX,
 };
 
 static const struct sun4i_spdif_quirks sun6i_a31_spdif_quirks = {
 	.reg_dac_txdata	= SUN4I_SPDIF_TXFIFO,
+	.reg_fctl_ftx   = SUN4I_SPDIF_FCTL_FTX,
 	.has_reset	= true,
 };
 

sound/soc/sunxi/sun4i-spdif.c static struct snd_soc_dai_driver sun4i_spdif_dai = { · line 449

Quoted 10 lines
sound/soc/sunxi/sun4i-spdif.c +6 -0
 static const struct sun4i_spdif_quirks sun8i_h3_spdif_quirks = {
 	.reg_dac_txdata	= SUN8I_SPDIF_TXFIFO,
+	.reg_fctl_ftx   = SUN4I_SPDIF_FCTL_FTX,
+	.has_reset	= true,
+};
 
+static const struct sun4i_spdif_quirks sun50i_h6_spdif_quirks = {
+	.reg_dac_txdata	= SUN8I_SPDIF_TXFIFO,
+	.reg_fctl_ftx   = SUN50I_H6_SPDIF_FCTL_FTX,
 	.has_reset	= true,

The reg_dac_txdata and reg_fctl_ftx changes here should also be part of a separate patch.

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Signature · 3 lines
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.
#7 lore raw

Re: [PATCH v2 2/5] ASoC: sun4i-spdif: Add support for H6 SoC

Hi Maxime,

Quoted 36 lines · Maxime Ripard
Quoted 34 lines · Clément Péron

Allwinner H6 has a different mapping for the fifo register controller.

Actually only the fifo tx flush bit is used.

Add a new quirk to know the correct fifo tx flush bit.

---
 sound/soc/sunxi/sun4i-spdif.c | 42 ++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 6 deletions(-)
sound/soc/sunxi/sun4i-spdif.c +12 -0
index b4af4aabead1..19e4bf9caa24 100644
@@ -75,6 +75,18 @@
      #define SUN4I_SPDIF_FCTL_RXOM(v)                ((v) << 0)
      #define SUN4I_SPDIF_FCTL_RXOM_MASK              GENMASK(1, 0)
 
+#define SUN50I_H6_SPDIF_FCTL (0x14)
+     #define SUN50I_H6_SPDIF_FCTL_HUB_EN             BIT(31)
+     #define SUN50I_H6_SPDIF_FCTL_FTX                BIT(30)
+     #define SUN50I_H6_SPDIF_FCTL_FRX                BIT(29)
+     #define SUN50I_H6_SPDIF_FCTL_TXTL(v)            ((v) << 12)
+     #define SUN50I_H6_SPDIF_FCTL_TXTL_MASK          GENMASK(19, 12)
+     #define SUN50I_H6_SPDIF_FCTL_RXTL(v)            ((v) << 4)
+     #define SUN50I_H6_SPDIF_FCTL_RXTL_MASK          GENMASK(10, 4)
+     #define SUN50I_H6_SPDIF_FCTL_TXIM               BIT(2)
+     #define SUN50I_H6_SPDIF_FCTL_RXOM(v)            ((v) << 0)
+     #define SUN50I_H6_SPDIF_FCTL_RXOM_MASK          GENMASK(1, 0)
+
 #define SUN4I_SPDIF_FSTA     (0x18)
      #define SUN4I_SPDIF_FSTA_TXE                    BIT(14)
      #define SUN4I_SPDIF_FSTA_TXECNTSHT              (8)
Quoted 8 lines

sound/soc/sunxi/sun4i-spdif.c struct sun4i_spdif_dev { · line 184

Quoted 5 lines
sound/soc/sunxi/sun4i-spdif.c +1 -0
@@ -169,16 +181,25 @@ struct sun4i_spdif_dev {
      struct snd_soc_dai_driver cpu_dai_drv;
      struct regmap *regmap;
      struct snd_dmaengine_dai_dma_data dma_params_tx;
+     const struct sun4i_spdif_quirks *quirks;

I guess this will generate a warning since the structure hasn't been defined yet?

It's a pointer to a structure so no warning from the compiler.

Quoted 11 lines

sound/soc/sunxi/sun4i-spdif.c struct sun4i_spdif_dev { · line 190

Quoted 7 lines
sound/soc/sunxi/sun4i-spdif.c +6 -0
+};
+
+struct sun4i_spdif_quirks {
+     unsigned int reg_dac_txdata;    /* TX FIFO offset for DMA config */
+     unsigned int reg_fctl_ftx;      /* TX FIFO flush bitmask */
+     bool has_reset;

You don't really need to move it around, you can just add the structure prototype.

Quoted 1 line

If you do want to move it around, then please do so in a separate patch

I have choose to move it to follow what is done in the sun4i-i2s. I will put it in a separate patch and make the comment a bit more proper.

Quoted 43 lines
Quoted 43 lines
sound/soc/sunxi/sun4i-spdif.c +8 -6
 };
 
 static void sun4i_spdif_configure(struct sun4i_spdif_dev *host)
 {
+     const struct sun4i_spdif_quirks *quirks = host->quirks;
+
      /* soft reset SPDIF */
      regmap_write(host->regmap, SUN4I_SPDIF_CTL, SUN4I_SPDIF_CTL_RESET);
 
      /* flush TX FIFO */
      regmap_update_bits(host->regmap, SUN4I_SPDIF_FCTL,
-                        SUN4I_SPDIF_FCTL_FTX, SUN4I_SPDIF_FCTL_FTX);
+                        quirks->reg_fctl_ftx, quirks->reg_fctl_ftx);
 
      /* clear TX counter */
      regmap_write(host->regmap, SUN4I_SPDIF_TXCNT, 0);
@@ -405,22 +426,26 @@ static struct snd_soc_dai_driver sun4i_spdif_dai = {
      .name = "spdif",
 };
 
-struct sun4i_spdif_quirks {
-     unsigned int reg_dac_txdata;    /* TX FIFO offset for DMA config */
-     bool has_reset;
-};
-
 static const struct sun4i_spdif_quirks sun4i_a10_spdif_quirks = {
      .reg_dac_txdata = SUN4I_SPDIF_TXFIFO,
+     .reg_fctl_ftx   = SUN4I_SPDIF_FCTL_FTX,
 };
 
 static const struct sun4i_spdif_quirks sun6i_a31_spdif_quirks = {
      .reg_dac_txdata = SUN4I_SPDIF_TXFIFO,
+     .reg_fctl_ftx   = SUN4I_SPDIF_FCTL_FTX,
      .has_reset      = true,
 };
 
 static const struct sun4i_spdif_quirks sun8i_h3_spdif_quirks = {
      .reg_dac_txdata = SUN8I_SPDIF_TXFIFO,
+     .reg_fctl_ftx   = SUN4I_SPDIF_FCTL_FTX,
+     .has_reset      = true,
+};
 
Quoted 7 lines

sound/soc/sunxi/sun4i-spdif.c static struct snd_soc_dai_driver sun4i_spdif_dai = { · line 449

Quoted 4 lines
sound/soc/sunxi/sun4i-spdif.c +3 -0
+static const struct sun4i_spdif_quirks sun50i_h6_spdif_quirks = {
+     .reg_dac_txdata = SUN8I_SPDIF_TXFIFO,
+     .reg_fctl_ftx   = SUN50I_H6_SPDIF_FCTL_FTX,
      .has_reset      = true,

The reg_dac_txdata and reg_fctl_ftx changes here should also be part of a separate patch.

You mean the reg_fctl_ftx quirk and the H6 introduction should be split ?

Thanks for the review,
Clement

Quoted 7 lines

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Signature · 3 lines
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.
#8 lore raw

Re: [PATCH v2 2/5] ASoC: sun4i-spdif: Add support for H6 SoC

Quoted 10 lines · Clément Péron
Quoted 8 lines

sound/soc/sunxi/sun4i-spdif.c struct sun4i_spdif_dev { · line 184

Quoted 5 lines
sound/soc/sunxi/sun4i-spdif.c +1 -0
@@ -169,16 +181,25 @@ struct sun4i_spdif_dev {
      struct snd_soc_dai_driver cpu_dai_drv;
      struct regmap *regmap;
      struct snd_dmaengine_dai_dma_data dma_params_tx;
+     const struct sun4i_spdif_quirks *quirks;

I guess this will generate a warning since the structure hasn't been defined yet?

It's a pointer to a structure so no warning from the compiler.

Damn, I was convinced just declaring a pointer to a structure would result to a gcc warning. Nevermind then.

Quoted 34 lines
Quoted 26 lines
Quoted 26 lines
sound/soc/sunxi/sun4i-spdif.c +5 -5
@@ -405,22 +426,26 @@ static struct snd_soc_dai_driver sun4i_spdif_dai = {
      .name = "spdif",
 };
 
-struct sun4i_spdif_quirks {
-     unsigned int reg_dac_txdata;    /* TX FIFO offset for DMA config */
-     bool has_reset;
-};
-
 static const struct sun4i_spdif_quirks sun4i_a10_spdif_quirks = {
      .reg_dac_txdata = SUN4I_SPDIF_TXFIFO,
+     .reg_fctl_ftx   = SUN4I_SPDIF_FCTL_FTX,
 };
 
 static const struct sun4i_spdif_quirks sun6i_a31_spdif_quirks = {
      .reg_dac_txdata = SUN4I_SPDIF_TXFIFO,
+     .reg_fctl_ftx   = SUN4I_SPDIF_FCTL_FTX,
      .has_reset      = true,
 };
 
 static const struct sun4i_spdif_quirks sun8i_h3_spdif_quirks = {
      .reg_dac_txdata = SUN8I_SPDIF_TXFIFO,
+     .reg_fctl_ftx   = SUN4I_SPDIF_FCTL_FTX,
+     .has_reset      = true,
+};
 
Quoted 7 lines

sound/soc/sunxi/sun4i-spdif.c static struct snd_soc_dai_driver sun4i_spdif_dai = { · line 449

Quoted 4 lines
sound/soc/sunxi/sun4i-spdif.c +3 -0
+static const struct sun4i_spdif_quirks sun50i_h6_spdif_quirks = {
+     .reg_dac_txdata = SUN8I_SPDIF_TXFIFO,
+     .reg_fctl_ftx   = SUN50I_H6_SPDIF_FCTL_FTX,
      .has_reset      = true,

The reg_dac_txdata and reg_fctl_ftx changes here should also be part of a separate patch.

Quoted 1 line

You mean the reg_fctl_ftx quirk and the H6 introduction should be split ?

Yep

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#9 lore raw

PATCH v2 3/5 arm64: dts: allwinner: Add SPDIF node for Allwinner H6

In reply to Clément Péron

The Allwinner H6 has a SPDIF controller called OWA (One Wire Audio).

Only one pinmuxing is available so set it as default.

---
 arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 38 ++++++++++++++++++++
 1 file changed, 38 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi +38 -0
index ad2077830f73..6c1debf11e5c 100644
@@ -83,6 +83,24 @@
 		method = "smc";
 	};
 
+	sound_spdif {
+		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";
+	};
+
 	timer {
 		compatible = "arm,armv8-timer";
 		interrupts = <GIC_PPI 13
@@ -264,6 +282,11 @@
 				bias-pull-up;
 			};
 
+			spdif_tx_pin: spdif-tx-pin {
+				pins = "PH7";
+				function = "spdif";
+			};
+
 			uart0_ph_pins: uart0-ph-pins {
 				pins = "PH0", "PH1";
 				function = "uart0";
@@ -391,6 +414,21 @@
 			};
 		};
 
+		spdif: spdif@5093000 {
+			#sound-dai-cells = <0>;
+			compatible = "allwinner,sun50i-h6-spdif";
+			reg = <0x05093000 0x400>;
+			interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_BUS_SPDIF>, <&ccu CLK_SPDIF>;
+			clock-names = "apb", "spdif";
+			resets = <&ccu RST_BUS_SPDIF>;
+			dmas = <&dma 2>;
+			dma-names = "tx";
+			pinctrl-names = "default";
+			pinctrl-0 = <&spdif_tx_pin>;
+			status = "disabled";
+		};
+
 		usb2otg: usb@5100000 {
 			compatible = "allwinner,sun50i-h6-musb",
 				     "allwinner,sun8i-a33-musb";
Signature · 1 line
2.17.1
#10 lore raw

PATCH v2 4/5 arm64: dts: allwinner: h6: Enable SPDIF for Beelink GS1

In reply to Clément Péron

Beelink GS1 board has a SPDIF out connector, so enable it in the device-tree.

---
 arch/arm64/boot/dts/allwinner/sun50i-h6-beelink-gs1.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-h6-beelink-gs1.dts +4 -0
index 0dc33c90dd60..76a95ad33dc5 100644
@@ -243,6 +243,10 @@
 	vcc-pm-supply = <&reg_aldo1>;
 };
 
+&spdif {
+	status = "okay";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_ph_pins>;
Signature · 1 line
2.17.1
#11 lore raw

PATCH v2 5/5 arm64: defconfig: Enable Sun4i SPDIF module

In reply to Clément Péron

Allwinner A64 and H6 use the Sun4i SPDIF driver.

Enable this to allow a proper support.

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index 2d9c39033c1a..423413768d79 100644
@@ -531,6 +531,7 @@ CONFIG_SND_SOC_RK3399_GRU_SOUND=m
 CONFIG_SND_MESON_AXG_SOUND_CARD=m
 CONFIG_SND_SOC_SAMSUNG=y
 CONFIG_SND_SOC_RCAR=m
+CONFIG_SND_SUN4I_SPDIF=m
 CONFIG_SND_SOC_AK4613=m
 CONFIG_SND_SOC_PCM3168A_I2C=m
 CONFIG_SND_SIMPLE_CARD=m
Signature · 1 line
2.17.1