Skip to content

Commit 45f1884

Browse files
flokliWim Van Sebroeck
authored andcommitted
watchdog: apple: set max_hw_heartbeat_ms instead of max_timeout
The hardware only supports timeouts slightly below 3mins, but by using max_hw_heartbeat_ms we can let the kernel take care of supporting larger timeouts than that requested from userspace. Switching to max_hw_heartbeat_ms also means our set_timeout function now needs to configure the hardware to the minimum of either the requested timeout (in seconds) or the maximum supported by the user (in seconds). Signed-off-by: Florian Klink <[email protected]> Reviewed-by: Wim Van Sebroeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 1aea3e1 commit 45f1884

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/watchdog/apple_wdt.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@ static int apple_wdt_ping(struct watchdog_device *wdd)
9595
static int apple_wdt_set_timeout(struct watchdog_device *wdd, unsigned int s)
9696
{
9797
struct apple_wdt *wdt = to_apple_wdt(wdd);
98+
u32 actual;
9899

99100
writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_CUR_TIME);
100-
writel_relaxed(wdt->clk_rate * s, wdt->regs + APPLE_WDT_WD1_BITE_TIME);
101+
102+
actual = min(s, wdd->max_hw_heartbeat_ms / 1000);
103+
writel_relaxed(wdt->clk_rate * actual, wdt->regs + APPLE_WDT_WD1_BITE_TIME);
101104

102105
wdd->timeout = s;
103106

@@ -177,7 +180,7 @@ static int apple_wdt_probe(struct platform_device *pdev)
177180

178181
wdt->wdd.ops = &apple_wdt_ops;
179182
wdt->wdd.info = &apple_wdt_info;
180-
wdt->wdd.max_timeout = U32_MAX / wdt->clk_rate;
183+
wdt->wdd.max_hw_heartbeat_ms = U32_MAX / wdt->clk_rate * 1000;
181184
wdt->wdd.timeout = APPLE_WDT_TIMEOUT_DEFAULT;
182185

183186
wdt_ctrl = readl_relaxed(wdt->regs + APPLE_WDT_WD1_CTRL);

0 commit comments

Comments
 (0)