1 // SPDX-License-Identifier: GPL-2.0
2 // SPDX-License-Identifier: GPL-2.0
3 /*
4  * Copyright (C) ASPEED Technology Inc.
5  * Chia-Wei Wang <chiawei_wang@aspeedtech.com>
6  */
7 
8 #include <common.h>
9 #include <dm.h>
10 #include <errno.h>
11 #include <sysreset.h>
12 #include <wdt.h>
13 #include <asm/io.h>
14 #include <linux/err.h>
15 
16 static int ast_sysreset_request(struct udevice *dev, enum sysreset_t type)
17 {
18 	struct udevice *wdt;
19 	int ret = uclass_first_device(UCLASS_WDT, &wdt);
20 
21 	if (ret)
22 		return ret;
23 
24 	ret = wdt_expire_now(wdt, 0);
25 	if (ret) {
26 		debug("Sysreset failed: %d", ret);
27 		return ret;
28 	}
29 
30 	return -EINPROGRESS;
31 }
32 
33 static struct sysreset_ops ast_sysreset = {
34 	.request	= ast_sysreset_request,
35 };
36 
37 U_BOOT_DRIVER(sysreset_ast) = {
38 	.name	= "ast_sysreset",
39 	.id	= UCLASS_SYSRESET,
40 	.ops	= &ast_sysreset,
41 };
42