Skip to contentSkip to conversation

Add HDMI audio support for HiKey

RFC PATCH Superseded John Stultz 4 participants 21 messages Jul 16, 2016 – Jul 20, 2016

Subsystems (5)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Add HDMI audio support for HiKey

This patch set is required for HDMI audio support on HiKey.

This patchset hasn't yet seen the light of lkml, so I suspect there will be a few revisions, but I wanted to send it out for an initial review.

The work is mostly that of Andy Green's, but I've taking a swing at forward porting and cleaning it up where I saw fit. So credit to Andy and blame to me. Apologies in advance, as I'm not super familiar with either DMA or ASoC driver.

The one bit missing to have audio fully working is changes to the adv7511 driver, but most of those changes are still out of tree, so I'll submit those changes once they land.

Feedback would be very much appreicated!

thanks
-john

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>

Andy Green (5):
k3dma: Fix hisi burst clipping
k3dma: Fix dma err offsets
k3dma: Fix "nobody cared" message seen on any error
k3dma: Add cyclic mode for audio
ASoC: hisilicon: Add hi6210 i2s audio driver for hdmi audio

John Stultz (2):
Kconfig: Allow k3dma driver to be selected for more then HISI3xx
platforms
dts: hi6220: Add k3-dma and i2s/hdmi audio support

 arch/arm64/boot/dts/hisilicon/hi6220.dtsi |  36 ++
 drivers/dma/Kconfig                       |   1 -
 drivers/dma/k3dma.c                       | 149 ++++++-
 sound/soc/Kconfig                         |   1 +
 sound/soc/Makefile                        |   1 +
 sound/soc/hisilicon/Kconfig               |   5 +
 sound/soc/hisilicon/Makefile              |   2 +
 sound/soc/hisilicon/hi6210-hdmi-card.c    | 131 ++++++
 sound/soc/hisilicon/hi6210-i2s.c          | 641 ++++++++++++++++++++++++++++++
 sound/soc/hisilicon/hi6210-i2s.h          | 276 +++++++++++++
 10 files changed, 1222 insertions(+), 21 deletions(-)
 create mode 100644 sound/soc/hisilicon/Kconfig
 create mode 100644 sound/soc/hisilicon/Makefile
 create mode 100644 sound/soc/hisilicon/hi6210-hdmi-card.c
 create mode 100644 sound/soc/hisilicon/hi6210-i2s.c
 create mode 100644 sound/soc/hisilicon/hi6210-i2s.h
Signature · 1 line
1.9.1
#3 lore raw

RFC PATCH 2/7 k3dma: Fix dma err offsets

From: Andy Green <[email protected]>

The offsets for ERR1 and ERR2 are wrong actually.
That's why you can never clear an error.

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>
[jstultz: Forward ported to mainline]
---
 drivers/dma/k3dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/k3dma.c +2 -2
index d01a11d..8dd050c 100644
@@ -34,8 +34,8 @@
 #define INT_ERR1_MASK		0x20
 #define INT_ERR2_MASK		0x24
 #define INT_TC1_RAW		0x600
-#define INT_ERR1_RAW		0x608
-#define INT_ERR2_RAW		0x610
+#define INT_ERR1_RAW		0x610
+#define INT_ERR2_RAW		0x618
 #define CH_PRI			0x688
 #define CH_STAT			0x690
 #define CX_CUR_CNT		0x704
Signature · 1 line
1.9.1
#5 lore raw

RFC PATCH 3/7 k3dma: Fix "nobody cared" message seen on any error

In reply to John Stultz

From: Andy Green <[email protected]>

As it was before, as soon as the DMAC IP felt there was an error he would return IRQ_NONE since no actual transfer had completed.

After spinning on that for 100K interrupts, Linux yanks the IRQ with a "nobody cared" error.

This patch lets it handle the interrupt and keep the IRQ alive.

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>
[jstultz: Forward ported to mainline]
---
 drivers/dma/k3dma.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/dma/k3dma.c +5 -3
index 8dd050c..c2906a82 100644
@@ -220,11 +220,13 @@ static irqreturn_t k3_dma_int_handler(int irq, void *dev_id)
 	writel_relaxed(err1, d->base + INT_ERR1_RAW);
 	writel_relaxed(err2, d->base + INT_ERR2_RAW);
 
-	if (irq_chan) {
+	if (irq_chan)
 		tasklet_schedule(&d->task);
+
+	if (irq_chan || err1 || err2)
 		return IRQ_HANDLED;
-	} else
-		return IRQ_NONE;
+
+	return IRQ_NONE;
 }
 
 static int k3_dma_start_txd(struct k3_dma_chan *c)
Signature · 1 line
1.9.1
#15 lore raw

PATCH 7/7 dts: hi6220: Add k3-dma and i2s/hdmi audio support

In reply to John Stultz

Add entry for k3-dma driver and i2s/hdmi audio devices.

This enables HDMI audio output.

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>
---
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 36 +++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
arch/arm64/boot/dts/hisilicon/hi6220.dtsi +36 -0
index 189d215..ba34962 100644
@@ -228,6 +228,8 @@
 		compatible = "simple-bus";
 		#address-cells = <2>;
 		#size-cells = <2>;
+		#sound-dai-cells = <0>;
+		interrupt-parent = <&gic>;
 		ranges;
 
 		sram: sram@fff80000 {
@@ -325,6 +327,19 @@
 			status = "disabled";
 		};
 
+		dma0: dma@f7370000 {
+			compatible = "hisilicon,k3-dma-1.0";
+			reg = <0x0 0xf7370000 0x0 0x1000>;
+			#dma-cells = <1>;
+			dma-channels = <15>;
+			dma-requests = <32>;
+			interrupts = <0 84 4>;
+			clocks = <&sys_ctrl HI6220_EDMAC_ACLK>;
+			dma-no-cci;
+			dma-type = "hi6220_dma";
+			status = "ok";
+		};
+
 		dual_timer0: timer@f8008000 {
 			compatible = "arm,sp804", "arm,primecell";
 			reg = <0x0 0xf8008000 0x0 0x1000>;
@@ -800,6 +815,27 @@
 			#thermal-sensor-cells = <1>;
 		};
 
