devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] watchdog: dw_wdt: common clock framework and devicetree support
@ 2013-06-26 18:03 Heiko Stübner
  2013-06-26 18:03 ` [PATCH 1/3] watchdog: dw_wdt: convert to SIMPLE_DEV_PM_OPS Heiko Stübner
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Heiko Stübner @ 2013-06-26 18:03 UTC (permalink / raw)
  To: Wim Van Sebroeck
  Cc: Jamie Iles, Grant Likely, Rob Herring, devicetree-discuss,
	linux-kernel, linux-watchdog

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

-- 
1.7.10.4

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

* [PATCH 1/3] watchdog: dw_wdt: convert to SIMPLE_DEV_PM_OPS
  2013-06-26 18:03 [PATCH 0/3] watchdog: dw_wdt: common clock framework and devicetree support Heiko Stübner
@ 2013-06-26 18:03 ` Heiko Stübner
  2013-06-26 18:04 ` [PATCH 2/3] watchdog: dw_wdt: use clk_prepare_enable and clk_disable_unprepare Heiko Stübner
  2013-06-26 18:05 ` [PATCH 3/3] watchdog: dw_wdt: add a devicetree binding Heiko Stübner
  2 siblings, 0 replies; 5+ messages in thread
From: Heiko Stübner @ 2013-06-26 18:03 UTC (permalink / raw)
  To: Wim Van Sebroeck
  Cc: Jamie Iles, Grant Likely, Rob Herring, devicetree-discuss,
	linux-kernel, linux-watchdog

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.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/watchdog/dw_wdt.c |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index e621098..4d3906d 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -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 */
 	},
 };
 
-- 
1.7.10.4

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

* [PATCH 2/3] watchdog: dw_wdt: use clk_prepare_enable and clk_disable_unprepare
  2013-06-26 18:03 [PATCH 0/3] watchdog: dw_wdt: common clock framework and devicetree support Heiko Stübner
  2013-06-26 18:03 ` [PATCH 1/3] watchdog: dw_wdt: convert to SIMPLE_DEV_PM_OPS Heiko Stübner
@ 2013-06-26 18:04 ` Heiko Stübner
  2013-06-26 18:05 ` [PATCH 3/3] watchdog: dw_wdt: add a devicetree binding Heiko Stübner
  2 siblings, 0 replies; 5+ messages in thread
From: Heiko Stübner @ 2013-06-26 18:04 UTC (permalink / raw)
  To: Wim Van Sebroeck
  Cc: Jamie Iles, Grant Likely, Rob Herring, devicetree-discuss,
	linux-kernel, linux-watchdog

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

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/watchdog/dw_wdt.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index 4d3906d..b922bec 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -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;
 }
-- 
1.7.10.4

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

* [PATCH 3/3] watchdog: dw_wdt: add a devicetree binding
  2013-06-26 18:03 [PATCH 0/3] watchdog: dw_wdt: common clock framework and devicetree support Heiko Stübner
  2013-06-26 18:03 ` [PATCH 1/3] watchdog: dw_wdt: convert to SIMPLE_DEV_PM_OPS Heiko Stübner
  2013-06-26 18:04 ` [PATCH 2/3] watchdog: dw_wdt: use clk_prepare_enable and clk_disable_unprepare Heiko Stübner
@ 2013-06-26 18:05 ` Heiko Stübner
  2013-06-27  6:31   ` Sachin Kamat
  2 siblings, 1 reply; 5+ messages in thread
From: Heiko Stübner @ 2013-06-26 18:05 UTC (permalink / raw)
  To: Wim Van Sebroeck
  Cc: Jamie Iles, Grant Likely, Rob Herring, devicetree-discuss,
	linux-kernel, linux-watchdog

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.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 .../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

diff --git a/Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt b/Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt
new file mode 100644
index 0000000..c20cdd1
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt
@@ -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>;
+	};
diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index b922bec..829e148 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -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,
 	},
 };
-- 
1.7.10.4

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

* Re: [PATCH 3/3] watchdog: dw_wdt: add a devicetree binding
  2013-06-26 18:05 ` [PATCH 3/3] watchdog: dw_wdt: add a devicetree binding Heiko Stübner
@ 2013-06-27  6:31   ` Sachin Kamat
  0 siblings, 0 replies; 5+ messages in thread
From: Sachin Kamat @ 2013-06-27  6:31 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: Wim Van Sebroeck, Jamie Iles, Grant Likely, Rob Herring,
	devicetree-discuss, linux-kernel, linux-watchdog

On 26 June 2013 23:35, Heiko Stübner <heiko@sntech.de> wrote:
> 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.
>
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> ---
>  .../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
>
> diff --git a/Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt b/Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt
> new file mode 100644
> index 0000000..c20cdd1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/watchdog/snps-dw-apb-wdt.txt
> @@ -0,0 +1,18 @@
> +* Synosis DesignWare APB Watchdog

Probably should be Synopsis?


-- 
With warm regards,
Sachin

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

end of thread, other threads:[~2013-06-27  6:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-26 18:03 [PATCH 0/3] watchdog: dw_wdt: common clock framework and devicetree support Heiko Stübner
2013-06-26 18:03 ` [PATCH 1/3] watchdog: dw_wdt: convert to SIMPLE_DEV_PM_OPS Heiko Stübner
2013-06-26 18:04 ` [PATCH 2/3] watchdog: dw_wdt: use clk_prepare_enable and clk_disable_unprepare Heiko Stübner
2013-06-26 18:05 ` [PATCH 3/3] watchdog: dw_wdt: add a devicetree binding Heiko Stübner
2013-06-27  6:31   ` Sachin Kamat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).