devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] mmc: MMCIF & SDHI: DT DMA support
@ 2013-06-06 15:46 Guennadi Liakhovetski
  2013-06-06 15:46 ` [PATCH 1/4] mmc: sh_mmcif: add support for Device Tree DMA bindings Guennadi Liakhovetski
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2013-06-06 15:46 UTC (permalink / raw)
  To: linux-sh
  Cc: Vinod Koul, Chris Ball, linux-mmc, devicetree-discuss,
	Rob Herring, Grant Likely, Magnus Damm, Simon Horman,
	Guennadi Liakhovetski

Also a re-send of four earlier submitted patches. This patch-series alone 
is not enough to support DMA in DT on these MMC host controllers, support 
in appropriate DMAC driver is added in a separate series. This, however, 
doesn't introduce a dependency, series can be applied in arbitrary order.

Cc: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>

Guennadi Liakhovetski (4):
  mmc: sh_mmcif: add support for Device Tree DMA bindings
  mmc: sdhi/tmio: make DMA filter implementation specific
  mmc: sdhi/tmio: switch to using dmaengine_slave_config()
  mmc: sdhi/tmio: add DT DMA support

 drivers/mmc/host/sh_mmcif.c       |   29 ++++++++++++++--------
 drivers/mmc/host/sh_mobile_sdhi.c |   24 ++++++++++++------
 drivers/mmc/host/tmio_mmc_dma.c   |   48 +++++++++++++++++++++++++++----------
 include/linux/mfd/tmio.h          |    5 ++++
 4 files changed, 74 insertions(+), 32 deletions(-)

-- 
1.7.2.5

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

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

* [PATCH 1/4] mmc: sh_mmcif: add support for Device Tree DMA bindings
  2013-06-06 15:46 [PATCH 0/4] mmc: MMCIF & SDHI: DT DMA support Guennadi Liakhovetski
@ 2013-06-06 15:46 ` Guennadi Liakhovetski
  2013-06-06 16:38   ` Sergei Shtylyov
  2013-06-06 15:46 ` [PATCH 2/4] mmc: sdhi/tmio: make DMA filter implementation specific Guennadi Liakhovetski
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Guennadi Liakhovetski @ 2013-06-06 15:46 UTC (permalink / raw)
  To: linux-sh
  Cc: Vinod Koul, Chris Ball, linux-mmc, devicetree-discuss,
	Rob Herring, Grant Likely, Magnus Damm, Simon Horman,
	Guennadi Liakhovetski

To use DMA in the Device Tree case the driver has to be modified
to use suitable API to obtain DMA channels.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
---
 drivers/mmc/host/sh_mmcif.c |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 06caaae..a0937ae 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -386,25 +386,30 @@ static void sh_mmcif_request_dma(struct sh_mmcif_host *host,
 
 	host->dma_active = false;
 
-	if (!pdata)
-		return;
-
-	if (pdata->slave_id_tx <= 0 || pdata->slave_id_rx <= 0)
-		return;
+	if (pdata) {
+		if (pdata->slave_id_tx <= 0 || pdata->slave_id_rx <= 0)
+			return;
+	} else {
+		if (!host->pd->dev.of_node)
+			return;
+	}
 
 	/* We can only either use DMA for both Tx and Rx or not use it at all */
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
 
-	host->chan_tx = dma_request_channel(mask, shdma_chan_filter,
-					    (void *)pdata->slave_id_tx);
+	host->chan_tx = dma_request_slave_channel_compat(mask, shdma_chan_filter,
+				pdata ? (void *)pdata->slave_id_tx : NULL,
+				&host->pd->dev, "tx");
 	dev_dbg(&host->pd->dev, "%s: TX: got channel %p\n", __func__,
 		host->chan_tx);
 
 	if (!host->chan_tx)
 		return;
 
-	cfg.slave_id = pdata->slave_id_tx;
+	/* In the OF case the driver will get the slave ID from the DT */
+	if (pdata)
+		cfg.slave_id = pdata->slave_id_tx;
 	cfg.direction = DMA_MEM_TO_DEV;
 	cfg.dst_addr = res->start + MMCIF_CE_DATA;
 	cfg.src_addr = 0;
@@ -412,15 +417,17 @@ static void sh_mmcif_request_dma(struct sh_mmcif_host *host,
 	if (ret < 0)
 		goto ecfgtx;
 
-	host->chan_rx = dma_request_channel(mask, shdma_chan_filter,
-					    (void *)pdata->slave_id_rx);
+	host->chan_rx = dma_request_slave_channel_compat(mask, shdma_chan_filter,
+				pdata ? (void *)pdata->slave_id_rx : NULL,
+				&host->pd->dev, "rx");
 	dev_dbg(&host->pd->dev, "%s: RX: got channel %p\n", __func__,
 		host->chan_rx);
 
 	if (!host->chan_rx)
 		goto erqrx;
 
-	cfg.slave_id = pdata->slave_id_rx;
+	if (pdata)
+		cfg.slave_id = pdata->slave_id_rx;
 	cfg.direction = DMA_DEV_TO_MEM;
 	cfg.dst_addr = 0;
 	cfg.src_addr = res->start + MMCIF_CE_DATA;
-- 
1.7.2.5


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

* [PATCH 2/4] mmc: sdhi/tmio: make DMA filter implementation specific
  2013-06-06 15:46 [PATCH 0/4] mmc: MMCIF & SDHI: DT DMA support Guennadi Liakhovetski
  2013-06-06 15:46 ` [PATCH 1/4] mmc: sh_mmcif: add support for Device Tree DMA bindings Guennadi Liakhovetski
@ 2013-06-06 15:46 ` Guennadi Liakhovetski
       [not found] ` <1370533588-23642-1-git-send-email-g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
  2013-06-06 15:46 ` [PATCH 4/4] mmc: sdhi/tmio: add DT DMA support Guennadi Liakhovetski
  3 siblings, 0 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2013-06-06 15:46 UTC (permalink / raw)
  To: linux-sh
  Cc: Vinod Koul, Chris Ball, linux-mmc, devicetree-discuss,
	Rob Herring, Grant Likely, Magnus Damm, Simon Horman,
	Samuel Ortiz, Guennadi Liakhovetski

So far only the SDHI implementation uses TMIO MMC with DMA. That way a DMA
channel filter function, defined in the TMIO driver wasn't a problem.
However, such a filter function is DMA controller specific. Since the SDHI
glue is only running on systems with the SHDMA DMA controller, the filter
function can safely be provided by it. Move it into SDHI.

Cc: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c |    9 +++++++++
 drivers/mmc/host/tmio_mmc_dma.c   |   12 ++----------
 include/linux/mfd/tmio.h          |    3 +++
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index fe90853..e0088d7 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -20,6 +20,7 @@
 
 #include <linux/kernel.h>
 #include <linux/clk.h>
+#include <linux/dmaengine.h>
 #include <linux/slab.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
@@ -124,6 +125,13 @@ static void sh_mobile_sdhi_cd_wakeup(const struct platform_device *pdev)
 	mmc_detect_change(dev_get_drvdata(&pdev->dev), msecs_to_jiffies(100));
 }
 
+static bool sh_mobile_sdhi_filter(struct dma_chan *chan, void *arg)
+{
+	dev_dbg(chan->device->dev, "%s: slave data %p\n", __func__, arg);
+	chan->private = arg;
+	return true;
+}
+
 static const struct sh_mobile_sdhi_ops sdhi_ops = {
 	.cd_wakeup = sh_mobile_sdhi_cd_wakeup,
 };
@@ -191,6 +199,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 			priv->dma_priv.chan_priv_tx = &priv->param_tx.shdma_slave;
 			priv->dma_priv.chan_priv_rx = &priv->param_rx.shdma_slave;
 			priv->dma_priv.alignment_shift = 1; /* 2-byte alignment */
+			priv->dma_priv.filter = sh_mobile_sdhi_filter;
 			mmc_data->dma = &priv->dma_priv;
 		}
 	}
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
index fff9286..dc4b10b 100644
--- a/drivers/mmc/host/tmio_mmc_dma.c
+++ b/drivers/mmc/host/tmio_mmc_dma.c
@@ -261,14 +261,6 @@ out:
 	spin_unlock_irq(&host->lock);
 }
 
