[RFC PATCH 13/19] board: ti: evm: Store wakeup reason on scratchpad memory

Prasanth Babu Mantena p-mantena at ti.com
Fri Mar 13 14:58:54 CET 2026


From: Abhash Kumar Jha <a-kumar2 at ti.com>

While resuming from suspend, the wakeup reason need to be stored
and this will be used by the linux kernel once its up.

Use the 32 bytes of MCU_PSRAM0_RAM area (addr = 0x40280000) to
store the wakeup reason.

Read the value as soon as it starts and store it internally.

Signed-off-by: Abhash Kumar Jha <a-kumar2 at ti.com>
Signed-off-by: Prasanth Babu Mantena <p-mantena at ti.com>
---
 arch/arm/mach-k3/include/mach/j721e_hardware.h  | 9 +++++++++
 arch/arm/mach-k3/include/mach/j784s4_hardware.h | 9 +++++++++
 board/ti/j721e/evm.c                            | 9 ++++++++-
 board/ti/j784s4/evm.c                           | 8 +++++++-
 4 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-k3/include/mach/j721e_hardware.h b/arch/arm/mach-k3/include/mach/j721e_hardware.h
index 587dd10eb1e..6913b992614 100644
--- a/arch/arm/mach-k3/include/mach/j721e_hardware.h
+++ b/arch/arm/mach-k3/include/mach/j721e_hardware.h
@@ -47,6 +47,7 @@
 
 /* MCU SCRATCHPAD usage */
 #define TI_SRAM_SCRATCH_BOARD_EEPROM_START	CONFIG_SYS_K3_MCU_SCRATCHPAD_BASE
+#define TI_SRAM_SCRATCH_LPM_START    0x40280000
 
 #if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__)
 
@@ -63,6 +64,14 @@ static const u32 put_device_ids[] = {
 #define J721E_DEV_MCU_ARMSS0_CPU0		250
 #define J721E_DEV_MCU_ARMSS0_CPU1		251
 
+struct lpm_scratch_space {
+	u16 wake_src;
+	u16 reserved;
+} __packed;
+
+#define TI_SRAM_LPM_SCRATCH ((struct lpm_scratch_space *)\
+				TI_SRAM_SCRATCH_LPM_START)
+
 static const u32 put_core_ids[] = {
 	J721E_DEV_MCU_ARMSS0_CPU1,
 	J721E_DEV_MCU_ARMSS0_CPU0,	/* Handle CPU0 after CPU1 */
diff --git a/arch/arm/mach-k3/include/mach/j784s4_hardware.h b/arch/arm/mach-k3/include/mach/j784s4_hardware.h
index dd51473419d..6137481e8a6 100644
--- a/arch/arm/mach-k3/include/mach/j784s4_hardware.h
+++ b/arch/arm/mach-k3/include/mach/j784s4_hardware.h
@@ -46,6 +46,7 @@
 
 /* MCU SCRATCHPAD usage */
 #define TI_SRAM_SCRATCH_BOARD_EEPROM_START	CONFIG_SYS_K3_MCU_SCRATCHPAD_BASE
+#define TI_SRAM_SCRATCH_LPM_START    0x40280000
 
 #if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__)
 
@@ -67,4 +68,12 @@ static const u32 put_core_ids[] = {
 	J784S4_DEV_MCU_ARMSS0_CPU0,     /* Handle CPU0 after CPU1 */
 };
 
+struct lpm_scratch_space {
+	u16 wake_src;
+	u16 reserved;
+} __packed;
+
+#define TI_SRAM_LPM_SCRATCH ((struct lpm_scratch_space *)\
+				TI_SRAM_SCRATCH_LPM_START)
+
 #endif /* __ASM_ARCH_J784S4_HARDWARE_H */
diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
index 368381c422a..efa4832f034 100644
--- a/board/ti/j721e/evm.c
+++ b/board/ti/j721e/evm.c
@@ -474,8 +474,10 @@ err_free_gpio:
 #if (IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_TARGET_J7200_R5_EVM))
 
 #define SCRATCH_PAD_REG_3 0xCB
-
 #define MAGIC_SUSPEND 0xBA
