From: Thomas Richard <thomas.richard@bootlin.com>
To: u-boot@lists.denx.de
Cc: nm@ti.com, thomas.richard@bootlin.com,
thomas.petazzoni@bootlin.com, gregory.clement@bootlin.com,
u-kumar1@ti.com, Tom Rini <trini@konsulko.com>
Subject: [PATCH v2 4/8] board: ti: j721e: Add resume detection for J7200
Date: Tue, 7 Nov 2023 17:17:58 +0100 [thread overview]
Message-ID: <20231107161802.855154-5-thomas.richard@bootlin.com> (raw)
In-Reply-To: <20231107161802.855154-1-thomas.richard@bootlin.com>
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@bootlin.com>
Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
(no changes since v1)
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@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@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
next prev parent reply other threads:[~2023-11-07 16:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-07 16:17 [PATCH v2 0/8] Suspend to RAM support for K3 J7200 Thomas Richard
2023-11-07 16:17 ` [PATCH v2 1/8] DO NOT MERGE: arm: dts: k3-j7200-r5-common: Add pmic node for esm Thomas Richard
2023-11-07 16:17 ` [PATCH v2 2/8] configs: j7200_evm_r5: Used reserved memory in DDR for stack Thomas Richard
2023-11-07 18:12 ` Tom Rini
2023-11-07 16:17 ` [PATCH v2 3/8] configs: j7200_evm_r5: Move address used for allocation in the reserved space Thomas Richard
2023-11-07 16:17 ` Thomas Richard [this message]
2023-11-07 18:16 ` [PATCH v2 4/8] board: ti: j721e: Add resume detection for J7200 Tom Rini
2023-11-07 16:17 ` [PATCH v2 5/8] ram: k3-ddrss: Add exit retention support Thomas Richard
2023-11-07 16:18 ` [PATCH v2 6/8] board: ti: j721e: Add the missing part of exit retention for k3-ddrss (J7200) Thomas Richard
2023-11-07 18:18 ` Tom Rini
2023-11-09 10:43 ` Thomas Richard
2023-11-09 14:07 ` Tom Rini
2023-11-07 16:18 ` [PATCH v2 7/8] board: ti: j721e: During resume spl restores TF-A and DM-Firmware Thomas Richard
2023-11-07 18:26 ` Tom Rini
2023-11-08 17:30 ` Andrew Davis
2023-11-09 11:29 ` Thomas Richard
2023-11-09 16:17 ` Andrew Davis
2023-11-07 16:18 ` [PATCH v2 8/8] arm: mach-k3: j7200: Skip fit processing when resuming Thomas Richard
2023-11-07 18:06 ` [PATCH v2 0/8] Suspend to RAM support for K3 J7200 Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231107161802.855154-5-thomas.richard@bootlin.com \
--to=thomas.richard@bootlin.com \
--cc=gregory.clement@bootlin.com \
--cc=nm@ti.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=u-kumar1@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox