42d48f1
From bb3e08008c0e48fd4f51a0f0957eecae61a24d69 Mon Sep 17 00:00:00 2001
42d48f1
From: Peter Robinson <pbrobinson@gmail.com>
42d48f1
Date: Tue, 1 Nov 2016 09:35:30 +0000
42d48f1
Subject: [PATCH] Revert "mmc: omap_hsmmc: Use dma_request_chan() for
42d48f1
 requesting DMA channel"
42d48f1
42d48f1
This reverts commit 81eef6ca92014845d40e3f1310e42b7010303acc.
42d48f1
---
42d48f1
 drivers/mmc/host/omap_hsmmc.c | 50 ++++++++++++++++++++++++++++++++++---------
42d48f1
 1 file changed, 40 insertions(+), 10 deletions(-)
42d48f1
42d48f1
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
42d48f1
index 24ebc9a..3563321 100644
42d48f1
--- a/drivers/mmc/host/omap_hsmmc.c
42d48f1
+++ b/drivers/mmc/host/omap_hsmmc.c
42d48f1
@@ -32,6 +32,7 @@
42d48f1
 #include <linux/of_irq.h>
42d48f1
 #include <linux/of_gpio.h>
42d48f1
 #include <linux/of_device.h>
42d48f1
+#include <linux/omap-dmaengine.h>
42d48f1
 #include <linux/mmc/host.h>
42d48f1
 #include <linux/mmc/core.h>
42d48f1
 #include <linux/mmc/mmc.h>
42d48f1
@@ -1992,6 +1993,8 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
42d48f1
 	struct resource *res;
42d48f1
 	int ret, irq;
42d48f1
 	const struct of_device_id *match;
42d48f1
+	dma_cap_mask_t mask;
42d48f1
+	unsigned tx_req, rx_req;
42d48f1
 	const struct omap_mmc_of_data *data;
42d48f1
 	void __iomem *base;
42d48f1
 
42d48f1
@@ -2121,17 +2124,44 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
42d48f1
 
42d48f1
 	omap_hsmmc_conf_bus_power(host);
42d48f1
 
42d48f1
-	host->rx_chan = dma_request_chan(&pdev->dev, "rx");
42d48f1
-	if (IS_ERR(host->rx_chan)) {
42d48f1
-		dev_err(mmc_dev(host->mmc), "RX DMA channel request failed\n");
42d48f1
-		ret = PTR_ERR(host->rx_chan);
42d48f1
+	if (!pdev->dev.of_node) {
42d48f1
+		res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
42d48f1
+		if (!res) {
42d48f1
+			dev_err(mmc_dev(host->mmc), "cannot get DMA TX channel\n");
42d48f1
+			ret = -ENXIO;
42d48f1
+			goto err_irq;
42d48f1
+		}
42d48f1
+		tx_req = res->start;
42d48f1
+
42d48f1
+		res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
42d48f1
+		if (!res) {
42d48f1
+			dev_err(mmc_dev(host->mmc), "cannot get DMA RX channel\n");
42d48f1
+			ret = -ENXIO;
42d48f1
+			goto err_irq;
42d48f1
+		}
42d48f1
+		rx_req = res->start;
42d48f1
+	}
42d48f1
+
42d48f1
+	dma_cap_zero(mask);
42d48f1
+	dma_cap_set(DMA_SLAVE, mask);
42d48f1
+
42d48f1
+	host->rx_chan =
42d48f1
+		dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
42d48f1
+						 &rx_req, &pdev->dev, "rx");
42d48f1
+
42d48f1
+	if (!host->rx_chan) {
42d48f1
+		dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel\n");
42d48f1
+		ret = -ENXIO;
42d48f1
 		goto err_irq;
42d48f1
 	}
42d48f1
 
42d48f1
-	host->tx_chan = dma_request_chan(&pdev->dev, "tx");
42d48f1
-	if (IS_ERR(host->tx_chan)) {
42d48f1
-		dev_err(mmc_dev(host->mmc), "TX DMA channel request failed\n");
42d48f1
-		ret = PTR_ERR(host->tx_chan);
42d48f1
+	host->tx_chan =
42d48f1
+		dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
42d48f1
+						 &tx_req, &pdev->dev, "tx");
42d48f1
+
42d48f1
+	if (!host->tx_chan) {
42d48f1
+		dev_err(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel\n");
42d48f1
+		ret = -ENXIO;
42d48f1
 		goto err_irq;
42d48f1
 	}
42d48f1
 
42d48f1
@@ -2189,9 +2219,9 @@ err_slot_name:
42d48f1
 	mmc_remove_host(mmc);
42d48f1
 err_irq:
42d48f1
 	device_init_wakeup(&pdev->dev, false);
42d48f1
-	if (!IS_ERR_OR_NULL(host->tx_chan))
42d48f1
+	if (host->tx_chan)
42d48f1
 		dma_release_channel(host->tx_chan);
42d48f1
-	if (!IS_ERR_OR_NULL(host->rx_chan))
42d48f1
+	if (host->rx_chan)
42d48f1
 		dma_release_channel(host->rx_chan);
42d48f1
 	pm_runtime_dont_use_autosuspend(host->dev);
42d48f1
 	pm_runtime_put_sync(host->dev);
42d48f1
-- 
42d48f1
2.9.3
42d48f1