-/* It might be necessary to make filter MFD specific */
-static bool tmio_mmc_filter(struct dma_chan *chan, void *arg)
-{
-	dev_dbg(chan->device->dev, "%s: slave data %p\n", __func__, arg);
-	chan->private = arg;
-	return true;
-}
-
 void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata)
 {
 	/* We can only either use DMA for both Tx and Rx or not use it at all */
@@ -281,7 +273,7 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
 		dma_cap_zero(mask);
 		dma_cap_set(DMA_SLAVE, mask);
 
-		host->chan_tx = dma_request_channel(mask, tmio_mmc_filter,
+		host->chan_tx = dma_request_channel(mask, pdata->dma->filter,
 						    pdata->dma->chan_priv_tx);
 		dev_dbg(&host->pdev->dev, "%s: TX: got channel %p\n", __func__,
 			host->chan_tx);
@@ -289,7 +281,7 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
 		if (!host->chan_tx)
 			return;
 
-		host->chan_rx = dma_request_channel(mask, tmio_mmc_filter,
+		host->chan_rx = dma_request_channel(mask, pdata->dma->filter,
 						    pdata->dma->chan_priv_rx);
 		dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__,
 			host->chan_rx);
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index 99bf3e66..0990d8a 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -81,10 +81,13 @@ int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base);
 void tmio_core_mmc_pwr(void __iomem *cnf, int shift, int state);
 void tmio_core_mmc_clk_div(void __iomem *cnf, int shift, int state);
 
+struct dma_chan;
+
 struct tmio_mmc_dma {
 	void *chan_priv_tx;
 	void *chan_priv_rx;
 	int alignment_shift;
+	bool (*filter)(struct dma_chan *chan, void *arg);
 };
 
 struct tmio_mmc_host;
-- 
1.7.2.5


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

* [PATCH 3/4] mmc: sdhi/tmio: switch to using dmaengine_slave_config()
       [not found] ` <1370533588-23642-1-git-send-email-g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
@ 2013-06-06 15:46   ` Guennadi Liakhovetski
  0 siblings, 0 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2013-06-06 15:46 UTC (permalink / raw)
  To: linux-sh-u79uwXL29TY76Z2rM5mHXA
  Cc: Samuel Ortiz, Vinod Koul, Magnus Damm,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Simon Horman,
	Chris Ball, Guennadi Liakhovetski

This removes the deprecated use of the .private member of struct dma_chan
and switches the sdhi / tmio mmc driver to using the
dmaengine_slave_config() channel configuration method.

Cc: Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Acked-by: Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/mmc/host/sh_mobile_sdhi.c |   33 ++++++++++++++++-----------------
 drivers/mmc/host/tmio_mmc_dma.c   |   25 +++++++++++++++++++++++++
 include/linux/mfd/tmio.h          |    2 ++
 3 files changed, 43 insertions(+), 17 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index e0088d7..7f45f62 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -20,7 +20,6 @@
 
 #include <linux/kernel.h>
 #include <linux/clk.h>
-#include <linux/dmaengine.h>
 #include <linux/slab.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
@@ -47,8 +46,6 @@ static const struct sh_mobile_sdhi_of_data sh_mobile_sdhi_of_cfg[] = {
 struct sh_mobile_sdhi {
 	struct clk *clk;
 	struct tmio_mmc_data mmc_data;
-	struct sh_dmae_slave param_tx;
-	struct sh_dmae_slave param_rx;
 	struct tmio_mmc_dma dma_priv;
 };
 
@@ -125,13 +122,6 @@ static void sh_mobile_sdhi_cd_wakeup(const struct platform_device *pdev)
 	mmc_detect_change(dev_get_drvdata(&pdev->dev), msecs_to_jiffies(100));
 }
 
-static bool sh_mobile_sdhi_filter(struct dma_chan *chan, void *arg)
-{
-	dev_dbg(chan->device->dev, "%s: slave data %p\n", __func__, arg);
-	chan->private = arg;
-	return true;
-}
-
 static const struct sh_mobile_sdhi_ops sdhi_ops = {
 	.cd_wakeup = sh_mobile_sdhi_cd_wakeup,
 };
@@ -194,13 +184,22 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 			mmc_data->get_cd = sh_mobile_sdhi_get_cd;
 
 		if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) {
-			priv->param_tx.shdma_slave.slave_id = p->dma_slave_tx;
-			priv->param_rx.shdma_slave.slave_id = p->dma_slave_rx;
-			priv->dma_priv.chan_priv_tx = &priv->param_tx.shdma_slave;
-			priv->dma_priv.chan_priv_rx = &priv->param_rx.shdma_slave;
-			priv->dma_priv.alignment_shift = 1; /* 2-byte alignment */
-			priv->dma_priv.filter = sh_mobile_sdhi_filter;
-			mmc_data->dma = &priv->dma_priv;
+			struct tmio_mmc_dma *dma_priv = &priv->dma_priv;
+
+			/*
+			 * Yes, we have to provide slave IDs twice to TMIO:
+			 * once as a filter parameter and once for channel
+			 * configuration as an explicit slave ID
+			 */
+			dma_priv->chan_priv_tx = (void *)p->dma_slave_tx;
+			dma_priv->chan_priv_rx = (void *)p->dma_slave_rx;
+			dma_priv->slave_id_tx = p->dma_slave_tx;
+			dma_priv->slave_id_rx = p->dma_slave_rx;
+
+			dma_priv->alignment_shift = 1; /* 2-byte alignment */
+			dma_priv->filter = shdma_chan_filter;
+
+			mmc_data->dma = dma_priv;
 		}
 	}
 
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
index dc4b10b..5fcf14f 100644
--- a/drivers/mmc/host/tmio_mmc_dma.c
+++ b/drivers/mmc/host/tmio_mmc_dma.c
@@ -268,7 +268,14 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
 		return;
 
 	if (!host->chan_tx && !host->chan_rx) {
+		struct resource *res = platform_get_resource(host->pdev,
+							     IORESOURCE_MEM, 0);
+		struct dma_slave_config cfg = {};
 		dma_cap_mask_t mask;
+		int ret;
+
+		if (!res)
+			return;
 
 		dma_cap_zero(mask);
 		dma_cap_set(DMA_SLAVE, mask);
@@ -281,6 +288,14 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
 		if (!host->chan_tx)
 			return;
 
+		cfg.slave_id = pdata->dma->slave_id_tx;
+		cfg.direction = DMA_MEM_TO_DEV;
+		cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->bus_shift);
+		cfg.src_addr = 0;
+		ret = dmaengine_slave_config(host->chan_tx, &cfg);
+		if (ret < 0)
+			goto ecfgtx;
+
 		host->chan_rx = dma_request_channel(mask, pdata->dma->filter,
 						    pdata->dma->chan_priv_rx);
 		dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__,
