aboutsummaryrefslogtreecommitdiffstats
path: root/roms/u-boot/drivers/sysreset/sysreset_ast.c
diff options
context:
space:
mode:
Diffstat (limited to 'roms/u-boot/drivers/sysreset/sysreset_ast.c')
-rw-r--r--roms/u-boot/drivers/sysreset/sysreset_ast.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/roms/u-boot/drivers/sysreset/sysreset_ast.c b/roms/u-boot/drivers/sysreset/sysreset_ast.c
new file mode 100644
index 000000000..d747ed00a
--- /dev/null
+++ b/roms/u-boot/drivers/sysreset/sysreset_ast.c
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2016 Google, Inc
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <log.h>
+#include <sysreset.h>
+#include <wdt.h>
+#include <asm/io.h>
+#include <asm/arch/wdt.h>
+#include <linux/err.h>
+#include <hang.h>
+
+static int ast_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+ struct udevice *wdt;
+ u32 reset_mode;
+ int ret = uclass_first_device(UCLASS_WDT, &wdt);
+
+ if (ret)
+ return ret;
+
+ switch (type) {
+ case SYSRESET_WARM:
+ reset_mode = WDT_CTRL_RESET_CPU;
+ break;
+ case SYSRESET_COLD:
+ reset_mode = WDT_CTRL_RESET_CHIP;
+ break;
+ default:
+ return -EPROTONOSUPPORT;
+ }
+
+#if !defined(CONFIG_SPL_BUILD)
+ ret = wdt_expire_now(wdt, reset_mode);
+ if (ret) {
+ debug("Sysreset failed: %d", ret);
+ return ret;
+ }
+#else
+ hang();
+#endif
+
+ return -EINPROGRESS;
+}
+
+static struct sysreset_ops ast_sysreset = {
+ .request = ast_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_ast) = {
+ .name = "ast_sysreset",
+ .id = UCLASS_SYSRESET,
+ .ops = &ast_sysreset,
+};