Skip to contentSkip to conversation

watchdog: dw_wdt: common clock framework and devicetree support

PATCH In review Heiko Stübner 4 participants 9 messages Jun 26, 2013 – Oct 29, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover watchdog: dw_wdt: common clock framework and devicetree support

This small series changes the dw_wdt driver, so that it is usable on machines using the common clock framework (needs the clk to be prepared) and devicetree (needs a binding).

Heiko Stuebner (3):
watchdog: dw_wdt: convert to SIMPLE_DEV_PM_OPS
watchdog: dw_wdt: use clk_prepare_enable and clk_disable_unprepare
watchdog: dw_wdt: add a devicetree binding

 .../bindings/watchdog/snps-dw-apb-wdt.txt          |   18 ++++++++++++
 drivers/watchdog/dw_wdt.c                          |   31 ++++++++++++--------
 2 files changed, 36 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/3 watchdog: dw_wdt: convert to SIMPLE_DEV_PM_OPS

The dw_wdt only provides PM_SLEEP operations, so convert the driver to use SIMPLE_DEV_PM_OPS instead of populating the struct manually. This has the added effect of simplifying the CONFIG_PM ifdefs.

---
 drivers/watchdog/dw_wdt.c |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/watchdog/dw_wdt.c +3 -8
index e621098..4d3906d 100644
@@ -252,7 +252,7 @@ static int dw_wdt_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int dw_wdt_suspend(struct device *dev)
 {
 	clk_disable(dw_wdt.clk);
@@ -271,12 +271,9 @@ static int dw_wdt_resume(struct device *dev)
 
 	return 0;
 }
+#endif /* CONFIG_PM_SLEEP */
 