+#define LPM_WAKE_SOURCE_PMIC_GPIO 0x91
+#define LPM_WAKE_SOURCE_MAIN_IO   0x80
+
 static void clear_isolation(void)
 {
 	int ret;
@@ -501,12 +503,14 @@ int board_is_resuming(void)
 	struct udevice *pmica;
 	struct udevice *pmicb;
 	u32 pmctrl_val = readl(PMCTRL_IO_1);
+	struct lpm_scratch_space *lpm_scratch = (struct lpm_scratch_space *)TI_SRAM_LPM_SCRATCH;
 	int ret;
 
 	if (gd_k3_resuming() >= 0)
 		goto end;
 
 	if ((pmctrl_val & IO_ISO_STATUS) == IO_ISO_STATUS) {
+		lpm_scratch->wake_src = LPM_WAKE_SOURCE_MAIN_IO;
 		clear_isolation();
 		gd_set_k3_resuming(1);
 		debug("Resuming from IO_DDR mode\n");
@@ -531,6 +535,7 @@ int board_is_resuming(void)
 
 	if (pmic_reg_read(pmica, SCRATCH_PAD_REG_3) == MAGIC_SUSPEND) {
 		debug("%s: board is resuming\n", __func__);
+		lpm_scratch->wake_src = LPM_WAKE_SOURCE_PMIC_GPIO;
 		gd_set_k3_resuming(1);
 
 		/* clean magic suspend */
@@ -538,6 +543,8 @@ int board_is_resuming(void)
 			printf("Failed to clean magic value for suspend detection in PMICA\n");
 	} else {
 		debug("%s: board is booting (no resume detected)\n", __func__);
+		lpm_scratch->wake_src = 0;
+		lpm_scratch->reserved = 0;
 		gd_set_k3_resuming(0);
 	}
 end:
diff --git a/board/ti/j784s4/evm.c b/board/ti/j784s4/evm.c
index 56d5abea6a9..3fd1a00c683 100644
--- a/board/ti/j784s4/evm.c
+++ b/board/ti/j784s4/evm.c
@@ -67,8 +67,9 @@ int board_late_init(void)
 #if (IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_TARGET_J784S4_R5_EVM))
 
 #define SCRATCH_PAD_REG_3 0xCB
-
 #define MAGIC_SUSPEND 0xBA
+#define LPM_WAKE_SOURCE_PMIC_GPIO 0x91
+#define LPM_WAKE_SOURCE_MCU_IO    0x81
 
 static void clear_isolation(void)
 {
@@ -95,12 +96,14 @@ int board_is_resuming(void)
 {
 	struct udevice *pmic;
 	u32 pmctrl_val = readl(WKUP_CTRL_MMR0_BASE + PMCTRL_IO_0);
+	struct lpm_scratch_space *lpm_scratch = (struct lpm_scratch_space *)TI_SRAM_LPM_SCRATCH;
 	int err;
 
 	if (gd_k3_resuming() >= 0)
 		goto end;
 
 	if ((pmctrl_val & IO_ISO_STATUS) == IO_ISO_STATUS) {
+		lpm_scratch->wake_src = LPM_WAKE_SOURCE_MCU_IO;
 		clear_isolation();
 		gd_set_k3_resuming(1);
 		debug("board is resuming from IO_DDR mode\n");
@@ -117,6 +120,7 @@ int board_is_resuming(void)
 
 	if (pmic_reg_read(pmic, SCRATCH_PAD_REG_3) == MAGIC_SUSPEND) {
 		debug("%s: board is resuming\n", __func__);
+		lpm_scratch->wake_src = LPM_WAKE_SOURCE_PMIC_GPIO;
 		gd_set_k3_resuming(1);
 
 		/* clean magic suspend */
@@ -124,6 +128,8 @@ int board_is_resuming(void)
 			printf("Failed to clean magic value for suspend detection in PMIC\n");
 	} else {
 		debug("%s: board is booting (no resume detected)\n", __func__);
+		lpm_scratch->wake_src = 0;
+		lpm_scratch->reserved = 0;
 		gd_set_k3_resuming(0);
 	}
 end:
-- 
2.34.1



More information about the U-Boot mailing list