[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <088a373c92bdee6e24da771c1ae2e4ed0887c0d7.1621343877.git.olivier.dautricourt@orolia.com>
Date: Tue, 18 May 2021 15:25:32 +0200
From: Olivier Dautricourt <olivier.dautricourt@...lia.com>
To: Rob Herring <robh+dt@...nel.org>, Vinod Koul <vkoul@...nel.org>,
Stefan Roese <sr@...x.de>
Cc: Olivier Dautricourt <olivier.dautricourt@...lia.com>,
dmaengine@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v5 3/3] dmaengine: altera-msgdma: add OF support
This driver had no device tree support.
- add compatible field "altr,socfpga-msgdma"
- define msgdma_of_xlate, with no argument
- register dma controller with of_dma_controller_register
Reviewed-by: Stefan Roese <sr@...x.de>
Signed-off-by: Olivier Dautricourt <olivier.dautricourt@...lia.com>
---
Notes:
Changes in v2:
none
Changes from v2 to v3:
Removed CONFIG_OF #ifdef's and use if (IS_ENABLED(CONFIG_OF))
only once.
Changes from v3 to v4
Reintroduce #ifdef CONFIG_OF for msgdma_match
as it produces a unused variable warning
Changes from v4 to v5
- As per Rob's comments on patch 1/2:
change compatible field from altr,msgdma to
altr,socfpga-msgdma.
- change commit title to fit previous commits naming
- As per Vinod's comments:
- use dma_get_slave_channel instead of dma_get_any_slave_channel which
makes more sense.
- remove if (IS_ENABLED(CONFIG_OF)) for of_dma_controller_register
as it is taken care by the core
drivers/dma/altera-msgdma.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
index 9a841ce5f0c5..acf0990d73ae 100644
--- a/drivers/dma/altera-msgdma.c
+++ b/drivers/dma/altera-msgdma.c
@@ -19,6 +19,7 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
+#include <linux/of_dma.h>
#include "dmaengine.h"
@@ -784,6 +785,14 @@ static int request_and_map(struct platform_device *pdev, const char *name,
return 0;
}
+static struct dma_chan *msgdma_of_xlate(struct of_phandle_args *dma_spec,
+ struct of_dma *ofdma)
+{
+ struct msgdma_device *d = ofdma->of_dma_data;
+
+ return dma_get_slave_channel(&d->dmachan);
+}
+
/**
* msgdma_probe - Driver probe function
* @pdev: Pointer to the platform_device structure
@@ -888,6 +897,13 @@ static int msgdma_probe(struct platform_device *pdev)
if (ret)
goto fail;
+ ret = of_dma_controller_register(pdev->dev.of_node,
+ msgdma_of_xlate, mdev);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to register dma controller");
+ goto fail;
+ }
+
dev_notice(&pdev->dev, "Altera mSGDMA driver probe success\n");
return 0;
@@ -916,9 +932,19 @@ static int msgdma_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_OF
+static const struct of_device_id msgdma_match[] = {
+ { .compatible = "altr,socfpga-msgdma", },
+ { }
+};
+
+MODULE_DEVICE_TABLE(of, msgdma_match);
+#endif
+
static struct platform_driver msgdma_driver = {
.driver = {
.name = "altera-msgdma",
+ .of_match_table = of_match_ptr(msgdma_match),
},
.probe = msgdma_probe,
.remove = msgdma_remove,
--
2.31.0.rc2
Powered by blists - more mailing lists