Lines Matching +full:wdt +full:- +full:timeout
1 // SPDX-License-Identifier: GPL-2.0
16 #include <linux/turris-omnia-mcu-interface.h>
17 #include "turris-omnia-mcu.h"
21 static unsigned int timeout; variable
22 module_param(timeout, int, 0);
23 MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds");
30 static int omnia_wdt_start(struct watchdog_device *wdt) in omnia_wdt_start() argument
32 struct omnia_mcu *mcu = watchdog_get_drvdata(wdt); in omnia_wdt_start()
34 return omnia_cmd_write_u8(mcu->client, OMNIA_CMD_SET_WATCHDOG_STATE, 1); in omnia_wdt_start()
37 static int omnia_wdt_stop(struct watchdog_device *wdt) in omnia_wdt_stop() argument
39 struct omnia_mcu *mcu = watchdog_get_drvdata(wdt); in omnia_wdt_stop()
41 return omnia_cmd_write_u8(mcu->client, OMNIA_CMD_SET_WATCHDOG_STATE, 0); in omnia_wdt_stop()
44 static int omnia_wdt_ping(struct watchdog_device *wdt) in omnia_wdt_ping() argument
46 struct omnia_mcu *mcu = watchdog_get_drvdata(wdt); in omnia_wdt_ping()
48 return omnia_cmd_write_u8(mcu->client, OMNIA_CMD_SET_WATCHDOG_STATE, 1); in omnia_wdt_ping()
51 static int omnia_wdt_set_timeout(struct watchdog_device *wdt, in omnia_wdt_set_timeout() argument
52 unsigned int timeout) in omnia_wdt_set_timeout() argument
54 struct omnia_mcu *mcu = watchdog_get_drvdata(wdt); in omnia_wdt_set_timeout()
56 return omnia_cmd_write_u16(mcu->client, OMNIA_CMD_SET_WDT_TIMEOUT, in omnia_wdt_set_timeout()
57 timeout * DECI); in omnia_wdt_set_timeout()
60 static unsigned int omnia_wdt_get_timeleft(struct watchdog_device *wdt) in omnia_wdt_get_timeleft() argument
62 struct omnia_mcu *mcu = watchdog_get_drvdata(wdt); in omnia_wdt_get_timeleft()
66 err = omnia_cmd_read_u16(mcu->client, OMNIA_CMD_GET_WDT_TIMELEFT, in omnia_wdt_get_timeleft()
69 dev_err(&mcu->client->dev, "Cannot get watchdog timeleft: %d\n", in omnia_wdt_get_timeleft()
93 struct device *dev = &mcu->client->dev; in omnia_mcu_register_watchdog()
97 if (!(mcu->features & OMNIA_FEAT_WDT_PING)) in omnia_mcu_register_watchdog()
100 mcu->wdt.info = &omnia_wdt_info; in omnia_mcu_register_watchdog()
101 mcu->wdt.ops = &omnia_wdt_ops; in omnia_mcu_register_watchdog()
102 mcu->wdt.parent = dev; in omnia_mcu_register_watchdog()
103 mcu->wdt.min_timeout = 1; in omnia_mcu_register_watchdog()
104 mcu->wdt.max_timeout = 65535 / DECI; in omnia_mcu_register_watchdog()
106 mcu->wdt.timeout = WATCHDOG_TIMEOUT; in omnia_mcu_register_watchdog()
107 watchdog_init_timeout(&mcu->wdt, timeout, dev); in omnia_mcu_register_watchdog()
109 watchdog_set_drvdata(&mcu->wdt, mcu); in omnia_mcu_register_watchdog()
111 omnia_wdt_set_timeout(&mcu->wdt, mcu->wdt.timeout); in omnia_mcu_register_watchdog()
113 err = omnia_cmd_read_u8(mcu->client, OMNIA_CMD_GET_WATCHDOG_STATE, in omnia_mcu_register_watchdog()
120 set_bit(WDOG_HW_RUNNING, &mcu->wdt.status); in omnia_mcu_register_watchdog()
122 watchdog_set_nowayout(&mcu->wdt, nowayout); in omnia_mcu_register_watchdog()
123 watchdog_stop_on_reboot(&mcu->wdt); in omnia_mcu_register_watchdog()
124 err = devm_watchdog_register_device(dev, &mcu->wdt); in omnia_mcu_register_watchdog()