All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT
@ 2014-05-23  6:21 Kuninori Morimoto
  2014-05-23  6:24 ` [PATCH 1/6] ASoC: rsnd: DT node clean up by using the of_node_put() Kuninori Morimoto
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2014-05-23  6:21 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


Hi Mark

These patches are tidyup code and fixup for DMA support of DT
#1 - #4 are cleanup code patches
#5 - #6 are fixup for DMA for DT

Kuninori Morimoto (6):
      ASoC: rsnd: DT node clean up by using the of_node_put()
      ASoC: rsnd: save platform_device instead of device
      ASoC: rsnd: remove rsnd_src_non_ops
      ASoC: rsnd: module name is unified
      ASoC: rsnd: care DMA slave channel name for DT
      ASoC: rsnd: add rsnd_gen_dma_addr() for DMAC addr

 .../devicetree/bindings/sound/renesas,rsnd.txt     |    1 +
 sound/soc/sh/rcar/core.c                           |   87 ++++++++++++++++--
 sound/soc/sh/rcar/dvc.c                            |   20 ++++-
 sound/soc/sh/rcar/gen.c                            |   95 ++++++++++++++++++++
 sound/soc/sh/rcar/rsnd.h                           |   10 ++-
 sound/soc/sh/rcar/src.c                            |   50 +++++++----
 sound/soc/sh/rcar/ssi.c                            |   28 ++++--
 7 files changed, 260 insertions(+), 31 deletions(-)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/6] ASoC: rsnd: DT node clean up by using the of_node_put()
  2014-05-23  6:21 [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT Kuninori Morimoto
@ 2014-05-23  6:24 ` Kuninori Morimoto
  2014-05-23  6:25 ` [PATCH 2/6] ASoC: rsnd: save platform_device instead of device Kuninori Morimoto
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2014-05-23  6:24 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood

Driver needs to call of_node_put() after of_get_chile_by_name()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/sh/rcar/src.c |    7 +++++--
 sound/soc/sh/rcar/ssi.c |    7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c
index 7da87cd..61009c4 100644
--- a/sound/soc/sh/rcar/src.c
+++ b/sound/soc/sh/rcar/src.c
@@ -598,18 +598,21 @@ static void rsnd_of_parse_src(struct platform_device *pdev,
 
 	nr = of_get_child_count(src_node);
 	if (!nr)
-		return;
+		goto rsnd_of_parse_src_end;
 
 	src_info = devm_kzalloc(dev,
 				sizeof(struct rsnd_src_platform_info) * nr,
 				GFP_KERNEL);
 	if (!src_info) {
 		dev_err(dev, "src info allocation error\n");
-		return;
+		goto rsnd_of_parse_src_end;
 	}
 
 	info->src_info		= src_info;
 	info->src_info_nr	= nr;
+
+rsnd_of_parse_src_end:
+	of_node_put(src_node);
 }
 
 int rsnd_src_probe(struct platform_device *pdev,
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 4b13edb..ea8d4e7 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -554,14 +554,14 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev,
 
 	nr = of_get_child_count(node);
 	if (!nr)
-		return;
+		goto rsnd_of_parse_ssi_end;
 
 	ssi_info = devm_kzalloc(dev,
 				sizeof(struct rsnd_ssi_platform_info) * nr,
 				GFP_KERNEL);
 	if (!ssi_info) {
 		dev_err(dev, "ssi info allocation error\n");
-		return;
+		goto rsnd_of_parse_ssi_end;
 	}
 
 	info->ssi_info		= ssi_info;
@@ -584,6 +584,9 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev,
 		 */
 		ssi_info->pio_irq = irq_of_parse_and_map(np, 0);
 	}
+
+rsnd_of_parse_ssi_end:
+	of_node_put(node);
 }
 
 int rsnd_ssi_probe(struct platform_device *pdev,
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/6] ASoC: rsnd: save platform_device instead of device
  2014-05-23  6:21 [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT Kuninori Morimoto
  2014-05-23  6:24 ` [PATCH 1/6] ASoC: rsnd: DT node clean up by using the of_node_put() Kuninori Morimoto
@ 2014-05-23  6:25 ` Kuninori Morimoto
  2014-05-23  6:25 ` [PATCH 3/6] ASoC: rsnd: remove rsnd_src_non_ops Kuninori Morimoto
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2014-05-23  6:25 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood

DT DMA support needs struct platform_device pointer,
and it can get struct device pointer from platform_device.
Save platform_device instead of device.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/sh/rcar/core.c |    2 +-
 sound/soc/sh/rcar/rsnd.h |    5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 1f6981a..073a293 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -957,7 +957,7 @@ static int rsnd_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	priv->dev	= dev;
