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