Hi Andrew,
On 06/01/26 22:53, Andrew Davis wrote:
On 1/5/26 10:38 AM, Markus Schneider-Pargmann (TI.com) wrote:
Add a small helper that uses memory regions referenced by the R5
devicetree node to calculate the LPM meta data address.
Signed-off-by: Markus Schneider-Pargmann (TI.com) <[email protected]>
---
arch/arm/mach-k3/am62xx-lpm-common.c | 45 ++++++++++++++++++++++++++
++++++++++
arch/arm/mach-k3/am62xx-lpm-common.h | 1 +
2 files changed, 46 insertions(+)
diff --git a/arch/arm/mach-k3/am62xx-lpm-common.c b/arch/arm/mach-k3/
am62xx-lpm-common.c
index
fa068c60ce9ccf9cec89aeae1d224b07091a3298..6870395aec838949b5c25a32262a6c30e6c88d2e 100644
--- a/arch/arm/mach-k3/am62xx-lpm-common.c
+++ b/arch/arm/mach-k3/am62xx-lpm-common.c
@@ -9,6 +9,8 @@
#include <config.h>
#include <asm/arch/hardware.h>
#include <asm/io.h>
+#include <dm/of_access.h>
+#include <dm/ofnode.h>
#include <linux/soc/ti/ti_sci_protocol.h>
#include <vsprintf.h>
#include <wait_bit.h>
@@ -48,6 +50,8 @@
#define WKUP_CTRL_MMR_CANUART_WAKE_OFF_MODE_STAT 0x18318
#define WKUP_CTRL_MMR_CANUART_WAKE_OFF_MODE_STAT_MW 0x555555
+#define K3_R5_MEMREGION_LPM_METADATA_OFFSET 0x108000
+
Could this offset into the R5's second reserved memory area change based
on the firmware used? Actually this whole thing feels hacky. Why not
just add the location to DT explicitly instead of trying to derive it.
The offset value of LPM Metadata in linker file will always be relative
to the position of DM's reserved memory region in DDR.
Reference:
https://github.com/TexasInstruments/mcupsdk-core-k3/blob/k3_main/examples/drivers/ipc/ipc_rpmsg_echo_linux/am62ax-sk/r5fss0-0_freertos/ti-arm-clang/linker.cmd#L169
Actually, don't we pick this address as part of the
TISCI_MSG_PREPARE_SLEEP?
This is not done as a part of PREPARE SLEEP message. As DM is the one
reserving static memory for LPM, it is already aware of the address
where context needs to be saved.
Or does DM do it now, either way there must be some better way to
coordinate
between DM and R5 SPL than hardcoded offsets..
Andrew
#define CLKSTOP_TRANSITION_TIMEOUT_MS 10
static int wkup_ctrl_remove_can_io_isolation(void)
@@ -126,6 +130,43 @@ int __maybe_unused
wkup_ctrl_remove_can_io_isolation_if_set(void)
}
#if IS_ENABLED(CONFIG_K3_IODDR)
+int wkup_r5f_am62_lpm_meta_data_addr(u64 *meta_data_addr)
+{
+ struct ofnode_phandle_args memregion_phandle;
+ ofnode memregion;
+ ofnode wkup_bus;
+ int ret;
+
+ wkup_bus = ofnode_path("/bus@f0000/bus@b00000");
+ if (!ofnode_valid(wkup_bus)) {
+ printf("Failed to find wkup bus\n");
+ return -EINVAL;
+ }
+
+ memregion = ofnode_by_compatible(wkup_bus, "ti,am62-r5f");
+ if (!ofnode_valid(memregion)) {
+ printf("Failed to find r5f devicetree node ti,am62-r5f\n");
+ return -EINVAL;
+ }
+
+ ret = ofnode_parse_phandle_with_args(memregion, "memory-region",
NULL,
+ 0, 1, &memregion_phandle);
+ if (ret) {
+ printf("Failed to parse phandle for second memory region\n");
+ return ret;
+ }
+
+ ret = ofnode_read_u64_index(memregion_phandle.node, "reg", 0,
meta_data_addr);
+ if (ret) {
+ printf("Failed to read memory region offset\n");
+ return ret;
+ }
+
+ *meta_data_addr += K3_R5_MEMREGION_LPM_METADATA_OFFSET;
+
...
Thanks and Regards,
Akashdeep Kaur