On 12/10/2025 7:38 PM, Markus Schneider-Pargmann (TI.com) wrote:
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.

Tested-by: Anshul Dalal <[email protected]>
Signed-off-by: Markus Schneider-Pargmann (TI.com) <[email protected]>
---
  arch/arm/mach-k3/common.c                | 19 +++++++++++++++++++
  arch/arm/mach-k3/common.h                |  1 +
  arch/arm/mach-k3/include/mach/hardware.h |  6 ++++++
  3 files changed, 26 insertions(+)

diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 
760aaad03411441e3cc169f2501134cf69dcbee6..a80cf87ce65a44c386539ade17c0f435e09de841
 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -115,6 +115,25 @@ void mmr_unlock(uintptr_t base, u32 partition)
        writel(CTRLMMR_LOCK_KICK1_UNLOCK_VAL, part_base + CTRLMMR_LOCK_KICK1);
  }
+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;
+}
+
+bool wkup_ctrl_is_lpm_exit(void)
+{
+       return IS_ENABLED(CONFIG_K3_IODDR) &&
+               wkup_ctrl_canuart_wakeup_active() &&
+               wkup_ctrl_canuart_magic_word_set();
+}

May not be valid for all SOC,  either move into some am62xx_base.c or make it  __weak, so that other SOCs can over-ride this if needed.


+
  bool is_rom_loaded_sysfw(struct rom_extended_boot_data *data)
  {
[..]    

Reply via email to