]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
Merge patch series "arm: mach-k3: am64x: Add reset cause for cpuinfo"
authorTom Rini <trini@konsulko.com>
Fri, 12 Sep 2025 18:30:15 +0000 (12:30 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 12 Sep 2025 19:49:34 +0000 (13:49 -0600)
Steffen Kothe <steffen.kothe@skothe.net> says:

AM64X hereby receives support for reset reason printing during boot.

Unfortunately does the AM64X register mapping slighlty differ from
the AM62X. WDT and PORZ are not part of the reset source register, but
the mapping remains the same for all other causes.

To prevent ifdef/else constructs, I decided to follow a simple
copy/paste approach and adjusted the logic accordingly.

Link: https://lore.kernel.org/r/20250831151706.404373-1-steffen.kothe@skothe.net
1  2 
arch/arm/mach-k3/am64x/boot.c
arch/arm/mach-k3/include/mach/am64_hardware.h

index ce8ae941be6f598b562d121ed92b0a4733b12a09,f88f92b9f23aca6dfd7810bed00833bb52a789a9..bf8e1a5cb44513c7a8dc22ac2fc43d0130dcb545
@@@ -103,3 -103,39 +103,39 @@@ u32 get_boot_device(void
  
        return bootmedia;
  }
 -         (reset_reason & (RST_SRC_SW_MAIN_POR_FROM_MAIN |
+ 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";
+ }
index 105b42986de57aea5da2dabdffb659e330266737,95ba488ba17459c9281cf380041ac968022f1af1..2717da07690140b497e213a61f43e8c5d698c68c
  /* Use Last 2K as Scratch pad */
  #define TI_SRAM_SCRATCH_BOARD_EEPROM_START            0x7019f800
  
 -
+ /* Reset Reason Detection */
+ #define CTRLMMR_MCU_RST_SRC                   (MCU_CTRL_MMR0_BASE + 0x18178)
+ /* Reset causes by bit mapping */
+ #define RST_SRC_SAFETY_ERR                    BIT(31)
+ #define RST_SRC_MAIN_ESM_ERR                  BIT(30)
+ #define RST_SRC_SW_MAIN_POR_FROM_MAIN         BIT(25)
+ #define RST_SRC_SW_MAIN_POR_FROM_MCU          BIT(24)
+ #define RST_SRC_SW_MAIN_WARM_FROM_MAIN                BIT(21)
+ #define RST_SRC_SW_MAIN_WARM_FROM_MCU         BIT(20)
+ #define RST_SRC_SW_MCU_WARM_RST                       BIT(16)
+ #define RST_SRC_SMS_WARM_RST                  BIT(13)
+ #define RST_SRC_SMS_COLD_RST                  BIT(12)
+ #define RST_SRC_DEBUG_RST                     BIT(8)
+ #define RST_SRC_THERMAL_RST                   BIT(4)
+ #define RST_SRC_MAIN_RESET_PIN                        BIT(2)
+ #define RST_SRC_MCU_RESET_PIN                 BIT(0)
 -
  #if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__)
  
  #define AM64X_DEV_RTI8                        127