@@ -289,6 +304,14 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
 		if (!host->chan_rx)
 			goto ereqrx;
 
+		cfg.slave_id = pdata->dma->slave_id_rx;
+		cfg.direction = DMA_DEV_TO_MEM;
+		cfg.src_addr = cfg.dst_addr;
+		cfg.dst_addr = 0;
+		ret = dmaengine_slave_config(host->chan_rx, &cfg);
+		if (ret < 0)
+			goto ecfgrx;
+
 		host->bounce_buf = (u8 *)__get_free_page(GFP_KERNEL | GFP_DMA);
 		if (!host->bounce_buf)
 			goto ebouncebuf;
@@ -302,9 +325,11 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
 	return;
 
 ebouncebuf:
+ecfgrx:
 	dma_release_channel(host->chan_rx);
 	host->chan_rx = NULL;
 ereqrx:
+ecfgtx:
 	dma_release_channel(host->chan_tx);
 	host->chan_tx = NULL;
 }
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index 0990d8a..ce35113 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -86,6 +86,8 @@ struct dma_chan;
 struct tmio_mmc_dma {
 	void *chan_priv_tx;
 	void *chan_priv_rx;
+	int slave_id_tx;
+	int slave_id_rx;
 	int alignment_shift;
 	bool (*filter)(struct dma_chan *chan, void *arg);
 };
-- 
1.7.2.5

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

* [PATCH 4/4] mmc: sdhi/tmio: add DT DMA support
  2013-06-06 15:46 [PATCH 0/4] mmc: MMCIF & SDHI: DT DMA support Guennadi Liakhovetski
                   ` (2 preceding siblings ...)
       [not found] ` <1370533588-23642-1-git-send-email-g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
