All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] watchdog: jz4740: Add DT support
@ 2015-01-27 15:11 ` Zubair Lutfullah Kakakhel
  0 siblings, 0 replies; 29+ messages in thread
From: Zubair Lutfullah Kakakhel @ 2015-01-27 15:11 UTC (permalink / raw)
  To: wim; +Cc: devicetree, linux-kernel, linux-watchdog, Zubair.Kakakhel, paul

Hi,

Here are two simple patches that add DT support to the jz4740 watchdog driver.

Patches are based on 3.19-rc6. Quite disjoint and stay within jz4740
so should apply easily on other trees.

If you would like to have them rebased to a different tree, please tell.

Thank-you

ZubairLK

Zubair Lutfullah Kakakhel (2):
  dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
  watchdog: jz4740: Add DT support

 .../devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt | 17 +++++++++++++++++
 drivers/watchdog/jz4740_wdt.c                           |  9 +++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt

-- 
1.9.1


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

* [PATCH 0/2] watchdog: jz4740: Add DT support
@ 2015-01-27 15:11 ` Zubair Lutfullah Kakakhel
  0 siblings, 0 replies; 29+ messages in thread
From: Zubair Lutfullah Kakakhel @ 2015-01-27 15:11 UTC (permalink / raw)
  To: wim-IQzOog9fTRqzQB+pC5nmwQ
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	Zubair.Kakakhel-1AXoQHu6uovQT0dZR+AlfA,
	paul-icTtO2rgO2OTuSrc4Mpeew

Hi,

Here are two simple patches that add DT support to the jz4740 watchdog driver.

Patches are based on 3.19-rc6. Quite disjoint and stay within jz4740
so should apply easily on other trees.

If you would like to have them rebased to a different tree, please tell.

Thank-you

ZubairLK

Zubair Lutfullah Kakakhel (2):
  dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
  watchdog: jz4740: Add DT support

 .../devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt | 17 +++++++++++++++++
 drivers/watchdog/jz4740_wdt.c                           |  9 +++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
  2015-01-27 15:11 ` Zubair Lutfullah Kakakhel
@ 2015-01-27 15:11   ` Zubair Lutfullah Kakakhel
  -1 siblings, 0 replies; 29+ messages in thread
From: Zubair Lutfullah Kakakhel @ 2015-01-27 15:11 UTC (permalink / raw)
  To: wim; +Cc: devicetree, linux-kernel, linux-watchdog, Zubair.Kakakhel, paul

Add binding for jz47xx watchdog timer. It is a simple watchdog timer.
Needs rtc clock and register addresses

Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>

---
The jz4740 is platform only at the moment.

But DT support is being added

See http://patchwork.linux-mips.org/bundle/paulburton/ci20-v3.20/

jz47xx is used because jz4780 will also use this driver
---
 .../devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt

diff --git a/Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt b/Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt
new file mode 100644
index 0000000..bf4c404
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt
@@ -0,0 +1,17 @@
+Ingenic Watchdog Timer (WDT) Controller for JZ47XX
+
+Required properties:
+compatible: "ingenic,jz4740-watchdog"
+reg: Register address and length for watchdog registers
+clocks: phandle to rtcclk
+clock-names: must be "rtc"
+
+Example:
+
+watchdog: jz47xx-watchdog@0x10002000 {
+	compatible = "ingenic,jz4780-watchdog";
+	reg = <0x10002000 0x100>;
+
+	clocks = <&rtclk>;
+	clock-names = "rtc";
+};
-- 
1.9.1


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

