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