From: Stanley Chu Date: Tue, 16 Dec 2025 02:47:24 +0000 (+0800) Subject: watchdog: npcm: Support more timeout value X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f74beb8dcf325707dcf6b4f6e260c940236f8067;p=thirdparty%2Fu-boot.git watchdog: npcm: Support more timeout value Calculate a timeout value that is close to the requested value. Signed-off-by: Stanley Chu --- diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c index 57b61215a2a..7becc646fda 100644 --- a/drivers/watchdog/npcm_wdt.c +++ b/drivers/watchdog/npcm_wdt.c @@ -27,26 +27,11 @@ struct npcm_wdt_priv { static int npcm_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags) { struct npcm_wdt_priv *priv = dev_get_priv(dev); - u32 time_out, val; - - time_out = (u32)(timeout_ms) / 1000; - if (time_out < 2) - val = 0x800; - else if (time_out < 3) - val = 0x420; - else if (time_out < 6) - val = 0x810; - else if (time_out < 11) - val = 0x430; - else if (time_out < 22) - val = 0x820; - else if (time_out < 44) - val = 0xc00; - else if (time_out < 87) - val = 0x830; - else if (time_out < 173) - val = 0xc10; - else if (time_out < 688) + u32 val; + + if (timeout_ms < 343552) + val = ((timeout_ms / 1342) << 16) + 0x800; + else if (timeout_ms < 688000) val = 0xc20; else val = 0xc30;