Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1350994 > unrolled thread

[PATCH 3/5] rtc: rtc-jz4740: Add support for devicetree

Started byPaul Cercueil <paul@crapouillou.net>
First post2016-03-05 23:50 +0100
Last post2016-03-17 15:00 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 3/5] rtc: rtc-jz4740: Add support for devicetree Paul Cercueil <paul@crapouillou.net> - 2016-03-05 23:50 +0100
    Re: [PATCH 3/5] rtc: rtc-jz4740: Add support for devicetree Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-03-17 13:10 +0100
      Re: [PATCH 3/5] rtc: rtc-jz4740: Add support for devicetree Harvey Hunt <harvey.hunt@imgtec.com> - 2016-03-17 14:40 +0100
        Re: [PATCH 3/5] rtc: rtc-jz4740: Add support for devicetree Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-03-17 15:00 +0100

#1350994 — [PATCH 3/5] rtc: rtc-jz4740: Add support for devicetree

FromPaul Cercueil <paul@crapouillou.net>
Date2016-03-05 23:50 +0100
Subject[PATCH 3/5] rtc: rtc-jz4740: Add support for devicetree
Message-ID<r9tbk-4pS-1@gated-at.bofh.it>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/rtc/rtc-jz4740.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
index 47617bd..3914b1c 100644
--- a/drivers/rtc/rtc-jz4740.c
+++ b/drivers/rtc/rtc-jz4740.c
@@ -17,6 +17,7 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/rtc.h>
 #include <linux/slab.h>
