Skip to content

Commit 2a31bf2

Browse files
kelvincheungWim Van Sebroeck
authored andcommitted
watchdog: loongson1_wdt: Implement restart handler
Implement restart handler for the Loongson-1 watchdog driver and define the watchdog registers instead of including the legacy header. Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20230330112051.551648-3-keguang.zhang@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
1 parent d0ee0e8 commit 2a31bf2

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

drivers/watchdog/loongson1_wdt.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
#include <linux/module.h>
88
#include <linux/platform_device.h>
99
#include <linux/watchdog.h>
10-
#include <loongson1.h>
10+
11+
/* Loongson 1 Watchdog Register Definitions */
12+
#define WDT_EN 0x0
13+
#define WDT_TIMER 0x4
14+
#define WDT_SET 0x8
1115

1216
#define DEFAULT_HEARTBEAT 30
1317

@@ -66,6 +70,18 @@ static int ls1x_wdt_stop(struct watchdog_device *wdt_dev)
6670
return 0;
6771
}
6872

73+
static int ls1x_wdt_restart(struct watchdog_device *wdt_dev,
74+
unsigned long action, void *data)
75+
{
76+
struct ls1x_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev);
77+
78+
writel(0x1, drvdata->base + WDT_EN);
79+
writel(0x1, drvdata->base + WDT_TIMER);
80+
writel(0x1, drvdata->base + WDT_SET);
81+
82+
return 0;
83+
}
84+
6985
static const struct watchdog_info ls1x_wdt_info = {
7086
.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
7187
.identity = "Loongson1 Watchdog",
@@ -77,6 +93,7 @@ static const struct watchdog_ops ls1x_wdt_ops = {
7793
.stop = ls1x_wdt_stop,
7894
.ping = ls1x_wdt_ping,
7995
.set_timeout = ls1x_wdt_set_timeout,
96+
.restart = ls1x_wdt_restart,
8097
};
8198

8299
static int ls1x_wdt_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)