[RFC PATCH 07/19] board: ti: j784s4: Add resume detection for J784s4
Prasanth Babu Mantena
p-mantena at ti.com
Fri Mar 13 14:58:48 CET 2026
From: Thomas Richard <thomas.richard at bootlin.com>
Add the capability to detect resume by implementing board_is_resuming(void).
To detect the resume, SPL searches a magic value (0xBA) in a register
of PMIC.
This value is set by DM-Firmware during the suspend sequence.
NB: As this is called in board_init_f(), there's no BSS, so we can't
use global/static variables.
Signed-off-by: Thomas Richard <thomas.richard at bootlin.com>
Co-developed-by: Gregory CLEMENT <gregory.clement at bootlin.com>
Signed-off-by: Gregory CLEMENT <gregory.clement at bootlin.com>
Signed-off-by: Prasanth Babu Mantena <p-mantena at ti.com>
---
arch/arm/mach-k3/j784s4/j784s4_init.c | 2 ++
board/ti/j784s4/evm.c | 41 +++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/arch/arm/mach-k3/j784s4/j784s4_init.c b/arch/arm/mach-k3/j784s4/j784s4_init.c
index 53f152ccd9c..161c68e474f 100644
--- a/arch/arm/mach-k3/j784s4/j784s4_init.c
+++ b/arch/arm/mach-k3/j784s4/j784s4_init.c
@@ -294,6 +294,8 @@ void board_init_f(ulong dummy)
{
struct udevice *dev;
int ret;
+ /* init resume flag */
+ gd_set_k3_resuming(-1);
k3_spl_init();
diff --git a/board/ti/j784s4/evm.c b/board/ti/j784s4/evm.c
index cabb3017ee1..42fb819c553 100644
--- a/board/ti/j784s4/evm.c
+++ b/board/ti/j784s4/evm.c
@@ -12,6 +12,7 @@
#include <init.h>
#include <spl.h>
#include <asm/arch/k3-ddr.h>
+#include <power/pmic.h>
#include "../common/fdt_ops.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -61,6 +62,46 @@ int board_late_init(void)
}
#endif
+#if (IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_TARGET_J784S4_R5_EVM))
+
+#define SCRATCH_PAD_REG_3 0xCB
+
+#define MAGIC_SUSPEND 0xBA
+
+/* in board_init_f(), there's no BSS, so we can't use global/static variables */
+int board_is_resuming(void)
+{
+ struct udevice *pmic;
+ int err;
+
+ if (gd_k3_resuming() >= 0)
+ goto end;
+
+ err = uclass_get_device_by_name(UCLASS_PMIC,
+ "pmic at 48", &pmic);
+ if (err) {
+ printf("Getting PMIC init failed: %d\n", err);
+ goto end;
+ }
+ debug("%s: PMIC is detected (%s)\n", __func__, pmic->name);
+
+ if (pmic_reg_read(pmic, SCRATCH_PAD_REG_3) == MAGIC_SUSPEND) {
+ debug("%s: board is resuming\n", __func__);
+ gd_set_k3_resuming(1);
+
+ /* clean magic suspend */
+ if (pmic_reg_write(pmic, SCRATCH_PAD_REG_3, 0))
+ printf("Failed to clean magic value for suspend detection in PMIC\n");
+ } else {
+ debug("%s: board is booting (no resume detected)\n", __func__);
+ gd_set_k3_resuming(0);
+ }
+end:
+ return gd_k3_resuming();
+}
+
+#endif /* CONFIG_SPL_BUILD && CONFIG_TARGET_J784s4_R5_EVM */
+
void spl_board_init(void)
{
struct udevice *dev;
--
2.34.1
More information about the U-Boot
mailing list