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