dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 2/2] drivers: dma: altera-msgdma: add OF support
@ 2021-04-29 14:18 Olivier Dautricourt
  2021-04-30  8:56 ` Stefan Roese
  2021-05-10 16:19 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Olivier Dautricourt @ 2021-04-29 14:18 UTC (permalink / raw)
  To: Rob Herring, Vinod Koul, Stefan Roese
  Cc: Olivier Dautricourt, dmaengine, devicetree, linux-kernel

This driver had no device tree support.

- add compatible field "altr,msgdma"
- define msgdma_of_xlate, with no argument
- register dma controller with of_dma_controller_register

Signed-off-by: Olivier Dautricourt <olivier.dautricourt@orolia.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

 drivers/dma/altera-msgdma.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
index 9a841ce5f0c5..7e58385facef 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_any_slave_channel(&d->dmadev);
+}
+
 /**
  * msgdma_probe - Driver probe function
  * @pdev: Pointer to the platform_device structure
@@ -888,6 +897,16 @@ static int msgdma_probe(struct platform_device *pdev)
 	if (ret)
 		goto fail;

+	if (IS_ENABLED(CONFIG_OF)) {
+		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 +935,19 @@ static int msgdma_remove(struct platform_device *pdev)
 	return 0;
 }

+#ifdef CONFIG_OF
+static const struct of_device_id msgdma_match[] = {
+	{ .compatible = "altr,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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v4 2/2] drivers: dma: altera-msgdma: add OF support
  2021-04-29 14:18 [PATCH v4 2/2] drivers: dma: altera-msgdma: add OF support Olivier Dautricourt
@ 2021-04-30  8:56 ` Stefan Roese
  2021-05-10 16:19 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Roese @ 2021-04-30  8:56 UTC (permalink / raw)
  To: Olivier Dautricourt, Rob Herring, Vinod Koul
  Cc: dmaengine, devicetree, linux-kernel

On 29.04.21 16:18, Olivier Dautricourt wrote:
> This driver had no device tree support.
> 
> - add compatible field "altr,msgdma"
> - define msgdma_of_xlate, with no argument
> - register dma controller with of_dma_controller_register
> 
> Signed-off-by: Olivier Dautricourt <olivier.dautricourt@orolia.com>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
> 
> 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
> 
>   drivers/dma/altera-msgdma.c | 29 +++++++++++++++++++++++++++++
>   1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
> index 9a841ce5f0c5..7e58385facef 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_any_slave_channel(&d->dmadev);
> +}
> +
>   /**
>    * msgdma_probe - Driver probe function
>    * @pdev: Pointer to the platform_device structure
> @@ -888,6 +897,16 @@ static int msgdma_probe(struct platform_device *pdev)
>   	if (ret)
>   		goto fail;
> 
> +	if (IS_ENABLED(CONFIG_OF)) {
> +		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 +935,19 @@ static int msgdma_remove(struct platform_device *pdev)
>   	return 0;
>   }
> 
> +#ifdef CONFIG_OF
> +static const struct of_device_id msgdma_match[] = {
> +	{ .compatible = "altr,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
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4 2/2] drivers: dma: altera-msgdma: add OF support
  2021-04-29 14:18 [PATCH v4 2/2] drivers: dma: altera-msgdma: add OF support Olivier Dautricourt
  2021-04-30  8:56 ` Stefan Roese
@ 2021-05-10 16:19 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2021-05-10 16:19 UTC (permalink / raw)
  To: Olivier Dautricourt
  Cc: Rob Herring, Stefan Roese, dmaengine, devicetree, linux-kernel

On 29-04-21, 16:18, Olivier Dautricourt wrote:
> This driver had no device tree support.
> 
> - add compatible field "altr,msgdma"
> - define msgdma_of_xlate, with no argument
> - register dma controller with of_dma_controller_register
> 
> Signed-off-by: Olivier Dautricourt <olivier.dautricourt@orolia.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
> 
>  drivers/dma/altera-msgdma.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
> index 9a841ce5f0c5..7e58385facef 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_any_slave_channel(&d->dmadev);

Interesting, why dma_get_any_slave_channel() dont you care for the right
slave channel which is required for your controller..?

> +}
> +
>  /**
>   * msgdma_probe - Driver probe function
>   * @pdev: Pointer to the platform_device structure
> @@ -888,6 +897,16 @@ static int msgdma_probe(struct platform_device *pdev)
>  	if (ret)
>  		goto fail;
> 
> +	if (IS_ENABLED(CONFIG_OF)) {

no need of this, it is taken care by the core

> +		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 +935,19 @@ static int msgdma_remove(struct platform_device *pdev)
>  	return 0;
>  }
> 
> +#ifdef CONFIG_OF
> +static const struct of_device_id msgdma_match[] = {
> +	{ .compatible = "altr,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

-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-10 16:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 14:18 [PATCH v4 2/2] drivers: dma: altera-msgdma: add OF support Olivier Dautricourt
2021-04-30  8:56 ` Stefan Roese
2021-05-10 16:19 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).