[PATCH 4/9] board: ti: j721e: Add resume detection for J7200
Thomas Richard
thomas.richard at bootlin.com
Mon Oct 16 16:11:30 CEST 2023
Add the capability to detect a resume.
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.
Based on the work of Gregory CLEMENT <gregory.clement at bootlin.com>
Signed-off-by: Thomas Richard <thomas.richard at bootlin.com>
Signed-off-by: Gregory CLEMENT <gregory.clement at bootlin.com>
---
board/ti/j721e/evm.c | 54 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
index 38fe447d8f..b4b94c8c69 100644
--- a/board/ti/j721e/evm.c
+++ b/board/ti/j721e/evm.c
@@ -22,6 +22,9 @@
#include <spl.h>
#include <dm.h>
#include <dm/uclass-internal.h>
+#if (IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_TARGET_J7200_R5_EVM))
+#include <power/pmic.h>
+#endif
#include "../common/board_detect.h"
@@ -528,6 +531,57 @@ 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
+
+static int resuming = -1;
+
+int board_is_resuming(void)
+{
+ struct udevice *pmica, *pmicb;
+ int ret;
+
+ if (resuming >= 0)
+ goto end;
+
+ ret = uclass_get_device_by_name(UCLASS_PMIC,
+ "tps659413 at 48", &pmica);
+ if (ret) {
+ printf("Getting PMICA init failed: %d\n", ret);
+ resuming = 0;
+ goto end;
+ }
+ debug("%s: PMICA is detected (%s)\n", __func__, pmica->name);
+
+ ret = uclass_get_device_by_name(UCLASS_PMIC,
+ "lp876441 at 4c", &pmicb);
+ if (ret) {
+ printf("Getting PMICB init failed: %d\n", ret);
+ resuming = 0;
+ goto end;
+ }
+ debug("%s: PMICB is detected (%s)\n", __func__, pmicb->name);
+
+ if ((pmic_reg_read(pmica, SCRATCH_PAD_REG_3) == MAGIC_SUSPEND)) {
+ resuming = 1;
+ debug("%s: board is resuming\n", __func__);
+
+ /* clean magic suspend */
+ if (pmic_reg_write(pmica, SCRATCH_PAD_REG_3, 0))
+ printf("Failed to clean magic value for suspend detection in PMICA\n");
+ } else {
+ resuming = 0;
+ debug("%s: board is booting (no resume detected)\n", __func__);
+ }
+end:
+ return resuming;
+}
+
+#endif /* CONFIG_SPL_BUILD && CONFIG_TARGET_J7200_R5_EVM */
+
void spl_board_init(void)
{
#if defined(CONFIG_ESM_K3) || defined(CONFIG_ESM_PMIC)
--
2.39.2
More information about the U-Boot
mailing list