+	priv->pdev	= pdev;
 	priv->info	= info;
 	spin_lock_init(&priv->lock);
 
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index 5aa7901..344f941 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -317,7 +317,7 @@ struct rsnd_of_data {
 
 struct rsnd_priv {
 
-	struct device *dev;
+	struct platform_device *pdev;
 	struct rcar_snd_info *info;
 	spinlock_t lock;
 
@@ -357,7 +357,8 @@ struct rsnd_priv {
 	int rdai_nr;
 };
 
-#define rsnd_priv_to_dev(priv)	((priv)->dev)
+#define rsnd_priv_to_pdev(priv)	((priv)->pdev)
+#define rsnd_priv_to_dev(priv)	(&(rsnd_priv_to_pdev(priv)->dev))
 #define rsnd_priv_to_info(priv)	((priv)->info)
 #define rsnd_lock(priv, flags) spin_lock_irqsave(&priv->lock, flags)
 #define rsnd_unlock(priv, flags) spin_unlock_irqrestore(&priv->lock, flags)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/6] ASoC: rsnd: remove rsnd_src_non_ops
  2014-05-23  6:21 [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT Kuninori Morimoto
  2014-05-23  6:24 ` [PATCH 1/6] ASoC: rsnd: DT node clean up by using the of_node_put() Kuninori Morimoto
  2014-05-23  6:25 ` [PATCH 2/6] ASoC: rsnd: save platform_device instead of device Kuninori Morimoto
@ 2014-05-23  6:25 ` Kuninori Morimoto
  2014-05-23  6:25 ` [PATCH 4/6] ASoC: rsnd: module name is unified Kuninori Morimoto
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2014-05-23  6:25 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood

Renesas sound driver is supporting Gen1/Gen2.
SRC probe can return error if it was unknown
generation.
Now, rsnd_src_non_ops is not needed.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/sh/rcar/src.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c
index 61009c4..c5ddbcc 100644
--- a/sound/soc/sh/rcar/src.c
+++ b/sound/soc/sh/rcar/src.c
@@ -268,10 +268,6 @@ static int rsnd_src_stop(struct rsnd_mod *mod,
 	return 0;
 }
 
-static struct rsnd_mod_ops rsnd_src_non_ops = {
-	.name	= "src (non)",
-};
-
 /*
  *		Gen1 functions
  */
@@ -627,6 +623,16 @@ int rsnd_src_probe(struct platform_device *pdev,
 	char name[RSND_SRC_NAME_SIZE];
 	int i, nr;
 
+	ops = NULL;
+	if (rsnd_is_gen1(priv))
+		ops = &rsnd_src_gen1_ops;
+	if (rsnd_is_gen2(priv))
+		ops = &rsnd_src_gen2_ops;
+	if (!ops) {
+		dev_err(dev, "unknown Generation\n");
+		return -EIO;
+	}
+
 	rsnd_of_parse_src(pdev, of_data, priv);
 
 	/*
@@ -655,12 +661,6 @@ int rsnd_src_probe(struct platform_device *pdev,
 		src->info = &info->src_info[i];
 		src->clk = clk;
 
-		ops = &rsnd_src_non_ops;
-		if (rsnd_is_gen1(priv))
-			ops = &rsnd_src_gen1_ops;
-		if (rsnd_is_gen2(priv))
-			ops = &rsnd_src_gen2_ops;
-
 		rsnd_mod_init(priv, &src->mod, ops, RSND_MOD_SRC, i);
 
 		dev_dbg(dev, "SRC%d probed\n", i);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/6] ASoC: rsnd: module name is unified
  2014-05-23  6:21 [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2014-05-23  6:25 ` [PATCH 3/6] ASoC: rsnd: remove rsnd_src_non_ops Kuninori Morimoto
@ 2014-05-23  6:25 ` Kuninori Morimoto
  2014-05-23  6:25 ` [PATCH 5/6] ASoC: rsnd: care DMA slave channel name for DT Kuninori Morimoto
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2014-05-23  6:25 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood

Renesas sound driver uses many modules (= SSI/SRC/DVC),
and each module had own name.
But, each module name can be used as several purpose,
like clock name, DMA name etc...
This patch uses common name for each module.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/sh/rcar/dvc.c |   20 ++++++++++++++++++--
 sound/soc/sh/rcar/src.c |   23 ++++++++++++++++++++---
 sound/soc/sh/rcar/ssi.c |   15 +++++++++++----
 3 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
index 74769b1..ed00070 100644
--- a/sound/soc/sh/rcar/dvc.c
+++ b/sound/soc/sh/rcar/dvc.c
@@ -13,6 +13,9 @@
 #define RSND_DVC_NAME_SIZE	16
 #define RSND_DVC_VOLUME_MAX	100
 #define RSND_DVC_VOLUME_NUM	2
+
+#define DVC_NAME "dvc"
+
 struct rsnd_dvc {
 	struct rsnd_dvc_platform_info *info; /* rcar_snd.h */
 	struct rsnd_mod mod;
@@ -43,6 +46,17 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
 	rsnd_mod_write(mod, DVC_VOL1R, vol[1]);
 }
 
+static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod,
+			       struct rsnd_dai *rdai)
+{
+	struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+	struct device *dev = rsnd_priv_to_dev(priv);
+
+	dev_dbg(dev, "%s (Gen2) is probed\n", rsnd_mod_name(mod));
+
+	return 0;
+}
+
 static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
 			 struct rsnd_dai *rdai)
 {
@@ -208,7 +222,8 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
 }
 
 static struct rsnd_mod_ops rsnd_dvc_ops = {
-	.name		= "dvc (gen2)",
+	.name		= DVC_NAME,
+	.probe		= rsnd_dvc_probe_gen2,
 	.init		= rsnd_dvc_init,
 	.quit		= rsnd_dvc_quit,
 	.start		= rsnd_dvc_start,
@@ -255,7 +270,8 @@ int rsnd_dvc_probe(struct platform_device *pdev,
 	priv->dvc	= dvc;
 
 	for_each_rsnd_dvc(dvc, priv, i) {
-		snprintf(name, RSND_DVC_NAME_SIZE, "dvc.%d", i);
+		snprintf(name, RSND_DVC_NAME_SIZE, "%s.%d",
+			 DVC_NAME, i);
 
 		clk = devm_clk_get(dev, name);
 		if (IS_ERR(clk))
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c
index c5ddbcc..4b5671b 100644
--- a/sound/soc/sh/rcar/src.c
+++ b/sound/soc/sh/rcar/src.c
@@ -10,6 +10,8 @@
  */
 #include "rsnd.h"
 
+#define SRC_NAME "src"
+
 struct rsnd_src {
 	struct rsnd_src_platform_info *info; /* rcar_snd.h */
 	struct rsnd_mod mod;
@@ -389,6 +391,17 @@ static int rsnd_src_set_convert_rate_gen1(struct rsnd_mod *mod,
 	return 0;
 }
 
+static int rsnd_src_probe_gen1(struct rsnd_mod *mod,
+			      struct rsnd_dai *rdai)
+{
+	struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+	struct device *dev = rsnd_priv_to_dev(priv);
+
+	dev_dbg(dev, "%s (Gen1) is probed\n", rsnd_mod_name(mod));
+
+	return 0;
+}
+
 static int rsnd_src_init_gen1(struct rsnd_mod *mod,
 			      struct rsnd_dai *rdai)
 {
@@ -434,7 +447,8 @@ static int rsnd_src_stop_gen1(struct rsnd_mod *mod,
 }
 
 static struct rsnd_mod_ops rsnd_src_gen1_ops = {
-	.name	= "sru (gen1)",
+	.name	= SRC_NAME,
+	.probe	= rsnd_src_probe_gen1,
 	.init	= rsnd_src_init_gen1,
 	.quit	= rsnd_src_quit,
 	.start	= rsnd_src_start_gen1,
@@ -498,6 +512,8 @@ static int rsnd_src_probe_gen2(struct rsnd_mod *mod,
 	if (ret < 0)
 		dev_err(dev, "SRC DMA failed\n");
 
+	dev_dbg(dev, "%s (Gen2) is probed\n", rsnd_mod_name(mod));
+
 	return ret;
 }
 
@@ -558,7 +574,7 @@ static int rsnd_src_stop_gen2(struct rsnd_mod *mod,
 }
 
 static struct rsnd_mod_ops rsnd_src_gen2_ops = {
-	.name	= "src (gen2)",
+	.name	= SRC_NAME,
 	.probe	= rsnd_src_probe_gen2,
 	.remove	= rsnd_src_remove_gen2,
 	.init	= rsnd_src_init_gen2,
@@ -652,7 +668,8 @@ int rsnd_src_probe(struct platform_device *pdev,
 	priv->src	= src;
 
 	for_each_rsnd_src(src, priv, i) {
-		snprintf(name, RSND_SRC_NAME_SIZE, "src.%d", i);
+		snprintf(name, RSND_SRC_NAME_SIZE, "%s.%d",
+			 SRC_NAME, i);
 
 		clk = devm_clk_get(dev, name);
 		if (IS_ERR(clk))
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index ea8d4e7..2d94a62 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -57,6 +57,8 @@
  */
 #define CONT		(1 << 8)	/* WS Continue Function */
 
+#define SSI_NAME "ssi"
+
 struct rsnd_ssi {
 	struct clk *clk;
 	struct rsnd_ssi_platform_info *info; /* rcar_snd.h */
@@ -373,6 +375,8 @@ static int rsnd_ssi_pio_probe(struct rsnd_mod *mod,
 	if (ret)
 		dev_err(dev, "SSI request interrupt failed\n");
 
+	dev_dbg(dev, "%s (PIO) is probed\n", rsnd_mod_name(mod));
+
 	return ret;
 }
 
@@ -405,7 +409,7 @@ static int rsnd_ssi_pio_stop(struct rsnd_mod *mod,
 }
 
 static struct rsnd_mod_ops rsnd_ssi_pio_ops = {
-	.name	= "ssi (pio)",
+	.name	= SSI_NAME,
 	.probe	= rsnd_ssi_pio_probe,
 	.init	= rsnd_ssi_init,
 	.quit	= rsnd_ssi_quit,
@@ -430,6 +434,8 @@ static int rsnd_ssi_dma_probe(struct rsnd_mod *mod,
 	if (ret < 0)
 		dev_err(dev, "SSI DMA failed\n");
 
+	dev_dbg(dev, "%s (DMA) is probed\n", rsnd_mod_name(mod));
+
 	return ret;
 }
 
@@ -480,7 +486,7 @@ static int rsnd_ssi_dma_stop(struct rsnd_mod *mod,
 }
 
 static struct rsnd_mod_ops rsnd_ssi_dma_ops = {
-	.name	= "ssi (dma)",
+	.name	= SSI_NAME,
 	.probe	= rsnd_ssi_dma_probe,
 	.remove	= rsnd_ssi_dma_remove,
 	.init	= rsnd_ssi_init,
@@ -493,7 +499,7 @@ static struct rsnd_mod_ops rsnd_ssi_dma_ops = {
  *		Non SSI
  */
 static struct rsnd_mod_ops rsnd_ssi_non_ops = {
-	.name	= "ssi (non)",
+	.name	= SSI_NAME,
 };
 
 /*
@@ -620,7 +626,8 @@ int rsnd_ssi_probe(struct platform_device *pdev,
 	for_each_rsnd_ssi(ssi, priv, i) {
 		pinfo = &info->ssi_info[i];
 
-		snprintf(name, RSND_SSI_NAME_SIZE, "ssi.%d", i);
+		snprintf(name, RSND_SSI_NAME_SIZE, "%s.%d",
+			 SSI_NAME, i);
 
 		clk = devm_clk_get(dev, name);
 		if (IS_ERR(clk))
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/6] ASoC: rsnd: care DMA slave channel name for DT
  2014-05-23  6:21 [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2014-05-23  6:25 ` [PATCH 4/6] ASoC: rsnd: module name is unified Kuninori Morimoto
@ 2014-05-23  6:25 ` Kuninori Morimoto
  2014-06-02 21:33   ` Ben Dooks
  2014-05-23  6:25 ` [PATCH 6/6] ASoC: rsnd: add rsnd_gen_dma_addr() for DMAC addr Kuninori Morimoto
  2014-05-26 13:35 ` [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT Mark Brown
  6 siblings, 1 reply; 10+ messages in thread
From: Kuninori Morimoto @ 2014-05-23  6:25 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood

Renesas sound driver is supporting to use DMAEngine.
But, DMA slave channel name "tx", "rx" is not enough
in DT case.
Becuase, it has many ports and path combination.

This patch adds rsnd_dma_of_name() to find
DMA channel name, for example
memory to SSI0 is "mem_ssi0",
SSI0 to memory is "ssi0_mem",
SSI0 to SRC0   is "ssi0_src0",
SRC0 to SSI0   is "src0_ssi0",
SRC0 to DVC0   is "src0_dvc0"...

Renesas sound want to use PIO transfer mode for some reasons.
It will be PIO tranfer mode if device node doesn't have
DMA settings.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 .../devicetree/bindings/sound/renesas,rsnd.txt     |    1 +
 sound/soc/sh/rcar/core.c                           |   80 +++++++++++++++++++-
 sound/soc/sh/rcar/ssi.c                            |    6 ++
 3 files changed, 86 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
index a44e917..8346cab 100644
--- a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
+++ b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
@@ -20,6 +20,7 @@ Required properties:
 SSI subnode properties:
 - interrupts			: Should contain SSI interrupt for PIO transfer
 - shared-pin			: if shared clock pin
+- pio-transfer			: use PIO transfer mode
 
 SRC subnode properties:
 no properties at this point
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 073a293..cddb76d 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -256,11 +256,81 @@ int rsnd_dma_available(struct rsnd_dma *dma)
 	return !!dma->chan;
 }
 
+#define DMA_NAME_SIZE 16
+#define MOD_MAX 4 /* MEM/SSI/SRC/DVC */
+static int _rsnd_dma_of_name(char *dma_name, struct rsnd_mod *mod)
+{
+	if (mod)
+		return snprintf(dma_name, DMA_NAME_SIZE / 2, "%s%d",
+			 rsnd_mod_name(mod), rsnd_mod_id(mod));
+	else
+		return snprintf(dma_name, DMA_NAME_SIZE / 2, "mem");
+
+}
+
+static void rsnd_dma_of_name(struct rsnd_dma *dma,
+			     int is_play, char *dma_name)
+{
+	struct rsnd_mod *this = rsnd_dma_to_mod(dma);
+	struct rsnd_dai_stream *io = rsnd_mod_to_io(this);
+	struct rsnd_mod *ssi = rsnd_io_to_mod_ssi(io);
+	struct rsnd_mod *src = rsnd_io_to_mod_src(io);
+	struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io);
+	struct rsnd_mod *mod[MOD_MAX];
+	struct rsnd_mod *src_mod, *dst_mod;
+	int i, index;
+
+
+	for (i = 0; i < MOD_MAX; i++)
+		mod[i] = NULL;
+
+	/*
+	 * in play case...
+	 *
+	 * src -> dst
+	 *
+	 * mem -> SSI
+	 * mem -> SRC -> SSI
+	 * mem -> SRC -> DVC -> SSI
+	 */
+	mod[0] = NULL; /* for "mem" */
+	index = 1;
+	for (i = 1; i < MOD_MAX; i++) {
+		if (!src) {
+			mod[i] = ssi;
+			break;
+		} else if (!dvc) {
+			mod[i] = src;
+			src = NULL;
+		} else {
+			mod[i] = dvc;
+			dvc = NULL;
+		}
+
+		if (mod[i] == this)
+			index = i;
+	}
+
+	if (is_play) {
+		src_mod = mod[index - 1];
+		dst_mod = mod[index];
+	} else {
+		src_mod = mod[index];
+		dst_mod = mod[index + 1];
+	}
+
+	index = 0;
+	index = _rsnd_dma_of_name(dma_name + index, src_mod);
+	*(dma_name + index++) = '_';
+	index = _rsnd_dma_of_name(dma_name + index, dst_mod);
+}
+
 int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma,
 		  int is_play, int id)
 {
 	struct device *dev = rsnd_priv_to_dev(priv);
 	struct dma_slave_config cfg;
+	char dma_name[DMA_NAME_SIZE];
 	dma_cap_mask_t mask;
 	int ret;
 
@@ -272,9 +342,17 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma,
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
 
+	if (dev->of_node)
+		rsnd_dma_of_name(dma, is_play, dma_name);
+	else
+		snprintf(dma_name, DMA_NAME_SIZE,
+			 is_play ? "tx" : "rx");
+
+	dev_dbg(dev, "dma name : %s\n", dma_name);
+
 	dma->chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
 						     (void *)id, dev,
-						     is_play ? "tx" : "rx");
+						     dma_name);
 	if (!dma->chan) {
 		dev_err(dev, "can't get dma channel\n");
 		return -EIO;
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 2d94a62..e0a4ba7 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -589,6 +589,12 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev,
 		 * irq
 		 */
 		ssi_info->pio_irq = irq_of_parse_and_map(np, 0);
+
+		/*
+		 * DMA
+		 */
+		ssi_info->dma_id = of_get_property(np, "pio-transfer", NULL) ?
+			0 : 1;
 	}
 
 rsnd_of_parse_ssi_end:
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/6] ASoC: rsnd: add rsnd_gen_dma_addr() for DMAC addr
  2014-05-23  6:21 [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2014-05-23  6:25 ` [PATCH 5/6] ASoC: rsnd: care DMA slave channel name for DT Kuninori Morimoto
@ 2014-05-23  6:25 ` Kuninori Morimoto
  2014-05-26 13:35 ` [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT Mark Brown
  6 siblings, 0 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2014-05-23  6:25 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood

The DMAC src/dst addr needs to be set from driver when DT case.
(It was set from SoC/DMAEngine code when non-DT case)
This patch adds rsnd_gen_dma_addr() to set DMAC src/dst addr.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/sh/rcar/core.c |    5 +--
 sound/soc/sh/rcar/gen.c  |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/sh/rcar/rsnd.h |    5 +++
 3 files changed, 101 insertions(+), 4 deletions(-)

diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index cddb76d..ebb5d46 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -358,10 +358,7 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma,
 		return -EIO;
 	}
 
-	cfg.slave_id	= id;
-	cfg.dst_addr	= 0; /* use default addr when playback */
-	cfg.src_addr	= 0; /* use default addr when capture */
-	cfg.direction	= is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
+	rsnd_gen_dma_addr(priv, dma, &cfg, is_play, id);
 
 	ret = dmaengine_slave_config(dma->chan, &cfg);
 	if (ret < 0)
diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c
index a1583b5..1dd2b7d 100644
--- a/sound/soc/sh/rcar/gen.c
+++ b/sound/soc/sh/rcar/gen.c
@@ -156,6 +156,101 @@ static int rsnd_gen_regmap_init(struct rsnd_priv *priv,
 }
 
 /*
+ *	DMA read/write register offset
+ *
+ *	RSND_xxx_I_N	for Audio DMAC input
+ *	RSND_xxx_O_N	for Audio DMAC output
+ *	RSND_xxx_I_P	for Audio DMAC peri peri input
+ *	RSND_xxx_O_P	for Audio DMAC peri peri output
+ *
+ *	ex) R-Car H2 case
+ *	      mod        / DMAC in    / DMAC out   / DMAC PP in / DMAC pp out
+ *	SSI : 0xec541000 / 0xec241008 / 0xec24100c / 0xec400000 / 0xec400000
+ *	SCU : 0xec500000 / 0xec000000 / 0xec004000 / 0xec300000 / 0xec304000
+ *	CMD : 0xec500000 / 0xec008000                             0xec308000
+ */
+#define RDMA_SSI_I_N(addr, i)	(addr ##_reg - 0x00300000 + (0x40 * i) + 0x8)
+#define RDMA_SSI_O_N(addr, i)	(addr ##_reg - 0x00300000 + (0x40 * i) + 0xc)
+
+#define RDMA_SSI_I_P(addr, i)	(addr ##_reg - 0x00141000 + (0x1000 * i))
+#define RDMA_SSI_O_P(addr, i)	(addr ##_reg - 0x00141000 + (0x1000 * i))
+
+#define RDMA_SRC_I_N(addr, i)	(addr ##_reg - 0x00500000 + (0x400 * i))
+#define RDMA_SRC_O_N(addr, i)	(addr ##_reg - 0x004fc000 + (0x400 * i))
+
+#define RDMA_SRC_I_P(addr, i)	(addr ##_reg - 0x00200000 + (0x400 * i))
+#define RDMA_SRC_O_P(addr, i)	(addr ##_reg - 0x001fc000 + (0x400 * i))
+
+#define RDMA_CMD_O_N(addr, i)	(addr ##_reg - 0x004f8000 + (0x400 * i))
+#define RDMA_CMD_O_P(addr, i)	(addr ##_reg - 0x001f8000 + (0x400 * i))
+
+void rsnd_gen_dma_addr(struct rsnd_priv *priv,
+		       struct rsnd_dma *dma,
+		       struct dma_slave_config *cfg,
+		       int is_play, int slave_id)
+{
+	struct platform_device *pdev = rsnd_priv_to_pdev(priv);
+	struct device *dev = rsnd_priv_to_dev(priv);
+	struct rsnd_mod *mod = rsnd_dma_to_mod(dma);
+	struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+	dma_addr_t ssi_reg = platform_get_resource(pdev,
+				IORESOURCE_MEM, RSND_GEN2_SSI)->start;
+	dma_addr_t src_reg = platform_get_resource(pdev,
+				IORESOURCE_MEM, RSND_GEN2_SCU)->start;
+	int is_ssi = !!(rsnd_io_to_mod_ssi(io) == mod);
+	int use_src = !!rsnd_io_to_mod_src(io);
+	int use_dvc = !!rsnd_io_to_mod_dvc(io);
+	int id = rsnd_mod_id(mod);
+	struct dma_addr {
+		dma_addr_t src_addr;
+		dma_addr_t dst_addr;
+	} dma_addrs[2][2][3] = {
+		{ /* SRC */
+			/* Capture */
+			{{ 0,				0 },
+			 { RDMA_SRC_O_N(src, id),	0 },
+			 { RDMA_CMD_O_N(src, id),	0 }},
+			/* Playback */
+			{{ 0,				0, },
+			 { 0,				RDMA_SRC_I_N(src, id) },
+			 { 0,				RDMA_SRC_I_N(src, id) }}
+		}, { /* SSI */
+			/* Capture */
+			{{ RDMA_SSI_O_N(ssi, id),	0 },
+			 { RDMA_SSI_O_P(ssi, id),	RDMA_SRC_I_P(src, id) },
+			 { RDMA_SSI_O_P(ssi, id),	RDMA_SRC_I_P(src, id) }},
+			/* Playback */
+			{{ 0,				RDMA_SSI_I_N(ssi, id) },
+			 { RDMA_SRC_O_P(src, id),	RDMA_SSI_I_P(ssi, id) },
+			 { RDMA_CMD_O_P(src, id),	RDMA_SSI_I_P(ssi, id) }}
+		}
+	};
+
+	cfg->slave_id	= slave_id;
+	cfg->src_addr	= 0;
+	cfg->dst_addr	= 0;
+	cfg->direction	= is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
+
+	/*
+	 * gen1 uses default DMA addr
+	 */
+	if (rsnd_is_gen1(priv))
+		return;
+
+	/* it shouldn't happen */
+	if (use_dvc & !use_src) {
+		dev_err(dev, "DVC is selected without SRC\n");
+		return;
+	}
+
+	cfg->src_addr = dma_addrs[is_ssi][is_play][use_src + use_dvc].src_addr;
+	cfg->dst_addr = dma_addrs[is_ssi][is_play][use_src + use_dvc].dst_addr;
+
+	dev_dbg(dev, "dma%d addr - src : %x / dst : %x\n",
+		id, cfg->src_addr, cfg->dst_addr);
+}
+
+/*
  *		Gen2
  */
 
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index 344f941..39d98af 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -281,6 +281,11 @@ int rsnd_gen_probe(struct platform_device *pdev,
 void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv,
 			       struct rsnd_mod *mod,
 			       enum rsnd_reg reg);
+void rsnd_gen_dma_addr(struct rsnd_priv *priv,
+		       struct rsnd_dma *dma,
+		       struct dma_slave_config *cfg,
+		       int is_play,  int slave_id);
+
 #define rsnd_is_gen1(s)		(((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1)
 #define rsnd_is_gen2(s)		(((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2)
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT
  2014-05-23  6:21 [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT Kuninori Morimoto
                   ` (5 preceding siblings ...)
  2014-05-23  6:25 ` [PATCH 6/6] ASoC: rsnd: add rsnd_gen_dma_addr() for DMAC addr Kuninori Morimoto
@ 2014-05-26 13:35 ` Mark Brown
  6 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2014-05-26 13:35 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto


[-- Attachment #1.1: Type: text/plain, Size: 248 bytes --]

On Thu, May 22, 2014 at 11:21:48PM -0700, Kuninori Morimoto wrote:
> 
> Hi Mark
> 
> These patches are tidyup code and fixup for DMA support of DT
> #1 - #4 are cleanup code patches
> #5 - #6 are fixup for DMA for DT

Applied all, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 5/6] ASoC: rsnd: care DMA slave channel name for DT
  2014-05-23  6:25 ` [PATCH 5/6] ASoC: rsnd: care DMA slave channel name for DT Kuninori Morimoto
@ 2014-06-02 21:33   ` Ben Dooks
  2014-06-03  0:43     ` Kuninori Morimoto
  0 siblings, 1 reply; 10+ messages in thread
From: Ben Dooks @ 2014-06-02 21:33 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA, Simon, Liam Girdwood

On 23/05/14 07:25, Kuninori Morimoto wrote:
> Renesas sound driver is supporting to use DMAEngine.
> But, DMA slave channel name "tx", "rx" is not enough
> in DT case.
> Becuase, it has many ports and path combination.
> 
> This patch adds rsnd_dma_of_name() to find
> DMA channel name, for example
> memory to SSI0 is "mem_ssi0",
> SSI0 to memory is "ssi0_mem",
> SSI0 to SRC0   is "ssi0_src0",
> SRC0 to SSI0   is "src0_ssi0",
> SRC0 to DVC0   is "src0_dvc0"...

I commented on another patch where the ssiX nodes are not being
used, this would be so much nicer if we removed the ssiX from the
name and used the of-pointer for the ssiX node to lookup the DMA...

This is going to produce a hugh list of DMA entries that are going
to be difficult to manage.

> Renesas sound want to use PIO transfer mode for some reasons.
> It will be PIO tranfer mode if device node doesn't have
> DMA settings.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  .../devicetree/bindings/sound/renesas,rsnd.txt     |    1 +
>  sound/soc/sh/rcar/core.c                           |   80 +++++++++++++++++++-
>  sound/soc/sh/rcar/ssi.c                            |    6 ++
>  3 files changed, 86 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
> index a44e917..8346cab 100644
> --- a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
> +++ b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
> @@ -20,6 +20,7 @@ Required properties:
>  SSI subnode properties:
>  - interrupts			: Should contain SSI interrupt for PIO transfer
>  - shared-pin			: if shared clock pin
> +- pio-transfer			: use PIO transfer mode
>  
>  SRC subnode properties:
>  no properties at this poin

> diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
> index 2d94a62..e0a4ba7 100644
> --- a/sound/soc/sh/rcar/ssi.c
> +++ b/sound/soc/sh/rcar/ssi.c
> @@ -589,6 +589,12 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev,
>  		 * irq
>  		 */
>  		ssi_info->pio_irq = irq_of_parse_and_map(np, 0);
> +
> +		/*
> +		 * DMA
> +		 */
> +		ssi_info->dma_id = of_get_property(np, "pio-transfer", NULL) ?
> +			0 : 1;

How about checking for the dma node, and if no present?

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 5/6] ASoC: rsnd: care DMA slave channel name for DT
  2014-06-02 21:33   ` Ben Dooks
@ 2014-06-03  0:43     ` Kuninori Morimoto
  0 siblings, 0 replies; 10+ messages in thread
From: Kuninori Morimoto @ 2014-06-03  0:43 UTC (permalink / raw)
  To: Ben Dooks; +Cc: Linux-ALSA, Mark Brown, Liam Girdwood, Simon


Hi Ben

> > Renesas sound driver is supporting to use DMAEngine.
> > But, DMA slave channel name "tx", "rx" is not enough
> > in DT case.
> > Becuase, it has many ports and path combination.
> > 
> > This patch adds rsnd_dma_of_name() to find
> > DMA channel name, for example
> > memory to SSI0 is "mem_ssi0",
> > SSI0 to memory is "ssi0_mem",
> > SSI0 to SRC0   is "ssi0_src0",
> > SRC0 to SSI0   is "src0_ssi0",
> > SRC0 to DVC0   is "src0_dvc0"...
> 
> I commented on another patch where the ssiX nodes are not being
> used, this would be so much nicer if we removed the ssiX from the
> name and used the of-pointer for the ssiX node to lookup the DMA...
> 
> This is going to produce a hugh list of DMA entries that are going
> to be difficult to manage.

Thank you for your comment.
I understand your opinion.
But, I don't want to use such style for DMA IMO.

You know R-Car sound is very complex IP collection.
And user want to use it as several patterns.
If SSI nodes has its specific DMA setting,
this means SRC/DVC needs to have same style too.

The DMA entry for SSI/SRC/DVC depends on data path.
This means, user *must* understand which IP can use which DMA.
(You know, R-Car sound uses Audio DMAC/Audio DMAC peri peri,
 and the pattern/use case is very complex)
And, user must care his DAI too.
If user failed his settings (= DAI and DMA entry for SSI/SRC/DVC),
someone (maybe me) needs to explain how R-Car sound is complex.
Then ask his DAI settings, research DMA settings, and answer.
This will happen for all user/integrater.
But, I don't want it :P

     * all settings must be correct *
     * but, it is difficult for user/beginner *

     playback = <&ssi0 &src1 &dvc0>;

     &ssi0 { dmas = <xxx>, dma-names = xxx };
     &src1 { dmas = <xxx>, dma-names = xxx };
     &dvc0 { dmas = <xxx>, dma-names = xxx };

Indeed above case needs many DMA entries on SoC DTSI file,
but, DMA entry for SSI/SRC/DVC will be decided automatically.
This case, user cares DAI only, it is very easy IMO.

     * user care only his DAI setting *

     playback = <&ssi0 &src1 &dvc0>;
     
     * it is very easy to exchange DAI setting *

     playback = <&ssi0 &src3>;

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-06-03  0:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-23  6:21 [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT Kuninori Morimoto
2014-05-23  6:24 ` [PATCH 1/6] ASoC: rsnd: DT node clean up by using the of_node_put() Kuninori Morimoto
2014-05-23  6:25 ` [PATCH 2/6] ASoC: rsnd: save platform_device instead of device Kuninori Morimoto
2014-05-23  6:25 ` [PATCH 3/6] ASoC: rsnd: remove rsnd_src_non_ops Kuninori Morimoto
2014-05-23  6:25 ` [PATCH 4/6] ASoC: rsnd: module name is unified Kuninori Morimoto
2014-05-23  6:25 ` [PATCH 5/6] ASoC: rsnd: care DMA slave channel name for DT Kuninori Morimoto
2014-06-02 21:33   ` Ben Dooks
2014-06-03  0:43     ` Kuninori Morimoto
2014-05-23  6:25 ` [PATCH 6/6] ASoC: rsnd: add rsnd_gen_dma_addr() for DMAC addr Kuninori Morimoto
2014-05-26 13:35 ` [PATCH 0/6] ASoC: rsnd: tidyup for DMA support for DT Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.