All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olivier Dautricourt <olivier.dautricourt@orolia.com>
To: Rob Herring <robh+dt@kernel.org>, Vinod Koul <vkoul@kernel.org>,
	Stefan Roese <sr@denx.de>
Cc: Olivier Dautricourt <olivier.dautricourt@orolia.com>,
	dmaengine@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v6 3/3] dmaengine: altera-msgdma: add OF support
Date: Wed, 9 Jun 2021 17:21:46 +0200	[thread overview]
Message-ID: <7459635ba093d87b6bf12413cf7cfe09f6e3019b.1623251990.git.olivier.dautricourt@orolia.com> (raw)
In-Reply-To: <7487a25cdb240d1be4a8593aa602c3c73d8f5acb.1623251990.git.olivier.dautricourt@orolia.com>

This driver had no device tree support.

- add compatible field "altr,socfpga-msgdma"
- register dma controller with of_dma_controller_register

Reviewed-by: Stefan Roese <sr@denx.de>
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

    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
    v6:
        use of_dma_xlate_by_chan_id and expect the dma cell to be 0 in dt (id of
        the unique channel)
        Check ret value of of_dma_controller_register
    	-EINVAL: non-dt device on OF system
    	0 or -ENODEV: success or non-of system
    	other: fail

        call of_dma_controller_free on dettach :)

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

diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
index 9a841ce5f0c5..0fe0676f8e1d 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"

@@ -888,6 +889,13 @@ static int msgdma_probe(struct platform_device *pdev)
 	if (ret)
 		goto fail;

+	ret = of_dma_controller_register(pdev->dev.of_node,
+					 of_dma_xlate_by_chan_id, dma_dev);
+	if (ret == -EINVAL)
+		dev_warn(&pdev->dev, "device was not probed from DT");
+	else if (ret && ret != -ENODEV)
+		goto fail;
+
 	dev_notice(&pdev->dev, "Altera mSGDMA driver probe success\n");

 	return 0;
@@ -908,6 +916,8 @@ static int msgdma_remove(struct platform_device *pdev)
 {
 	struct msgdma_device *mdev = platform_get_drvdata(pdev);

+	if (pdev->dev.of_node)
+		of_dma_controller_free(pdev->dev.of_node);
 	dma_async_device_unregister(&mdev->dmadev);
 	msgdma_dev_remove(mdev);

@@ -916,9 +926,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


--
Olivier Dautricourt


  parent reply	other threads:[~2021-06-09 15:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 15:20 [PATCH v6 1/3] dt-bindings: dma: add schema for altera-msgdma Olivier Dautricourt
2021-06-09 15:20 ` [PATCH v6 2/3] MAINTAINERS: add entry for Altera mSGDMA Olivier Dautricourt
2021-06-10  5:22   ` Stefan Roese
2021-06-09 15:21 ` Olivier Dautricourt [this message]
2021-06-16 10:44 ` [PATCH v6 1/3] dt-bindings: dma: add schema for altera-msgdma Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7459635ba093d87b6bf12413cf7cfe09f6e3019b.1623251990.git.olivier.dautricourt@orolia.com \
    --to=olivier.dautricourt@orolia.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sr@denx.de \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.