@ 2013-06-06 15:46 ` Guennadi Liakhovetski
  3 siblings, 0 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2013-06-06 15:46 UTC (permalink / raw)
  To: linux-sh
  Cc: Vinod Koul, Chris Ball, linux-mmc, devicetree-discuss,
	Rob Herring, Grant Likely, Magnus Damm, Simon Horman,
	Guennadi Liakhovetski

Add support for initialising DMA from the Device Tree.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
---
 drivers/mmc/host/sh_mobile_sdhi.c |   14 +++++++-------
 drivers/mmc/host/tmio_mmc_dma.c   |   19 ++++++++++++-------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 7f45f62..cc4c872 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -144,6 +144,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 	struct tmio_mmc_host *host;
 	int irq, ret, i = 0;
 	bool multiplexed_isr = true;
+	struct tmio_mmc_dma *dma_priv;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(struct sh_mobile_sdhi), GFP_KERNEL);
 	if (priv == NULL) {
@@ -152,6 +153,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 	}
 
 	mmc_data = &priv->mmc_data;
+	dma_priv = &priv->dma_priv;
 
 	if (p) {
 		if (p->init) {
@@ -184,8 +186,6 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 			mmc_data->get_cd = sh_mobile_sdhi_get_cd;
 
 		if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) {
-			struct tmio_mmc_dma *dma_priv = &priv->dma_priv;
-
 			/*
 			 * Yes, we have to provide slave IDs twice to TMIO:
 			 * once as a filter parameter and once for channel
@@ -195,14 +195,14 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 			dma_priv->chan_priv_rx = (void *)p->dma_slave_rx;
 			dma_priv->slave_id_tx = p->dma_slave_tx;
 			dma_priv->slave_id_rx = p->dma_slave_rx;
-
-			dma_priv->alignment_shift = 1; /* 2-byte alignment */
-			dma_priv->filter = shdma_chan_filter;
-
-			mmc_data->dma = dma_priv;
 		}
 	}
 
+	dma_priv->alignment_shift = 1; /* 2-byte alignment */
+	dma_priv->filter = shdma_chan_filter;
+
+	mmc_data->dma = dma_priv;
+
 	/*
 	 * All SDHI blocks support 2-byte and larger block sizes in 4-bit
 	 * bus width mode.
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
index 5fcf14f..47bdb8f 100644
--- a/drivers/mmc/host/tmio_mmc_dma.c
+++ b/drivers/mmc/host/tmio_mmc_dma.c
@@ -264,7 +264,8 @@ out:
 void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata)
 {
 	/* We can only either use DMA for both Tx and Rx or not use it at all */
-	if (!pdata->dma)
+	if (!pdata->dma || (!host->pdev->dev.of_node &&
+		(!pdata->dma->chan_priv_tx || !pdata->dma->chan_priv_rx)))
 		return;
 
 	if (!host->chan_tx && !host->chan_rx) {
@@ -280,15 +281,17 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
 		dma_cap_zero(mask);
 		dma_cap_set(DMA_SLAVE, mask);
 
-		host->chan_tx = dma_request_channel(mask, pdata->dma->filter,
-						    pdata->dma->chan_priv_tx);
+		host->chan_tx = dma_request_slave_channel_compat(mask,
+					pdata->dma->filter, pdata->dma->chan_priv_tx,
+					&host->pdev->dev, "tx");
 		dev_dbg(&host->pdev->dev, "%s: TX: got channel %p\n", __func__,
 			host->chan_tx);
 
 		if (!host->chan_tx)
 			return;
 
-		cfg.slave_id = pdata->dma->slave_id_tx;
+		if (pdata->dma->chan_priv_tx)
+			cfg.slave_id = pdata->dma->slave_id_tx;
 		cfg.direction = DMA_MEM_TO_DEV;
 		cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->bus_shift);
 		cfg.src_addr = 0;
@@ -296,15 +299,17 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
 		if (ret < 0)
 			goto ecfgtx;
 
-		host->chan_rx = dma_request_channel(mask, pdata->dma->filter,
-						    pdata->dma->chan_priv_rx);
+		host->chan_rx = dma_request_slave_channel_compat(mask,
+					pdata->dma->filter, pdata->dma->chan_priv_rx,
+					&host->pdev->dev, "rx");
 		dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__,
 			host->chan_rx);
 
 		if (!host->chan_rx)
 			goto ereqrx;
 
-		cfg.slave_id = pdata->dma->slave_id_rx;
+		if (pdata->dma->chan_priv_rx)
+			cfg.slave_id = pdata->dma->slave_id_rx;
 		cfg.direction = DMA_DEV_TO_MEM;
 		cfg.src_addr = cfg.dst_addr;
 		cfg.dst_addr = 0;
-- 
1.7.2.5


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

* Re: [PATCH 1/4] mmc: sh_mmcif: add support for Device Tree DMA bindings
  2013-06-06 15:46 ` [PATCH 1/4] mmc: sh_mmcif: add support for Device Tree DMA bindings Guennadi Liakhovetski