-static const struct dev_pm_ops dw_wdt_pm_ops = {
-	.suspend	= dw_wdt_suspend,
-	.resume		= dw_wdt_resume,
-};
-#endif /* CONFIG_PM */
+static SIMPLE_DEV_PM_OPS(dw_wdt_pm_ops, dw_wdt_suspend, dw_wdt_resume);
 
 static const struct file_operations wdt_fops = {
 	.owner		= THIS_MODULE,
@@ -346,9 +343,7 @@ static struct platform_driver dw_wdt_driver = {
 	.driver		= {
 		.name	= "dw_wdt",
 		.owner	= THIS_MODULE,
-#ifdef CONFIG_PM
 		.pm	= &dw_wdt_pm_ops,
-#endif /* CONFIG_PM */
 	},
 };
 
Signature · 1 line
1.7.10.4
maintainer Reviewed-by on v1 1/3
#2 lore raw

Re: [1/3] watchdog: dw_wdt: convert to SIMPLE_DEV_PM_OPS

Quoted 6 lines · On Thu, Jun 27, 2013 at 02:03:52AM -0000…

The dw_wdt only provides PM_SLEEP operations, so convert the driver to use SIMPLE_DEV_PM_OPS instead of populating the struct manually. This has the added effect of simplifying the CONFIG_PM ifdefs.

#3 lore raw

PATCH 2/3 watchdog: dw_wdt: use clk_prepare_enable and clk_disable_unprepare

In reply to Heiko Stübner

This is necessary to make the driver work with platforms using the common clock framework.

---
 drivers/watchdog/dw_wdt.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/watchdog/dw_wdt.c +5 -5
index 4d3906d..b922bec 100644
@@ -255,14 +255,14 @@ static int dw_wdt_release(struct inode *inode, struct file *filp)
 #ifdef CONFIG_PM_SLEEP
 static int dw_wdt_suspend(struct device *dev)
 {
-	clk_disable(dw_wdt.clk);
+	clk_disable_unprepare(dw_wdt.clk);
 
 	return 0;
 }
 
 static int dw_wdt_resume(struct device *dev)
 {
-	int err = clk_enable(dw_wdt.clk);
+	int err = clk_prepare_enable(dw_wdt.clk);
 
 	if (err)
 		return err;
@@ -306,7 +306,7 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
 	if (IS_ERR(dw_wdt.clk))
 		return PTR_ERR(dw_wdt.clk);
 
-	ret = clk_enable(dw_wdt.clk);
+	ret = clk_prepare_enable(dw_wdt.clk);
 	if (ret)
 		return ret;
 
@@ -323,7 +323,7 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
 	return 0;
 
 out_disable_clk:
-	clk_disable(dw_wdt.clk);
+	clk_disable_unprepare(dw_wdt.clk);
 
 	return ret;
 }
@@ -332,7 +332,7 @@ static int dw_wdt_drv_remove(struct platform_device *pdev)
 {
 	misc_deregister(&dw_wdt_miscdev);
 
-	clk_disable(dw_wdt.clk);
+	clk_disable_unprepare(dw_wdt.clk);
 
 	return 0;
 }
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH 3/3 watchdog: dw_wdt: add a devicetree binding

In reply to Heiko Stübner

The dw_wdt does not use any platform-specific data, so no new properties need to be introduced. The dw-apb-wdt naming follows other designware components in the kernel and is also written like this in documentation describing the component.

---
 .../devicetree/bindings/watchdog/snps-dw-apb-wdt.txt |   18 ++++++++++++++++++
 drivers/watchdog/dw_wdt.c                            |   10 ++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt
Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt new file +18 -0
new file mode 100644
index 0000000..c20cdd1
@@ -0,0 +1,18 @@
+* Synosis DesignWare APB Watchdog
+
+The Watchdog controller is used for resuming system operation
+after a preset amount of time during which the WDT reset event has not
+occurred.
+
+Required properties:
+- compatible : "snps,dw-apb-wdt"
+- reg : offset and length of the register set for the device.
+- clocks : the periphal clock of the controller.
+
+Example:
+
+	watchdog@2004c000 {
+		compatible = "snps,dw-apb-wdt";
+		reg = <0x2004c000 0x100>;
+		clocks = <&wdt_clock>;
+	};
drivers/watchdog/dw_wdt.c +10 -0
index b922bec..829e148 100644
@@ -35,6 +35,7 @@
 #include <linux/timer.h>
 #include <linux/uaccess.h>
 #include <linux/watchdog.h>
+#include <linux/of.h>
 
 #define WDOG_CONTROL_REG_OFFSET		    0x00
 #define WDOG_CONTROL_REG_WDT_EN_MASK	    0x01
@@ -337,12 +338,21 @@ static int dw_wdt_drv_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id dw_wdt_of_match[] = {
+	{ .compatible = "snps,dw-apb-wdt", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
+#endif
+
 static struct platform_driver dw_wdt_driver = {
 	.probe		= dw_wdt_drv_probe,
 	.remove		= dw_wdt_drv_remove,
 	.driver		= {
 		.name	= "dw_wdt",
 		.owner	= THIS_MODULE,
+		.of_match_table = of_match_ptr(dw_wdt_of_match),
 		.pm	= &dw_wdt_pm_ops,
 	},
 };
Signature · 1 line
1.7.10.4
#6 lore raw

Re: [PATCH 3/3] watchdog: dw_wdt: add a devicetree binding

Quoted 18 lines · Heiko Stübner

The dw_wdt does not use any platform-specific data, so no new properties need to be introduced. The dw-apb-wdt naming follows other designware components in the kernel and is also written like this in documentation describing the component.

---
 .../devicetree/bindings/watchdog/snps-dw-apb-wdt.txt |   18 ++++++++++++++++++
 drivers/watchdog/dw_wdt.c                            |   10 ++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt
Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt new file +0 -0
new file mode 100644
index 0000000..c20cdd1

Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt line 1

Quoted 1 line
Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt new file +1 -0
@@ -0,0 +1,18 @@
+* Synosis DesignWare APB Watchdog

Probably should be Synopsis?

Signature · 2 lines
With warm regards,
Sachin
#7 lore raw
In reply to Heiko Stübner

Hi Heiko,

Quoted 9 lines

This small series changes the dw_wdt driver, so that it is usable on machines using the common clock framework (needs the clk to be prepared) and devicetree (needs a binding).

Heiko Stuebner (3):
watchdog: dw_wdt: convert to SIMPLE_DEV_PM_OPS
watchdog: dw_wdt: use clk_prepare_enable and clk_disable_unprepare
watchdog: dw_wdt: add a devicetree binding

Quoted 4 lines
 .../bindings/watchdog/snps-dw-apb-wdt.txt          |   18 ++++++++++++
 drivers/watchdog/dw_wdt.c                          |   31 ++++++++++++--------
 2 files changed, 36 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt

patches 1 and 2 have been added to linux-watchdog-next.
Patch 3 has been replaced with Dinh Nguyen's patch (watchdog: dw: Enable OF support for DW watchdog timer).

Kind regards,
Wim.

#8 lore raw

Hi Wim,

Am Dienstag, 29. Oktober 2013, 08:32:55 schrieb Wim Van Sebroeck:

Quoted 15 lines
Quoted 9 lines

This small series changes the dw_wdt driver, so that it is usable on machines using the common clock framework (needs the clk to be prepared) and devicetree (needs a binding).

Heiko Stuebner (3):
watchdog: dw_wdt: convert to SIMPLE_DEV_PM_OPS
watchdog: dw_wdt: use clk_prepare_enable and clk_disable_unprepare
watchdog: dw_wdt: add a devicetree binding

Quoted 5 lines
 .../bindings/watchdog/snps-dw-apb-wdt.txt          |   18 ++++++++++++
 drivers/watchdog/dw_wdt.c                          |   31
 ++++++++++++-------- 2 files changed, 36 insertions(+), 13 deletions(-)
 create mode 100644

Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt

Quoted 3 lines

patches 1 and 2 have been added to linux-watchdog-next.
Patch 3 has been replaced with Dinh Nguyen's patch (watchdog: dw: Enable OF support for DW watchdog timer).

cool ... totally forgot about this series.

Shared IPs-blocks are a nice thing, making stuff not depend on individual lazy developers [like me this time ;-) ]

Heiko