From b36388217d489316997048f5eae28f3a57209ff8 Mon Sep 17 00:00:00 2001 From: Stanley Chu Date: Thu, 14 Aug 2025 16:54:51 +0800 Subject: [PATCH] watchdog: npcm: Support more timeout value Calculate a timeout value that is close to the requested value. Signed-off-by: Stanley Chu --- drivers/watchdog/npcm_wdt.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c index 57b61215a2a3..7becc646fda9 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;