@ 2013-06-06 16:38   ` Sergei Shtylyov
  0 siblings, 0 replies; 6+ messages in thread
From: Sergei Shtylyov @ 2013-06-06 16:38 UTC (permalink / raw)
  To: Guennadi Liakhovetski
  Cc: linux-sh, Vinod Koul, Chris Ball, linux-mmc, devicetree-discuss,
	Rob Herring, Grant Likely, Magnus Damm, Simon Horman,
	Guennadi Liakhovetski

Hello.

On 06/06/2013 07:46 PM, Guennadi Liakhovetski wrote:

> To use DMA in the Device Tree case the driver has to be modified
> to use suitable API to obtain DMA channels.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
> ---
>   drivers/mmc/host/sh_mmcif.c |   29 ++++++++++++++++++-----------
>   1 files changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
> index 06caaae..a0937ae 100644
> --- a/drivers/mmc/host/sh_mmcif.c
> +++ b/drivers/mmc/host/sh_mmcif.c
> @@ -386,25 +386,30 @@ static void sh_mmcif_request_dma(struct sh_mmcif_host *host,
>   
>   	host->dma_active = false;
>   
> -	if (!pdata)
> -		return;
> -
> -	if (pdata->slave_id_tx <= 0 || pdata->slave_id_rx <= 0)
> -		return;
> +	if (pdata) {
> +		if (pdata->slave_id_tx <= 0 || pdata->slave_id_rx <= 0)
> +			return;
> +	} else {
> +		if (!host->pd->dev.of_node)

   Why not *else if*?

> +			return;
> +	}
>   
>   	/* We can only either use DMA for both Tx and Rx or not use it at all */
>   	dma_cap_zero(mask);
>   	dma_cap_set(DMA_SLAVE, mask);
>   
> -	host->chan_tx = dma_request_channel(mask, shdma_chan_filter,
> -					    (void *)pdata->slave_id_tx);
> +	host->chan_tx = dma_request_slave_channel_compat(mask, shdma_chan_filter,
> +				pdata ? (void *)pdata->slave_id_tx : NULL,
> +				&host->pd->dev, "tx");

    Could you leave the indentation unchanged here?

> @@ -412,15 +417,17 @@ static void sh_mmcif_request_dma(struct sh_mmcif_host *host,
>   	if (ret < 0)
>   		goto ecfgtx;
>   
> -	host->chan_rx = dma_request_channel(mask, shdma_chan_filter,
> -					    (void *)pdata->slave_id_rx);
> +	host->chan_rx = dma_request_slave_channel_compat(mask, shdma_chan_filter,
> +				pdata ? (void *)pdata->slave_id_rx : NULL,
> +				&host->pd->dev, "rx");

    ... and here?

WBR, Sergei


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

end of thread, other threads:[~2013-06-06 16:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-06 15:46 [PATCH 0/4] mmc: MMCIF & SDHI: DT DMA support Guennadi Liakhovetski
2013-06-06 15:46 ` [PATCH 1/4] mmc: sh_mmcif: add support for Device Tree DMA bindings Guennadi Liakhovetski
2013-06-06 16:38   ` Sergei Shtylyov
2013-06-06 15:46 ` [PATCH 2/4] mmc: sdhi/tmio: make DMA filter implementation specific Guennadi Liakhovetski
     [not found] ` <1370533588-23642-1-git-send-email-g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
2013-06-06 15:46   ` [PATCH 3/4] mmc: sdhi/tmio: switch to using dmaengine_slave_config() Guennadi Liakhovetski
2013-06-06 15:46 ` [PATCH 4/4] mmc: sdhi/tmio: add DT DMA support Guennadi Liakhovetski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).