Skip to contentSkip to conversation

dmaengine: xgene-dma: Add ACPI support for X-Gene DMA engine driver

PATCH Applied Rameshwar Prasad Sahu 3 participants 7 messages Jul 21, 2015 – Aug 20, 2015 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: xgene-dma: Add ACPI support for X-Gene DMA engine driver

This patch adds ACPI support for the APM X-Gene DMA engine driver.

---
 drivers/dma/xgene-dma.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/dma/xgene-dma.c +21 -7
index dff22ab..d0a148d 100644
@@ -21,6 +21,7 @@
  * NOTE: PM support is currently not available.
  */
 
+#include <linux/acpi.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
@@ -1944,16 +1945,18 @@ static int xgene_dma_probe(struct platform_device *pdev)
 		return ret;
 
 	pdma->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(pdma->clk)) {
+	if (IS_ERR(pdma->clk) && !ACPI_COMPANION(&pdev->dev)) {
 		dev_err(&pdev->dev, "Failed to get clk\n");
 		return PTR_ERR(pdma->clk);
 	}
 
 	/* Enable clk before accessing registers */
-	ret = clk_prepare_enable(pdma->clk);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to enable clk %d\n", ret);
-		return ret;
+	if (!IS_ERR(pdma->clk)) {
+		ret = clk_prepare_enable(pdma->clk);
+		if (ret) {
+			dev_err(&pdev->dev, "Failed to enable clk %d\n", ret);
+			return ret;
+		}
 	}
 
 	/* Remove DMA RAM out of shutdown */
@@ -1998,7 +2001,8 @@ err_request_irq:
 
 err_dma_mask:
 err_clk_enable:
-	clk_disable_unprepare(pdma->clk);
+	if (!IS_ERR(pdma->clk))
+		clk_disable_unprepare(pdma->clk);
 
 	return ret;
 }
@@ -2022,11 +2026,20 @@ static int xgene_dma_remove(struct platform_device *pdev)
 		xgene_dma_delete_chan_rings(chan);
 	}
 
