Skip to contentSkip to conversation

Add SPDIF support for Allwinner SoCs

PATCH Superseded [email protected] 3 participants 18 messages Sep 30, 2015 – Oct 26, 2015

Subsystems (4)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add SPDIF support for Allwinner SoCs

From: Marcus Cooper <[email protected]>

This patch set adds support for the Allwinner SPDIF transceiver as present on the A10, A20 and A31 SoC boards.

For now just the SPDIF transmitter has been tested on a Mele A2000.

In order for this patch set to be functional we require audio clock patches which will be delivered separately. For those that are interested I've pushed the patches here with all the required changes to get SPDIF audio out of the device.

https://github.com/codekipper/linux-sunxi/commits/spdif_delivery

This is version 2 of the patch series. After Mark's initial comments I realised that I shouldn't of blindly copied the register set-up from the original SDK that was released. It doesn't help also that the datasheet that finally emerged lacked a serious amount of detail. If anybody does recognise the IP used for the block then please speak out.

In short, much of the code that was in the first release is no longer here.

I'm still unsure about the machine driver setup. Simple card seems a bit overkill and what I've added is pretty much a copy of what is done in imx-spdif. I'm not planning on arguing the case for my method so if you can advise then I'm all ears.

Thanks in advance,
CK

---
Changes since v1:
- Moved sunxi-machine-spdif.c to seperate patch
- replaced sunxi in naming scheme with sun4i in the sun4i-spdif driver.
- split tx controller into seperate enable/disable functions
- moved setclk and setfmt functionality into hw params
- added support for mono signals.
- cleaned up probe clock set up.
- removed all writes to transmit status registers.
- removed of_id
- removed power management code.
- Added support for more rates.
---
Marcus Cooper (4):
dt-bindings: add sunxi SPDIF transceiver bindings
dt-binding: Add sunxi S/PDIF machine driver
ASoC: sunxi: Add S/PDIF machine driver.
ASOC: sunxi: Add support for the spdif block

 .../devicetree/bindings/sound/sunxi,spdif.txt      |  49 ++
 .../bindings/sound/sunxi-audio-spdif.txt           |  36 ++
 sound/soc/sunxi/Kconfig                            |  12 +
 sound/soc/sunxi/Makefile                           |   4 +
 sound/soc/sunxi/sun4i-spdif.c                      | 612 +++++++++++++++++++++
 sound/soc/sunxi/sunxi-machine-spdif.c              | 108 ++++
 6 files changed, 821 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/sunxi,spdif.txt
 create mode 100644 Documentation/devicetree/bindings/sound/sunxi-audio-spdif.txt
 create mode 100644 sound/soc/sunxi/sun4i-spdif.c
 create mode 100644 sound/soc/sunxi/sunxi-machine-spdif.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/4 dt-bindings: add sunxi SPDIF transceiver bindings

From: Marcus Cooper <[email protected]>

Add devicetree bindings for the SPDIF transceiver found on found on Allwinners A10, A20 and A31 SoCs.

---
 .../devicetree/bindings/sound/sunxi,spdif.txt      | 49 ++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/sunxi,spdif.txt
Documentation/devicetree/bindings/sound/sunxi,spdif.txt new file +49 -0
new file mode 100644
index 0000000..1868722
@@ -0,0 +1,49 @@
+Allwinner Sony/Philips Digital Interface Format (S/PDIF) Controller
+
+The Allwinner S/PDIF audio block is a transceiver that allows the
+processor to receive and transmit digital audio via an coaxial cable or
+a fibre cable.
+
+Required properties:
+
+  - compatible		: should be one of the following:
+    - "allwinner,sun4i-a10-spdif": for the Allwinner A10 SoC
+    - "allwinner,sun7i-a20-spdif": for the Allwinner A20 SoC
+    - "allwinner,sun6i-a31-spdif": for the Allwinner A31 SoC
+
+  - 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:
+	"apb"		  clock for the spdif bus.
+	"audio"		  clock from the audio pll.
+	"spdif"		  clock for spdif controller.
+
+Optional:
+
+  - spdif-in		: Enable block for capturing an SPDIF signal.
+
+  - spdif-out		: Enable block for transmitting an SPDIF signal.
+
+Example:
+
+spdif: spdif@01c21000 {
+	compatible = "allwinner,sun4i-a10-spdif";
+	reg = <0x01c21000 0x40>;
+	interrupts = <13>;
+	clocks = <&apb0_gates 1>, <&pll2 0>, <&spdif_clk>;
+	clock-names = "apb", "audio", "spdif";
+	dmas = <&dma 0 2>, <&dma 0 2>;
+	dma-names = "rx", "tx";
+	spdif-in = "disabled";
+	spdif-out = "okay";
+	status = "okay";
+};
Signature · 1 line
1.9.1
#6 lore raw

PATCH v2 2/4 dt-binding: Add sunxi S/PDIF machine driver

In reply to [email protected]

From: Marcus Cooper <[email protected]>

Add device tree bindings for the SPDIF machine driver for Allwinner SoC devices.

---
 .../bindings/sound/sunxi-audio-spdif.txt           | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/sunxi-audio-spdif.txt
Documentation/devicetree/bindings/sound/sunxi-audio-spdif.txt new file +36 -0
new file mode 100644
index 0000000..b9e8152
@@ -0,0 +1,36 @@
+Allwinner audio complex with S/PDIF transceiver
+
+Required properties:
+
+  - compatible		: "Allwinner,sunxi-audio-spdif"
+
+  - model		: The user-visible name of this sound complex
+
+  - spdif-controller	: The phandle of the Allwinner S/PDIF controller
+
+
+Optional properties:
+
+  - spdif-out		: This is a boolean property. If present, the
+			  transmitting function of S/PDIF will be enabled,
+			  indicating there's a physical S/PDIF out connector
+			  or jack on the board or it's connecting to some
+			  other IP block, such as an HDMI encoder or
+			  display-controller.
+
+  - spdif-in		: This is a boolean property. If present, the receiving
+			  function of S/PDIF will be enabled, indicating there
+			  is a physical S/PDIF in connector/jack on the board.
+
+* Note: At least one of these two properties should be set in the DT binding.
+
+
+Example:
+
+sound-spdif {
+	compatible = "allwinner,sunxi-audio-spdif";
+	model = "sunxi-spdif";
+	spdif-controller = <&spdif>;
+	spdif-out;
+	spdif-in;
+};
Signature · 1 line
1.9.1
#7 lore raw

