arm: mach-k3: am64x: Implement get_reset_reason()
authorSteffen Kothe <steffen.kothe@skothe.net>
Sun, 31 Aug 2025 15:17:06 +0000 (15:17 +0000)
committerTom Rini <trini@konsulko.com>
Fri, 12 Sep 2025 18:30:08 +0000 (12:30 -0600)
Implement get_reset_reason() for AM64x to enable reporting of the reset
cause in the cpuinfo output.

Notice that the AM64x does not support dedicated reset cause bits for
WDT and PORZ as the AM62x does.

An explanation of this difference is not part of the technical reference
manual and remains unclear.

Signed-off-by: Steffen Kothe <steffen.kothe@skothe.net>
Reviewed-by: Bryan Brattlof <bb@ti.com>
arch/arm/mach-k3/am64x/boot.c

index ce8ae94..f88f92b 100644 (file)
@@ -103,3 +103,39 @@ u32 get_boot_device(void)
 
        return bootmedia;
 }
+
+const char *get_reset_reason(void)
+{
+       u32 reset_reason = readl(CTRLMMR_MCU_RST_SRC);
+
+       /* After reading reset source register, software must clear it */
+       if (reset_reason)
+               writel(reset_reason, CTRLMMR_MCU_RST_SRC);
+
+       if (reset_reason == 0 ||
+          (reset_reason & (RST_SRC_SW_MAIN_POR_FROM_MAIN |
+                           RST_SRC_SW_MAIN_POR_FROM_MCU)))
+               return "POR";
+
+       if (reset_reason & (RST_SRC_SAFETY_ERR | RST_SRC_MAIN_ESM_ERR))
+               return "ESM";
+
+       if (reset_reason & (RST_SRC_SW_MAIN_WARM_FROM_MAIN |
+                           RST_SRC_SW_MAIN_WARM_FROM_MCU  |
+                           RST_SRC_SW_MCU_WARM_RST))
+               return "RST";
+
+       if (reset_reason & (RST_SRC_SMS_WARM_RST | RST_SRC_SMS_COLD_RST))
+               return "DMSC";
+
+       if (reset_reason & RST_SRC_DEBUG_RST)
+               return "JTAG";
+
+       if (reset_reason & RST_SRC_THERMAL_RST)
+               return "THERMAL";
+
+       if (reset_reason & (RST_SRC_MAIN_RESET_PIN | RST_SRC_MCU_RESET_PIN))
+               return "PIN";
+
+       return "UNKNOWN";
+}