+		i2s0: hi6210_i2s {
+			compatible = "hisilicon,hi6210-i2s";
+			reg = <0x0 0xf7118000 0x0 0x8000>, /* i2s unit */
+			      <0x0 0xf7030000 0x0 0x400>,  /* syscon */
+			      <0x0 0xf7032000 0x0 0x400>;  /* pmctrl */
+			interrupts = <0 123 0x4>; /* 155 "DigACodec_intr"-32 */
+			pinctrl-names = "default";
+			pinctrl-0 = <&bt_pmx_func &bt_cfg_func>;
+			clocks = <&sys_ctrl HI6220_DACODEC_PCLK>,
+				 <&sys_ctrl HI6220_BBPPLL0_DIV>;
+			clock-names = "dacodec", "i2s-base";
+			dmas = <&dma0 15 &dma0 14>;
+			dma-names = "rx", "tx";
+		};
+
+		hi6210_hdmi_card: hi6210_hdmi_card {
+			compatible = "hisilicon,hi6210-hdmi-audio-card";
+			reg = <0 0 0 0>;
+			sound-dai = <&i2s0>;
+		};
+
 		thermal-zones {
 
 			cls0: cls0 {
Signature · 1 line
1.9.1
#11 lore raw

RFC PATCH 6/7 ASoC: hisilicon: Add hi6210 i2s audio driver for hdmi audio

In reply to John Stultz

From: Andy Green <[email protected]>

Add driver for hi6210 i2s controller found on hi6220 boards.

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>
[jstultz: Forward ported to mainline, limit rates to 48k]
---
 sound/soc/Kconfig                      |   1 +
 sound/soc/Makefile                     |   1 +
 sound/soc/hisilicon/Kconfig            |   5 +
 sound/soc/hisilicon/Makefile           |   2 +
 sound/soc/hisilicon/hi6210-hdmi-card.c | 131 +++++++
 sound/soc/hisilicon/hi6210-i2s.c       | 641 +++++++++++++++++++++++++++++++++
 sound/soc/hisilicon/hi6210-i2s.h       | 276 ++++++++++++++
 7 files changed, 1057 insertions(+)
 create mode 100644 sound/soc/hisilicon/Kconfig
 create mode 100644 sound/soc/hisilicon/Makefile
 create mode 100644 sound/soc/hisilicon/hi6210-hdmi-card.c
 create mode 100644 sound/soc/hisilicon/hi6210-i2s.c
 create mode 100644 sound/soc/hisilicon/hi6210-i2s.h
sound/soc/Kconfig +1 -0
index 182d92e..9df9658 100644
@@ -47,6 +47,7 @@ source "sound/soc/cirrus/Kconfig"
 source "sound/soc/davinci/Kconfig"
 source "sound/soc/dwc/Kconfig"
 source "sound/soc/fsl/Kconfig"
+source "sound/soc/hisilicon/Kconfig"
 source "sound/soc/jz4740/Kconfig"
 source "sound/soc/nuc900/Kconfig"
 source "sound/soc/omap/Kconfig"
sound/soc/Makefile +1 -0
index 9a30f21..2f6aabb 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_SND_SOC)	+= cirrus/
 obj-$(CONFIG_SND_SOC)	+= davinci/
 obj-$(CONFIG_SND_SOC)	+= dwc/
 obj-$(CONFIG_SND_SOC)	+= fsl/
+obj-$(CONFIG_SND_SOC)	+= hisilicon/
 obj-$(CONFIG_SND_SOC)	+= jz4740/
 obj-$(CONFIG_SND_SOC)	+= img/
 obj-$(CONFIG_SND_SOC)	+= intel/
sound/soc/hisilicon/Kconfig new file +5 -0
new file mode 100644
index 0000000..4356d5a
@@ -0,0 +1,5 @@
+config SND_I2S_HI6210_I2S
+	tristate "Hisilicon I2S controller"
+	select SND_SOC_GENERIC_DMAENGINE_PCM
+	help
+	  Hisilicon I2S
sound/soc/hisilicon/Makefile new file +2 -0
new file mode 100644
index 0000000..43a5504
@@ -0,0 +1,2 @@
+obj-$(CONFIG_SND_I2S_HI6210_I2S) += hi6210-i2s.o \
+				    hi6210-hdmi-card.o
\ No newline at end of file
sound/soc/hisilicon/hi6210-hdmi-card.c new file +131 -0

131 lines not on this page · raw message

sound/soc/hisilicon/hi6210-i2s.c new file +641 -0

641 lines not on this page · raw message

sound/soc/hisilicon/hi6210-i2s.h new file +276 -0

276 lines not on this page · raw message

Signature · 1 line
1.9.1
#9 lore raw

RFC PATCH 5/7 Kconfig: Allow k3dma driver to be selected for more then HISI3xx platforms

In reply to John Stultz

This allows the k3dma driver to be selected on HiKey

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>
---
 drivers/dma/Kconfig | 1 -
 1 file changed, 1 deletion(-)
drivers/dma/Kconfig +0 -1
index 8c98779..c5a230d 100644
@@ -279,7 +279,6 @@ config INTEL_MIC_X100_DMA
 
 config K3_DMA
 	tristate "Hisilicon K3 DMA support"
-	depends on ARCH_HI3xxx
 	select DMA_ENGINE
 	select DMA_VIRTUAL_CHANNELS
 	help
Signature · 1 line
1.9.1
#7 lore raw

RFC PATCH 4/7 k3dma: Add cyclic mode for audio

In reply to John Stultz

From: Andy Green <[email protected]>

Currently the k3dma driver doesn't offer the cyclic mode necessary for handling audio.

This patch adds it.

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>

[jstultz: Forward ported to mainline, removed a few
bits of logic that didn't seem to have much effect]

---
 drivers/dma/k3dma.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 121 insertions(+), 14 deletions(-)
drivers/dma/k3dma.c +121 -14
index c2906a82..eff7483 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Linaro Ltd.
+ * Copyright (c) 2013 - 2015 Linaro Ltd.
  * Copyright (c) 2013 Hisilicon Limited.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -25,22 +25,27 @@
 
 #define DRIVER_NAME		"k3-dma"
 #define DMA_MAX_SIZE		0x1ffc
+#define DMA_CYCLIC_MAX_PERIOD	0x1000
 
 #define INT_STAT		0x00
 #define INT_TC1			0x04
+#define INT_TC2			0x08
 #define INT_ERR1		0x0c
 #define INT_ERR2		0x10
 #define INT_TC1_MASK		0x18
+#define INT_TC2_MASK		0x1c
 #define INT_ERR1_MASK		0x20
 #define INT_ERR2_MASK		0x24
 #define INT_TC1_RAW		0x600
+#define INT_TC2_RAW		0x608
 #define INT_ERR1_RAW		0x610
 #define INT_ERR2_RAW		0x618
 #define CH_PRI			0x688
 #define CH_STAT			0x690
 #define CX_CUR_CNT		0x704
 #define CX_LLI			0x800
-#define CX_CNT			0x810
+#define CX_CNT1			0x80c
+#define CX_CNT0			0x810
 #define CX_SRC			0x814
 #define CX_DST			0x818
 #define CX_CFG			0x81c
@@ -49,6 +54,7 @@
 
 #define CX_LLI_CHAIN_EN		0x2
 #define CX_CFG_EN		0x1
+#define CX_CFG_NODEIRQ		BIT(1)
 #define CX_CFG_MEM2PER		(0x1 << 2)
 #define CX_CFG_PER2MEM		(0x2 << 2)
 #define CX_CFG_SRCINCR		(0x1 << 31)
@@ -81,6 +87,7 @@ struct k3_dma_chan {
 	enum dma_transfer_direction dir;
 	dma_addr_t		dev_addr;
 	enum dma_status		status;
+	bool			cyclic;
 };
 
 struct k3_dma_phy {
@@ -134,6 +141,7 @@ static void k3_dma_terminate_chan(struct k3_dma_phy *phy, struct k3_dma_dev *d)
 
 	val = 0x1 << phy->idx;
 	writel_relaxed(val, d->base + INT_TC1_RAW);
+	writel_relaxed(val, d->base + INT_TC2_RAW);
 	writel_relaxed(val, d->base + INT_ERR1_RAW);
 	writel_relaxed(val, d->base + INT_ERR2_RAW);
 }
@@ -141,11 +149,15 @@ static void k3_dma_terminate_chan(struct k3_dma_phy *phy, struct k3_dma_dev *d)
 static void k3_dma_set_desc(struct k3_dma_phy *phy, struct k3_desc_hw *hw)
 {
 	writel_relaxed(hw->lli, phy->base + CX_LLI);
-	writel_relaxed(hw->count, phy->base + CX_CNT);
+	writel_relaxed(hw->count, phy->base + CX_CNT0);
 	writel_relaxed(hw->saddr, phy->base + CX_SRC);
 	writel_relaxed(hw->daddr, phy->base + CX_DST);
 	writel_relaxed(AXI_CFG_DEFAULT, phy->base + AXI_CFG);
 	writel_relaxed(hw->config, phy->base + CX_CFG);
+	pr_debug("%s: desc %p: ch idx = %d, lli: 0x%x, count: 0x%x,"
+		" saddr: 0x%x, daddr 0x%x, cfg: 0x%x\n", __func__,
+		(void *) hw, phy->idx, hw->lli,	hw->count, hw->saddr,
+		hw->daddr, hw->config);
 }
 
 static u32 k3_dma_get_curr_cnt(struct k3_dma_dev *d, struct k3_dma_phy *phy)
@@ -175,11 +187,13 @@ static void k3_dma_enable_dma(struct k3_dma_dev *d, bool on)
 
 		/* unmask irq */
 		writel_relaxed(0xffff, d->base + INT_TC1_MASK);
+		writel_relaxed(0xffff, d->base + INT_TC2_MASK);
 		writel_relaxed(0xffff, d->base + INT_ERR1_MASK);
 		writel_relaxed(0xffff, d->base + INT_ERR2_MASK);
 	} else {
 		/* mask irq */
 		writel_relaxed(0x0, d->base + INT_TC1_MASK);
+		writel_relaxed(0x0, d->base + INT_TC2_MASK);
 		writel_relaxed(0x0, d->base + INT_ERR1_MASK);
 		writel_relaxed(0x0, d->base + INT_ERR2_MASK);
 	}
@@ -192,24 +206,31 @@ static irqreturn_t k3_dma_int_handler(int irq, void *dev_id)
 	struct k3_dma_chan *c;
 	u32 stat = readl_relaxed(d->base + INT_STAT);
 	u32 tc1  = readl_relaxed(d->base + INT_TC1);
+	u32 tc2  = readl_relaxed(d->base + INT_TC2);
 	u32 err1 = readl_relaxed(d->base + INT_ERR1);
 	u32 err2 = readl_relaxed(d->base + INT_ERR2);
 	u32 i, irq_chan = 0;
 
 	while (stat) {
 		i = __ffs(stat);
-		stat &= (stat - 1);
-		if (likely(tc1 & BIT(i))) {
+		stat &= ~BIT(i);
+		if (likely(tc1 & BIT(i)) || (tc2 & BIT(i))) {
+			unsigned long flags;
+
 			p = &d->phy[i];
 			c = p->vchan;
-			if (c) {
-				unsigned long flags;
-
+			if (c && (tc1 & BIT(i))) {
 				spin_lock_irqsave(&c->vc.lock, flags);
 				vchan_cookie_complete(&p->ds_run->vd);
 				p->ds_done = p->ds_run;
 				spin_unlock_irqrestore(&c->vc.lock, flags);
 			}
+			if (c && (tc2 & BIT(i))) {
+				spin_lock_irqsave(&c->vc.lock, flags);
+				if (p->ds_run != NULL)
+					vchan_cyclic_callback(&p->ds_run->vd);
+				spin_unlock_irqrestore(&c->vc.lock, flags);
+			}
 			irq_chan |= BIT(i);
 		}
 		if (unlikely((err1 & BIT(i)) || (err2 & BIT(i))))
@@ -217,6 +238,7 @@ static irqreturn_t k3_dma_int_handler(int irq, void *dev_id)
 	}
 
 	writel_relaxed(irq_chan, d->base + INT_TC1_RAW);
+	writel_relaxed(irq_chan, d->base + INT_TC2_RAW);
 	writel_relaxed(err1, d->base + INT_ERR1_RAW);
 	writel_relaxed(err2, d->base + INT_ERR2_RAW);
 
@@ -352,7 +374,7 @@ static enum dma_status k3_dma_tx_status(struct dma_chan *chan,
 	 * its total size.
 	 */
 	vd = vchan_find_desc(&c->vc, cookie);
-	if (vd) {
+	if (vd && !c->cyclic) {
 		bytes = container_of(vd, struct k3_dma_desc_sw, vd)->size;
 	} else if ((!p) || (!p->ds_run)) {
 		bytes = 0;
@@ -362,7 +384,8 @@ static enum dma_status k3_dma_tx_status(struct dma_chan *chan,
 
 		bytes = k3_dma_get_curr_cnt(d, p);
 		clli = k3_dma_get_curr_lli(p);
-		index = (clli - ds->desc_hw_lli) / sizeof(struct k3_desc_hw);
+		index = ((clli - ds->desc_hw_lli) /
+				sizeof(struct k3_desc_hw)) + 1;
 		for (; index < ds->desc_num; index++) {
 			bytes += ds->desc_hw[index].count;
 			/* end of lli */
@@ -403,14 +426,22 @@ static void k3_dma_issue_pending(struct dma_chan *chan)
 static void k3_dma_fill_desc(struct k3_dma_desc_sw *ds, dma_addr_t dst,
 			dma_addr_t src, size_t len, u32 num, u32 ccfg)
 {
-	if ((num + 1) < ds->desc_num)
+	if (num != ds->desc_num - 1)
 		ds->desc_hw[num].lli = ds->desc_hw_lli + (num + 1) *
 			sizeof(struct k3_desc_hw);
+
 	ds->desc_hw[num].lli |= CX_LLI_CHAIN_EN;
 	ds->desc_hw[num].count = len;
 	ds->desc_hw[num].saddr = src;
 	ds->desc_hw[num].daddr = dst;
 	ds->desc_hw[num].config = ccfg;
+
+	pr_debug("%s: k3_dma_desc_sw = %p, desc_hw = %p (num = %d) lli: 0x%x,"
+		" count: 0x%x, saddr: 0x%x, daddr 0x%x, cfg: 0x%x\n", __func__,
+		(void *)ds, &ds->desc_hw[num], num,
+		ds->desc_hw[num].lli, ds->desc_hw[num].count,
+		ds->desc_hw[num].saddr, ds->desc_hw[num].daddr,
+		ds->desc_hw[num].config);
 }
 
 static struct dma_async_tx_descriptor *k3_dma_prep_memcpy(
@@ -431,6 +462,7 @@ static struct dma_async_tx_descriptor *k3_dma_prep_memcpy(
 		dev_dbg(chan->device->dev, "vchan %p: kzalloc fail\n", &c->vc);
 		return NULL;
 	}
+	c->cyclic = 0;
 	ds->desc_hw_lli = __virt_to_phys((unsigned long)&ds->desc_hw[0]);
 	ds->size = len;
 	ds->desc_num = num;
@@ -476,17 +508,19 @@ static struct dma_async_tx_descriptor *k3_dma_prep_slave_sg(
 	if (sgl == NULL)
 		return NULL;
 
+	c->cyclic = 0;
+
 	for_each_sg(sgl, sg, sglen, i) {
 		avail = sg_dma_len(sg);
+		pr_err("   avail=0x%x\n", (int)avail);
 		if (avail > DMA_MAX_SIZE)
 			num += DIV_ROUND_UP(avail, DMA_MAX_SIZE) - 1;
 	}
 
 	ds = kzalloc(sizeof(*ds) + num * sizeof(ds->desc_hw[0]), GFP_ATOMIC);
-	if (!ds) {
-		dev_dbg(chan->device->dev, "vchan %p: kzalloc fail\n", &c->vc);
+	if (!ds)
 		return NULL;
-	}
+
 	ds->desc_hw_lli = __virt_to_phys((unsigned long)&ds->desc_hw[0]);
 	ds->desc_num = num;
 	num = 0;
@@ -519,6 +553,77 @@ static struct dma_async_tx_descriptor *k3_dma_prep_slave_sg(
 	return vchan_tx_prep(&c->vc, &ds->vd, flags);
 }
 
+static struct dma_async_tx_descriptor *
+k3_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr,
+		       size_t buf_len, size_t period_len,
+		       enum dma_transfer_direction dir,
+		       unsigned long flags)
+{
+	struct k3_dma_chan *c = to_k3_chan(chan);
+	struct k3_dma_desc_sw *ds;
+	size_t len, avail, total = 0;
+	dma_addr_t addr, src = 0, dst = 0;
+	int num = 1, since = 0;
+	size_t modulo = DMA_CYCLIC_MAX_PERIOD;
+	u32 en_tc2 = 0;
+
+	pr_debug("%s: buf %p, dst %p, buf len %d, period_len = %d, dir %d\n",
+	       __func__, (void *)buf_addr, (void *)to_k3_chan(chan)->dev_addr,
+	       (int)buf_len, (int)period_len, (int)dir);
+
+	avail = buf_len;
+	if (avail > modulo)
+		num += DIV_ROUND_UP(avail, modulo) - 1;
+
+	ds = kzalloc(sizeof(*ds) + num * sizeof(ds->desc_hw[0]), GFP_ATOMIC);
+	if (!ds)
+		return NULL;
+
+	ds->desc_hw_lli = __virt_to_phys((unsigned long)&ds->desc_hw[0]);
+	ds->desc_num = num;
+
+	c->cyclic = 1;
+	addr = buf_addr;
+	avail = buf_len;
+	total = avail;
+	num = 0;
+
+	if (period_len < modulo)
+		modulo = period_len;
+
+	do {
+		len = min_t(size_t, avail, modulo);
+
+		if (dir == DMA_MEM_TO_DEV) {
+			src = addr;
+			dst = c->dev_addr;
+		} else if (dir == DMA_DEV_TO_MEM) {
+			src = c->dev_addr;
+			dst = addr;
+		}
+		since += len;
+		if (since >= period_len) {
+			/* descriptor asks for TC2 interrupt on completion */
+			en_tc2 = CX_CFG_NODEIRQ;
+			since -= period_len;
+		} else
+			en_tc2 = 0;
+
+		k3_dma_fill_desc(ds, dst, src, len, num++, c->ccfg | en_tc2);
+
+		addr += len;
+		avail -= len;
+	} while (avail);
+
+	/* "Cyclic" == end of link points back to start of link */
+	ds->desc_hw[num - 1].lli |= ds->desc_hw_lli;
+
+	ds->size = total;
+
+	return vchan_tx_prep(&c->vc, &ds->vd, flags);
+}
+
+
 static int k3_dma_config(struct dma_chan *chan,
 			 struct dma_slave_config *cfg)
 {
@@ -723,11 +828,13 @@ static int k3_dma_probe(struct platform_device *op)
 	INIT_LIST_HEAD(&d->slave.channels);
 	dma_cap_set(DMA_SLAVE, d->slave.cap_mask);
 	dma_cap_set(DMA_MEMCPY, d->slave.cap_mask);
+	dma_cap_set(DMA_CYCLIC, d->slave.cap_mask);
 	d->slave.dev = &op->dev;
 	d->slave.device_free_chan_resources = k3_dma_free_chan_resources;
 	d->slave.device_tx_status = k3_dma_tx_status;
 	d->slave.device_prep_dma_memcpy = k3_dma_prep_memcpy;
 	d->slave.device_prep_slave_sg = k3_dma_prep_slave_sg;
+	d->slave.device_prep_dma_cyclic = k3_dma_prep_dma_cyclic;
 	d->slave.device_issue_pending = k3_dma_issue_pending;
 	d->slave.device_config = k3_dma_config;
 	d->slave.device_pause = k3_dma_transfer_pause;
Signature · 1 line
1.9.1
#1 lore raw

RFC PATCH 1/7 k3dma: Fix hisi burst clipping

In reply to John Stultz

From: Andy Green <[email protected]>

Max burst len is a 4-bit field, but at the moment it's clipped with a 5-bit constant... reduce it to that which can be expressed

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>
[jstultz: Forward ported to mainline]
---
 drivers/dma/k3dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/k3dma.c +1 -1
index 1ba2fd7..d01a11d 100644
@@ -552,7 +552,7 @@ static int k3_dma_config(struct dma_chan *chan,
 	c->ccfg |= (val << 12) | (val << 16);
 
 	if ((maxburst == 0) || (maxburst > 16))
-		val = 16;
+		val = 15;
 	else
 		val = maxburst - 1;
 	c->ccfg |= (val << 20) | (val << 24);
Signature · 1 line
1.9.1
#18 lore raw
In reply to John Stultz
Quoted 11 lines · John Stultz

This patch set is required for HDMI audio support on HiKey.

This patchset hasn't yet seen the light of lkml, so I suspect there will be a few revisions, but I wanted to send it out for an initial review.

The work is mostly that of Andy Green's, but I've taking a swing at forward porting and cleaning it up where I saw fit. So credit to Andy and blame to me. Apologies in advance, as I'm not super familiar with either DMA or ASoC driver.

Quoted 5 lines

The one bit missing to have audio fully working is changes to the adv7511 driver, but most of those changes are still out of tree, so I'll submit those changes once they land.

Feedback would be very much appreicated!

Thanks John, it's good to know that work didn't go to waste.

The linaro.org email in the patches is dead, since I resigned from Linaro a few months ago.  If the goal of adding it to the kernel is to make it possible to contact the author, it should change to <[email protected]>.
There are (were) a couple of limitations with it that should be commented somewhere:

 1) The cyclic DMA, at least going into the I2S FIFO, had what appeared to be hw bugs when I left it, I had asked hisilicon about it but got no useful reply.  The DMA worked well generally, but there were audible clicks and pops at intervals even though the DMA really is cyclic.  I dunno whether they got around to looking at it or not: if not, there should probably be a comment in the driver about it.  There were notes in the I2S FIFO docs (it seemed the likely culprit) about needing to take care about FIFO trigger levels but didn't seem to change anything.

 2) The driver only exposes 48kHz / 2ch.

Otherwise it worked well.

Thanks again for upstreaming it.

-Andy

Quoted 49 lines

thanks
-john

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>

Andy Green (5):
  k3dma: Fix hisi burst clipping
  k3dma: Fix dma err offsets
  k3dma: Fix "nobody cared" message seen on any error
  k3dma: Add cyclic mode for audio
  ASoC: hisilicon:  Add hi6210 i2s audio driver for hdmi audio

John Stultz (2):
  Kconfig: Allow k3dma driver to be selected for more then HISI3xx platforms
  dts: hi6220: Add k3-dma and i2s/hdmi audio support

 arch/arm64/boot/dts/hisilicon/hi6220.dtsi |  36 ++ drivers/dma/Kconfig                       |   1 - drivers/dma/k3dma.c                       | 149 ++++++- sound/soc/Kconfig                         |   1 + sound/soc/Makefile                        |   1 + sound/soc/hisilicon/Kconfig               |   5 + sound/soc/hisilicon/Makefile              |   2 + sound/soc/hisilicon/hi6210-hdmi-card.c    | 131 ++++++ sound/soc/hisilicon/hi6210-i2s.c          | 641
++++++++++++++++++++++++++++++
 sound/soc/hisilicon/hi6210-i2s.h          | 276 +++++++++++++

 10 files changed, 1222 insertions(+), 21 deletions(-)

 create mode 100644 sound/soc/hisilicon/Kconfig create mode 100644 sound/soc/hisilicon/Makefile create mode 100644 sound/soc/hisilicon/hi6210-hdmi-card.c create mode 100644 sound/soc/hisilicon/hi6210-i2s.c create mode 100644 sound/soc/hisilicon/hi6210-i2s.h

#19 lore raw
Quoted 16 lines · Andy Green
Quoted 15 lines · John Stultz

This patch set is required for HDMI audio support on HiKey.

This patchset hasn't yet seen the light of lkml, so I suspect there will be a few revisions, but I wanted to send it out for an initial review.

The work is mostly that of Andy Green's, but I've taking a swing at forward porting and cleaning it up where I saw fit. So credit to Andy and blame to me. Apologies in advance, as I'm not super familiar with either DMA or ASoC driver.

The one bit missing to have audio fully working is changes to the adv7511 driver, but most of those changes are still out of tree, so I'll submit those changes once they land.

Quoted 8 lines
Quoted 1 line

Feedback would be very much appreicated!

Thanks John, it's good to know that work didn't go to waste.

The linaro.org email in the patches is dead, since I resigned from Linaro a few months ago. If the goal of adding it to the kernel is to make it possible to contact the author, it should change to <[email protected]>.

Yea. I'm not sure what the communities policy on Author/SoB lines in the face of email address changes.
For the moment I'll leave the credit lines as is (since that's how I got them, and changing SoB's is usually a big no no). But if others have advice on how to best handle this I'd appreciate it. I'll be sure to leave your new email in the Cc: entries.
(Though I need to figure out how to get git send-email to not cc the author line to avoid the reply-all noise)

Quoted 11 lines

There are (were) a couple of limitations with it that should be commented somewhere:

1) The cyclic DMA, at least going into the I2S FIFO, had what appeared
to be hw bugs when I left it, I had asked hisilicon about it but got no useful reply. The DMA worked well generally, but there were audible clicks and pops at intervals even though the DMA really is cyclic. I dunno whether they got around to looking at it or not: if not, there should probably be a comment in the driver about it. There were notes in the I2S FIFO docs (it seemed the likely culprit) about needing to take care about FIFO trigger levels but didn't seem to change anything.

So against the 4.4 and later kernels, I've no longer had trouble with the pops and noise. There is an outstanding issue of a occasional DMA error from the hardware on the first transfer after opening the audio device, but some of the HiSi folks are looking into that.

Quoted 1 line

2) The driver only exposes 48kHz / 2ch.

Yea. I've limited the i2s/hdmi-card driver to only 48k to match.

thanks
-john

maintainer
#20 lore raw
Quoted 2 lines · John Stultz

Yea. I'm not sure what the communities policy on Author/SoB lines in the face of email address changes.

Given that the signoff is all about DCO and hence licensing it should probably stay with Linaro.

maintainer
#10 lore raw

Re: [RFC][PATCH 5/7] Kconfig: Allow k3dma driver to be selected for more then HISI3xx platforms

In reply to John Stultz

drivers/dma/Kconfig config INTEL_MIC_X100_DMA · line 284

Quoted 8 lines · John Stultz

This allows the k3dma driver to be selected on HiKey

config K3_DMA

drivers/dma/Kconfig +0 -1
 	tristate "Hisilicon K3 DMA support"
-	depends on ARCH_HI3xxx
 	select DMA_ENGINE
 	select DMA_VIRTUAL_CHANNELS
 	help

And *every* other platform ever. You probably want

	ARCH_HI3xxx || ARCH_HISI || COMPILE_TEST

here.

maintainer
#12 lore raw

Re: [RFC][PATCH 6/7] ASoC: hisilicon: Add hi6210 i2s audio driver for hdmi audio

In reply to John Stultz
Quoted 8 lines · John Stultz
 sound/soc/Kconfig                      |   1 +
 sound/soc/Makefile                     |   1 +
 sound/soc/hisilicon/Kconfig            |   5 +
 sound/soc/hisilicon/Makefile           |   2 +
 sound/soc/hisilicon/hi6210-hdmi-card.c | 131 +++++++
 sound/soc/hisilicon/hi6210-i2s.c       | 641 +++++++++++++++++++++++++++++++++
 sound/soc/hisilicon/hi6210-i2s.h       | 276 ++++++++++++++
 7 files changed, 1057 insertions(+)

This is adding several different drivers so should be at least one patch per driver. Combining many different drivers into one patch makes it more difficult to review as the patch gets larger and more fatiguing and causes review problems in one driver to block others. Look at how existing drivers are added to the same subsystem.

Quoted 6 lines
sound/soc/hisilicon/hi6210-hdmi-card.c new file +6 -0
+static int hdmi_hw_params(struct snd_pcm_substream *substream,
+			  struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+	int ret;

sound/soc/hisilicon/hi6210-hdmi-card.c line 30

Quoted 10 lines
sound/soc/hisilicon/hi6210-hdmi-card.c new file +10 -0
+
+	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+			SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+	if (ret)
+		return ret;
+
+	/* set i2s system clock */
+	ret = snd_soc_dai_set_sysclk(cpu_dai, 0, 24576000, SND_SOC_CLOCK_IN);
+	if (ret)
+		return ret;

Neither of these depends at all on the parameters so they should be being set on init, not at hw_params time. In the case of the DAI format this should be done with dai_fmt in the dai_link.

sound/soc/hisilicon/hi6210-hdmi-card.c line 44

Quoted 1 line
sound/soc/hisilicon/hi6210-hdmi-card.c new file +1 -0
+	.cpu_dai_name = "f7118000.hi6210_i2s",

Why is this not connected up in DT - as things stand the card has zero reuse potential. Though given that this has

sound/soc/hisilicon/hi6210-hdmi-card.c line 45

Quoted 1 line
sound/soc/hisilicon/hi6210-hdmi-card.c new file +1 -0
+	.codec_name = "0.hi6210_hdmi_card",

If you've got a CODEC with hdmi_card in the name that suggests there's a serious abstraction problem going on somewhere.

sound/soc/hisilicon/hi6210-i2s.c line 90

Quoted 6 lines
sound/soc/hisilicon/hi6210-i2s.c new file +6 -0
+static void hi6210_bits(struct hi6210_i2s *i2s, u32 ofs, u32 reset, u32 set)
+{
+	u32 val = readl(i2s->base + ofs) & ~reset;
+
+	writel(val | set, i2s->base + ofs);
+}

This isn't the usual pattern for read/modify/write operations in the kernel and doesn't seem like it's going to be great for legibility - the reader has to remember which order clear and set are and the name doesn't give many clues.

sound/soc/hisilicon/hi6210-i2s.c line 134

Quoted 5 lines
sound/soc/hisilicon/hi6210-i2s.c new file +5 -0
+	hi6210_bits(i2s, HII2S_DIG_FILTER_MODULE_CFG,
+		    HII2S_DIG_FILTER_MODULE_CFG__DACR_MIXER_IN2_MUTE |
+		    HII2S_DIG_FILTER_MODULE_CFG__DACL_MIXER_IN2_MUTE,
+		    0
+	);

Coding style, the final ); is just weird. These register names make this look like there's some routing control going on here which should be being exposed to users.

sound/soc/hisilicon/hi6210-i2s.c line 199

Quoted 5 lines
sound/soc/hisilicon/hi6210-i2s.c new file +5 -0
+	for (n = 0; n < i2s->clocks; n++) {
+		ret = clk_prepare_enable(i2s->clk[n]);
+		if (ret)
+			return ret;
+	}

This won't unwind things on error.

sound/soc/hisilicon/hi6210-i2s.c line 206

Quoted 6 lines
sound/soc/hisilicon/hi6210-i2s.c new file +6 -0
+	ret = clk_set_rate(i2s->clk[1], 49152000);
+	if (ret) {
+		dev_err(i2s->dev, "%s: setting 49.152MHz base rate failed %d\n",
+			__func__, ret);
+		return ret;
+	}

Magic array index there isn't great.

sound/soc/hisilicon/hi6210-i2s.c line 270

Quoted 12 lines
sound/soc/hisilicon/hi6210-i2s.c new file +12 -0
+static void hi6210_i2s_txctrl(struct snd_soc_dai *cpu_dai, int on)
+{
+	struct hi6210_i2s *i2s = dev_get_drvdata(cpu_dai->dev);
+
+	spin_lock(&i2s->lock);
+
+	if (on) {
+		/* enable S2 TX */
+		hi6210_bits(i2s, HII2S_I2S_CFG, 0, HII2S_I2S_CFG__S2_IF_TX_EN);
+	} else
+		/* disable S2 TX */
+		hi6210_bits(i2s, HII2S_I2S_CFG, HII2S_I2S_CFG__S2_IF_TX_EN, 0);

Coding style, { } on both side or neither :(

sound/soc/hisilicon/hi6210-i2s.c line 292

Quoted 5 lines
sound/soc/hisilicon/hi6210-i2s.c new file +5 -0
+static int hi6210_i2s_set_sysclk(struct snd_soc_dai *cpu_dai,
+			     int clk_id, unsigned int freq, int dir)
+{
+	return 0;
+}

Remove empty operations, if the operation can reasonably be ignored the frameworks will handle that well.

sound/soc/hisilicon/hi6210-i2s.c line 300

Quoted 7 lines
sound/soc/hisilicon/hi6210-i2s.c new file +7 -0
+static int hi6210_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
+{
+	struct hi6210_i2s *i2s = dev_get_drvdata(cpu_dai->dev);
+
+	i2s->format = fmt;
+	i2s->master = (i2s->format & SND_SOC_DAIFMT_MASTER_MASK) ==
+		      SND_SOC_DAIFMT_CBS_CFS;

We're validating this elsewhere rather than when the user sets it.

Quoted 10 lines
sound/soc/hisilicon/hi6210-i2s.c new file +10 -0
+	switch (i2s->rate) {
+	case 8000:
+		u = HII2S_FS_RATE_8KHZ;
+		break;
+	case 16000:
+		u = HII2S_FS_RATE_16KHZ;
+		break;
+	case 32000:
+		u = HII2S_FS_RATE_32KHZ;
+		break;

sound/soc/hisilicon/hi6210-i2s.c line 387

Quoted 10 lines
sound/soc/hisilicon/hi6210-i2s.c new file +10 -0
+	case 48000:
+		u = HII2S_FS_RATE_48KHZ;
+		break;
+	case 96000:
+		u = HII2S_FS_RATE_96KHZ;
+		break;
+	case 192000:
+		u = HII2S_FS_RATE_192KHZ;
+		break;
+	};

Should have validation on the default case. I'm not super convinced that u is a helpful variable name for the temporaries in this driver, it's not a convention I've ever seen before so I had to go and check what was going on.

sound/soc/hisilicon/hi6210-i2s.c line 489

Quoted 5 lines
sound/soc/hisilicon/hi6210-i2s.c new file +5 -0
+};
+
+#include <sound/dmaengine_pcm.h>
+
+static const struct snd_pcm_hardware snd_hi6210_hardware = {

Why are we including files in the middle of the driver?

sound/soc/hisilicon/hi6210-i2s.c line 501

Quoted 12 lines
sound/soc/hisilicon/hi6210-i2s.c new file +12 -0
+	.info                   = SNDRV_PCM_INFO_MMAP |
+				  SNDRV_PCM_INFO_MMAP_VALID |
+				  SNDRV_PCM_INFO_PAUSE |
+				  SNDRV_PCM_INFO_RESUME |
+				  SNDRV_PCM_INFO_INTERLEAVED |
+				  SNDRV_PCM_INFO_HALF_DUPLEX,
+	.period_bytes_min       = 4096,
+	.period_bytes_max       = 4096,
+	.periods_min            = 4,
+	.periods_max            = UINT_MAX,
+	.buffer_bytes_max       = SIZE_MAX,
+};

Why are we open coding dmaengine configuration here? The core code should be able to discover this by querying the dmaengine driver.

sound/soc/hisilicon/hi6210-i2s.c line 518

Quoted 10 lines
sound/soc/hisilicon/hi6210-i2s.c new file +10 -0
+static int hi6210_i2s_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct hi6210_i2s *i2s;
+	struct resource *res;
+	int ret;
+
+	i2s = kzalloc(sizeof(*i2s), GFP_KERNEL);
+	if (!i2s)
+		return -ENOMEM;

devm_kzalloc().

Review

Quoted 2 lines
(quoted diff) +2 -0
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {

No need to check, devm_ioremap_resource() will do this for you.

sound/soc/hisilicon/hi6210-i2s.c line 535

Quoted 3 lines
sound/soc/hisilicon/hi6210-i2s.c new file +3 -0
+	i2s->base = devm_ioremap_resource(dev, res);
+	if (i2s->base == NULL) {
+		dev_err(&pdev->dev, "ioremap failed\n");

devm_ioremap_resource() is quite noisy when it fails, probably no need for another error especially one that's not saying what we failed to map.

sound/soc/hisilicon/hi6210-i2s.c line 575

Quoted 12 lines
sound/soc/hisilicon/hi6210-i2s.c new file +12 -0
+	do {
+		i2s->clk[i2s->clocks] = of_clk_get(pdev->dev.of_node,
+						   i2s->clocks);
+		if (IS_ERR_OR_NULL(i2s->clk[i2s->clocks]))
+			break;
+		i2s->clocks++;
+	} while (i2s->clocks < ARRAY_SIZE(i2s->clk));
+	if (!i2s->clocks) {
+		ret = PTR_ERR(i2s->clk[0]);
+		dev_err(&pdev->dev, "Failed to get clock\n");
+		goto err2;
+	}

So we grab some random clocks until we hit an error, hope that the second one we find is whatever one we were explicitly setting rates on and ignore errors other than possibly a failure to find any clocks at all. This isn't great at all, it's not going to be very robust. We should know what clocks we're looking for, we should use the regular clock API to get them (so we're not tied to DT and so we get a devm version) and we should care about errors on all the clocks.

sound/soc/hisilicon/hi6210-i2s.c line 590

Quoted 1 line
sound/soc/hisilicon/hi6210-i2s.c new file +1 -0
+	dev_info(&pdev->dev, "Registered as %s\n", i2s->dai.name);

This is just noise, remove it.

sound/soc/hisilicon/hi6210-i2s.c line 623

Quoted 4 lines
sound/soc/hisilicon/hi6210-i2s.c new file +4 -0
+static const struct of_device_id hi6210_i2s_dt_ids[] = {
+	{ .compatible = "hisilicon,hi6210-i2s" },
+	{ /* sentinel */ }
+};

The code makes this look like it's not just an I2S controller.

maintainer
#16 lore raw

Re: [PATCH 7/7] dts: hi6220: Add k3-dma and i2s/hdmi audio support

In reply to John Stultz
Quoted 3 lines · John Stultz

Add entry for k3-dma driver and i2s/hdmi audio devices.

This enables HDMI audio output.

These bindings appear to be undocumented. All new bindings require documentation.

arch/arm64/boot/dts/hisilicon/hi6220.dtsi line 822

Quoted 5 lines
arch/arm64/boot/dts/hisilicon/hi6220.dtsi +5 -0
+		i2s0: hi6210_i2s {
+			compatible = "hisilicon,hi6210-i2s";
+			reg = <0x0 0xf7118000 0x0 0x8000>, /* i2s unit */
+			      <0x0 0xf7030000 0x0 0x400>,  /* syscon */
+			      <0x0 0xf7032000 0x0 0x400>;  /* pmctrl */

Some of this looks like we should be using a system controller binding rather than listing the system controller directly here. The magic number indexing for the resources is also not good, we should be using reg-names to get name based lookups (I had been going to query that on the binding document when I failed to find it...).

Acked-by on v1 1/7
#2 lore raw

Re: [RFC][PATCH 1/7] k3dma: Fix hisi burst clipping

In reply to John Stultz
Quoted 15 lines · John Stultz

From: Andy Green <[email protected]>

Max burst len is a 4-bit field, but at the moment it's clipped with a 5-bit constant... reduce it to that which can be expressed

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Quoted 8 lines
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>
[jstultz: Forward ported to mainline]
Quoted 18 lines
---
  drivers/dma/k3dma.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/k3dma.c +1 -1
index 1ba2fd7..d01a11d 100644
@@ -552,7 +552,7 @@ static int k3_dma_config(struct dma_chan *chan,
  	c->ccfg |= (val << 12) | (val << 16);
 
  	if ((maxburst == 0) || (maxburst > 16))
-		val = 16;
+		val = 15;
  	else
  		val = maxburst - 1;
  	c->ccfg |= (val << 20) | (val << 24);
Acked-by on v1 2/7
#4 lore raw

Re: [RFC][PATCH 2/7] k3dma: Fix dma err offsets

In reply to John Stultz
Quoted 15 lines · John Stultz

From: Andy Green <[email protected]>

The offsets for ERR1 and ERR2 are wrong actually.
That's why you can never clear an error.

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Quoted 8 lines
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>
[jstultz: Forward ported to mainline]
Acked-by on v1 3/7
#6 lore raw

Re: [RFC][PATCH 3/7] k3dma: Fix "nobody cared" message seen on any error

In reply to John Stultz
Quoted 20 lines · John Stultz

From: Andy Green <[email protected]>

As it was before, as soon as the DMAC IP felt there was an error he would return IRQ_NONE since no actual transfer had completed.

After spinning on that for 100K interrupts, Linux yanks the IRQ with a "nobody cared" error.

This patch lets it handle the interrupt and keep the IRQ alive.

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Quoted 8 lines
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>
[jstultz: Forward ported to mainline]
Quoted 26 lines
---
  drivers/dma/k3dma.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
drivers/dma/k3dma.c +5 -3
index 8dd050c..c2906a82 100644
@@ -220,11 +220,13 @@ static irqreturn_t k3_dma_int_handler(int irq, void *dev_id)
  	writel_relaxed(err1, d->base + INT_ERR1_RAW);
  	writel_relaxed(err2, d->base + INT_ERR2_RAW);
 
-	if (irq_chan) {
+	if (irq_chan)
  		tasklet_schedule(&d->task);
+
+	if (irq_chan || err1 || err2)
  		return IRQ_HANDLED;
-	} else
-		return IRQ_NONE;
+
+	return IRQ_NONE;
  }
 
  static int k3_dma_start_txd(struct k3_dma_chan *c)
Acked-by on v1 4/7
#8 lore raw

Re: [RFC][PATCH 4/7] k3dma: Add cyclic mode for audio

In reply to John Stultz
Quoted 23 lines · John Stultz

From: Andy Green <[email protected]>

Currently the k3dma driver doesn't offer the cyclic mode necessary for handling audio.

This patch adds it.

Cc Zhangfei Gao <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Dan Williams <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Wei Xu <[email protected]>
Cc Rob Herring <[email protected]>
Cc Andy Green <[email protected]>
Cc Dave Long <[email protected]>
Cc Guodong Xu <[email protected]>
Quoted 3 lines

[jstultz: Forward ported to mainline, removed a few
bits of logic that didn't seem to have much effect]

Could you change pr_xxx to dev_xxx, and remove one print.

Otherwise

Quoted 196 lines
---
  drivers/dma/k3dma.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++------
  1 file changed, 121 insertions(+), 14 deletions(-)
drivers/dma/k3dma.c +43 -11
index c2906a82..eff7483 100644
@@ -1,5 +1,5 @@
  /*
- * Copyright (c) 2013 Linaro Ltd.
+ * Copyright (c) 2013 - 2015 Linaro Ltd.
   * Copyright (c) 2013 Hisilicon Limited.
   *
   * This program is free software; you can redistribute it and/or modify
@@ -25,22 +25,27 @@
 
  #define DRIVER_NAME		"k3-dma"
  #define DMA_MAX_SIZE		0x1ffc
+#define DMA_CYCLIC_MAX_PERIOD	0x1000
 
  #define INT_STAT		0x00
  #define INT_TC1			0x04
+#define INT_TC2			0x08
  #define INT_ERR1		0x0c
  #define INT_ERR2		0x10
  #define INT_TC1_MASK		0x18
+#define INT_TC2_MASK		0x1c
  #define INT_ERR1_MASK		0x20
  #define INT_ERR2_MASK		0x24
  #define INT_TC1_RAW		0x600
+#define INT_TC2_RAW		0x608
  #define INT_ERR1_RAW		0x610
  #define INT_ERR2_RAW		0x618
  #define CH_PRI			0x688
  #define CH_STAT			0x690
  #define CX_CUR_CNT		0x704
  #define CX_LLI			0x800
-#define CX_CNT			0x810
+#define CX_CNT1			0x80c
+#define CX_CNT0			0x810
  #define CX_SRC			0x814
  #define CX_DST			0x818
  #define CX_CFG			0x81c
@@ -49,6 +54,7 @@
 
  #define CX_LLI_CHAIN_EN		0x2
  #define CX_CFG_EN		0x1
+#define CX_CFG_NODEIRQ		BIT(1)
  #define CX_CFG_MEM2PER		(0x1 << 2)
  #define CX_CFG_PER2MEM		(0x2 << 2)
  #define CX_CFG_SRCINCR		(0x1 << 31)
@@ -81,6 +87,7 @@ struct k3_dma_chan {
  	enum dma_transfer_direction dir;
  	dma_addr_t		dev_addr;
  	enum dma_status		status;
+	bool			cyclic;
  };
 
  struct k3_dma_phy {
@@ -134,6 +141,7 @@ static void k3_dma_terminate_chan(struct k3_dma_phy *phy, struct k3_dma_dev *d)
 
  	val = 0x1 << phy->idx;
  	writel_relaxed(val, d->base + INT_TC1_RAW);
+	writel_relaxed(val, d->base + INT_TC2_RAW);
  	writel_relaxed(val, d->base + INT_ERR1_RAW);
  	writel_relaxed(val, d->base + INT_ERR2_RAW);
  }
@@ -141,11 +149,15 @@ static void k3_dma_terminate_chan(struct k3_dma_phy *phy, struct k3_dma_dev *d)
  static void k3_dma_set_desc(struct k3_dma_phy *phy, struct k3_desc_hw *hw)
  {
  	writel_relaxed(hw->lli, phy->base + CX_LLI);
-	writel_relaxed(hw->count, phy->base + CX_CNT);
+	writel_relaxed(hw->count, phy->base + CX_CNT0);
  	writel_relaxed(hw->saddr, phy->base + CX_SRC);
  	writel_relaxed(hw->daddr, phy->base + CX_DST);
  	writel_relaxed(AXI_CFG_DEFAULT, phy->base + AXI_CFG);
  	writel_relaxed(hw->config, phy->base + CX_CFG);
+	pr_debug("%s: desc %p: ch idx = %d, lli: 0x%x, count: 0x%x,"
+		" saddr: 0x%x, daddr 0x%x, cfg: 0x%x\n", __func__,
+		(void *) hw, phy->idx, hw->lli,	hw->count, hw->saddr,
+		hw->daddr, hw->config);
  }
 
  static u32 k3_dma_get_curr_cnt(struct k3_dma_dev *d, struct k3_dma_phy *phy)
@@ -175,11 +187,13 @@ static void k3_dma_enable_dma(struct k3_dma_dev *d, bool on)
 
  		/* unmask irq */
  		writel_relaxed(0xffff, d->base + INT_TC1_MASK);
+		writel_relaxed(0xffff, d->base + INT_TC2_MASK);
  		writel_relaxed(0xffff, d->base + INT_ERR1_MASK);
  		writel_relaxed(0xffff, d->base + INT_ERR2_MASK);
  	} else {
  		/* mask irq */
  		writel_relaxed(0x0, d->base + INT_TC1_MASK);
+		writel_relaxed(0x0, d->base + INT_TC2_MASK);
  		writel_relaxed(0x0, d->base + INT_ERR1_MASK);
  		writel_relaxed(0x0, d->base + INT_ERR2_MASK);
  	}
@@ -192,24 +206,31 @@ static irqreturn_t k3_dma_int_handler(int irq, void *dev_id)
  	struct k3_dma_chan *c;
  	u32 stat = readl_relaxed(d->base + INT_STAT);
  	u32 tc1  = readl_relaxed(d->base + INT_TC1);
+	u32 tc2  = readl_relaxed(d->base + INT_TC2);
  	u32 err1 = readl_relaxed(d->base + INT_ERR1);
  	u32 err2 = readl_relaxed(d->base + INT_ERR2);
  	u32 i, irq_chan = 0;
 
  	while (stat) {
  		i = __ffs(stat);
-		stat &= (stat - 1);
-		if (likely(tc1 & BIT(i))) {
+		stat &= ~BIT(i);
+		if (likely(tc1 & BIT(i)) || (tc2 & BIT(i))) {
+			unsigned long flags;
+
  			p = &d->phy[i];
  			c = p->vchan;
-			if (c) {
-				unsigned long flags;
-
+			if (c && (tc1 & BIT(i))) {
  				spin_lock_irqsave(&c->vc.lock, flags);
  				vchan_cookie_complete(&p->ds_run->vd);
  				p->ds_done = p->ds_run;
  				spin_unlock_irqrestore(&c->vc.lock, flags);
  			}
+			if (c && (tc2 & BIT(i))) {
+				spin_lock_irqsave(&c->vc.lock, flags);
+				if (p->ds_run != NULL)
+					vchan_cyclic_callback(&p->ds_run->vd);
+				spin_unlock_irqrestore(&c->vc.lock, flags);
+			}
  			irq_chan |= BIT(i);
  		}
  		if (unlikely((err1 & BIT(i)) || (err2 & BIT(i))))
@@ -217,6 +238,7 @@ static irqreturn_t k3_dma_int_handler(int irq, void *dev_id)
  	}
 
  	writel_relaxed(irq_chan, d->base + INT_TC1_RAW);
+	writel_relaxed(irq_chan, d->base + INT_TC2_RAW);
  	writel_relaxed(err1, d->base + INT_ERR1_RAW);
  	writel_relaxed(err2, d->base + INT_ERR2_RAW);
 
@@ -352,7 +374,7 @@ static enum dma_status k3_dma_tx_status(struct dma_chan *chan,
  	 * its total size.
  	 */
  	vd = vchan_find_desc(&c->vc, cookie);
-	if (vd) {
+	if (vd && !c->cyclic) {
  		bytes = container_of(vd, struct k3_dma_desc_sw, vd)->size;
  	} else if ((!p) || (!p->ds_run)) {
  		bytes = 0;
@@ -362,7 +384,8 @@ static enum dma_status k3_dma_tx_status(struct dma_chan *chan,
 
  		bytes = k3_dma_get_curr_cnt(d, p);
  		clli = k3_dma_get_curr_lli(p);
-		index = (clli - ds->desc_hw_lli) / sizeof(struct k3_desc_hw);
+		index = ((clli - ds->desc_hw_lli) /
+				sizeof(struct k3_desc_hw)) + 1;
  		for (; index < ds->desc_num; index++) {
  			bytes += ds->desc_hw[index].count;
  			/* end of lli */
@@ -403,14 +426,22 @@ static void k3_dma_issue_pending(struct dma_chan *chan)
  static void k3_dma_fill_desc(struct k3_dma_desc_sw *ds, dma_addr_t dst,
  			dma_addr_t src, size_t len, u32 num, u32 ccfg)
  {
-	if ((num + 1) < ds->desc_num)
+	if (num != ds->desc_num - 1)
  		ds->desc_hw[num].lli = ds->desc_hw_lli + (num + 1) *
  			sizeof(struct k3_desc_hw);
+
  	ds->desc_hw[num].lli |= CX_LLI_CHAIN_EN;
  	ds->desc_hw[num].count = len;
  	ds->desc_hw[num].saddr = src;
  	ds->desc_hw[num].daddr = dst;
  	ds->desc_hw[num].config = ccfg;
+
+	pr_debug("%s: k3_dma_desc_sw = %p, desc_hw = %p (num = %d) lli: 0x%x,"
+		" count: 0x%x, saddr: 0x%x, daddr 0x%x, cfg: 0x%x\n", __func__,
+		(void *)ds, &ds->desc_hw[num], num,
+		ds->desc_hw[num].lli, ds->desc_hw[num].count,
+		ds->desc_hw[num].saddr, ds->desc_hw[num].daddr,
+		ds->desc_hw[num].config);
  }
 
  static struct dma_async_tx_descriptor *k3_dma_prep_memcpy(
@@ -431,6 +462,7 @@ static struct dma_async_tx_descriptor *k3_dma_prep_memcpy(
  		dev_dbg(chan->device->dev, "vchan %p: kzalloc fail\n", &c->vc);
  		return NULL;
  	}
+	c->cyclic = 0;
  	ds->desc_hw_lli = __virt_to_phys((unsigned long)&ds->desc_hw[0]);
  	ds->size = len;
  	ds->desc_num = num;

drivers/dma/k3dma.c static struct dma_async_tx_descriptor *k3_dma_prep_slave_sg( · line 515

Quoted 8 lines
drivers/dma/k3dma.c +3 -0
@@ -476,17 +508,19 @@ static struct dma_async_tx_descriptor *k3_dma_prep_slave_sg(
  	if (sgl == NULL)
  		return NULL;
 
+	c->cyclic = 0;
+
  	for_each_sg(sgl, sg, sglen, i) {
  		avail = sg_dma_len(sg);
+		pr_err("   avail=0x%x\n", (int)avail);

Do we need this print?

Quoted 107 lines
drivers/dma/k3dma.c +75 -3
  		if (avail > DMA_MAX_SIZE)
  			num += DIV_ROUND_UP(avail, DMA_MAX_SIZE) - 1;
  	}
 
  	ds = kzalloc(sizeof(*ds) + num * sizeof(ds->desc_hw[0]), GFP_ATOMIC);
-	if (!ds) {
-		dev_dbg(chan->device->dev, "vchan %p: kzalloc fail\n", &c->vc);
+	if (!ds)
  		return NULL;
-	}
+
  	ds->desc_hw_lli = __virt_to_phys((unsigned long)&ds->desc_hw[0]);
  	ds->desc_num = num;
  	num = 0;
@@ -519,6 +553,77 @@ static struct dma_async_tx_descriptor *k3_dma_prep_slave_sg(
  	return vchan_tx_prep(&c->vc, &ds->vd, flags);
  }
 
+static struct dma_async_tx_descriptor *
+k3_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr,
+		       size_t buf_len, size_t period_len,
+		       enum dma_transfer_direction dir,
+		       unsigned long flags)
+{
+	struct k3_dma_chan *c = to_k3_chan(chan);
+	struct k3_dma_desc_sw *ds;
+	size_t len, avail, total = 0;
+	dma_addr_t addr, src = 0, dst = 0;
+	int num = 1, since = 0;
+	size_t modulo = DMA_CYCLIC_MAX_PERIOD;
+	u32 en_tc2 = 0;
+
+	pr_debug("%s: buf %p, dst %p, buf len %d, period_len = %d, dir %d\n",
+	       __func__, (void *)buf_addr, (void *)to_k3_chan(chan)->dev_addr,
+	       (int)buf_len, (int)period_len, (int)dir);
+
+	avail = buf_len;
+	if (avail > modulo)
+		num += DIV_ROUND_UP(avail, modulo) - 1;
+
+	ds = kzalloc(sizeof(*ds) + num * sizeof(ds->desc_hw[0]), GFP_ATOMIC);
+	if (!ds)
+		return NULL;
+
+	ds->desc_hw_lli = __virt_to_phys((unsigned long)&ds->desc_hw[0]);
+	ds->desc_num = num;
+
+	c->cyclic = 1;
+	addr = buf_addr;
+	avail = buf_len;
+	total = avail;
+	num = 0;
+
+	if (period_len < modulo)
+		modulo = period_len;
+
+	do {
+		len = min_t(size_t, avail, modulo);
+
+		if (dir == DMA_MEM_TO_DEV) {
+			src = addr;
+			dst = c->dev_addr;
+		} else if (dir == DMA_DEV_TO_MEM) {
+			src = c->dev_addr;
+			dst = addr;
+		}
+		since += len;
+		if (since >= period_len) {
+			/* descriptor asks for TC2 interrupt on completion */
+			en_tc2 = CX_CFG_NODEIRQ;
+			since -= period_len;
+		} else
+			en_tc2 = 0;
+
+		k3_dma_fill_desc(ds, dst, src, len, num++, c->ccfg | en_tc2);
+
+		addr += len;
+		avail -= len;
+	} while (avail);
+
+	/* "Cyclic" == end of link points back to start of link */
+	ds->desc_hw[num - 1].lli |= ds->desc_hw_lli;
+
+	ds->size = total;
+
+	return vchan_tx_prep(&c->vc, &ds->vd, flags);
+}
+
+
  static int k3_dma_config(struct dma_chan *chan,
  			 struct dma_slave_config *cfg)
  {
@@ -723,11 +828,13 @@ static int k3_dma_probe(struct platform_device *op)
  	INIT_LIST_HEAD(&d->slave.channels);
  	dma_cap_set(DMA_SLAVE, d->slave.cap_mask);
  	dma_cap_set(DMA_MEMCPY, d->slave.cap_mask);
+	dma_cap_set(DMA_CYCLIC, d->slave.cap_mask);
  	d->slave.dev = &op->dev;
  	d->slave.device_free_chan_resources = k3_dma_free_chan_resources;
  	d->slave.device_tx_status = k3_dma_tx_status;
  	d->slave.device_prep_dma_memcpy = k3_dma_prep_memcpy;
  	d->slave.device_prep_slave_sg = k3_dma_prep_slave_sg;
+	d->slave.device_prep_dma_cyclic = k3_dma_prep_dma_cyclic;
  	d->slave.device_issue_pending = k3_dma_issue_pending;
  	d->slave.device_config = k3_dma_config;
  	d->slave.device_pause = k3_dma_transfer_pause;
#17 lore raw

Re: [PATCH 7/7] dts: hi6220: Add k3-dma and i2s/hdmi audio support

In reply to Mark Brown
Quoted 8 lines · Mark Brown
Quoted 3 lines · John Stultz

Add entry for k3-dma driver and i2s/hdmi audio devices.

This enables HDMI audio output.

These bindings appear to be undocumented. All new bindings require documentation.

Yea. I figured there would be potentially substantial enough changes required that doing a initial draft (which given my limited knowledge of the hardware, would be mostly boilerplate) might not be worth it for the first RFC.

Quoted 11 lines

arch/arm64/boot/dts/hisilicon/hi6220.dtsi line 822

Quoted 5 lines
arch/arm64/boot/dts/hisilicon/hi6220.dtsi +5 -0
+             i2s0: hi6210_i2s {
+                     compatible = "hisilicon,hi6210-i2s";
+                     reg = <0x0 0xf7118000 0x0 0x8000>, /* i2s unit */
+                           <0x0 0xf7030000 0x0 0x400>,  /* syscon */
+                           <0x0 0xf7032000 0x0 0x400>;  /* pmctrl */

Some of this looks like we should be using a system controller binding rather than listing the system controller directly here. The magic number indexing for the resources is also not good, we should be using reg-names to get name based lookups (I had been going to query that on the binding document when I failed to find it...).

Ok. I'll need to dig a bit to understand it better, but will try to address this.

thanks
-john

#13 lore raw

Re: [RFC][PATCH 6/7] ASoC: hisilicon: Add hi6210 i2s audio driver for hdmi audio

In reply to Mark Brown
Quoted 11 lines · Mark Brown
Quoted 2 lines · John Stultz

+ .cpu_dai_name = "f7118000.hi6210_i2s",

Why is this not connected up in DT - as things stand the card has zero reuse potential. Though given that this has

Quoted 1 line

+ .codec_name = "0.hi6210_hdmi_card",

If you've got a CODEC with hdmi_card in the name that suggests there's a serious abstraction problem going on somewhere.

Yea. So I've been splitting up the patch and looking at how this might be wired up via devicetree instead.

I've basically stripped the hdmi-card driver down and it really just seems to be:

static struct snd_soc_dai_driver hi6210_hdmi_dai = {
        .name = "hi6210_hdmi_dai",
        .playback = {
                .channels_min = 2,
                .channels_max = 2,
                .rates = SNDRV_PCM_RATE_48000,
                .formats = SNDRV_PCM_FMTBIT_S16_LE,
        },
};

Then the probe/remove logic to register the codec, and connected it up with the simple card driver.

Though it seems kind of silly to have a whole driver (and devicetree entry for the probe hook) just to fill and install the above structure. Is there a simpler way to specify that via a DT node instead?

Quoted 6 lines

sound/soc/hisilicon/hi6210-i2s.c line 623

Quoted 4 lines
sound/soc/hisilicon/hi6210-i2s.c new file +4 -0
+static const struct of_device_id hi6210_i2s_dt_ids[] = {
+     { .compatible = "hisilicon,hi6210-i2s" },
+     { /* sentinel */ }
+};

The code makes this look like it's not just an I2S controller.

I'm not sure I follow this? The dt ids make it seem like this driver is not an i2s controller?

I think I've addressed the other issue you've pointed out in this patch, so I'll likely be sending out another revision later today.

thanks
-john

maintainer
#14 lore raw

Re: [RFC][PATCH 6/7] ASoC: hisilicon: Add hi6210 i2s audio driver for hdmi audio

Quoted 7 lines · John Stultz

Then the probe/remove logic to register the codec, and connected it up with the simple card driver.

Though it seems kind of silly to have a whole driver (and devicetree entry for the probe hook) just to fill and install the above structure. Is there a simpler way to specify that via a DT node instead?

Well, if you can use simple-card why not just use simple-card?

Quoted 9 lines
Quoted 6 lines

sound/soc/hisilicon/hi6210-i2s.c line 623

Quoted 4 lines
sound/soc/hisilicon/hi6210-i2s.c new file +4 -0
+static const struct of_device_id hi6210_i2s_dt_ids[] = {
+     { .compatible = "hisilicon,hi6210-i2s" },
+     { /* sentinel */ }
+};

The code makes this look like it's not just an I2S controller.

I'm not sure I follow this? The dt ids make it seem like this driver is not an i2s controller?

No. The *code* makes this look like it's not an I2S controller. It looks like it's a driver for a DSP/mixing block which may have an integrated I2S controller, I pointed out things like some of the routing control.