aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/mach-npcm/npcm8xx/reset.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-npcm/npcm8xx/reset.c')
-rw-r--r--arch/arm/mach-npcm/npcm8xx/reset.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/arch/arm/mach-npcm/npcm8xx/reset.c b/arch/arm/mach-npcm/npcm8xx/reset.c
new file mode 100644
index 0000000000..6954e6c6a1
--- /dev/null
+++ b/arch/arm/mach-npcm/npcm8xx/reset.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 Nuvoton Technology Corp.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/gcr.h>
+#include <asm/arch/rst.h>
+
+void reset_cpu(void)
+{
+ /* Generate a watchdog0 reset */
+ writel(WTCR_WTR | WTCR_WTRE | WTCR_WTE, WTCR0_REG);
+
+ while (1)
+ ;
+}
+
+void reset_misc(void)
+{
+ struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+
+ clrbits_le32(&gcr->intcr2, INTCR2_WDC);
+}
+
+int npcm_get_reset_status(void)
+{
+ struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
+ u32 val;
+
+ val = readl(&gcr->ressr);
+ if (!val)
+ val = readl(&gcr->intcr2);
+
+ return val & RST_STS_MASK;
+}