[PATCH v2 05/22] arm: mach-k3: common: Add CANUART wakeup check helpers
Markus Schneider-Pargmann
msp at baylibre.com
Fri Jun 13 15:19:25 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 517065bd3a18a5d28270e9cf2f552afa8acb1ed6..9ee47732929dd08f77aefb2f0d65ac93c79d25a2 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -127,13 +127,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 390a6fd41f6a30c9e7837342deb000d308fd802d..b3c1702b8125d0c8248ac15dee4387a807b516d6 100644
--- a/arch/arm/mach-k3/common.h
+++ b/arch/arm/mach-k3/common.h
@@ -50,6 +50,7 @@ struct ti_sci_handle *get_ti_sci_handle(void);
void do_board_detect(void);
void ti_secure_image_check_binary(void **p_image, size_t *p_size);
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