diff mbox

[V2,2/2] dmaengine: OMAP: Register SDMA controller with Device Tree DMA driver

Message ID 1360285506-22354-3-git-send-email-jon-hunter@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hunter, Jon Feb. 8, 2013, 1:05 a.m. UTC
If the device-tree blob is present during boot, then register the SDMA
controller with the device-tree DMA driver so that we can use device-tree
to look-up DMA client information.

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
---
 arch/arm/mach-omap2/dma.c |    4 ++++
 drivers/dma/omap-dma.c    |   37 +++++++++++++++++++++++++++++++++++--
 2 files changed, 39 insertions(+), 2 deletions(-)

Comments

Felipe Balbi Feb. 8, 2013, 7:55 a.m. UTC | #1
Hi,

On Thu, Feb 07, 2013 at 07:05:06PM -0600, Jon Hunter wrote:
> If the device-tree blob is present during boot, then register the SDMA
> controller with the device-tree DMA driver so that we can use device-tree
> to look-up DMA client information.
> 
> Signed-off-by: Jon Hunter <jon-hunter@ti.com>

single comment below, other than that:

Reviewed-by: Felipe Balbi <balbi@ti.com>

> ---
>  arch/arm/mach-omap2/dma.c |    4 ++++
>  drivers/dma/omap-dma.c    |   37 +++++++++++++++++++++++++++++++++++--
>  2 files changed, 39 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/dma.c b/arch/arm/mach-omap2/dma.c
> index 5cd8d76..71dadff 100644
> --- a/arch/arm/mach-omap2/dma.c
> +++ b/arch/arm/mach-omap2/dma.c
> @@ -28,6 +28,7 @@
>  #include <linux/init.h>
>  #include <linux/device.h>
>  #include <linux/dma-mapping.h>
> +#include <linux/of.h>
>  #include <linux/omap-dma.h>
>  
>  #include "soc.h"
> @@ -304,6 +305,9 @@ static int __init omap2_system_dma_init(void)
>  	if (res)
>  		return res;
>  
> +	if (of_have_populated_dt())
> +		return res;
> +
>  	pdev = platform_device_register_full(&omap_dma_dev_info);
>  	if (IS_ERR(pdev))
>  		return PTR_ERR(pdev);
> diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
> index c4b4fd2..0067bd0 100644
> --- a/drivers/dma/omap-dma.c
> +++ b/drivers/dma/omap-dma.c
> @@ -16,6 +16,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  #include <linux/spinlock.h>
> +#include <linux/of_dma.h>
> +#include <linux/of_device.h>
>  
>  #include "virt-dma.h"
>  
> @@ -67,6 +69,8 @@ static const unsigned es_bytes[] = {
>  	[OMAP_DMA_DATA_TYPE_S32] = 4,
>  };
>  
> +static struct of_dma_filter_info info;

Arnd also mentioned that since all fields belonging to this are
constant, you could statically initialize them here. He also mentioned
you should call this by a more descriptive name:
Hunter, Jon Feb. 8, 2013, 3:05 p.m. UTC | #2
On 02/08/2013 01:55 AM, Felipe Balbi wrote:
> Hi,
> 
> On Thu, Feb 07, 2013 at 07:05:06PM -0600, Jon Hunter wrote:
>> If the device-tree blob is present during boot, then register the SDMA
>> controller with the device-tree DMA driver so that we can use device-tree
>> to look-up DMA client information.
>>
>> Signed-off-by: Jon Hunter <jon-hunter@ti.com>
> 
> single comment below, other than that:
> 
> Reviewed-by: Felipe Balbi <balbi@ti.com>
> 
>> ---
>>  arch/arm/mach-omap2/dma.c |    4 ++++
>>  drivers/dma/omap-dma.c    |   37 +++++++++++++++++++++++++++++++++++--
>>  2 files changed, 39 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/dma.c b/arch/arm/mach-omap2/dma.c
>> index 5cd8d76..71dadff 100644
>> --- a/arch/arm/mach-omap2/dma.c
>> +++ b/arch/arm/mach-omap2/dma.c
>> @@ -28,6 +28,7 @@
>>  #include <linux/init.h>
>>  #include <linux/device.h>
>>  #include <linux/dma-mapping.h>
>> +#include <linux/of.h>
>>  #include <linux/omap-dma.h>
>>  
>>  #include "soc.h"
>> @@ -304,6 +305,9 @@ static int __init omap2_system_dma_init(void)
>>  	if (res)
>>  		return res;
>>  
>> +	if (of_have_populated_dt())
>> +		return res;
>> +
>>  	pdev = platform_device_register_full(&omap_dma_dev_info);
>>  	if (IS_ERR(pdev))
>>  		return PTR_ERR(pdev);
>> diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
>> index c4b4fd2..0067bd0 100644
>> --- a/drivers/dma/omap-dma.c
>> +++ b/drivers/dma/omap-dma.c
>> @@ -16,6 +16,8 @@
>>  #include <linux/platform_device.h>
>>  #include <linux/slab.h>
>>  #include <linux/spinlock.h>
>> +#include <linux/of_dma.h>
>> +#include <linux/of_device.h>
>>  
>>  #include "virt-dma.h"
>>  
>> @@ -67,6 +69,8 @@ static const unsigned es_bytes[] = {
>>  	[OMAP_DMA_DATA_TYPE_S32] = 4,
>>  };
>>  
>> +static struct of_dma_filter_info info;
> 
> Arnd also mentioned that since all fields belonging to this are
> constant, you could statically initialize them here. He also mentioned
> you should call this by a more descriptive name:

