[PATCH 18/20] board: ti: evm: Store wakeup reason on scratchpad memory
Andrew Davis
afd at ti.com
Thu Apr 30 19:32:32 CEST 2026
On 4/30/26 3:44 AM, Richard Genoud (TI) wrote:
> 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>
> ---
> arch/arm/mach-k3/include/mach/j721e_hardware.h | 1 +
> arch/arm/mach-k3/include/mach/j784s4_hardware.h | 1 +
> board/ti/common/k3-lpm.h | 5 +++++
> board/ti/j721e/evm.c | 9 +++++++++
> board/ti/j784s4/evm.c | 9 +++++++++
> 5 files changed, 25 insertions(+)
>
> diff --git a/arch/arm/mach-k3/include/mach/j721e_hardware.h b/arch/arm/mach-k3/include/mach/j721e_hardware.h
> index 587dd10eb1ea..d58e2b3e1bb2 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
Should this be a Kconfig option?
Andrew
>
> #if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__)
>
> diff --git a/arch/arm/mach-k3/include/mach/j784s4_hardware.h b/arch/arm/mach-k3/include/mach/j784s4_hardware.h
> index dd51473419dd..2fc81902f879 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__)
>
> diff --git a/board/ti/common/k3-lpm.h b/board/ti/common/k3-lpm.h
> index a2141a0c25a8..dfd8f8486f08 100644
> --- a/board/ti/common/k3-lpm.h
> +++ b/board/ti/common/k3-lpm.h
> @@ -13,5 +13,10 @@
> /* PMIC register where the magic value resides */
> #define K3_LPM_SCRATCH_PAD_REG 0xcb
>
> +struct lpm_scratch_space {
> + u16 wake_src;
> + u16 reserved;
> +} __packed;
> +
> #endif /* __K3_LPM_H */
>
> diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
> index 41eea1bdea95..a9f469fea1f7 100644
> --- a/board/ti/j721e/evm.c
> +++ b/board/ti/j721e/evm.c
> @@ -474,6 +474,9 @@ err_free_gpio:
>
> #if (IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_TARGET_J7200_R5_EVM))
>
> +#define LPM_WAKE_SOURCE_PMIC_GPIO 0x91
> +#define LPM_WAKE_SOURCE_MAIN_IO 0x80
> +
> static void clear_isolation(void)
> {
> int ret;
> @@ -498,12 +501,15 @@ bool j7xx_board_is_resuming(void)
> {
> struct udevice *pmica;
> u32 pmctrl_val = readl(PMCTRL_IO_1);
> + struct lpm_scratch_space *lpm_scratch;
> int ret;
>
> if (gd_k3_resuming() != K3_RESUME_STATE_UNKNOWN)
> goto end;
>
> + lpm_scratch = (struct lpm_scratch_space *)TI_SRAM_SCRATCH_LPM_START;
> if ((pmctrl_val & IO_ISO_STATUS) == IO_ISO_STATUS) {
> + lpm_scratch->wake_src = LPM_WAKE_SOURCE_MAIN_IO;
> clear_isolation();
> gd_set_k3_resuming(K3_RESUME_STATE_RESUMING);
> debug("Resuming from IO_DDR mode\n");
> @@ -520,6 +526,7 @@ bool j7xx_board_is_resuming(void)
>
> if (pmic_reg_read(pmica, K3_LPM_SCRATCH_PAD_REG) == K3_LPM_MAGIC_SUSPEND) {
> debug("%s: board is resuming\n", __func__);
> + lpm_scratch->wake_src = LPM_WAKE_SOURCE_PMIC_GPIO;
> gd_set_k3_resuming(K3_RESUME_STATE_RESUMING);
>
> /* clean magic suspend */
> @@ -527,6 +534,8 @@ bool j7xx_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(K3_RESUME_STATE_BOOTING);
> }
> end:
> diff --git a/board/ti/j784s4/evm.c b/board/ti/j784s4/evm.c
> index eef56556a33c..b94ec7f3653b 100644
> --- a/board/ti/j784s4/evm.c
> +++ b/board/ti/j784s4/evm.c
> @@ -68,6 +68,9 @@ int board_late_init(void)
> #if (IS_ENABLED(CONFIG_SPL_BUILD) && (IS_ENABLED(CONFIG_TARGET_J784S4_R5_EVM) || \
> IS_ENABLED(CONFIG_TARGET_J742S2_R5_EVM)))
>
> +#define LPM_WAKE_SOURCE_PMIC_GPIO 0x91
> +#define LPM_WAKE_SOURCE_MCU_IO 0x81
> +
> static void clear_isolation(void)
> {
> int ret;
> @@ -93,12 +96,15 @@ bool j7xx_board_is_resuming(void)
> {
> struct udevice *pmic;
> u32 pmctrl_val = readl(WKUP_CTRL_MMR0_BASE + PMCTRL_IO_0);
> + struct lpm_scratch_space *lpm_scratch;
> int err;
>
> if (gd_k3_resuming() != K3_RESUME_STATE_UNKNOWN)
> goto end;
>
> + lpm_scratch = (struct lpm_scratch_space *)TI_SRAM_SCRATCH_LPM_START;
> if ((pmctrl_val & IO_ISO_STATUS) == IO_ISO_STATUS) {
> + lpm_scratch->wake_src = LPM_WAKE_SOURCE_MCU_IO;
> clear_isolation();
> gd_set_k3_resuming(K3_RESUME_STATE_RESUMING);
> debug("board is resuming from IO_DDR mode\n");
> @@ -115,6 +121,7 @@ bool j7xx_board_is_resuming(void)
>
> if (pmic_reg_read(pmic, K3_LPM_SCRATCH_PAD_REG) == K3_LPM_MAGIC_SUSPEND) {
> debug("%s: board is resuming\n", __func__);
> + lpm_scratch->wake_src = LPM_WAKE_SOURCE_PMIC_GPIO;
> gd_set_k3_resuming(K3_RESUME_STATE_RESUMING);
>
> /* clean magic suspend */
> @@ -122,6 +129,8 @@ bool j7xx_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(K3_RESUME_STATE_BOOTING);
> }
> end:
More information about the U-Boot
mailing list