-	clk_disable_unprepare(pdma->clk);
+	if (!IS_ERR(pdma->clk))
+		clk_disable_unprepare(pdma->clk);
 
 	return 0;
 }
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id xgene_dma_acpi_match_ptr[] = {
+	{"APMC0D43", 0},
+	{},
+};
+MODULE_DEVICE_TABLE(acpi, xgene_dma_acpi_match_ptr);
+#endif
+
 static const struct of_device_id xgene_dma_of_match_ptr[] = {
 	{.compatible = "apm,xgene-storm-dma",},
 	{},
@@ -2039,6 +2052,7 @@ static struct platform_driver xgene_dma_driver = {
 	.driver = {
 		.name = "X-Gene-DMA",
 		.of_match_table = xgene_dma_of_match_ptr,
+		.acpi_match_table = ACPI_PTR(xgene_dma_acpi_match_ptr),
 	},
 };
 

--
1.8.2.1

#1 lore raw

Hi Vinod,

Quoted 84 lines · Rameshwar Prasad Sahu

This patch adds ACPI support for the APM X-Gene DMA engine driver.

---
 drivers/dma/xgene-dma.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/dma/xgene-dma.c +21 -8
index dff22ab..d0a148d 100644
@@ -21,6 +21,7 @@
  * NOTE: PM support is currently not available.
  */
 
+#include <linux/acpi.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
@@ -1944,16 +1945,18 @@ static int xgene_dma_probe(struct platform_device *pdev)
                return ret;
 
        pdma->clk = devm_clk_get(&pdev->dev, NULL);
-       if (IS_ERR(pdma->clk)) {
+       if (IS_ERR(pdma->clk) && !ACPI_COMPANION(&pdev->dev)) {
                dev_err(&pdev->dev, "Failed to get clk\n");
                return PTR_ERR(pdma->clk);
        }
 
        /* Enable clk before accessing registers */
-       ret = clk_prepare_enable(pdma->clk);
-       if (ret) {
-               dev_err(&pdev->dev, "Failed to enable clk %d\n", ret);
-               return ret;
+       if (!IS_ERR(pdma->clk)) {
+               ret = clk_prepare_enable(pdma->clk);
+               if (ret) {
+                       dev_err(&pdev->dev, "Failed to enable clk %d\n", ret);
+                       return ret;
+               }
        }
 
        /* Remove DMA RAM out of shutdown */
@@ -1998,7 +2001,8 @@ err_request_irq:
 
 err_dma_mask:
 err_clk_enable:
-       clk_disable_unprepare(pdma->clk);
+       if (!IS_ERR(pdma->clk))
+               clk_disable_unprepare(pdma->clk);
 
        return ret;
 }
@@ -2022,11 +2026,20 @@ static int xgene_dma_remove(struct platform_device *pdev)
                xgene_dma_delete_chan_rings(chan);
        }
 
-       clk_disable_unprepare(pdma->clk);
+       if (!IS_ERR(pdma->clk))
+               clk_disable_unprepare(pdma->clk);
 
        return 0;
 }
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id xgene_dma_acpi_match_ptr[] = {
+       {"APMC0D43", 0},
+       {},
+};
+MODULE_DEVICE_TABLE(acpi, xgene_dma_acpi_match_ptr);
+#endif
+
 static const struct of_device_id xgene_dma_of_match_ptr[] = {
        {.compatible = "apm,xgene-storm-dma",},
        {},
@@ -2039,6 +2052,7 @@ static struct platform_driver xgene_dma_driver = {
        .driver = {
                .name = "X-Gene-DMA",
                .of_match_table = xgene_dma_of_match_ptr,
+               .acpi_match_table = ACPI_PTR(xgene_dma_acpi_match_ptr),
        },
 };
 
--
Quoted 1 line

1.8.2.1

Any comment here ??

#3 lore raw

Hi Arnd,

Quoted 7 lines · Arnd Bergmann
Quoted 4 lines · On Tuesday 21 July 2015 18:44:39 Rameshwar Prasad Sahu wrote:

This patch adds ACPI support for the APM X-Gene DMA engine driver.

How does a slave driver refer to a channel in case of ACPI?

We don't support slave dma here. This driver supports only memcp, xor, pq, scatter-gather offloading, so,
client driver can use linux dmaengine APIs like dma_request_channel() etc to request channel.

Quoted 6 lines

Arnd
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 9 lines · On Thursday 30 July 2015 14:21:07 Rameshwar Sahu wrote:

Hi Arnd,

Quoted 6 lines · Arnd Bergmann
Quoted 4 lines · On Tuesday 21 July 2015 18:44:39 Rameshwar Prasad Sahu wrote:

This patch adds ACPI support for the APM X-Gene DMA engine driver.

Quoted 6 lines
Quoted 1 line

How does a slave driver refer to a channel in case of ACPI?

We don't support slave dma here. This driver supports only memcp, xor, pq, scatter-gather offloading, so,
client driver can use linux dmaengine APIs like dma_request_channel() etc to request channel.

Ok, makes sense. Thanks!

Arnd

#5 lore raw
In reply to Rameshwar Prasad Sahu

Hi Vinod,

Quoted 84 lines · Rameshwar Prasad Sahu

This patch adds ACPI support for the APM X-Gene DMA engine driver.

---
 drivers/dma/xgene-dma.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/dma/xgene-dma.c +21 -8
index dff22ab..d0a148d 100644
@@ -21,6 +21,7 @@
  * NOTE: PM support is currently not available.
  */
 
+#include <linux/acpi.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
@@ -1944,16 +1945,18 @@ static int xgene_dma_probe(struct platform_device *pdev)
                return ret;
 
        pdma->clk = devm_clk_get(&pdev->dev, NULL);
-       if (IS_ERR(pdma->clk)) {
+       if (IS_ERR(pdma->clk) && !ACPI_COMPANION(&pdev->dev)) {
                dev_err(&pdev->dev, "Failed to get clk\n");
                return PTR_ERR(pdma->clk);
        }
 
        /* Enable clk before accessing registers */
-       ret = clk_prepare_enable(pdma->clk);
-       if (ret) {
-               dev_err(&pdev->dev, "Failed to enable clk %d\n", ret);
-               return ret;
+       if (!IS_ERR(pdma->clk)) {
+               ret = clk_prepare_enable(pdma->clk);
+               if (ret) {
+                       dev_err(&pdev->dev, "Failed to enable clk %d\n", ret);
+                       return ret;
+               }
        }
 
        /* Remove DMA RAM out of shutdown */
@@ -1998,7 +2001,8 @@ err_request_irq:
 
 err_dma_mask:
 err_clk_enable:
-       clk_disable_unprepare(pdma->clk);
+       if (!IS_ERR(pdma->clk))
+               clk_disable_unprepare(pdma->clk);
 
        return ret;
 }
@@ -2022,11 +2026,20 @@ static int xgene_dma_remove(struct platform_device *pdev)
                xgene_dma_delete_chan_rings(chan);
        }
 
-       clk_disable_unprepare(pdma->clk);
+       if (!IS_ERR(pdma->clk))
+               clk_disable_unprepare(pdma->clk);
 
        return 0;
 }
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id xgene_dma_acpi_match_ptr[] = {
+       {"APMC0D43", 0},
+       {},
+};
+MODULE_DEVICE_TABLE(acpi, xgene_dma_acpi_match_ptr);
+#endif
+
 static const struct of_device_id xgene_dma_of_match_ptr[] = {
        {.compatible = "apm,xgene-storm-dma",},
        {},
@@ -2039,6 +2052,7 @@ static struct platform_driver xgene_dma_driver = {
        .driver = {
                .name = "X-Gene-DMA",
                .of_match_table = xgene_dma_of_match_ptr,
+               .acpi_match_table = ACPI_PTR(xgene_dma_acpi_match_ptr),
        },
 };
 
--
Quoted 1 line

1.8.2.1

Any Comments on the above patch ??