Oops sorry missed that comment. Will fix up and re-send.

Cheers
Jon

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

Patch

diff --git a/arch/arm/mach-omap2/dma.c b/arch/arm/mach-omap2/dma.c
index 5cd8d76..71dadff 100644
--- a/arch/arm/mach-omap2/dma.c
+++ b/arch/arm/mach-omap2/dma.c
@@ -28,6 +28,7 @@ 
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
+#include <linux/of.h>
 #include <linux/omap-dma.h>
 
 #include "soc.h"
@@ -304,6 +305,9 @@  static int __init omap2_system_dma_init(void)
 	if (res)
 		return res;
 
+	if (of_have_populated_dt())
+		return res;
+
 	pdev = platform_device_register_full(&omap_dma_dev_info);
 	if (IS_ERR(pdev))
 		return PTR_ERR(pdev);
diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index c4b4fd2..0067bd0 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -16,6 +16,8 @@ 
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/of_dma.h>
+#include <linux/of_device.h>
 
 #include "virt-dma.h"
 
@@ -67,6 +69,8 @@  static const unsigned es_bytes[] = {
 	[OMAP_DMA_DATA_TYPE_S32] = 4,
 };
 
+static struct of_dma_filter_info info;
+
 static inline struct omap_dmadev *to_omap_dma_dev(struct dma_device *d)
 {
 	return container_of(d, struct omap_dmadev, ddev);
@@ -621,8 +625,23 @@  static int omap_dma_probe(struct platform_device *pdev)
 		pr_warn("OMAP-DMA: failed to register slave DMA engine device: %d\n",
 			rc);
 		omap_dma_free(od);
-	} else {
-		platform_set_drvdata(pdev, od);
+		return rc;
+	}
+
+	platform_set_drvdata(pdev, od);
+
+	if (pdev->dev.of_node) {
+		info.dma_cap = od->ddev.cap_mask;
+		info.filter_fn = omap_dma_filter_fn;
+
+		/* Device-tree DMA controller registration */
+		rc = of_dma_controller_register(pdev->dev.of_node,
+				of_dma_simple_xlate, &info);
+		if (rc) {
+			pr_warn("OMAP-DMA: failed to register DMA controller\n");
+			dma_async_device_unregister(&od->ddev);
+			omap_dma_free(od);
+		}
 	}
 
 	dev_info(&pdev->dev, "OMAP DMA engine driver\n");
@@ -634,18 +653,32 @@  static int omap_dma_remove(struct platform_device *pdev)
 {
 	struct omap_dmadev *od = platform_get_drvdata(pdev);
 
+	if (pdev->dev.of_node)
+		of_dma_controller_free(pdev->dev.of_node);
+
 	dma_async_device_unregister(&od->ddev);
 	omap_dma_free(od);
 
 	return 0;
 }
 
+static const struct of_device_id omap_dma_match[] = {
+	{ .compatible = "ti,omap2420-sdma", },
+	{ .compatible = "ti,omap2430-sdma", },
+	{ .compatible = "ti,omap3430-sdma", },
+	{ .compatible = "ti,omap3630-sdma", },
+	{ .compatible = "ti,omap4430-sdma", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, omap_dma_match);
+
 static struct platform_driver omap_dma_driver = {
 	.probe	= omap_dma_probe,
 	.remove	= omap_dma_remove,
 	.driver = {
 		.name = "omap-dma-engine",
 		.owner = THIS_MODULE,
+		.of_match_table = of_match_ptr(omap_dma_match),
 	},
 };