2 * (C) Copyright 2016 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0
12 #include <asm/arch/wdt.h>
13 #include <linux/err.h>
15 /* Number of Watchdog Timer ticks before reset */
16 #define AST_WDT_RESET_TIMEOUT 10
17 #define AST_WDT_FOR_RESET 0
19 static int ast_sysreset_request(struct udevice *dev, enum sysreset_t type)
21 struct ast_wdt *wdt = ast_get_wdt(AST_WDT_FOR_RESET);
29 reset_mode = WDT_CTRL_RESET_CPU;
32 reset_mode = WDT_CTRL_RESET_CHIP;
35 return -EPROTONOSUPPORT;
38 /* Clear reset mode bits */
39 clrsetbits_le32(&wdt->ctrl,
40 (WDT_CTRL_RESET_MODE_MASK << WDT_CTRL_RESET_MODE_SHIFT),
41 (reset_mode << WDT_CTRL_RESET_MODE_SHIFT));
42 wdt_start(wdt, AST_WDT_RESET_TIMEOUT);
47 static struct sysreset_ops ast_sysreset = {
48 .request = ast_sysreset_request,
51 U_BOOT_DRIVER(sysreset_ast) = {
52 .name = "ast_sysreset",
53 .id = UCLASS_SYSRESET,