diff options
author | Michal Simek <michal.simek@xilinx.com> | 2018-05-17 14:06:06 +0200 |
---|---|---|
committer | Michal Simek <michal.simek@xilinx.com> | 2018-05-31 13:50:39 +0200 |
commit | d348beaa63fa86d298e76d18c6699b14cbcc0f0f (patch) | |
tree | 1b8ff1a1f391d53ef85e88ac605e31f4ee432fba /board | |
parent | b168591c899e869dc4fcd71752cbe32c91355348 (diff) |
arm64: zynqmp: Show reset reason
Read reset reason reg and show it in log and also save it as variable.
Clearing reset reason when it is read to show only one status
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Diffstat (limited to 'board')
-rw-r--r-- | board/xilinx/zynqmp/zynqmp.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index e41fec32df3..d3450ef6372 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -449,6 +449,47 @@ void reset_cpu(ulong addr) { } +static const struct { + u32 bit; + const char *name; +} reset_reasons[] = { + { RESET_REASON_DEBUG_SYS, "DEBUG" }, + { RESET_REASON_SOFT, "SOFT" }, + { RESET_REASON_SRST, "SRST" }, + { RESET_REASON_PSONLY, "PS-ONLY" }, + { RESET_REASON_PMU, "PMU" }, + { RESET_REASON_INTERNAL, "INTERNAL" }, + { RESET_REASON_EXTERNAL, "EXTERNAL" }, + {} +}; + +static u32 reset_reason(void) +{ + u32 ret; + int i; + const char *reason = NULL; + + ret = readl(&crlapb_base->reset_reason); + + puts("Reset reason:\t"); + + for (i = 0; i < ARRAY_SIZE(reset_reasons); i++) { + if (ret & reset_reasons[i].bit) { + reason = reset_reasons[i].name; + printf("%s ", reset_reasons[i].name); + break; + } + } + + puts("\n"); + + env_set("reset_reason", reason); + + writel(~0, &crlapb_base->reset_reason); + + return ret; +} + int board_late_init(void) { u32 reg = 0; @@ -540,6 +581,8 @@ int board_late_init(void) env_set("boot_targets", new_targets); + reset_reason(); + return 0; } |