From patchwork Fri Jan 24 04:44:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 240030 List-Id: U-Boot discussion From: marex at denx.de (Marek Vasut) Date: Fri, 24 Jan 2020 05:44:24 +0100 Subject: [PATCH 2/3] watchdog: omap_wdt: Fix WDT reloading In-Reply-To: <20200124044425.469550-1-marex@denx.de> References: <20200124044425.469550-1-marex@denx.de> Message-ID: <20200124044425.469550-2-marex@denx.de> The watchdog timer value was never updated in the hardware by this driver, so the watchdog triggered on some random stale value that was left in the hardware. The TI SPRUH37C says, quote: 20.4.3.9 Modifying Timer Count/Load Values and Prescaler Setting ... After a write access, the load register value and prescaler ratio registers are updated immediately, but new values are considered only after the next consecutive counter overflow or after a new trigger command (the WDT_WTGR register). This means at least one trigger must happen. The driver probably depended on someone calling it's .reset() callback, however that is not guaranteed e.g. if the WDT operates without servicing. Add this missing trigger. Signed-off-by: Marek Vasut Cc: Grygorii Strashko Cc: Sam Protsenko Cc: Suniel Mahesh --- drivers/watchdog/omap_wdt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index b9cdf70036..85425ca505 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c @@ -219,6 +219,16 @@ static int omap3_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags) while ((readl(&priv->regs->wdtwwps)) & WDT_WWPS_PEND_WSPR) ; + /* Trigger the watchdog to actually reload the counter. */ + while ((readl(&priv->regs->wdtwwps)) & WDT_WWPS_PEND_WTGR) + ; + + priv->wdt_trgr_pattern = ~(priv->wdt_trgr_pattern); + writel(priv->wdt_trgr_pattern, &priv->regs->wdtwtgr); + + while ((readl(&priv->regs->wdtwwps)) & WDT_WWPS_PEND_WTGR) + ; + return 0; }