PATCH v2 3/4 ASoC: sunxi: Add S/PDIF machine driver.

In reply to [email protected]

From: Marcus Cooper <[email protected]>

---
 sound/soc/sunxi/sunxi-machine-spdif.c | 108 ++++++++++++++++++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 sound/soc/sunxi/sunxi-machine-spdif.c
sound/soc/sunxi/sunxi-machine-spdif.c new file +108 -0
new file mode 100644
index 0000000..2adb727
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2015 Andrea Venturi <be17068-p0aYb1w59bq9tCD/[email protected]>
+ * From code by (C) 2013 Freescale Semiconductor, Inc.
+ * (sound/soc/fsl/imx-spdif.c)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <sound/soc.h>
+
+struct sunxi_machine_spdif_data {
+	struct snd_soc_dai_link dai;
+	struct snd_soc_card card;
+};
+
+static int sunxi_machine_spdif_audio_probe(struct platform_device *pdev)
+{
+	struct device_node *spdif_np, *np = pdev->dev.of_node;
+	struct sunxi_machine_spdif_data *data;
+	int ret = 0;
+
+	dev_dbg(&pdev->dev, "%s: Looking for spdif-controller\n", __func__);
+	spdif_np = of_parse_phandle(np, "spdif-controller", 0);
+	if (!spdif_np) {
+		dev_err(&pdev->dev, "failed to find spdif-controller\n");
+		ret = -EINVAL;
+		goto end;
+	}
+
+	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+	if (!data) {
+		ret = -ENOMEM;
+		goto end;
+	}
+
+	data->dai.name = "S/PDIF PCM";
+	data->dai.stream_name = "S/PDIF PCM";
+	data->dai.codec_dai_name = "snd-soc-dummy-dai";
+	data->dai.codec_name = "snd-soc-dummy";
+	data->dai.cpu_of_node = spdif_np;
+	data->dai.platform_of_node = spdif_np;
+	data->dai.playback_only = true;
+	data->dai.capture_only = true;
+
+	if (of_property_read_bool(np, "spdif-out"))
+		data->dai.capture_only = false;
+
+	if (of_property_read_bool(np, "spdif-in"))
+		data->dai.playback_only = false;
+
+	if (data->dai.playback_only && data->dai.capture_only) {
+		dev_err(&pdev->dev, "no enabled S/PDIF DAI link\n");
+		goto end;
+	}
+
+	data->card.dev = &pdev->dev;
+	data->card.dai_link = &data->dai;
+	data->card.num_links = 1;
+	data->card.owner = THIS_MODULE;
+
+	ret = snd_soc_of_parse_card_name(&data->card, "model");
+	if (ret)
+		goto end;
+
+	ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
+	if (ret) {
+		dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret);
+		goto end;
+	}
+
+	platform_set_drvdata(pdev, data);
+
+end:
+	of_node_put(spdif_np);
+
+	return ret;
+}
+
+static const struct of_device_id sunxi_machine_spdif_dt_ids[] = {
+	{ .compatible = "allwinner,sunxi-audio-spdif", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, sunxi_machine_spdif_dt_ids);
+
+static struct platform_driver sunxi_machine_spdif_driver = {
+	.driver = {
+		.name = "sunxi-machine-spdif",
+		.of_match_table = sunxi_machine_spdif_dt_ids,
+	},
+	.probe = sunxi_machine_spdif_audio_probe,
+};
+
+module_platform_driver(sunxi_machine_spdif_driver);
+
+MODULE_AUTHOR("Marcus Cooper <[email protected]>");
+MODULE_AUTHOR("Andrea Venturi, <be17068-p0aYb1w59bq9tCD/[email protected]>");
+MODULE_DESCRIPTION("Allwinner sunxi S/PDIF machine driver");
+MODULE_LICENSE("GPL v2");
Signature · 1 line
1.9.1
#8 lore raw

PATCH v2 4/4 ASOC: sunxi: Add support for the spdif block

In reply to [email protected]

From: Marcus Cooper <[email protected]>

The sun4i, sun6i and sun7i SoC families have an SPDIF block which is capable of playback and capture.

This patch enables the playback of this block for
the sun4i and sun7i families.

---
 sound/soc/sunxi/Kconfig       |  12 +
 sound/soc/sunxi/Makefile      |   4 +
 sound/soc/sunxi/sun4i-spdif.c | 612 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 628 insertions(+)
 create mode 100644 sound/soc/sunxi/sun4i-spdif.c
sound/soc/sunxi/Kconfig +12 -0
index 84c72ec..2ebf43d 100644
@@ -8,4 +8,16 @@ config SND_SUN4I_CODEC
 	  Select Y or M to add support for the Codec embedded in the Allwinner
 	  A10 and affiliated SoCs.
 
+config SND_SOC_SUNXI_DAI_SPDIF
+        tristate
+	depends on OF
+        select SND_SOC_GENERIC_DMAENGINE_PCM
+        select REGMAP_MMIO
+
+config SND_SOC_SUNXI_MACHINE_SPDIF
+        tristate "APB on-chip sun4i/sun5i/sun7i SPDIF"
+	depends on OF
+        select SND_SOC_SUNXI_DAI_SPDIF
+        help
+          Say Y if you want to add support for SoC S/PDIF audio as simple audio card.
 endmenu
sound/soc/sunxi/Makefile +4 -0
index ea8a08c..c8c0a00 100644
@@ -1,2 +1,6 @@
 obj-$(CONFIG_SND_SUN4I_CODEC) += sun4i-codec.o
 
+snd-soc-sunxi-dai-spdif-objs := sun4i-spdif.o
+obj-$(CONFIG_SND_SOC_SUNXI_DAI_SPDIF) += snd-soc-sunxi-dai-spdif.o
+snd-soc-sunxi-machine-spdif-objs := sunxi-machine-spdif.o
+obj-$(CONFIG_SND_SOC_SUNXI_MACHINE_SPDIF) += snd-soc-sunxi-machine-spdif.o
sound/soc/sunxi/sun4i-spdif.c new file +612 -0

612 lines not on this page · raw message

Signature · 1 line
1.9.1
#9 lore raw

[PATCH] ASOC: sunxi: fix platform_no_drv_owner.cocci warnings

sound/soc/sunxi/sun4i-spdif.c:599:3-8: No need to set .owner here. The core will do it.

sound/soc/sunxi/sun4i-spdif.c:599:3-8: No need to set .owner here. The core will do it.

Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

---

 sun4i-spdif.c |    1 -
 1 file changed, 1 deletion(-)
sound/soc/sunxi/sun4i-spdif.c +0 -1
@@ -596,7 +596,6 @@ static int sun4i_spdif_remove(struct pla
 static struct platform_driver sun4i_spdif_driver = {
 	.driver		= {
 		.name	= "sun4i-spdif",
-		.owner	= THIS_MODULE,
 		.of_match_table = of_match_ptr(sun4i_spdif_of_match),
 	},
 	.probe		= sun4i_spdif_probe,
#10 lore raw

Re: [PATCH v2 4/4] ASOC: sunxi: Add support for the spdif block

In reply to [email protected]
coccinelle warnings: (new ones prefixed by >>)

Hi Marcus,

[auto build test results on next-20150930 -- if it's inappropriate base, please ignore]

coccinelle warnings: (new ones prefixed by >>)

>> sound/soc/sunxi/sun4i-spdif.c:599:3-8: No need to set .owner here. The core will do it.

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#11 lore raw

[RFC PATCH] ASOC: sunxi: sun4i_snd_txctrl_on() can be static

In reply to [email protected]
Signed-off-by: Fengguang Wu <[email protected]>
---
 sun4i-spdif.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sunxi/sun4i-spdif.c +2 -2
index 5fff6f6..cf0ed80 100644
@@ -204,7 +204,7 @@ static void sun4i_spdif_configure(struct sun4i_spdif_dev *host)
 
 }
 
-void sun4i_snd_txctrl_on(struct snd_pcm_substream *substream,
+static void sun4i_snd_txctrl_on(struct snd_pcm_substream *substream,
 				struct sun4i_spdif_dev *host)
 {
 	if (substream->runtime->channels == 1)
@@ -228,7 +228,7 @@ void sun4i_snd_txctrl_on(struct snd_pcm_substream *substream,
 					SUN4I_SPDIF_CTL_GEN);
 }
 
-void sun4i_snd_txctrl_off(struct snd_pcm_substream *substream,
+static void sun4i_snd_txctrl_off(struct snd_pcm_substream *substream,
 				struct sun4i_spdif_dev *host)
 {
 	/* SPDIF TX DISABLE */
#12 lore raw

Re: [PATCH v2 4/4] ASOC: sunxi: Add support for the spdif block

In reply to [email protected]
reproduce:

Hi Marcus,

[auto build test results on next-20150930 -- if it's inappropriate base, please ignore]

reproduce:

  # apt-get install sparse
  make ARCH=x86_64 allmodconfig
  make C=1 CF=-D__CHECK_ENDIAN__

sparse warnings: (new ones prefixed by >>)

>> sound/soc/sunxi/sun4i-spdif.c:207:6: sparse: symbol 'sun4i_snd_txctrl_on' was not declared. Should it be static?
>> sound/soc/sunxi/sun4i-spdif.c:231:6: sparse: symbol 'sun4i_snd_txctrl_off' was not declared. Should it be static?
>> sound/soc/sunxi/sun4i-spdif.c:451:28: sparse: incorrect type in initializer (different base types)

sound/soc/sunxi/sun4i-spdif.c:451:28: expected unsigned long long [unsigned] [usertype] formats
sound/soc/sunxi/sun4i-spdif.c:451:28: got restricted snd_pcm_format_t

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#13 lore raw

Re: [PATCH v2 4/4] ASOC: sunxi: Add support for the spdif block

In reply to [email protected]
Quoted 26 lines · On Wed, Sep 30, 2015 at 07:50:58PM +0200…

From: Marcus Cooper <[email protected]>

The sun4i, sun6i and sun7i SoC families have an SPDIF block which is capable of playback and capture.

This patch enables the playback of this block for
the sun4i and sun7i families.

---
 sound/soc/sunxi/Kconfig       |  12 +
 sound/soc/sunxi/Makefile      |   4 +
 sound/soc/sunxi/sun4i-spdif.c | 612 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 628 insertions(+)
 create mode 100644 sound/soc/sunxi/sun4i-spdif.c
sound/soc/sunxi/Kconfig +2 -0
index 84c72ec..2ebf43d 100644
@@ -8,4 +8,16 @@ config SND_SUN4I_CODEC
 	  Select Y or M to add support for the Codec embedded in the Allwinner
 	  A10 and affiliated SoCs.
 
+config SND_SOC_SUNXI_DAI_SPDIF
+        tristate

sound/soc/sunxi/Kconfig config SND_SUN4I_CODEC · line 22

Quoted 10 lines
sound/soc/sunxi/Kconfig +10 -0
+	depends on OF
+        select SND_SOC_GENERIC_DMAENGINE_PCM
+        select REGMAP_MMIO
+
+config SND_SOC_SUNXI_MACHINE_SPDIF
+        tristate "APB on-chip sun4i/sun5i/sun7i SPDIF"
+	depends on OF
+        select SND_SOC_SUNXI_DAI_SPDIF
+        help
+          Say Y if you want to add support for SoC S/PDIF audio as simple audio card.

You still haven't said why you can't use simple-card...

sound/soc/sunxi/Kconfig config SND_SUN4I_CODEC

Quoted 10 lines
sound/soc/sunxi/Kconfig +10 -0
+static void sun4i_spdif_configure(struct sun4i_spdif_dev *host)
+{
+	u32 reg_val;
+
+	/* soft reset SPDIF */
+	regmap_write(host->regmap, SUN4I_SPDIF_CTL, SUN4I_SPDIF_CTL_RESET);
+
+	/* MCLK OUTPUT enable */
+	regmap_update_bits(host->regmap, SUN4I_SPDIF_CTL,
+			SUN4I_SPDIF_CTL_MCLKOUTEN, SUN4I_SPDIF_CTL_MCLKOUTEN);

The alignment is still not right....

sound/soc/sunxi/Kconfig

Quoted 7 lines
sound/soc/sunxi/Kconfig +7 -0
+	/* flush TX FIFO */
+	regmap_update_bits(host->regmap, SUN4I_SPDIF_FCTL,
+			SUN4I_SPDIF_FCTL_FTX, SUN4I_SPDIF_FCTL_FTX);
+
+	/* clear interrupt status */
+	regmap_read(host->regmap, SUN4I_SPDIF_ISTA, &reg_val);
+	regmap_write(host->regmap, SUN4I_SPDIF_ISTA, reg_val);

You're not using any interrupts. Why is this needed?

sound/soc/sunxi/Kconfig

Quoted 12 lines
sound/soc/sunxi/Kconfig +12 -0
+static int sun4i_spdif_startup(struct snd_pcm_substream *substream,
+				struct snd_soc_dai *cpu_dai)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct sun4i_spdif_dev *host = snd_soc_dai_get_drvdata(rtd->cpu_dai);
+
+	if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+		return -EINVAL;
+
+	sun4i_spdif_configure(host);
+
+	return clk_prepare_enable(host->clk);

You're still not using pm_runtime...

Quoted 68 lines
sound/soc/sunxi/Kconfig +68 -0
+}
+
+static void sun4i_spdif_shutdown(struct snd_pcm_substream *substream,
+				struct snd_soc_dai *dai)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct sun4i_spdif_dev *host = snd_soc_dai_get_drvdata(rtd->cpu_dai);
+
+	if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+		return;
+
+	clk_disable_unprepare(host->clk);
+}
+
+static int sun4i_spdif_hw_params(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params,
+				struct snd_soc_dai *cpu_dai)
+{
+	int ret = 0;
+	int fmt;
+	unsigned long rate = params_rate(params);
+	u32 mclk_div = 0;
+	unsigned int mclk = 0;
+	u32 reg_val;
+	struct sun4i_spdif_dev *host = snd_soc_dai_get_drvdata(cpu_dai);
+	struct platform_device *pdev = host->pdev;
+
+	/* Add the PCM and raw data select interface */
+	switch (params_channels(params)) {
+	case 1: /* PCM mode */
+	case 2:
+		fmt = 0;
+		break;
+	case 4: /* raw data mode */
+		fmt = SUN4I_SPDIF_TXCFG_NONAUDIO;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	switch (params_format(params)) {
+	case SNDRV_PCM_FORMAT_S16_LE:
+		fmt |= SUN4I_SPDIF_TXCFG_FMT16BIT;
+		break;
+	case SNDRV_PCM_FORMAT_S20_3LE:
+		fmt |= SUN4I_SPDIF_TXCFG_FMT20BIT;
+		break;
+	case SNDRV_PCM_FORMAT_S24_LE:
+		fmt |= SUN4I_SPDIF_TXCFG_FMT24BIT;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	switch (rate) {
+	case 22050:
+	case 44100:
+	case 88200:
+	case 176400:
+		mclk = 22579200;
+		break;
+	case 24000:
+	case 32000:
+	case 48000:
+	case 96000:
+	case 192000:
+		mclk = 24576000;
+		break;

sound/soc/sunxi/Kconfig

Quoted 10 lines
sound/soc/sunxi/Kconfig +10 -0
+	default:
+		return -EINVAL;
+	}
+
+	ret = clk_set_rate(host->audio_clk, mclk);
+	if (ret < 0) {
+		dev_err(&pdev->dev,
+			"Setting pll2 clock rate for %d Hz failed!\n", mclk);
+		return ret;
+	}

You're still using the PLL2...

Quoted 5 lines
sound/soc/sunxi/Kconfig +5 -0
+
+	ret = clk_set_rate(host->clk, mclk);
+	if (ret < 0) {
+		dev_err(&pdev->dev,
+			"Setting SPDIF clock rate for %d Hz failed!\n", mclk);

sound/soc/sunxi/Kconfig

Quoted 10 lines
sound/soc/sunxi/Kconfig +10 -0
+		return ret;
+	}
+
+	reg_val = 0;
+	reg_val &= ~SUN4I_SPDIF_FCTL_FIFOSRC;
+	reg_val |= SUN4I_SPDIF_FCTL_TXTL_MASK;
+	reg_val |= SUN4I_SPDIF_FCTL_RXTL_MASK;
+	reg_val |= SUN4I_SPDIF_FCTL_TXIM;
+	reg_val |= SUN4I_SPDIF_FCTL_RXOM_MASK;
+	regmap_write(host->regmap, SUN4I_SPDIF_FCTL, reg_val);

You're still not using regmap_update_bits...

IF you're really going to ignore all the comments we did, please tell us upfront. That way, we will not waste our time doing a review of your patches.

Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

Re: [PATCH v2 1/4] dt-bindings: add sunxi SPDIF transceiver bindings

In reply to [email protected]
Quoted 19 lines · On Wed, Sep 30, 2015 at 07:50:55PM +0200…

From: Marcus Cooper <[email protected]>

Add devicetree bindings for the SPDIF transceiver found on found on Allwinners A10, A20 and A31 SoCs.

---
 .../devicetree/bindings/sound/sunxi,spdif.txt      | 49 ++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/sunxi,spdif.txt
Documentation/devicetree/bindings/sound/sunxi,spdif.txt new file +2 -0
new file mode 100644
index 0000000..1868722
@@ -0,0 +1,49 @@
+Allwinner Sony/Philips Digital Interface Format (S/PDIF) Controller
+

Documentation/devicetree/bindings/sound/sunxi,spdif.txt line 12

Quoted 10 lines
Documentation/devicetree/bindings/sound/sunxi,spdif.txt new file +10 -0
+The Allwinner S/PDIF audio block is a transceiver that allows the
+processor to receive and transmit digital audio via an coaxial cable or
+a fibre cable.
+
+Required properties:
+
+  - compatible		: should be one of the following:
+    - "allwinner,sun4i-a10-spdif": for the Allwinner A10 SoC
+    - "allwinner,sun7i-a20-spdif": for the Allwinner A20 SoC
+    - "allwinner,sun6i-a31-spdif": for the Allwinner A31 SoC

Are all these compatibles really work? Is there any significant difference between the controller on all these SoCs?

Thanks,
Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

Re: [PATCH v2 1/4] dt-bindings: add sunxi SPDIF transceiver bindings

Quoted 8 lines

Documentation/devicetree/bindings/sound/sunxi,spdif.txt line 12

Quoted 5 lines
Documentation/devicetree/bindings/sound/sunxi,spdif.txt new file +5 -0
+
+  - compatible               : should be one of the following:
+    - "allwinner,sun4i-a10-spdif": for the Allwinner A10 SoC
+    - "allwinner,sun7i-a20-spdif": for the Allwinner A20 SoC
+    - "allwinner,sun6i-a31-spdif": for the Allwinner A31 SoC

Are all these compatibles really work? Is there any significant difference between the controller on all these SoCs?

Let us assume that there isn't any difference. Remember SPDIF details for all of these devices is sketchy. In the A10 User Manual, it's not even mentioned although devices such as the Mele A2000 which I use come with the physical connector. It's only when the A20 Manual was released that we see the pin details and related components. We didn't see a SPDIF block spec until the H3 User Manual was released.

Looking at the SDK code I've only seen fifo level settings to be different for the sun6i family. It was this release that also showed Rx rotines. The fact of the matter is we won't know until these SoCs have been tested and with that in mind I'm happy to remove all capabilities for now until then.

BR,
CK

Quoted 8 lines

Thanks,
Maxime

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

#14 lore raw

Re: [PATCH v2 4/4] ASOC: sunxi: Add support for the spdif block

In reply to Maxime Ripard
Quoted 6 lines
Quoted 6 lines
sound/soc/sunxi/Kconfig +6 -0
+config SND_SOC_SUNXI_DAI_SPDIF
+        tristate
+     depends on OF
+        select SND_SOC_GENERIC_DMAENGINE_PCM
+        select REGMAP_MMIO
+
Quoted 8 lines

sound/soc/sunxi/Kconfig config SND_SUN4I_CODEC · line 22

Quoted 6 lines
sound/soc/sunxi/Kconfig +6 -0
+config SND_SOC_SUNXI_MACHINE_SPDIF
+        tristate "APB on-chip sun4i/sun5i/sun7i SPDIF"
+     depends on OF
+        select SND_SOC_SUNXI_DAI_SPDIF
+        help
+          Say Y if you want to add support for SoC S/PDIF audio as simple audio card.

You still haven't said why you can't use simple-card...

I mentioned in the covering letter that I thought that simple-card was overkill. There is also a thread concerning issues with the ordering of module bringup here
http://mailman.alsa-project.org/pipermail/alsa-devel/2013-December/070534.html.
I was initially trying to use the dummy spdif transmitter but couldn't get it working, this set up works for me. I haven't got an audio guy sitting next to me to ping and have reached out for some guidance. I can do this using simple-card, it just with all the driver refactoring it was the main place where I thought things would break.

Quoted 13 lines

sound/soc/sunxi/sun4i-spdif.c line 192

Quoted 11 lines
sound/soc/sunxi/sun4i-spdif.c new file +10 -0
+static void sun4i_spdif_configure(struct sun4i_spdif_dev *host)
+{
+     u32 reg_val;
+
+     /* soft reset SPDIF */
+     regmap_write(host->regmap, SUN4I_SPDIF_CTL, SUN4I_SPDIF_CTL_RESET);
+
+     /* MCLK OUTPUT enable */
+     regmap_update_bits(host->regmap, SUN4I_SPDIF_CTL,
+                     SUN4I_SPDIF_CTL_MCLKOUTEN, SUN4I_SPDIF_CTL_MCLKOUTEN);

The alignment is still not right....

I'm not even sure if we need mclk output enabled. Let me see what happens when I remove this.

Quoted 10 lines

sound/soc/sunxi/sun4i-spdif.c line 200

Quoted 8 lines
sound/soc/sunxi/sun4i-spdif.c new file +7 -0
+     /* flush TX FIFO */
+     regmap_update_bits(host->regmap, SUN4I_SPDIF_FCTL,
+                     SUN4I_SPDIF_FCTL_FTX, SUN4I_SPDIF_FCTL_FTX);
+
+     /* clear interrupt status */
+     regmap_read(host->regmap, SUN4I_SPDIF_ISTA, &reg_val);
+     regmap_write(host->regmap, SUN4I_SPDIF_ISTA, reg_val);

You're not using any interrupts. Why is this needed?

ditto. This wasn't brought up in the previous reviews.

Quoted 15 lines

sound/soc/sunxi/sun4i-spdif.c line 258

Quoted 13 lines
sound/soc/sunxi/sun4i-spdif.c new file +12 -0
+static int sun4i_spdif_startup(struct snd_pcm_substream *substream,
+                             struct snd_soc_dai *cpu_dai)
+{
+     struct snd_soc_pcm_runtime *rtd = substream->private_data;
+     struct sun4i_spdif_dev *host = snd_soc_dai_get_drvdata(rtd->cpu_dai);
+
+     if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+             return -EINVAL;
+
+     sun4i_spdif_configure(host);
+
+     return clk_prepare_enable(host->clk);

You're still not using pm_runtime...

I've removed the pm stuff and this is the same as you have it in sun4i-codec.

Quoted 10 lines

sound/soc/sunxi/sun4i-spdif.c line 336

Quoted 8 lines
sound/soc/sunxi/sun4i-spdif.c new file +7 -0
+
+     ret = clk_set_rate(host->audio_clk, mclk);
+     if (ret < 0) {
+             dev_err(&pdev->dev,
+                     "Setting pll2 clock rate for %d Hz failed!\n", mclk);
+             return ret;
+     }

You're still using the PLL2...

I commented this out and it stopped working...let me check again.

Quoted 10 lines
Quoted 10 lines
sound/soc/sunxi/sun4i-spdif.c new file +9 -0
+
+     ret = clk_set_rate(host->clk, mclk);
+     if (ret < 0) {
+             dev_err(&pdev->dev,
+                     "Setting SPDIF clock rate for %d Hz failed!\n", mclk);
+             return ret;
+     }
+
+     reg_val = 0;
Quoted 8 lines

sound/soc/sunxi/sun4i-spdif.c line 351

Quoted 6 lines
sound/soc/sunxi/sun4i-spdif.c new file +6 -0
+     reg_val &= ~SUN4I_SPDIF_FCTL_FIFOSRC;
+     reg_val |= SUN4I_SPDIF_FCTL_TXTL_MASK;
+     reg_val |= SUN4I_SPDIF_FCTL_RXTL_MASK;
+     reg_val |= SUN4I_SPDIF_FCTL_TXIM;
+     reg_val |= SUN4I_SPDIF_FCTL_RXOM_MASK;
+     regmap_write(host->regmap, SUN4I_SPDIF_FCTL, reg_val);

You're still not using regmap_update_bits...

Why would I need to?, this is the first write to the register before playback and I'm not interested in keeping any of the previous fifo settings. Will remove"reg_val &= ~SUN4I_SPDIF_FCTL_FIFOSRC;" as that's not doing anything.

Quoted 4 lines

IF you're really going to ignore all the comments we did, please tell us upfront. That way, we will not waste our time doing a review of your patches.

All is a strong word....did you even read my covering letter?....there was a major refactoring of the code and I think I covered a majority of the comments. Apologies if you feel that you'd wasted a lot of time of this....it can't be any more that the EVB dts.
Thanks anyway,
CK

Quoted 7 lines

Maxime

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

#4 lore raw

Re: [PATCH v2 1/4] dt-bindings: add sunxi SPDIF transceiver bindings

In reply to Code Kipper
Quoted 16 lines · Code Kipper
Quoted 8 lines

Documentation/devicetree/bindings/sound/sunxi,spdif.txt line 12

Quoted 5 lines
Documentation/devicetree/bindings/sound/sunxi,spdif.txt new file +5 -0
+
+  - compatible               : should be one of the following:
+    - "allwinner,sun4i-a10-spdif": for the Allwinner A10 SoC
+    - "allwinner,sun7i-a20-spdif": for the Allwinner A20 SoC
+    - "allwinner,sun6i-a31-spdif": for the Allwinner A31 SoC

Are all these compatibles really work? Is there any significant difference between the controller on all these SoCs?

Let us assume that there isn't any difference. Remember SPDIF details for all of these devices is sketchy. In the A10 User Manual, it's not even mentioned although devices such as the Mele A2000 which I use come with the physical connector. It's only when the A20 Manual was released that we see the pin details and related components. We didn't see a SPDIF block spec until the H3 User Manual was released.

Quoted 5 lines

Looking at the SDK code I've only seen fifo level settings to be different for the sun6i family. It was this release that also showed Rx rotines. The fact of the matter is we won't know until these SoCs have been tested and with that in mind I'm happy to remove all capabilities for now until then.

The point was more that you document compatibles that you are not actually supporting.

You've only tested it on one SoC (and it actually works only on one SoC, or at least with one compatible), so only document that.

Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#5 lore raw

Re: [PATCH v2 1/4] dt-bindings: add sunxi SPDIF transceiver bindings

Quoted 23 lines · Maxime Ripard
Quoted 16 lines · Code Kipper
Quoted 8 lines

Documentation/devicetree/bindings/sound/sunxi,spdif.txt line 12

Quoted 5 lines
Documentation/devicetree/bindings/sound/sunxi,spdif.txt new file +5 -0
+
+  - compatible               : should be one of the following:
+    - "allwinner,sun4i-a10-spdif": for the Allwinner A10 SoC
+    - "allwinner,sun7i-a20-spdif": for the Allwinner A20 SoC
+    - "allwinner,sun6i-a31-spdif": for the Allwinner A31 SoC

Are all these compatibles really work? Is there any significant difference between the controller on all these SoCs?

Let us assume that there isn't any difference. Remember SPDIF details for all of these devices is sketchy. In the A10 User Manual, it's not even mentioned although devices such as the Mele A2000 which I use come with the physical connector. It's only when the A20 Manual was released that we see the pin details and related components. We didn't see a SPDIF block spec until the H3 User Manual was released.

Quoted 5 lines

Looking at the SDK code I've only seen fifo level settings to be different for the sun6i family. It was this release that also showed Rx rotines. The fact of the matter is we won't know until these SoCs have been tested and with that in mind I'm happy to remove all capabilities for now until then.

Quoted 5 lines

The point was more that you document compatibles that you are not actually supporting.

You've only tested it on one SoC (and it actually works only on one SoC, or at least with one compatible), so only document that.

Fixed,
Thanks,
CK

Quoted 7 lines

Maxime

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

#15 lore raw

Re: [PATCH v2 4/4] ASOC: sunxi: Add support for the spdif block

In reply to Code Kipper
Quoted 15 lines · Code Kipper
Quoted 6 lines
Quoted 6 lines
sound/soc/sunxi/Kconfig +6 -0
+config SND_SOC_SUNXI_DAI_SPDIF
+        tristate
+     depends on OF
+        select SND_SOC_GENERIC_DMAENGINE_PCM
+        select REGMAP_MMIO
+
Quoted 8 lines

sound/soc/sunxi/Kconfig config SND_SUN4I_CODEC · line 22

Quoted 6 lines
sound/soc/sunxi/Kconfig +6 -0
+config SND_SOC_SUNXI_MACHINE_SPDIF
+        tristate "APB on-chip sun4i/sun5i/sun7i SPDIF"
+     depends on OF
+        select SND_SOC_SUNXI_DAI_SPDIF
+        help
+          Say Y if you want to add support for SoC S/PDIF audio as simple audio card.

You still haven't said why you can't use simple-card...

Quoted 2 lines

I mentioned in the covering letter that I thought that simple-card was overkill.

Overkill for what? It adds no code, that will put no new maintainance burden, without any duplication. While your code also adds all that.

Quoted 8 lines

There is also a thread concerning issues with the ordering of module bringup here
http://mailman.alsa-project.org/pipermail/alsa-devel/2013-December/070534.html.
I was initially trying to use the dummy spdif transmitter but couldn't get it working, this set up works for me. I haven't got an audio guy sitting next to me to ping and have reached out for some guidance. I can do this using simple-card, it just with all the driver refactoring it was the main place where I thought things would break.

We're all on IRC.

Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
sound/soc/sunxi/sun4i-spdif.c new file +4 -0
+static void sun4i_spdif_configure(struct sun4i_spdif_dev *host)
+{
+     u32 reg_val;
+
Quoted 8 lines

sound/soc/sunxi/sun4i-spdif.c line 192

Quoted 6 lines
sound/soc/sunxi/sun4i-spdif.c new file +6 -0
+     /* soft reset SPDIF */
+     regmap_write(host->regmap, SUN4I_SPDIF_CTL, SUN4I_SPDIF_CTL_RESET);
+
+     /* MCLK OUTPUT enable */
+     regmap_update_bits(host->regmap, SUN4I_SPDIF_CTL,
+                     SUN4I_SPDIF_CTL_MCLKOUTEN, SUN4I_SPDIF_CTL_MCLKOUTEN);

The alignment is still not right....

Quoted 2 lines

I'm not even sure if we need mclk output enabled. Let me see what happens when I remove this.

It's not really the point. The alignment of all your wrapped lines is wrong.

Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
sound/soc/sunxi/sun4i-spdif.c new file +6 -0
+static int sun4i_spdif_startup(struct snd_pcm_substream *substream,
+                             struct snd_soc_dai *cpu_dai)
+{
+     struct snd_soc_pcm_runtime *rtd = substream->private_data;
+     struct sun4i_spdif_dev *host = snd_soc_dai_get_drvdata(rtd->cpu_dai);
+
Quoted 8 lines

sound/soc/sunxi/sun4i-spdif.c line 258

Quoted 6 lines
sound/soc/sunxi/sun4i-spdif.c new file +6 -0
+     if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+             return -EINVAL;
+
+     sun4i_spdif_configure(host);
+
+     return clk_prepare_enable(host->clk);

You're still not using pm_runtime...

Quoted 2 lines

I've removed the pm stuff and this is the same as you have it in sun4i-codec.

You've removed the suspend code, and both Mark and I asked you to use runtime_pm to handle your bus clock.

And this has also been asked for the codec.

Quoted 11 lines
Quoted 9 lines

sound/soc/sunxi/sun4i-spdif.c line 336

Quoted 7 lines
sound/soc/sunxi/sun4i-spdif.c new file +7 -0
+
+     ret = clk_set_rate(host->audio_clk, mclk);
+     if (ret < 0) {
+             dev_err(&pdev->dev,
+                     "Setting pll2 clock rate for %d Hz failed!\n", mclk);
+             return ret;
+     }

You're still using the PLL2...

I commented this out and it stopped working...let me check again.

Then something is wrong somewhere else that needs to be fixed, either in the clock driver or in this driver. Did you update all the other references to PLL2 as well?

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
sound/soc/sunxi/sun4i-spdif.c new file +9 -0
+
+     ret = clk_set_rate(host->clk, mclk);
+     if (ret < 0) {
+             dev_err(&pdev->dev,
+                     "Setting SPDIF clock rate for %d Hz failed!\n", mclk);
+             return ret;
+     }
+
+     reg_val = 0;
Quoted 8 lines

sound/soc/sunxi/sun4i-spdif.c line 351

Quoted 6 lines
sound/soc/sunxi/sun4i-spdif.c new file +6 -0
+     reg_val &= ~SUN4I_SPDIF_FCTL_FIFOSRC;
+     reg_val |= SUN4I_SPDIF_FCTL_TXTL_MASK;
+     reg_val |= SUN4I_SPDIF_FCTL_RXTL_MASK;
+     reg_val |= SUN4I_SPDIF_FCTL_TXIM;
+     reg_val |= SUN4I_SPDIF_FCTL_RXOM_MASK;
+     regmap_write(host->regmap, SUN4I_SPDIF_FCTL, reg_val);

You're still not using regmap_update_bits...

Quoted 4 lines

Why would I need to?, this is the first write to the register before playback and I'm not interested in keeping any of the previous fifo settings. Will remove"reg_val &= ~SUN4I_SPDIF_FCTL_FIFOSRC;" as that's not doing anything.

Dropping the masking is also an option.

Quoted 8 lines
Quoted 3 lines

IF you're really going to ignore all the comments we did, please tell us upfront. That way, we will not waste our time doing a review of your patches.

All is a strong word....did you even read my covering letter?....there was a major refactoring of the code and I think I covered a majority of the comments. Apologies if you feel that you'd wasted a lot of time of this....it can't be any more that the EVB dts.

The point of this is that this is a discussion. You simply ignored most of the comments, without even mentionning why you wanted to ignore them, and simply sent a new version.

If you feel like one comment is invalid, let's discuss this, like you did here. But silently discarding them is not an option and actually quite rude.

Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#16 lore raw

Re: [PATCH v2 4/4] ASOC: sunxi: Add support for the spdif block

Quoted 31 lines · Maxime Ripard
Quoted 15 lines · Code Kipper
Quoted 6 lines
Quoted 6 lines
sound/soc/sunxi/Kconfig +6 -0
+config SND_SOC_SUNXI_DAI_SPDIF
+        tristate
+     depends on OF
+        select SND_SOC_GENERIC_DMAENGINE_PCM
+        select REGMAP_MMIO
+
Quoted 8 lines

sound/soc/sunxi/Kconfig config SND_SUN4I_CODEC · line 22

Quoted 6 lines
sound/soc/sunxi/Kconfig +6 -0
+config SND_SOC_SUNXI_MACHINE_SPDIF
+        tristate "APB on-chip sun4i/sun5i/sun7i SPDIF"
+     depends on OF
+        select SND_SOC_SUNXI_DAI_SPDIF
+        help
+          Say Y if you want to add support for SoC S/PDIF audio as simple audio card.

You still haven't said why you can't use simple-card...

Quoted 2 lines

I mentioned in the covering letter that I thought that simple-card was overkill.

Overkill for what? It adds no code, that will put no new maintainance burden, without any duplication. While your code also adds all that.

Quoted 8 lines

There is also a thread concerning issues with the ordering of module bringup here
http://mailman.alsa-project.org/pipermail/alsa-devel/2013-December/070534.html.
I was initially trying to use the dummy spdif transmitter but couldn't get it working, this set up works for me. I haven't got an audio guy sitting next to me to ping and have reached out for some guidance. I can do this using simple-card, it just with all the driver refactoring it was the main place where I thought things would break.

Quoted 1 line

We're all on IRC.

OK, let me sit on the next patch release until I've properly investigated this. I'm not a big IRCer so I will need to change my habits.

Quoted 15 lines
Quoted 15 lines
Quoted 14 lines

sound/soc/sunxi/sun4i-spdif.c line 192

Quoted 12 lines
sound/soc/sunxi/sun4i-spdif.c new file +10 -0
+static void sun4i_spdif_configure(struct sun4i_spdif_dev *host)
+{
+     u32 reg_val;
+
+     /* soft reset SPDIF */
+     regmap_write(host->regmap, SUN4I_SPDIF_CTL, SUN4I_SPDIF_CTL_RESET);
+
+     /* MCLK OUTPUT enable */
+     regmap_update_bits(host->regmap, SUN4I_SPDIF_CTL,
+                     SUN4I_SPDIF_CTL_MCLKOUTEN, SUN4I_SPDIF_CTL_MCLKOUTEN);

The alignment is still not right....

Quoted 5 lines
Quoted 2 lines

I'm not even sure if we need mclk output enabled. Let me see what happens when I remove this.

It's not really the point. The alignment of all your wrapped lines is wrong.

Ahhhh....I was brought up to not mix tabs and spaces and I now see with a quick check that checkpatch doesn't barf...I'll fix this.

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines

sound/soc/sunxi/sun4i-spdif.c line 258

Quoted 13 lines
sound/soc/sunxi/sun4i-spdif.c new file +12 -0
+static int sun4i_spdif_startup(struct snd_pcm_substream *substream,
+                             struct snd_soc_dai *cpu_dai)
+{
+     struct snd_soc_pcm_runtime *rtd = substream->private_data;
+     struct sun4i_spdif_dev *host = snd_soc_dai_get_drvdata(rtd->cpu_dai);
+
+     if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+             return -EINVAL;
+
+     sun4i_spdif_configure(host);
+
+     return clk_prepare_enable(host->clk);

You're still not using pm_runtime...

Quoted 7 lines
Quoted 2 lines

I've removed the pm stuff and this is the same as you have it in sun4i-codec.

You've removed the suspend code, and both Mark and I asked you to use runtime_pm to handle your bus clock.

And this has also been asked for the codec.

You asked if I had tested the pm operations which I hadn't so I removed them after looking at your driver and searching for pm_runtime usage elsewhere in sound/soc. I will add them back.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
sound/soc/sunxi/sun4i-spdif.c new file +7 -0
+
+     ret = clk_set_rate(host->audio_clk, mclk);
+     if (ret < 0) {
+             dev_err(&pdev->dev,
+                     "Setting pll2 clock rate for %d Hz failed!\n", mclk);
+             return ret;
+     }
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

You're still using the PLL2...

I commented this out and it stopped working...let me check again.

Then something is wrong somewhere else that needs to be fixed, either in the clock driver or in this driver. Did you update all the other references to PLL2 as well?

To be honest...the underlying clock code that I used wasn't based on your latest patches. I'll relook at this, maybe my dsti is at fault.

Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 8 lines
sound/soc/sunxi/sun4i-spdif.c new file +5 -0
+
+     ret = clk_set_rate(host->clk, mclk);
+     if (ret < 0) {
+             dev_err(&pdev->dev,
+                     "Setting SPDIF clock rate for %d Hz failed!\n", mclk);

sound/soc/sunxi/sun4i-spdif.c line 351

Quoted 10 lines
sound/soc/sunxi/sun4i-spdif.c new file +10 -0
+             return ret;
+     }
+
+     reg_val = 0;
+     reg_val &= ~SUN4I_SPDIF_FCTL_FIFOSRC;
+     reg_val |= SUN4I_SPDIF_FCTL_TXTL_MASK;
+     reg_val |= SUN4I_SPDIF_FCTL_RXTL_MASK;
+     reg_val |= SUN4I_SPDIF_FCTL_TXIM;
+     reg_val |= SUN4I_SPDIF_FCTL_RXOM_MASK;
+     regmap_write(host->regmap, SUN4I_SPDIF_FCTL, reg_val);

You're still not using regmap_update_bits...

Quoted 6 lines
Quoted 4 lines

Why would I need to?, this is the first write to the register before playback and I'm not interested in keeping any of the previous fifo settings. Will remove"reg_val &= ~SUN4I_SPDIF_FCTL_FIFOSRC;" as that's not doing anything.

Dropping the masking is also an option.

Yeah...that still doesn't look right. I'll investigate.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

IF you're really going to ignore all the comments we did, please tell us upfront. That way, we will not waste our time doing a review of your patches.

All is a strong word....did you even read my covering letter?....there was a major refactoring of the code and I think I covered a majority of the comments. Apologies if you feel that you'd wasted a lot of time of this....it can't be any more that the EVB dts.

Quoted 7 lines

The point of this is that this is a discussion. You simply ignored most of the comments, without even mentionning why you wanted to ignore them, and simply sent a new version.

If you feel like one comment is invalid, let's discuss this, like you did here. But silently discarding them is not an option and actually quite rude.

I won't be in such a rush to resend the next patch set. I'll clear up everything and if I run into any difficulties then I'll push to my github and ping you on IRC.
Thanks,
CK

Quoted 7 lines

Maxime

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

#17 lore raw

Re: [PATCH v2 4/4] ASOC: sunxi: Add support for the spdif block

Hi,

Quoted 13 lines · Code Kipper
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines

sound/soc/sunxi/sun4i-spdif.c line 192

Quoted 10 lines
sound/soc/sunxi/sun4i-spdif.c new file +10 -0
+static void sun4i_spdif_configure(struct sun4i_spdif_dev *host)
+{
+     u32 reg_val;
+
+     /* soft reset SPDIF */
+     regmap_write(host->regmap, SUN4I_SPDIF_CTL, SUN4I_SPDIF_CTL_RESET);
+
+     /* MCLK OUTPUT enable */
+     regmap_update_bits(host->regmap, SUN4I_SPDIF_CTL,
+                     SUN4I_SPDIF_CTL_MCLKOUTEN, SUN4I_SPDIF_CTL_MCLKOUTEN);

The alignment is still not right....

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I'm not even sure if we need mclk output enabled. Let me see what happens when I remove this.

It's not really the point. The alignment of all your wrapped lines is wrong.

Ahhhh....I was brought up to not mix tabs and spaces and I now see with a quick check that checkpatch doesn't barf...I'll fix this.

checkpatch --strict does

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 6 lines
Quoted 6 lines
sound/soc/sunxi/sun4i-spdif.c new file +6 -0
+static int sun4i_spdif_startup(struct snd_pcm_substream *substream,
+                             struct snd_soc_dai *cpu_dai)
+{
+     struct snd_soc_pcm_runtime *rtd = substream->private_data;
+     struct sun4i_spdif_dev *host = snd_soc_dai_get_drvdata(rtd->cpu_dai);
+
Quoted 8 lines

sound/soc/sunxi/sun4i-spdif.c line 258

Quoted 6 lines
sound/soc/sunxi/sun4i-spdif.c new file +6 -0
+     if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+             return -EINVAL;
+
+     sun4i_spdif_configure(host);
+
+     return clk_prepare_enable(host->clk);

You're still not using pm_runtime...

I've removed the pm stuff and this is the same as you have it in sun4i-codec.

Quoted 8 lines
Quoted 4 lines

You've removed the suspend code, and both Mark and I asked you to use runtime_pm to handle your bus clock.

And this has also been asked for the codec.

You asked if I had tested the pm operations which I hadn't so I removed them after looking at your driver and searching for pm_runtime usage elsewhere in sound/soc. I will add them back.

What we asked you to remove were the suspend / resume hooks. What we want you to add are runtime_pm hooks. These are not the same hooks, and they're not called at the same moment.

The suspend / resume hooks are called before entering suspend and after coming back from it. We don't have no way to suspend at the moment, so there's no way you've been able to test it.

The runtime_pm hooks are called whenever your device start to be used (for example when you start playing back an audio file on your system).

Thanks!
Maxime

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