All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cor Peters <cpeters-JQzsJ8WnmGqc6Wr4J9gsBQC/G2K4zDHf@public.gmane.org>
To: linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 1/2] Watchdog: omap_wdt: Retrieve bootstatus via syscon
Date: Tue, 15 Nov 2016 09:44:03 +0100	[thread overview]
Message-ID: <2736782.ivGPcGWbll@corpeters> (raw)

The current way to retrieve the bootstatus does not work with
device-tree based systems. This patch uses syscon to retrieve the
watchdog boot status from the PRM_DEV registers.

Signed-off-by: Cor Peters <cpeters-JQzsJ8WnmGqc6Wr4J9gsBQC/G2K4zDHf@public.gmane.org>
---
 drivers/watchdog/omap_wdt.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 1b02bfa..fed3f9c 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -41,6 +41,8 @@
 #include <linux/slab.h>
 #include <linux/pm_runtime.h>
 #include <linux/platform_data/omap-wd-timer.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
 
 #include "omap_wdt.h"
 
@@ -230,9 +232,11 @@ static unsigned int omap_wdt_get_timeleft(struct watchdog_device *wdog)
 static int omap_wdt_probe(struct platform_device *pdev)
 {
        struct omap_wd_timer_platform_data *pdata = dev_get_platdata(&pdev->dev);
+       struct regmap *rm = syscon_regmap_lookup_by_compatible("ti,omap3-prcm-dev");
        struct resource *res;
        struct omap_wdt_dev *wdev;
        int ret;
+       u32 rs = 0;
 
        wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
        if (!wdev)
@@ -267,9 +271,17 @@ static int omap_wdt_probe(struct platform_device *pdev)
 
        if (pdata && pdata->read_reset_sources) {
                u32 rs = pdata->read_reset_sources();
-               if (rs & (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT))
-                       wdev->wdog.bootstatus = WDIOF_CARDRESET;
        }
+       else if (!IS_ERR(rm)) {
+               if (regmap_read(rm, 2 * sizeof(u32), &rs) >= 0) {
+                       /* reset register */
+                       regmap_write(rm, 2 * sizeof(u32),
+                               (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT) );
+               }
+       }
+
+       if (rs & (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT))
+               wdev->wdog.bootstatus = WDIOF_CARDRESET;
 
        if (!early_enable)
                omap_wdt_disable(wdev);
-- 
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

WARNING: multiple messages have this Message-ID (diff)
From: Cor Peters <cpeters@victronenergy.com>
To: <linux-omap@vger.kernel.org>
Cc: <linux-watchdog@vger.kernel.org>
Subject: [PATCH 1/2] Watchdog: omap_wdt: Retrieve bootstatus via syscon
Date: Tue, 15 Nov 2016 09:44:03 +0100	[thread overview]
Message-ID: <2736782.ivGPcGWbll@corpeters> (raw)

The current way to retrieve the bootstatus does not work with
device-tree based systems. This patch uses syscon to retrieve the
watchdog boot status from the PRM_DEV registers.

Signed-off-by: Cor Peters <cpeters@victronenergy.com>
---
 drivers/watchdog/omap_wdt.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 1b02bfa..fed3f9c 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -41,6 +41,8 @@
 #include <linux/slab.h>
 #include <linux/pm_runtime.h>
 #include <linux/platform_data/omap-wd-timer.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
 
 #include "omap_wdt.h"
 
@@ -230,9 +232,11 @@ static unsigned int omap_wdt_get_timeleft(struct watchdog_device *wdog)
 static int omap_wdt_probe(struct platform_device *pdev)
 {
        struct omap_wd_timer_platform_data *pdata = dev_get_platdata(&pdev->dev);
+       struct regmap *rm = syscon_regmap_lookup_by_compatible("ti,omap3-prcm-dev");
        struct resource *res;
        struct omap_wdt_dev *wdev;
        int ret;
+       u32 rs = 0;
 
        wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
        if (!wdev)
@@ -267,9 +271,17 @@ static int omap_wdt_probe(struct platform_device *pdev)
 
        if (pdata && pdata->read_reset_sources) {
                u32 rs = pdata->read_reset_sources();
-               if (rs & (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT))
-                       wdev->wdog.bootstatus = WDIOF_CARDRESET;
        }
+       else if (!IS_ERR(rm)) {
+               if (regmap_read(rm, 2 * sizeof(u32), &rs) >= 0) {
+                       /* reset register */
+                       regmap_write(rm, 2 * sizeof(u32),
+                               (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT) );
+               }
+       }
+
+       if (rs & (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT))
+               wdev->wdog.bootstatus = WDIOF_CARDRESET;
 
        if (!early_enable)
                omap_wdt_disable(wdev);
-- 
1.9.1


             reply	other threads:[~2016-11-15  8:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-15  8:44 Cor Peters [this message]
2016-11-15  8:44 ` [PATCH 1/2] Watchdog: omap_wdt: Retrieve bootstatus via syscon Cor Peters
2016-11-15 14:09 ` Guenter Roeck
2016-11-15 14:09   ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2736782.ivGPcGWbll@corpeters \
    --to=cpeters-jqzsj8wnmgqc6wr4j9gsbqc/g2k4zdhf@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.