[PATCH v5 01/13] arm: mach-k3: Remove CANUART IO isolation

Dhruva Gole d-gole at ti.com
Tue Nov 11 10:28:28 CET 2025


On Nov 10, 2025 at 21:10:25 +0100, Markus Schneider-Pargmann (TI.com) wrote:
> After leaving the Partial-IO mode or other deep sleep states, the IO
> isolation needs to be removed. This routine is shared by at least am62,
> am62a and am62p.
> 
> The original function for testing was developed by
> Akashdeep Kaur <a-kaur at ti.com>
> 
> Tested-by: Anshul Dalal <anshuld at ti.com>
> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp at baylibre.com>
> ---
>  arch/arm/mach-k3/am62ax/am62a7_init.c    |  2 ++
>  arch/arm/mach-k3/am62px/am62p5_init.c    |  2 ++
>  arch/arm/mach-k3/am62x/am625_init.c      |  2 ++
>  arch/arm/mach-k3/common.c                | 56 ++++++++++++++++++++++++++++++++
>  arch/arm/mach-k3/common.h                |  1 +
>  arch/arm/mach-k3/include/mach/hardware.h | 29 +++++++++++++++++
>  6 files changed, 92 insertions(+)
> 
> diff --git a/arch/arm/mach-k3/am62ax/am62a7_init.c b/arch/arm/mach-k3/am62ax/am62a7_init.c
> index 48d578e7d6f180f06b42003313bf643c725eae7e..60645272c816023798cc5d6fa46a2c569143343b 100644
> --- a/arch/arm/mach-k3/am62ax/am62a7_init.c
> +++ b/arch/arm/mach-k3/am62ax/am62a7_init.c
> @@ -101,6 +101,8 @@ void board_init_f(ulong dummy)
>  	/* Init DM early */
>  	spl_early_init();
>  
> +	wkup_ctrl_remove_can_io_isolation_if_set();
> +
>  	/*
>  	 * Process pinctrl for the serial0 and serial3, aka WKUP_UART0 and
>  	 * MAIN_UART1 modules and continue regardless of the result of pinctrl.
> diff --git a/arch/arm/mach-k3/am62px/am62p5_init.c b/arch/arm/mach-k3/am62px/am62p5_init.c
> index aebd5200b0db9959805d04408b34d283e21b6e2c..1c47debca61598ecacae03d83b4001a72dda164a 100644
> --- a/arch/arm/mach-k3/am62px/am62p5_init.c
> +++ b/arch/arm/mach-k3/am62px/am62p5_init.c
> @@ -160,6 +160,8 @@ void board_init_f(ulong dummy)
>  	if (ret)
>  		panic("spl_early_init() failed: %d\n", ret);
>  
> +	wkup_ctrl_remove_can_io_isolation_if_set();
> +
>  	/*
>  	 * Process pinctrl for the serial0 and serial3, aka WKUP_UART0 and
>  	 * MAIN_UART1 modules and continue regardless of the result of pinctrl.
> diff --git a/arch/arm/mach-k3/am62x/am625_init.c b/arch/arm/mach-k3/am62x/am625_init.c
> index 14f93ac998f7d11997b753550c0ea38926e35e64..6eae8929ef7722ff46f67c82d2e17eff618eaff2 100644
> --- a/arch/arm/mach-k3/am62x/am625_init.c
> +++ b/arch/arm/mach-k3/am62x/am625_init.c
> @@ -201,6 +201,8 @@ void board_init_f(ulong dummy)
>  	/* Init DM early */
>  	spl_early_init();
>  
> +	wkup_ctrl_remove_can_io_isolation_if_set();
> +
>  	/*
>  	 * Process pinctrl for the serial0 and serial3, aka WKUP_UART0 and
>  	 * MAIN_UART1 modules and continue regardless of the result of pinctrl.
> diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
> index 7c06764af8256b7fd27f8e7f208a597b1b91652b..b4a605503d27b29d0fb962fbe4c94650a1f6c54f 100644
> --- a/arch/arm/mach-k3/common.c
> +++ b/arch/arm/mach-k3/common.c
> @@ -33,6 +33,9 @@
>  #include <asm/armv8/mmu.h>
>  #include <mach/k3-common-fdt.h>
>  #include <mach/k3-ddr.h>
> +#include <wait_bit.h>
> +
> +#define CLKSTOP_TRANSITION_TIMEOUT_MS	10
>  
>  #define PROC_BOOT_CTRL_FLAG_R5_CORE_HALT	0x00000001
>  #define PROC_BOOT_STATUS_FLAG_R5_WFI		0x00000002
> @@ -115,6 +118,59 @@ void mmr_unlock(uintptr_t base, u32 partition)
>  	writel(CTRLMMR_LOCK_KICK1_UNLOCK_VAL, part_base + CTRLMMR_LOCK_KICK1);
>  }
>  
> +static void wkup_ctrl_remove_can_io_isolation(void)
> +{
> +	const void *wait_reg = (const void *)(WKUP_CTRL_MMR0_BASE +
> +					      WKUP_CTRL_MMR_CANUART_WAKE_STAT1);
> +	int ret;
> +	u32 reg = 0;
> +
> +	/* Program magic word */
> +	reg = readl(WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_CTRL);
> +	reg |= WKUP_CTRL_MMR_CANUART_WAKE_CTRL_MW << WKUP_CTRL_MMR_CANUART_WAKE_CTRL_MW_SHIFT;
> +	writel(reg, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_CTRL);
> +
> +	/* Set enable bit. */
> +	reg |= WKUP_CTRL_MMR_CANUART_WAKE_CTRL_MW_LOAD_EN;
> +	writel(reg, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_CTRL);
> +
> +	/* Clear enable bit. */
> +	reg &= ~WKUP_CTRL_MMR_CANUART_WAKE_CTRL_MW_LOAD_EN;
> +	writel(reg, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_CTRL);
> +
> +	/* wait for CAN_ONLY_IO signal to be 0 */
> +	ret = wait_for_bit_32(wait_reg,
> +			      WKUP_CTRL_MMR_CANUART_WAKE_STAT1_CANUART_IO_MODE,
> +			      false,
> +			      CLKSTOP_TRANSITION_TIMEOUT_MS,
> +			      false);
> +	if (ret < 0)
> +		return;
> +
> +	/* Reset magic word */
> +	writel(0, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_CTRL);
> +
> +	/* Remove WKUP IO isolation */
> +	reg = readl(WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_PMCTRL_IO_0);
> +	reg = reg & WKUP_CTRL_MMR_PMCTRL_IO_0_WRITE_MASK & ~WKUP_CTRL_MMR_PMCTRL_IO_0_GLOBAL_WUEN_0;
> +	writel(reg, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_PMCTRL_IO_0);
> +
> +	/* clear global IO isolation */
> +	reg = readl(WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_PMCTRL_IO_0);
> +	reg = reg & WKUP_CTRL_MMR_PMCTRL_IO_0_WRITE_MASK & ~WKUP_CTRL_MMR_PMCTRL_IO_0_IO_ISO_CTRL_0;
> +	writel(reg, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_PMCTRL_IO_0);
> +

Nit: Missing what the below writel 0's are doing, I guess it's just
resetting them to reset value? Add a comment to explain so that those
without hardware sequence knowledge may understand.

> +	writel(0, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_DEEPSLEEP_CTRL);
> +	writel(0, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_PMCTRL_IO_GLB);
> +}
[...]

Either way,
Reviewed-by: Dhruva Gole <d-gole at ti.com>

-- 
Best regards,
Dhruva Gole
Texas Instruments Incorporated


More information about the U-Boot mailing list