@@ -245,6 +246,13 @@ void jz4740_rtc_poweroff(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(jz4740_rtc_poweroff);
 
+static const struct of_device_id jz4740_rtc_of_match[] = {
+	{ .compatible = "ingenic,jz4740-rtc", .data = (void *) ID_JZ4740 },
+	{ .compatible = "ingenic,jz4780-rtc", .data = (void *) ID_JZ4780 },
+	{},
+};
+MODULE_DEVICE_TABLE(of, jz4740_rtc_of_match);
+
 static int jz4740_rtc_probe(struct platform_device *pdev)
 {
 	int ret;
@@ -252,12 +260,17 @@ static int jz4740_rtc_probe(struct platform_device *pdev)
 	uint32_t scratchpad;
 	struct resource *mem;
 	const struct platform_device_id *id = platform_get_device_id(pdev);
+	const struct of_device_id *of_id = of_match_device(
+			jz4740_rtc_of_match, &pdev->dev);
 
 	rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
 	if (!rtc)
 		return -ENOMEM;
 
-	rtc->type = id->driver_data;
+	if (of_id)
+		rtc->type = (enum jz4740_rtc_type) of_id->data;
+	else
+		rtc->type = id->driver_data;
 
 	rtc->irq = platform_get_irq(pdev, 0);
 	if (rtc->irq < 0) {
@@ -345,6 +358,7 @@ static struct platform_driver jz4740_rtc_driver = {
 	.driver	 = {
 		.name  = "jz4740-rtc",
 		.pm    = JZ4740_RTC_PM_OPS,
+		.of_match_table = of_match_ptr(jz4740_rtc_of_match),
 	},
 	.id_table = jz4740_rtc_ids,
 };
-- 
2.7.0

[toc] | [next] | [standalone]


#1359792

FromAlexandre Belloni <alexandre.belloni@free-electrons.com>
Date2016-03-17 13:10 +0100
Message-ID<rdEUA-7h0-39@gated-at.bofh.it>
In reply to#1350994
On 05/03/2016 at 23:38:49 +0100, Paul Cercueil wrote :
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/rtc/rtc-jz4740.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
> index 47617bd..3914b1c 100644
> --- a/drivers/rtc/rtc-jz4740.c
> +++ b/drivers/rtc/rtc-jz4740.c
> @@ -17,6 +17,7 @@
>  #include <linux/io.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> +#include <linux/of_device.h>
>  #include <linux/platform_device.h>
>  #include <linux/rtc.h>
>  #include <linux/slab.h>
> @@ -245,6 +246,13 @@ void jz4740_rtc_poweroff(struct device *dev)
>  }
>  EXPORT_SYMBOL_GPL(jz4740_rtc_poweroff);
>  
> +static const struct of_device_id jz4740_rtc_of_match[] = {
> +	{ .compatible = "ingenic,jz4740-rtc", .data = (void *) ID_JZ4740 },
> +	{ .compatible = "ingenic,jz4780-rtc", .data = (void *) ID_JZ4780 },

ingenic is not in Documentation/devicetree/bindings/vendor-prefixes.txt,
you have to add it there before using it.

Also, no space is necessary after the "(void *)" cast.

> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, jz4740_rtc_of_match);
> +
>  static int jz4740_rtc_probe(struct platform_device *pdev)
>  {
>  	int ret;
> @@ -252,12 +260,17 @@ static int jz4740_rtc_probe(struct platform_device *pdev)
>  	uint32_t scratchpad;
>  	struct resource *mem;
>  	const struct platform_device_id *id = platform_get_device_id(pdev);
> +	const struct of_device_id *of_id = of_match_device(
> +			jz4740_rtc_of_match, &pdev->dev);
>  
>  	rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
>  	if (!rtc)
>  		return -ENOMEM;
>  
> -	rtc->type = id->driver_data;
> +	if (of_id)
> +		rtc->type = (enum jz4740_rtc_type) of_id->data;

No space after that cast either.

> +	else
> +		rtc->type = id->driver_data;
>  
>  	rtc->irq = platform_get_irq(pdev, 0);
>  	if (rtc->irq < 0) {
> @@ -345,6 +358,7 @@ static struct platform_driver jz4740_rtc_driver = {
>  	.driver	 = {
>  		.name  = "jz4740-rtc",
>  		.pm    = JZ4740_RTC_PM_OPS,
> +		.of_match_table = of_match_ptr(jz4740_rtc_of_match),
>  	},
>  	.id_table = jz4740_rtc_ids,
>  };
> -- 
> 2.7.0
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[toc] | [prev] | [next] | [standalone]


#1359851

FromHarvey Hunt <harvey.hunt@imgtec.com>
Date2016-03-17 14:40 +0100
Message-ID<rdGjD-80w-5@gated-at.bofh.it>
In reply to#1359792
Hi Alexandre,

On 17/03/16 12:08, Alexandre Belloni wrote:
> On 05/03/2016 at 23:38:49 +0100, Paul Cercueil wrote :
>> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>> ---
>>   drivers/rtc/rtc-jz4740.c | 16 +++++++++++++++-
>>   1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
>> index 47617bd..3914b1c 100644
>> --- a/drivers/rtc/rtc-jz4740.c
>> +++ b/drivers/rtc/rtc-jz4740.c
>> @@ -17,6 +17,7 @@
>>   #include <linux/io.h>
>>   #include <linux/kernel.h>
>>   #include <linux/module.h>
>> +#include <linux/of_device.h>
>>   #include <linux/platform_device.h>
>>   #include <linux/rtc.h>
>>   #include <linux/slab.h>
>> @@ -245,6 +246,13 @@ void jz4740_rtc_poweroff(struct device *dev)
>>   }
>>   EXPORT_SYMBOL_GPL(jz4740_rtc_poweroff);
>>
>> +static const struct of_device_id jz4740_rtc_of_match[] = {
>> +	{ .compatible = "ingenic,jz4740-rtc", .data = (void *) ID_JZ4740 },
>> +	{ .compatible = "ingenic,jz4780-rtc", .data = (void *) ID_JZ4780 },
>
> ingenic is not in Documentation/devicetree/bindings/vendor-prefixes.txt,
> you have to add it there before using it.

Ingenic is in vendor-prefixes.txt - it was added by Commit f289cc7 
("devicetree/bindings: add Ingenic Semiconductor vendor prefix").

Thanks,

Harvey

[toc] | [prev] | [next] | [standalone]


#1359873

FromAlexandre Belloni <alexandre.belloni@free-electrons.com>
Date2016-03-17 15:00 +0100
Message-ID<rdGD2-87J-29@gated-at.bofh.it>
In reply to#1359851
On 17/03/2016 at 13:33:04 +0000, Harvey Hunt wrote :
> On 17/03/16 12:08, Alexandre Belloni wrote:
> >On 05/03/2016 at 23:38:49 +0100, Paul Cercueil wrote :
> >>Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> >>---
> >>  drivers/rtc/rtc-jz4740.c | 16 +++++++++++++++-
> >>  1 file changed, 15 insertions(+), 1 deletion(-)
> >>
> >>diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
> >>index 47617bd..3914b1c 100644
> >>--- a/drivers/rtc/rtc-jz4740.c
> >>+++ b/drivers/rtc/rtc-jz4740.c
> >>@@ -17,6 +17,7 @@
> >>  #include <linux/io.h>
> >>  #include <linux/kernel.h>
> >>  #include <linux/module.h>
> >>+#include <linux/of_device.h>
> >>  #include <linux/platform_device.h>
> >>  #include <linux/rtc.h>
> >>  #include <linux/slab.h>
> >>@@ -245,6 +246,13 @@ void jz4740_rtc_poweroff(struct device *dev)
> >>  }
> >>  EXPORT_SYMBOL_GPL(jz4740_rtc_poweroff);
> >>
> >>+static const struct of_device_id jz4740_rtc_of_match[] = {
> >>+	{ .compatible = "ingenic,jz4740-rtc", .data = (void *) ID_JZ4740 },
> >>+	{ .compatible = "ingenic,jz4780-rtc", .data = (void *) ID_JZ4780 },
> >
> >ingenic is not in Documentation/devicetree/bindings/vendor-prefixes.txt,
> >you have to add it there before using it.
> 
> Ingenic is in vendor-prefixes.txt - it was added by Commit f289cc7
> ("devicetree/bindings: add Ingenic Semiconductor vendor prefix").
> 

Indeed, I was looking at an old v4.1 based branch instead of master.

You can forget that comment :)


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web