From 774616b69a59103569d40b1faaac4fe470f9c5c9 Mon Sep 17 00:00:00 2001 From: Bai Ping Date: Mon, 19 Dec 2016 18:11:07 +0800 Subject: MLK-13632 driver: watchdog: Fix system reset when sending wdog unlock sequence For i.MX7ULP wdog, when we want to unlock the wdog with 16bit unlock command, the two unlock command sequence must be write to WDOG_CNT register within 16 bus clocks, otherwise, system may be reset unexpected. As writel include memory barrier, if we use writel to send the unlock command, it may take more time than 16 bus clock, so we should use writel_relaxed to write the unlock command to the CNT register. Signed-off-by: Bai Ping --- drivers/watchdog/imx7ulp_wdt.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'drivers/watchdog') diff --git a/drivers/watchdog/imx7ulp_wdt.c b/drivers/watchdog/imx7ulp_wdt.c index 845c900b5bcb..b54268849ce6 100644 --- a/drivers/watchdog/imx7ulp_wdt.c +++ b/drivers/watchdog/imx7ulp_wdt.c @@ -146,15 +146,10 @@ static inline void imx7ulp_wdt_init(void __iomem *base, unsigned int timeout) local_irq_disable(); - /* - * if the wdog is in unlocked status, the UNLOCK - * sequence no need to be send. - */ - val = readl(base + WDOG_CS); - if (!(val & WDOG_CS_ULK)) { - writel(UNLOCK_SEQ0, base + WDOG_CNT); - writel(UNLOCK_SEQ1, base + WDOG_CNT); - } + /* unlock the wdog for reconfiguration */ + writel_relaxed(UNLOCK_SEQ0, base + WDOG_CNT); + writel_relaxed(UNLOCK_SEQ1, base + WDOG_CNT); + /*set an initial timeout value in TOVAL */ writel(timeout, base + WDOG_TOVAL); /* enable 32bit command sequence and reconfigure */ -- cgit v1.2.3