[PATCH 03/20] board: ti: j721e: Add resume detection for J721e/J7200
Kumar, Udit
u-kumar1 at ti.com
Mon May 11 11:53:21 CEST 2026
On 4/30/2026 2:13 PM, Richard Genoud (TI) wrote:
> From: "Thomas Richard (TI)" <thomas.richard at bootlin.com>
>
> Add the capability to detect a resume. This overrides the weak
> function j7xx_board_is_resuming(void).
> To detect the resume, SPL searches a magic value (0xBA) in a register
> of PMICA.
> This value is set by DM-Firmware during the suspend sequence.
>
> Signed-off-by: Thomas Richard (TI) <thomas.richard at bootlin.com>
> Co-developed-by: Gregory CLEMENT (TI) <gregory.clement at bootlin.com>
> Signed-off-by: Gregory CLEMENT (TI) <gregory.clement at bootlin.com>
> Co-developed-by: Richard Genoud (TI) <richard.genoud at bootlin.com>
> Signed-off-by: Richard Genoud (TI) <richard.genoud at bootlin.com>
> ---
> board/ti/common/k3-lpm.h | 17 +++++++++++++++++
> board/ti/j721e/evm.c | 37 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 54 insertions(+)
> create mode 100644 board/ti/common/k3-lpm.h
>
> diff --git a/board/ti/common/k3-lpm.h b/board/ti/common/k3-lpm.h
> new file mode 100644
> index 000000000000..a2141a0c25a8
> --- /dev/null
> +++ b/board/ti/common/k3-lpm.h
> @@ -0,0 +1,17 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (C) 2026, Texas Instruments Incorporated - https://www.ti.com/
> + * Copyright (C) 2026, Bootlin
> + */
> +
> +#ifndef __K3_LPM_H
> +#define __K3_LPM_H
> +
> +/* Magic value in PMIC register to indicate the suspend state (SOC_OFF) */
> +#define K3_LPM_MAGIC_SUSPEND 0xba
> +
> +/* PMIC register where the magic value resides */
> +#define K3_LPM_SCRATCH_PAD_REG 0xcb
> +
> +#endif /* __K3_LPM_H */
> +
> diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
> index 881392bd963a..67ff13828514 100644
> --- a/board/ti/j721e/evm.c
> +++ b/board/ti/j721e/evm.c
> @@ -17,9 +17,11 @@
> #include <spl.h>
> #include <dm.h>
> #include <asm/arch/k3-ddr.h>
> +#include <power/pmic.h>
>
> #include "../common/board_detect.h"
> #include "../common/fdt_ops.h"
> +#include "../common/k3-lpm.h"
>
> #define board_is_j721e_som() (board_ti_k3_is("J721EX-PM1-SOM") || \
> board_ti_k3_is("J721EX-PM2-SOM"))
> @@ -469,6 +471,41 @@ err_free_gpio:
> }
> }
>
> +#if (IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_TARGET_J7200_R5_EVM))
> +
> +bool j7xx_board_is_resuming(void)
> +{
> + struct udevice *pmica;
> + int ret;
> +
> + if (gd_k3_resuming() != K3_RESUME_STATE_UNKNOWN)
> + goto end;
> +
> + ret = uclass_get_device_by_name(UCLASS_PMIC,
> + "pmic at 48", &pmica);
> + if (ret) {
> + printf("Getting PMICA init failed: %d\n", ret);
> + goto end;
> + }
> + debug("%s: PMICA is detected (%s)\n", __func__, pmica->name);
> +
> + if (pmic_reg_read(pmica, K3_LPM_SCRATCH_PAD_REG) == K3_LPM_MAGIC_SUSPEND) {
> + debug("%s: board is resuming\n", __func__);
> + gd_set_k3_resuming(K3_RESUME_STATE_RESUMING);
If you failed to clear magic word then, we are not in correct state.
So doing all work with PMIC, set state to resuming
> +
> + /* clean magic suspend */
> + if (pmic_reg_write(pmica, K3_LPM_SCRATCH_PAD_REG, 0))
> + printf("Failed to clean magic value for suspend detection in PMICA\n");
> + } else {
> + debug("%s: board is booting (no resume detected)\n", __func__);
> + gd_set_k3_resuming(K3_RESUME_STATE_BOOTING);
> + }
> +end:
> + return gd_k3_resuming() == K3_RESUME_STATE_RESUMING;
> +}
> +
> +#endif /* CONFIG_SPL_BUILD && CONFIG_TARGET_J7200_R5_EVM */
> +
> void spl_board_init(void)
> {
> struct udevice *dev;
More information about the U-Boot
mailing list