Skip to content

Commit db60d55

Browse files
ccpalexWim Van Sebroeck
authored andcommitted
watchdog: imx_sc_wdt: detect if already running
Firmware (SC) WDT can be already enabled in U-Boot. Detect this case and make CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED functional by setting WDOG_HW_RUNNING. Signed-off-by: Alexander Sverdlin <[email protected]> Reviewed-by: Guenter Roeck <[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 6adb559 commit db60d55

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/watchdog/imx_sc_wdt.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,25 @@ static int imx_sc_wdt_ping(struct watchdog_device *wdog)
5656
return 0;
5757
}
5858

59+
static bool imx_sc_wdt_is_running(void)
60+
{
61+
struct arm_smccc_res res;
62+
63+
arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_START_WDOG,
64+
0, 0, 0, 0, 0, 0, &res);
65+
66+
/* Already enabled (SC_TIMER_ERR_BUSY)? */
67+
if (res.a0 == SC_TIMER_ERR_BUSY)
68+
return true;
69+
70+
/* Undo only if that was us who has (successfully) enabled the WDT */
71+
if (!res.a0)
72+
arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_STOP_WDOG,
73+
0, 0, 0, 0, 0, 0, &res);
74+
75+
return false;
76+
}
77+
5978
static int imx_sc_wdt_start(struct watchdog_device *wdog)
6079
{
6180
struct arm_smccc_res res;
@@ -183,6 +202,9 @@ static int imx_sc_wdt_probe(struct platform_device *pdev)
183202
if (ret)
184203
return ret;
185204

205+
if (imx_sc_wdt_is_running())
206+
set_bit(WDOG_HW_RUNNING, &wdog->status);
207+
186208
watchdog_stop_on_reboot(wdog);
187209
watchdog_stop_on_unregister(wdog);
188210

0 commit comments

Comments
 (0)