* [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
@ 2015-01-27 15:11   ` Zubair Lutfullah Kakakhel
  0 siblings, 0 replies; 29+ messages in thread
From: Zubair Lutfullah Kakakhel @ 2015-01-27 15:11 UTC (permalink / raw)
  To: wim; +Cc: devicetree, linux-kernel, linux-watchdog, Zubair.Kakakhel, paul

Add binding for jz47xx watchdog timer. It is a simple watchdog timer.
Needs rtc clock and register addresses

Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>

---
The jz4740 is platform only at the moment.

But DT support is being added

See http://patchwork.linux-mips.org/bundle/paulburton/ci20-v3.20/

jz47xx is used because jz4780 will also use this driver
---
 .../devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt

diff --git a/Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt b/Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt
new file mode 100644
index 0000000..bf4c404
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt
@@ -0,0 +1,17 @@
+Ingenic Watchdog Timer (WDT) Controller for JZ47XX
+
+Required properties:
+compatible: "ingenic,jz4740-watchdog"
+reg: Register address and length for watchdog registers
+clocks: phandle to rtcclk
+clock-names: must be "rtc"
+
+Example:
+
+watchdog: jz47xx-watchdog@0x10002000 {
+	compatible = "ingenic,jz4780-watchdog";
+	reg = <0x10002000 0x100>;
+
+	clocks = <&rtclk>;
+	clock-names = "rtc";
+};
-- 
1.9.1

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

* [PATCH 2/2] watchdog: jz4740: Add DT support
@ 2015-01-27 15:11   ` Zubair Lutfullah Kakakhel
  0 siblings, 0 replies; 29+ messages in thread
From: Zubair Lutfullah Kakakhel @ 2015-01-27 15:11 UTC (permalink / raw)
  To: wim; +Cc: devicetree, linux-kernel, linux-watchdog, Zubair.Kakakhel, paul

Add DT support to the jz4740 driver. Simple of_match_ptr. No other
modification for probe needed

Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
---
 drivers/watchdog/jz4740_wdt.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/watchdog/jz4740_wdt.c b/drivers/watchdog/jz4740_wdt.c
index 18e41af..4420ec3 100644
--- a/drivers/watchdog/jz4740_wdt.c
+++ b/drivers/watchdog/jz4740_wdt.c
@@ -24,6 +24,7 @@
 #include <linux/clk.h>
 #include <linux/slab.h>
 #include <linux/err.h>
+#include <linux/of.h>
 
 #include <asm/mach-jz4740/timer.h>
 
@@ -142,6 +143,13 @@ static const struct watchdog_ops jz4740_wdt_ops = {
 	.set_timeout = jz4740_wdt_set_timeout,
 };
 
+#ifdef CONFIG_OF
+static const struct of_device_id jz4740_of_matches[] = {
+	{ .compatible = "ingenic,jz4740-watchdog", },
+	{ /* sentinel */ }
+};
+#endif
+
 static int jz4740_wdt_probe(struct platform_device *pdev)
 {
 	struct jz4740_wdt_drvdata *drvdata;
@@ -211,6 +219,7 @@ static struct platform_driver jz4740_wdt_driver = {
 	.remove = jz4740_wdt_remove,
 	.driver = {
 		.name = "jz4740-wdt",
+		.of_match_table = of_match_ptr(jz4740_of_matches),
 	},
 };
 
-- 
1.9.1


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

* [PATCH 2/2] watchdog: jz4740: Add DT support
@ 2015-01-27 15:11   ` Zubair Lutfullah Kakakhel
  0 siblings, 0 replies; 29+ messages in thread
From: Zubair Lutfullah Kakakhel @ 2015-01-27 15:11 UTC (permalink / raw)
  To: wim-IQzOog9fTRqzQB+pC5nmwQ
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	Zubair.Kakakhel-1AXoQHu6uovQT0dZR+AlfA,
	paul-icTtO2rgO2OTuSrc4Mpeew

Add DT support to the jz4740 driver. Simple of_match_ptr. No other
modification for probe needed

Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
---
 drivers/watchdog/jz4740_wdt.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/watchdog/jz4740_wdt.c b/drivers/watchdog/jz4740_wdt.c
index 18e41af..4420ec3 100644
--- a/drivers/watchdog/jz4740_wdt.c
+++ b/drivers/watchdog/jz4740_wdt.c
@@ -24,6 +24,7 @@
 #include <linux/clk.h>
 #include <linux/slab.h>
 #include <linux/err.h>
+#include <linux/of.h>
 
 #include <asm/mach-jz4740/timer.h>
 
@@ -142,6 +143,13 @@ static const struct watchdog_ops jz4740_wdt_ops = {
 	.set_timeout = jz4740_wdt_set_timeout,
 };
 
+#ifdef CONFIG_OF
+static const struct of_device_id jz4740_of_matches[] = {
+	{ .compatible = "ingenic,jz4740-watchdog", },
+	{ /* sentinel */ }
+};
+#endif
+
 static int jz4740_wdt_probe(struct platform_device *pdev)
 {
 	struct jz4740_wdt_drvdata *drvdata;
@@ -211,6 +219,7 @@ static struct platform_driver jz4740_wdt_driver = {
 	.remove = jz4740_wdt_remove,
 	.driver = {
 		.name = "jz4740-wdt",
+		.of_match_table = of_match_ptr(jz4740_of_matches),
 	},
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
@ 2015-01-27 16:30     ` Guenter Roeck
  0 siblings, 0 replies; 29+ messages in thread
From: Guenter Roeck @ 2015-01-27 16:30 UTC (permalink / raw)
  To: Zubair Lutfullah Kakakhel
  Cc: wim, devicetree, linux-kernel, linux-watchdog, paul

On Tue, Jan 27, 2015 at 03:11:29PM +0000, Zubair Lutfullah Kakakhel wrote:
> Add binding for jz47xx watchdog timer. It is a simple watchdog timer.
> Needs rtc clock and register addresses
> 
> Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
> 
> ---
> The jz4740 is platform only at the moment.
> 
> But DT support is being added
> 
> See http://patchwork.linux-mips.org/bundle/paulburton/ci20-v3.20/
> 
> jz47xx is used because jz4780 will also use this driver

Not a valid argument. Please use jz4740, per convention.

xx implies anything from 00 to 99, which is not necessarily correct.
If support for other chips is added, that information can be mentioned
in the file itself, as it is done for many other drivers.

> ---
>  .../devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt
> 
> diff --git a/Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt b/Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt
> new file mode 100644
> index 0000000..bf4c404
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt
> @@ -0,0 +1,17 @@
> +Ingenic Watchdog Timer (WDT) Controller for JZ47XX
> +
> +Required properties:
> +compatible: "ingenic,jz4740-watchdog"
> +reg: Register address and length for watchdog registers
> +clocks: phandle to rtcclk
> +clock-names: must be "rtc"
> +
> +Example:
> +
> +watchdog: jz47xx-watchdog@0x10002000 {
> +	compatible = "ingenic,jz4780-watchdog";

"ingenic,jz4780-watchdog" is not listed as possible value above,
nor is it listed in the patch itself, so you can not use it here.

> +	reg = <0x10002000 0x100>;
> +
> +	clocks = <&rtclk>;
> +	clock-names = "rtc";
> +};
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
@ 2015-01-27 16:30     ` Guenter Roeck
  0 siblings, 0 replies; 29+ messages in thread
From: Guenter Roeck @ 2015-01-27 16:30 UTC (permalink / raw)
  To: Zubair Lutfullah Kakakhel
  Cc: wim-IQzOog9fTRqzQB+pC5nmwQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	paul-icTtO2rgO2OTuSrc4Mpeew

On Tue, Jan 27, 2015 at 03:11:29PM +0000, Zubair Lutfullah Kakakhel wrote:
> Add binding for jz47xx watchdog timer. It is a simple watchdog timer.
> Needs rtc clock and register addresses
> 
> Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
> 
> ---
> The jz4740 is platform only at the moment.
> 
> But DT support is being added
> 
> See http://patchwork.linux-mips.org/bundle/paulburton/ci20-v3.20/
> 
> jz47xx is used because jz4780 will also use this driver

Not a valid argument. Please use jz4740, per convention.

xx implies anything from 00 to 99, which is not necessarily correct.
If support for other chips is added, that information can be mentioned
in the file itself, as it is done for many other drivers.

> ---
>  .../devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt
> 
> diff --git a/Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt b/Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt
> new file mode 100644
> index 0000000..bf4c404
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/watchdog/ingenic,jz47xx-wdt.txt
> @@ -0,0 +1,17 @@
> +Ingenic Watchdog Timer (WDT) Controller for JZ47XX
> +
> +Required properties:
> +compatible: "ingenic,jz4740-watchdog"
> +reg: Register address and length for watchdog registers
> +clocks: phandle to rtcclk
> +clock-names: must be "rtc"
> +
> +Example:
> +
> +watchdog: jz47xx-watchdog@0x10002000 {
> +	compatible = "ingenic,jz4780-watchdog";

"ingenic,jz4780-watchdog" is not listed as possible value above,
nor is it listed in the patch itself, so you can not use it here.

> +	reg = <0x10002000 0x100>;
> +
> +	clocks = <&rtclk>;
> +	clock-names = "rtc";
> +};
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/2] watchdog: jz4740: Add DT support
@ 2015-01-27 16:31     ` Guenter Roeck
  0 siblings, 0 replies; 29+ messages in thread
From: Guenter Roeck @ 2015-01-27 16:31 UTC (permalink / raw)
  To: Zubair Lutfullah Kakakhel
  Cc: wim, devicetree, linux-kernel, linux-watchdog, paul

On Tue, Jan 27, 2015 at 03:11:30PM +0000, Zubair Lutfullah Kakakhel wrote:
> Add DT support to the jz4740 driver. Simple of_match_ptr. No other
> modification for probe needed
> 
> Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>

Reviewed-by: Guenetr Roeck <linux@roeck-us.net>

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

* Re: [PATCH 2/2] watchdog: jz4740: Add DT support
@ 2015-01-27 16:31     ` Guenter Roeck
  0 siblings, 0 replies; 29+ messages in thread
From: Guenter Roeck @ 2015-01-27 16:31 UTC (permalink / raw)
  To: Zubair Lutfullah Kakakhel
  Cc: wim-IQzOog9fTRqzQB+pC5nmwQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	paul-icTtO2rgO2OTuSrc4Mpeew

On Tue, Jan 27, 2015 at 03:11:30PM +0000, Zubair Lutfullah Kakakhel wrote:
> Add DT support to the jz4740 driver. Simple of_match_ptr. No other
> modification for probe needed
> 
> Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>

Reviewed-by: Guenetr Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/2] watchdog: jz4740: Add DT support
@ 2015-01-27 20:15     ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2015-01-27 20:15 UTC (permalink / raw)
  To: Zubair Lutfullah Kakakhel
  Cc: wim, devicetree, linux-kernel, linux-watchdog, paul

On Tuesday 27 January 2015 15:11:30 Zubair Lutfullah Kakakhel wrote:
>  };
>  
> +#ifdef CONFIG_OF
> +static const struct of_device_id jz4740_of_matches[] = {
> +       { .compatible = "ingenic,jz4740-watchdog", },
> +       { /* sentinel */ }
> +};
> +#endif
> +
>  static int jz4740_wdt_probe(struct platform_device *pdev)
>  {
>         struct jz4740_wdt_drvdata *drvdata;
> @@ -211,6 +219,7 @@ static struct platform_driver jz4740_wdt_driver = {
>         .remove = jz4740_wdt_remove,
>         .driver = {
>                 .name = "jz4740-wdt",
> +               .of_match_table = of_match_ptr(jz4740_of_matches),
>         },
> 

Why the #ifdef? Presumably we want to move over jz4740 to DT-only in the
long run, so you could just remove the #ifdef and the of_match_ptr()
wrapper.

Also, you should add a MODULE_DEVICE_TABLE() entry.

	Arnd

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

* Re: [PATCH 2/2] watchdog: jz4740: Add DT support
@ 2015-01-27 20:15     ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2015-01-27 20:15 UTC (permalink / raw)
  To: Zubair Lutfullah Kakakhel
  Cc: wim-IQzOog9fTRqzQB+pC5nmwQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	paul-icTtO2rgO2OTuSrc4Mpeew

On Tuesday 27 January 2015 15:11:30 Zubair Lutfullah Kakakhel wrote:
>  };
>  
> +#ifdef CONFIG_OF
> +static const struct of_device_id jz4740_of_matches[] = {
> +       { .compatible = "ingenic,jz4740-watchdog", },
> +       { /* sentinel */ }
> +};
> +#endif
> +
>  static int jz4740_wdt_probe(struct platform_device *pdev)
>  {
>         struct jz4740_wdt_drvdata *drvdata;
> @@ -211,6 +219,7 @@ static struct platform_driver jz4740_wdt_driver = {
>         .remove = jz4740_wdt_remove,
>         .driver = {
>                 .name = "jz4740-wdt",
> +               .of_match_table = of_match_ptr(jz4740_of_matches),
>         },
> 

Why the #ifdef? Presumably we want to move over jz4740 to DT-only in the
long run, so you could just remove the #ifdef and the of_match_ptr()
wrapper.

Also, you should add a MODULE_DEVICE_TABLE() entry.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
@ 2015-01-27 20:16     ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2015-01-27 20:16 UTC (permalink / raw)
  To: Zubair Lutfullah Kakakhel
  Cc: wim, devicetree, linux-kernel, linux-watchdog, paul

On Tuesday 27 January 2015 15:11:29 Zubair Lutfullah Kakakhel wrote:
> +clocks: phandle to rtcclk
> +clock-names: must be "rtc"
> +
> +Example:
> +
> +watchdog: jz47xx-watchdog@0x10002000 {
> +       compatible = "ingenic,jz4780-watchdog";
> +       reg = <0x10002000 0x100>;
> +
> +       clocks = <&rtclk>;
> +       clock-names = "rtc";
> +};

Why is the name "rtc"? are you sure you are not confusing the output
name of the clock controller with the input of the watchdog device?

It's suspicious that both have similar names.

	Arnd

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
@ 2015-01-27 20:16     ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2015-01-27 20:16 UTC (permalink / raw)
  To: Zubair Lutfullah Kakakhel
  Cc: wim-IQzOog9fTRqzQB+pC5nmwQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	paul-icTtO2rgO2OTuSrc4Mpeew

On Tuesday 27 January 2015 15:11:29 Zubair Lutfullah Kakakhel wrote:
> +clocks: phandle to rtcclk
> +clock-names: must be "rtc"
> +
> +Example:
> +
> +watchdog: jz47xx-watchdog@0x10002000 {
> +       compatible = "ingenic,jz4780-watchdog";
> +       reg = <0x10002000 0x100>;
> +
> +       clocks = <&rtclk>;
> +       clock-names = "rtc";
> +};

Why is the name "rtc"? are you sure you are not confusing the output
name of the clock controller with the input of the watchdog device?

It's suspicious that both have similar names.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
  2015-01-27 20:16     ` Arnd Bergmann
@ 2015-01-27 20:52       ` Guenter Roeck
  -1 siblings, 0 replies; 29+ messages in thread
From: Guenter Roeck @ 2015-01-27 20:52 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Zubair Lutfullah Kakakhel, wim, devicetree, linux-kernel,
	linux-watchdog, paul

On Tue, Jan 27, 2015 at 09:16:45PM +0100, Arnd Bergmann wrote:
> On Tuesday 27 January 2015 15:11:29 Zubair Lutfullah Kakakhel wrote:
> > +clocks: phandle to rtcclk
> > +clock-names: must be "rtc"
> > +
> > +Example:
> > +
> > +watchdog: jz47xx-watchdog@0x10002000 {
> > +       compatible = "ingenic,jz4780-watchdog";
> > +       reg = <0x10002000 0x100>;
> > +
> > +       clocks = <&rtclk>;
> > +       clock-names = "rtc";
> > +};
> 
> Why is the name "rtc"? are you sure you are not confusing the output
> name of the clock controller with the input of the watchdog device?
> 
Driver does this (today):

	 drvdata->rtc_clk = clk_get(&pdev->dev, "rtc");

Isn't that the name to use ? Just wondering.

Thanks,
Guenter

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
@ 2015-01-27 20:52       ` Guenter Roeck
  0 siblings, 0 replies; 29+ messages in thread
From: Guenter Roeck @ 2015-01-27 20:52 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Zubair Lutfullah Kakakhel, wim-IQzOog9fTRqzQB+pC5nmwQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	paul-icTtO2rgO2OTuSrc4Mpeew

On Tue, Jan 27, 2015 at 09:16:45PM +0100, Arnd Bergmann wrote:
> On Tuesday 27 January 2015 15:11:29 Zubair Lutfullah Kakakhel wrote:
> > +clocks: phandle to rtcclk
> > +clock-names: must be "rtc"
> > +
> > +Example:
> > +
> > +watchdog: jz47xx-watchdog@0x10002000 {
> > +       compatible = "ingenic,jz4780-watchdog";
> > +       reg = <0x10002000 0x100>;
> > +
> > +       clocks = <&rtclk>;
> > +       clock-names = "rtc";
> > +};
> 
> Why is the name "rtc"? are you sure you are not confusing the output
> name of the clock controller with the input of the watchdog device?
> 
Driver does this (today):

	 drvdata->rtc_clk = clk_get(&pdev->dev, "rtc");

Isn't that the name to use ? Just wondering.

Thanks,
Guenter
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/2] watchdog: jz4740: Add DT support
  2015-01-27 20:15     ` Arnd Bergmann
@ 2015-01-27 20:54       ` Guenter Roeck
  -1 siblings, 0 replies; 29+ messages in thread
From: Guenter Roeck @ 2015-01-27 20:54 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Zubair Lutfullah Kakakhel, wim, devicetree, linux-kernel,
	linux-watchdog, paul

On Tue, Jan 27, 2015 at 09:15:37PM +0100, Arnd Bergmann wrote:
> On Tuesday 27 January 2015 15:11:30 Zubair Lutfullah Kakakhel wrote:
> >  };
> >  
> > +#ifdef CONFIG_OF
> > +static const struct of_device_id jz4740_of_matches[] = {
> > +       { .compatible = "ingenic,jz4740-watchdog", },
> > +       { /* sentinel */ }
> > +};
> > +#endif
> > +
> >  static int jz4740_wdt_probe(struct platform_device *pdev)
> >  {
> >         struct jz4740_wdt_drvdata *drvdata;
> > @@ -211,6 +219,7 @@ static struct platform_driver jz4740_wdt_driver = {
> >         .remove = jz4740_wdt_remove,
> >         .driver = {
> >                 .name = "jz4740-wdt",
> > +               .of_match_table = of_match_ptr(jz4740_of_matches),
> >         },
> > 
> 
> Why the #ifdef? Presumably we want to move over jz4740 to DT-only in the
> long run, so you could just remove the #ifdef and the of_match_ptr()
> wrapper.
> 
Only if "depends on OF" is added to its Kconfig entry, or am I missing
something ?

Guenter

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

* Re: [PATCH 2/2] watchdog: jz4740: Add DT support
@ 2015-01-27 20:54       ` Guenter Roeck
  0 siblings, 0 replies; 29+ messages in thread
From: Guenter Roeck @ 2015-01-27 20:54 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Zubair Lutfullah Kakakhel, wim-IQzOog9fTRqzQB+pC5nmwQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	paul-icTtO2rgO2OTuSrc4Mpeew

On Tue, Jan 27, 2015 at 09:15:37PM +0100, Arnd Bergmann wrote:
> On Tuesday 27 January 2015 15:11:30 Zubair Lutfullah Kakakhel wrote:
> >  };
> >  
> > +#ifdef CONFIG_OF
> > +static const struct of_device_id jz4740_of_matches[] = {
> > +       { .compatible = "ingenic,jz4740-watchdog", },
> > +       { /* sentinel */ }
> > +};
> > +#endif
> > +
> >  static int jz4740_wdt_probe(struct platform_device *pdev)
> >  {
> >         struct jz4740_wdt_drvdata *drvdata;
> > @@ -211,6 +219,7 @@ static struct platform_driver jz4740_wdt_driver = {
> >         .remove = jz4740_wdt_remove,
> >         .driver = {
> >                 .name = "jz4740-wdt",
> > +               .of_match_table = of_match_ptr(jz4740_of_matches),
> >         },
> > 
> 
> Why the #ifdef? Presumably we want to move over jz4740 to DT-only in the
> long run, so you could just remove the #ifdef and the of_match_ptr()
> wrapper.
> 
Only if "depends on OF" is added to its Kconfig entry, or am I missing
something ?

Guenter
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/2] watchdog: jz4740: Add DT support
@ 2015-01-27 21:23         ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2015-01-27 21:23 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Zubair Lutfullah Kakakhel, wim, devicetree, linux-kernel,
	linux-watchdog, paul

On Tuesday 27 January 2015 12:54:30 Guenter Roeck wrote:
> On Tue, Jan 27, 2015 at 09:15:37PM +0100, Arnd Bergmann wrote:
> > On Tuesday 27 January 2015 15:11:30 Zubair Lutfullah Kakakhel wrote:
> > >  };
> > >  
> > > +#ifdef CONFIG_OF
> > > +static const struct of_device_id jz4740_of_matches[] = {
> > > +       { .compatible = "ingenic,jz4740-watchdog", },
> > > +       { /* sentinel */ }
> > > +};
> > > +#endif
> > > +
> > >  static int jz4740_wdt_probe(struct platform_device *pdev)
> > >  {
> > >         struct jz4740_wdt_drvdata *drvdata;
> > > @@ -211,6 +219,7 @@ static struct platform_driver jz4740_wdt_driver = {
> > >         .remove = jz4740_wdt_remove,
> > >         .driver = {
> > >                 .name = "jz4740-wdt",
> > > +               .of_match_table = of_match_ptr(jz4740_of_matches),
> > >         },
> > > 
> > 
> > Why the #ifdef? Presumably we want to move over jz4740 to DT-only in the
> > long run, so you could just remove the #ifdef and the of_match_ptr()
> > wrapper.
> > 
> Only if "depends on OF" is added to its Kconfig entry, or am I missing
> something ?
> 

I'm pretty sure you don't need that, it will still compile and link
fine, the only downside being a few wasted bytes to store the compatible
string and the array.

	Arnd

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

* Re: [PATCH 2/2] watchdog: jz4740: Add DT support
@ 2015-01-27 21:23         ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2015-01-27 21:23 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Zubair Lutfullah Kakakhel, wim-IQzOog9fTRqzQB+pC5nmwQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	paul-icTtO2rgO2OTuSrc4Mpeew

On Tuesday 27 January 2015 12:54:30 Guenter Roeck wrote:
> On Tue, Jan 27, 2015 at 09:15:37PM +0100, Arnd Bergmann wrote:
> > On Tuesday 27 January 2015 15:11:30 Zubair Lutfullah Kakakhel wrote:
> > >  };
> > >  
> > > +#ifdef CONFIG_OF
> > > +static const struct of_device_id jz4740_of_matches[] = {
> > > +       { .compatible = "ingenic,jz4740-watchdog", },
> > > +       { /* sentinel */ }
> > > +};
> > > +#endif
> > > +
> > >  static int jz4740_wdt_probe(struct platform_device *pdev)
> > >  {
> > >         struct jz4740_wdt_drvdata *drvdata;
> > > @@ -211,6 +219,7 @@ static struct platform_driver jz4740_wdt_driver = {
> > >         .remove = jz4740_wdt_remove,
> > >         .driver = {
> > >                 .name = "jz4740-wdt",
> > > +               .of_match_table = of_match_ptr(jz4740_of_matches),
> > >         },
> > > 
> > 
> > Why the #ifdef? Presumably we want to move over jz4740 to DT-only in the
> > long run, so you could just remove the #ifdef and the of_match_ptr()
> > wrapper.
> > 
> Only if "depends on OF" is added to its Kconfig entry, or am I missing
> something ?
> 

I'm pretty sure you don't need that, it will still compile and link
fine, the only downside being a few wasted bytes to store the compatible
string and the array.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
  2015-01-27 20:52       ` Guenter Roeck
  (?)
@ 2015-01-27 21:29       ` Arnd Bergmann
  2015-01-27 22:19         ` Guenter Roeck
  -1 siblings, 1 reply; 29+ messages in thread
From: Arnd Bergmann @ 2015-01-27 21:29 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Zubair Lutfullah Kakakhel, wim, devicetree, linux-kernel,
	linux-watchdog, paul

On Tuesday 27 January 2015 12:52:29 Guenter Roeck wrote:
> Driver does this (today):
> 
>          drvdata->rtc_clk = clk_get(&pdev->dev, "rtc");
> 
> Isn't that the name to use ? Just wondering.

Just because the driver uses it at the moment does not mean it's the name
that the IP block uses.

clk_get() has the unpleasant property of doing fuzzy matching
on the name that is passed. It first tries to use the string
as the name of the clock input of the device, but if that is
not there, it falls back to looking for a global clk with a con_id.

In DT, we only support the first kind, but if a driver currently
uses the second, you get the wrong name.

Looking at arch/mips/jz4740/clock.c now, this seems to be exactly
what is going on here: there is no clkdev_add call to associate
the device clocks, so it can only match a global clock entry. :(

	Arnd

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
  2015-01-27 21:29       ` Arnd Bergmann
@ 2015-01-27 22:19         ` Guenter Roeck
  2015-01-27 22:36             ` Arnd Bergmann
  0 siblings, 1 reply; 29+ messages in thread
From: Guenter Roeck @ 2015-01-27 22:19 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Zubair Lutfullah Kakakhel, wim, devicetree, linux-kernel,
	linux-watchdog, paul

On Tue, Jan 27, 2015 at 10:29:49PM +0100, Arnd Bergmann wrote:
> On Tuesday 27 January 2015 12:52:29 Guenter Roeck wrote:
> > Driver does this (today):
> > 
> >          drvdata->rtc_clk = clk_get(&pdev->dev, "rtc");
> > 
> > Isn't that the name to use ? Just wondering.
> 
> Just because the driver uses it at the moment does not mean it's the name
> that the IP block uses.
> 
> clk_get() has the unpleasant property of doing fuzzy matching
> on the name that is passed. It first tries to use the string
> as the name of the clock input of the device, but if that is
> not there, it falls back to looking for a global clk with a con_id.
> 
> In DT, we only support the first kind, but if a driver currently
> uses the second, you get the wrong name.
> 
> Looking at arch/mips/jz4740/clock.c now, this seems to be exactly
> what is going on here: there is no clkdev_add call to associate
> the device clocks, so it can only match a global clock entry. :(
> 
Me confused :-(.

Does that mean the driver needs to be fixed, that the DT property
needs to change (to what ?), or both ?

Thanks,
Guenter

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
@ 2015-01-27 22:36             ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2015-01-27 22:36 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Zubair Lutfullah Kakakhel, wim, devicetree, linux-kernel,
	linux-watchdog, paul

On Tuesday 27 January 2015 14:19:09 Guenter Roeck wrote:
> On Tue, Jan 27, 2015 at 10:29:49PM +0100, Arnd Bergmann wrote:
> > On Tuesday 27 January 2015 12:52:29 Guenter Roeck wrote:
> > > Driver does this (today):
> > > 
> > >          drvdata->rtc_clk = clk_get(&pdev->dev, "rtc");
> > > 
> > > Isn't that the name to use ? Just wondering.
> > 
> > Just because the driver uses it at the moment does not mean it's the name
> > that the IP block uses.
> > 
> > clk_get() has the unpleasant property of doing fuzzy matching
> > on the name that is passed. It first tries to use the string
> > as the name of the clock input of the device, but if that is
> > not there, it falls back to looking for a global clk with a con_id.
> > 
> > In DT, we only support the first kind, but if a driver currently
> > uses the second, you get the wrong name.
> > 
> > Looking at arch/mips/jz4740/clock.c now, this seems to be exactly
> > what is going on here: there is no clkdev_add call to associate
> > the device clocks, so it can only match a global clock entry. 
> > 
> Me confused :-(.
> 
> Does that mean the driver needs to be fixed, that the DT property
> needs to change (to what ?), or both ?

Both.

The jz47xx clock driver should register a clkdev lookup table with
proper clock input names for each clock that is referenced by a
device, and then the drivers can use the right names.

In a lot of cases, the best name for a clock is no name so you
just use an anonymous clock like

	clk = clk_get(dev, NULL);

but this still requires a clock lookup table.

	Arnd

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
@ 2015-01-27 22:36             ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2015-01-27 22:36 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Zubair Lutfullah Kakakhel, wim-IQzOog9fTRqzQB+pC5nmwQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	paul-icTtO2rgO2OTuSrc4Mpeew

On Tuesday 27 January 2015 14:19:09 Guenter Roeck wrote:
> On Tue, Jan 27, 2015 at 10:29:49PM +0100, Arnd Bergmann wrote:
> > On Tuesday 27 January 2015 12:52:29 Guenter Roeck wrote:
> > > Driver does this (today):
> > > 
> > >          drvdata->rtc_clk = clk_get(&pdev->dev, "rtc");
> > > 
> > > Isn't that the name to use ? Just wondering.
> > 
> > Just because the driver uses it at the moment does not mean it's the name
> > that the IP block uses.
> > 
> > clk_get() has the unpleasant property of doing fuzzy matching
> > on the name that is passed. It first tries to use the string
> > as the name of the clock input of the device, but if that is
> > not there, it falls back to looking for a global clk with a con_id.
> > 
> > In DT, we only support the first kind, but if a driver currently
> > uses the second, you get the wrong name.
> > 
> > Looking at arch/mips/jz4740/clock.c now, this seems to be exactly
> > what is going on here: there is no clkdev_add call to associate
> > the device clocks, so it can only match a global clock entry. 
> > 
> Me confused :-(.
> 
> Does that mean the driver needs to be fixed, that the DT property
> needs to change (to what ?), or both ?

Both.

The jz47xx clock driver should register a clkdev lookup table with
proper clock input names for each clock that is referenced by a
device, and then the drivers can use the right names.

In a lot of cases, the best name for a clock is no name so you
just use an anonymous clock like

	clk = clk_get(dev, NULL);

but this still requires a clock lookup table.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
  2015-01-27 22:36             ` Arnd Bergmann
@ 2015-01-27 22:42               ` Arnd Bergmann
  -1 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2015-01-27 22:42 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Zubair Lutfullah Kakakhel, wim, devicetree, linux-kernel,
	linux-watchdog, paul

On Tuesday 27 January 2015 23:36:36 Arnd Bergmann wrote:
> On Tuesday 27 January 2015 14:19:09 Guenter Roeck wrote:
> > On Tue, Jan 27, 2015 at 10:29:49PM +0100, Arnd Bergmann wrote:
> > > On Tuesday 27 January 2015 12:52:29 Guenter Roeck wrote:
> > > > Driver does this (today):
> > > > 
> > > >          drvdata->rtc_clk = clk_get(&pdev->dev, "rtc");
> > > > 
> > > > Isn't that the name to use ? Just wondering.
> > > 
> > > Just because the driver uses it at the moment does not mean it's the name
> > > that the IP block uses.
> > > 
> > > clk_get() has the unpleasant property of doing fuzzy matching
> > > on the name that is passed. It first tries to use the string
> > > as the name of the clock input of the device, but if that is
> > > not there, it falls back to looking for a global clk with a con_id.
> > > 
> > > In DT, we only support the first kind, but if a driver currently
> > > uses the second, you get the wrong name.
> > > 
> > > Looking at arch/mips/jz4740/clock.c now, this seems to be exactly
> > > what is going on here: there is no clkdev_add call to associate
> > > the device clocks, so it can only match a global clock entry. 
> > > 
> > Me confused :-(.
> > 
> > Does that mean the driver needs to be fixed, that the DT property
> > needs to change (to what ?), or both ?
> 
> Both.
> 
> The jz47xx clock driver should register a clkdev lookup table with
> proper clock input names for each clock that is referenced by a
> device, and then the drivers can use the right names.
> 
> In a lot of cases, the best name for a clock is no name so you
> just use an anonymous clock like
> 
>         clk = clk_get(dev, NULL);
> 
> but this still requires a clock lookup table.

To illustrate why the current approach is wrong, think of a driver
that handles a device that can be used on two different SoCs.

The name used by the clock provider is SoC specific, so the driver
would need to know which SoC it's being used on in order to pass
the right clock signal name. clkdev is meant to solve this by providing
a lookup between the device/clock-input pair and the actual clock.

Apparently jz4740 does not share any devices with another SoC at
the moment, so this has not been a problem, but if jz4780 has
a slightly different clock tree, it's already broken.

	Arnd

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
@ 2015-01-27 22:42               ` Arnd Bergmann
  0 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2015-01-27 22:42 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Zubair Lutfullah Kakakhel, wim-IQzOog9fTRqzQB+pC5nmwQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	paul-icTtO2rgO2OTuSrc4Mpeew

On Tuesday 27 January 2015 23:36:36 Arnd Bergmann wrote:
> On Tuesday 27 January 2015 14:19:09 Guenter Roeck wrote:
> > On Tue, Jan 27, 2015 at 10:29:49PM +0100, Arnd Bergmann wrote:
> > > On Tuesday 27 January 2015 12:52:29 Guenter Roeck wrote:
> > > > Driver does this (today):
> > > > 
> > > >          drvdata->rtc_clk = clk_get(&pdev->dev, "rtc");
> > > > 
> > > > Isn't that the name to use ? Just wondering.
> > > 
> > > Just because the driver uses it at the moment does not mean it's the name
> > > that the IP block uses.
> > > 
> > > clk_get() has the unpleasant property of doing fuzzy matching
> > > on the name that is passed. It first tries to use the string
> > > as the name of the clock input of the device, but if that is
> > > not there, it falls back to looking for a global clk with a con_id.
> > > 
> > > In DT, we only support the first kind, but if a driver currently
> > > uses the second, you get the wrong name.
> > > 
> > > Looking at arch/mips/jz4740/clock.c now, this seems to be exactly
> > > what is going on here: there is no clkdev_add call to associate
> > > the device clocks, so it can only match a global clock entry. 
> > > 
> > Me confused :-(.
> > 
> > Does that mean the driver needs to be fixed, that the DT property
> > needs to change (to what ?), or both ?
> 
> Both.
> 
> The jz47xx clock driver should register a clkdev lookup table with
> proper clock input names for each clock that is referenced by a
> device, and then the drivers can use the right names.
> 
> In a lot of cases, the best name for a clock is no name so you
> just use an anonymous clock like
> 
>         clk = clk_get(dev, NULL);
> 
> but this still requires a clock lookup table.

To illustrate why the current approach is wrong, think of a driver
that handles a device that can be used on two different SoCs.

The name used by the clock provider is SoC specific, so the driver
would need to know which SoC it's being used on in order to pass
the right clock signal name. clkdev is meant to solve this by providing
a lookup between the device/clock-input pair and the actual clock.

Apparently jz4740 does not share any devices with another SoC at
the moment, so this has not been a problem, but if jz4780 has
a slightly different clock tree, it's already broken.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
  2015-01-27 22:42               ` Arnd Bergmann
@ 2015-01-28 10:27                 ` Zubair Lutfullah Kakakhel
  -1 siblings, 0 replies; 29+ messages in thread
From: Zubair Lutfullah Kakakhel @ 2015-01-28 10:27 UTC (permalink / raw)
  To: Arnd Bergmann, Guenter Roeck
  Cc: wim, devicetree, linux-kernel, linux-watchdog, paul



On 27/01/15 22:42, Arnd Bergmann wrote:
> On Tuesday 27 January 2015 23:36:36 Arnd Bergmann wrote:
>> On Tuesday 27 January 2015 14:19:09 Guenter Roeck wrote:
>>> On Tue, Jan 27, 2015 at 10:29:49PM +0100, Arnd Bergmann wrote:
>>>> On Tuesday 27 January 2015 12:52:29 Guenter Roeck wrote:
>>>>> Driver does this (today):
>>>>>
>>>>>          drvdata->rtc_clk = clk_get(&pdev->dev, "rtc");
>>>>>
>>>>> Isn't that the name to use ? Just wondering.
>>>>
>>>> Just because the driver uses it at the moment does not mean it's the name
>>>> that the IP block uses.
>>>>
>>>> clk_get() has the unpleasant property of doing fuzzy matching
>>>> on the name that is passed. It first tries to use the string
>>>> as the name of the clock input of the device, but if that is
>>>> not there, it falls back to looking for a global clk with a con_id.
>>>>
>>>> In DT, we only support the first kind, but if a driver currently
>>>> uses the second, you get the wrong name.
>>>>
>>>> Looking at arch/mips/jz4740/clock.c now, this seems to be exactly
>>>> what is going on here: there is no clkdev_add call to associate
>>>> the device clocks, so it can only match a global clock entry. 
>>>>
>>> Me confused :-(.
>>>
>>> Does that mean the driver needs to be fixed, that the DT property
>>> needs to change (to what ?), or both ?
>>
>> Both.
>>
>> The jz47xx clock driver should register a clkdev lookup table with
>> proper clock input names for each clock that is referenced by a
>> device, and then the drivers can use the right names.
>>
>> In a lot of cases, the best name for a clock is no name so you
>> just use an anonymous clock like
>>
>>         clk = clk_get(dev, NULL);
>>
>> but this still requires a clock lookup table.
> 
> To illustrate why the current approach is wrong, think of a driver
> that handles a device that can be used on two different SoCs.
> 
> The name used by the clock provider is SoC specific, so the driver
> would need to know which SoC it's being used on in order to pass
> the right clock signal name. clkdev is meant to solve this by providing
> a lookup between the device/clock-input pair and the actual clock.
> 
> Apparently jz4740 does not share any devices with another SoC at
> the moment, so this has not been a problem, but if jz4780 has
> a slightly different clock tree, it's already broken.
> 
> 	Arnd
> 

There is on-going work to fix jz4740, add jz4780 and shake the entire clock tree as well.

Patch 14 onwards in this series
http://patchwork.linux-mips.org/bundle/paulburton/ci20-v3.20/

Instead of lumping things out in huge changesets, I intended to push out the minor patches that are disjoint.

That was the purpose of sending these two patches.

Current binding requires the clock-name to be "rtc". Hence the name at the moment.

Regards,
ZubairLK

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
@ 2015-01-28 10:27                 ` Zubair Lutfullah Kakakhel
  0 siblings, 0 replies; 29+ messages in thread
From: Zubair Lutfullah Kakakhel @ 2015-01-28 10:27 UTC (permalink / raw)
  To: Arnd Bergmann, Guenter Roeck
  Cc: wim, devicetree, linux-kernel, linux-watchdog, paul



On 27/01/15 22:42, Arnd Bergmann wrote:
> On Tuesday 27 January 2015 23:36:36 Arnd Bergmann wrote:
>> On Tuesday 27 January 2015 14:19:09 Guenter Roeck wrote:
>>> On Tue, Jan 27, 2015 at 10:29:49PM +0100, Arnd Bergmann wrote:
>>>> On Tuesday 27 January 2015 12:52:29 Guenter Roeck wrote:
>>>>> Driver does this (today):
>>>>>
>>>>>          drvdata->rtc_clk = clk_get(&pdev->dev, "rtc");
>>>>>
>>>>> Isn't that the name to use ? Just wondering.
>>>>
>>>> Just because the driver uses it at the moment does not mean it's the name
>>>> that the IP block uses.
>>>>
>>>> clk_get() has the unpleasant property of doing fuzzy matching
>>>> on the name that is passed. It first tries to use the string
>>>> as the name of the clock input of the device, but if that is
>>>> not there, it falls back to looking for a global clk with a con_id.
>>>>
>>>> In DT, we only support the first kind, but if a driver currently
>>>> uses the second, you get the wrong name.
>>>>
>>>> Looking at arch/mips/jz4740/clock.c now, this seems to be exactly
>>>> what is going on here: there is no clkdev_add call to associate
>>>> the device clocks, so it can only match a global clock entry. 
>>>>
>>> Me confused :-(.
>>>
>>> Does that mean the driver needs to be fixed, that the DT property
>>> needs to change (to what ?), or both ?
>>
>> Both.
>>
>> The jz47xx clock driver should register a clkdev lookup table with
>> proper clock input names for each clock that is referenced by a
>> device, and then the drivers can use the right names.
>>
>> In a lot of cases, the best name for a clock is no name so you
>> just use an anonymous clock like
>>
>>         clk = clk_get(dev, NULL);
>>
>> but this still requires a clock lookup table.
> 
> To illustrate why the current approach is wrong, think of a driver
> that handles a device that can be used on two different SoCs.
> 
> The name used by the clock provider is SoC specific, so the driver
> would need to know which SoC it's being used on in order to pass
> the right clock signal name. clkdev is meant to solve this by providing
> a lookup between the device/clock-input pair and the actual clock.
> 
> Apparently jz4740 does not share any devices with another SoC at
> the moment, so this has not been a problem, but if jz4780 has
> a slightly different clock tree, it's already broken.
> 
> 	Arnd
> 

There is on-going work to fix jz4740, add jz4780 and shake the entire clock tree as well.

Patch 14 onwards in this series
http://patchwork.linux-mips.org/bundle/paulburton/ci20-v3.20/

Instead of lumping things out in huge changesets, I intended to push out the minor patches that are disjoint.

That was the purpose of sending these two patches.

Current binding requires the clock-name to be "rtc". Hence the name at the moment.

Regards,
ZubairLK

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

* Re: [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer
  2015-01-28 10:27                 ` Zubair Lutfullah Kakakhel
  (?)
@ 2015-01-28 11:23                 ` Arnd Bergmann
  -1 siblings, 0 replies; 29+ messages in thread
From: Arnd Bergmann @ 2015-01-28 11:23 UTC (permalink / raw)
  To: Zubair Lutfullah Kakakhel
  Cc: Guenter Roeck, wim, devicetree, linux-kernel, linux-watchdog, paul

On Wednesday 28 January 2015 10:27:00 Zubair Lutfullah Kakakhel wrote:
> 
> There is on-going work to fix jz4740, add jz4780 and shake the entire clock tree as well.
> 
> Patch 14 onwards in this series
> http://patchwork.linux-mips.org/bundle/paulburton/ci20-v3.20/

Right, that looks good.
 
> Instead of lumping things out in huge changesets, I intended to push out the minor patches that are disjoint.
> 
> That was the purpose of sending these two patches.
> 
> Current binding requires the clock-name to be "rtc". Hence the name at the moment.

The problem with the binding is that once you've established it, it
is very hard to change. One possible solution would be to try
'of_clk_get(dev->of_node, 0)' in the driver first, and only then
call clk_get(dev, "rtc"). Doing that, you can have an anonymous clock
in the DT without waiting for the clock driver to get merged first
or breaking the existing setup.

	Arnd

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

end of thread, other threads:[~2015-01-29  2:14 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-27 15:11 [PATCH 0/2] watchdog: jz4740: Add DT support Zubair Lutfullah Kakakhel
2015-01-27 15:11 ` Zubair Lutfullah Kakakhel
2015-01-27 15:11 ` [PATCH 1/2] dt: watchdog: Add DT binding documentation for jz47xx watchdog timer Zubair Lutfullah Kakakhel
2015-01-27 15:11   ` Zubair Lutfullah Kakakhel
2015-01-27 16:30   ` Guenter Roeck
2015-01-27 16:30     ` Guenter Roeck
2015-01-27 20:16   ` Arnd Bergmann
2015-01-27 20:16     ` Arnd Bergmann
2015-01-27 20:52     ` Guenter Roeck
2015-01-27 20:52       ` Guenter Roeck
2015-01-27 21:29       ` Arnd Bergmann
2015-01-27 22:19         ` Guenter Roeck
2015-01-27 22:36           ` Arnd Bergmann
2015-01-27 22:36             ` Arnd Bergmann
2015-01-27 22:42             ` Arnd Bergmann
2015-01-27 22:42               ` Arnd Bergmann
2015-01-28 10:27               ` Zubair Lutfullah Kakakhel
2015-01-28 10:27                 ` Zubair Lutfullah Kakakhel
2015-01-28 11:23                 ` Arnd Bergmann
2015-01-27 15:11 ` [PATCH 2/2] watchdog: jz4740: Add DT support Zubair Lutfullah Kakakhel
2015-01-27 15:11   ` Zubair Lutfullah Kakakhel
2015-01-27 16:31   ` Guenter Roeck
2015-01-27 16:31     ` Guenter Roeck
2015-01-27 20:15   ` Arnd Bergmann
2015-01-27 20:15     ` Arnd Bergmann
2015-01-27 20:54     ` Guenter Roeck
2015-01-27 20:54       ` Guenter Roeck
2015-01-27 21:23       ` Arnd Bergmann
2015-01-27 21:23         ` Arnd Bergmann

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.