All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/7] ti: wdt: omap: Disable watchdog timer before performing initialization
Date: Sun, 19 Feb 2017 23:24:38 +0100	[thread overview]
Message-ID: <1487543082-24746-5-git-send-email-lukma@denx.de> (raw)
In-Reply-To: <1487543082-24746-1-git-send-email-lukma@denx.de>

The OMAP WDT IP block requires to be stopped before any write to its
registers is performed.

This problem has been thoroughly described in Linux kernel:

"watchdog: omap: assert the counter being stopped before reprogramming:
SHA1: 530c11d432727c697629ad5f9d00ee8e2864d453

Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
 drivers/watchdog/omap_wdt.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 7ea4b60..7b1f429 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -81,10 +81,32 @@ static int omap_wdt_set_timeout(unsigned int timeout)
 	return 0;
 }
 
+void hw_watchdog_disable(void)
+{
+	struct wd_timer *wdt = (struct wd_timer *)WDT_BASE;
+
+	/*
+	 * Disable watchdog
+	 */
+	writel(0xAAAA, &wdt->wdtwspr);
+	while (readl(&wdt->wdtwwps) != 0x0)
+		;
+	writel(0x5555, &wdt->wdtwspr);
+	while (readl(&wdt->wdtwwps) != 0x0)
+		;
+}
+
 void hw_watchdog_init(void)
 {
 	struct wd_timer *wdt = (struct wd_timer *)WDT_BASE;
 
+	/*
+	 * Make sure the watchdog is disabled. This is unfortunately required
+	 * because writing to various registers with the watchdog running has no
+	 * effect.
+	 */
+	hw_watchdog_disable();
+
 	/* initialize prescaler */
 	while (readl(&wdt->wdtwwps) & WDT_WWPS_PEND_WCLR)
 		;
@@ -104,18 +126,3 @@ void hw_watchdog_init(void)
 	while ((readl(&wdt->wdtwwps)) & WDT_WWPS_PEND_WSPR)
 		;
 }
-
-void hw_watchdog_disable(void)
-{
-	struct wd_timer *wdt = (struct wd_timer *)WDT_BASE;
-
-	/*
-	 * Disable watchdog
-	 */
-	writel(0xAAAA, &wdt->wdtwspr);
-	while (readl(&wdt->wdtwwps) != 0x0)
-		;
-	writel(0x5555, &wdt->wdtwspr);
-	while (readl(&wdt->wdtwwps) != 0x0)
-		;
-}
-- 
2.1.4

  parent reply	other threads:[~2017-02-19 22:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-19 22:24 [U-Boot] [PATCH 0/7] ti: wdt: Fixes for am57xx/dra7 Watchdog Lukasz Majewski
2017-02-19 22:24 ` Lukasz Majewski
2017-02-19 22:24 ` [U-Boot] [PATCH 1/7] ti: wdt: common: Make the wdt IP defines common for the TI platform Lukasz Majewski
2017-02-20  2:24   ` Tom Rini
2017-04-10 18:24   ` [U-Boot] [U-Boot, " Tom Rini
2017-02-19 22:24 ` [U-Boot] [PATCH 2/7] ti: wdt: omap5: Define WDT_BASE for omap5+ SoC Lukasz Majewski
2017-02-20  2:24   ` Tom Rini
2017-04-10 18:24   ` [U-Boot] [U-Boot, " Tom Rini
2017-02-19 22:24 ` Lukasz Majewski [this message]
2017-02-20  2:25   ` [U-Boot] [PATCH 3/7] ti: wdt: omap: Disable watchdog timer before performing initialization Tom Rini
2017-04-07 20:29     ` Lukasz Majewski
2017-04-10 18:24   ` [U-Boot] [U-Boot, " Tom Rini
2017-02-19 22:24 ` [U-Boot] [PATCH 4/7] ti: wdt: hwinit-common: Remove legacy watchdog disable code Lukasz Majewski
2017-02-20  2:25   ` Tom Rini
2017-02-20  6:42   ` Lokesh Vutla
2017-02-20  7:32     ` Lukasz Majewski
2017-02-19 22:24 ` [U-Boot] [PATCH 5/7] ti: wdt: omap5: Remove not needed struct watchdog definition Lukasz Majewski
2017-02-20  2:25   ` Tom Rini
2017-02-19 22:24 ` [U-Boot] [PATCH 6/7] ti: wdt: omap: Use CONFIG_HW_WATCHDOG_TIMEOUT_MS to specify watchdog timeout Lukasz Majewski
2017-02-20  2:23   ` Tom Rini
2017-02-19 22:24 ` [U-Boot] [PATCH 7/7] ti: wdt: Enable OMAP watchdog in u-boot's board_f.c Lukasz Majewski
2017-02-20  2:24   ` Tom Rini
2017-02-20  7:35     ` Lukasz Majewski
2017-02-20 12:11       ` Tom Rini

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=1487543082-24746-5-git-send-email-lukma@denx.de \
    --to=lukma@denx.de \
    --cc=u-boot@lists.denx.de \
    /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.