[PATCH v3 05/22] arm: mach-k3: common: Add CANUART wakeup check helpers
Markus Schneider-Pargmann
msp at baylibre.com
Mon Jun 23 14:08:28 CEST 2025
Add dedicated helper functions to check CANUART wake registers and magic
word. This helps determining if we are in a wakeup or if CAN IO
isolation has to be removed.
Also add a helper to detect a low power mode exit/resume.
Signed-off-by: Markus Schneider-Pargmann <msp at baylibre.com>
---
arch/arm/mach-k3/common.c | 22 ++++++++++++++++++++--
arch/arm/mach-k3/common.h | 1 +
arch/arm/mach-k3/include/mach/hardware.h | 3 +++
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index ff4f2150d318689a87909eb106b0b6fa8ff98f70..7c3f42e35b0f3a5aa7ed0bf01a1479b29d947540 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -161,13 +161,31 @@ static void wkup_ctrl_remove_can_io_isolation(void)
writel(0, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_PMCTRL_IO_GLB);
}
+static bool wkup_ctrl_canuart_wakeup_active(void)
+{
+ return !!(readl(WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_STAT1) &
+ WKUP_CTRL_MMR_CANUART_WAKE_STAT1_CANUART_IO_MODE);
+}
+
+static bool wkup_ctrl_canuart_magic_word_set(void)
+{
+ return readl(WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_OFF_MODE_STAT) ==
+ WKUP_CTRL_MMR_CANUART_WAKE_OFF_MODE_STAT_MW;
+}
+
void wkup_ctrl_remove_can_io_isolation_if_set(void)
{
- if (readl(WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_STAT1) &
- WKUP_CTRL_MMR_CANUART_WAKE_STAT1_CANUART_IO_MODE)
+ if (wkup_ctrl_canuart_wakeup_active() && !wkup_ctrl_canuart_magic_word_set())
wkup_ctrl_remove_can_io_isolation();
}
+bool wkup_ctrl_is_lpm_exit(void)
+{
+ return IS_ENABLED(CONFIG_K3_IODDR) &&
+ wkup_ctrl_canuart_wakeup_active() &&
+ wkup_ctrl_canuart_magic_word_set();
+}
+
bool is_rom_loaded_sysfw(struct rom_extended_boot_data *data)
{
if (strncmp(data->header, K3_ROM_BOOT_HEADER_MAGIC, 7))
diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h
index 49417679e2ec7210d5c95540f476a5d8ee548617..b7dd52fd1792cb6e3eab5c9f3863f983a8ac08df 100644
--- a/arch/arm/mach-k3/common.h
+++ b/arch/arm/mach-k3/common.h
@@ -52,6 +52,7 @@ void do_board_detect(void);
void ti_secure_image_check_binary(void **p_image, size_t *p_size);
int shutdown_mcu_r5_core1(void);
void wkup_ctrl_remove_can_io_isolation_if_set(void);
+bool wkup_ctrl_is_lpm_exit(void);
#if (IS_ENABLED(CONFIG_K3_QOS))
void setup_qos(void);
diff --git a/arch/arm/mach-k3/include/mach/hardware.h b/arch/arm/mach-k3/include/mach/hardware.h
index d7c759420524faf48ea26c66607c6a899d1321b3..e4e7dd61c0689db11083b81f2e74ba8bea74577e 100644
--- a/arch/arm/mach-k3/include/mach/hardware.h
+++ b/arch/arm/mach-k3/include/mach/hardware.h
@@ -128,6 +128,9 @@ K3_SOC_ID(j722s, J722S)
#define WKUP_CTRL_MMR_CANUART_WAKE_STAT1 0x1830c
#define WKUP_CTRL_MMR_CANUART_WAKE_STAT1_CANUART_IO_MODE BIT(0)
+#define WKUP_CTRL_MMR_CANUART_WAKE_OFF_MODE_STAT 0x18318
+#define WKUP_CTRL_MMR_CANUART_WAKE_OFF_MODE_STAT_MW 0x555555
+
#define WKUP_CTRL_MMR_PMCTRL_IO_0 0x18084
#define WKUP_CTRL_MMR_PMCTRL_IO_0_ISOCLK_OVRD_0 BIT(0)
#define WKUP_CTRL_MMR_PMCTRL_IO_0_ISOOVR_EXTEND_0 BIT(4)
--
2.49.0
More information about the U-Boot
mailing list