On HS-SE platforms TIFS takes longer to initialize. TIFS only removes
the firewall on the registers at the end of initialization. On HS-SE the
U-Boot ctrl_mmr_unlock() can happen before TIFS removed the firewall
leading to a race condition. This leads to a broken watchdog since the
signal configuration doesn't succeed because the write doesn't take
effect.

Wait for TIFS to be initialized using k3_sysfw_wait_ready() before doing
ctrl_mmr_unlock(). As spl_early_init() may already probe some drivers, I
am attaching to the EVT_DM_POST_INIT_F event to wait for TIFS and call
ctrl_mmr_unlock() before anything got probed.

Link: 
https://lore.kernel.org/u-boot/[email protected]/
Link: https://lore.kernel.org/u-boot/[email protected]/
Signed-off-by: Markus Schneider-Pargmann <[email protected]>
---
 arch/arm/mach-k3/Kconfig              |  1 +
 arch/arm/mach-k3/am62ax/am62a7_init.c | 17 +++++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-k3/Kconfig b/arch/arm/mach-k3/Kconfig
index b1f290c1d765..405c5d4fad94 100644
--- a/arch/arm/mach-k3/Kconfig
+++ b/arch/arm/mach-k3/Kconfig
@@ -10,6 +10,7 @@ config SOC_K3_AM625
 
 config SOC_K3_AM62A7
        bool "TI's K3 based AM62A7 SoC Family Support"
+       select SPL_DM_EVENT if SPL
 
 config SOC_K3_AM62P5
        bool "TI's K3 based AM62P5 SoC Family Support"
diff --git a/arch/arm/mach-k3/am62ax/am62a7_init.c 
b/arch/arm/mach-k3/am62ax/am62a7_init.c
index 0d86d52ef267..ddfe84217ab4 100644
--- a/arch/arm/mach-k3/am62ax/am62a7_init.c
+++ b/arch/arm/mach-k3/am62ax/am62a7_init.c
@@ -11,6 +11,7 @@
 #include <dm.h>
 #include <dm/uclass-internal.h>
 #include <dm/pinctrl.h>
+#include <event.h>
 
 #include "../sysfw-loader.h"
 #include "../common.h"
@@ -110,6 +111,20 @@ static void ctrl_mmr_unlock(void)
        mmr_unlock(PADCFG_MMR1_BASE, 1);
 }
 
+/*
+ * Called by spl_early_init() after all devices are bound, but before any of
+ * them are probed. TIFS has to finish its initialization before CTRL_MMR can
+ * be unlocked, and any device probe may already need the unlocked CTRL_MMR.
+ */
+static int k3_spl_dm_post_init_f(void)
+{
+       k3_sysfw_wait_ready();
+       ctrl_mmr_unlock();
+
+       return 0;
+}
+EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, k3_spl_dm_post_init_f);
+
 static __maybe_unused void enable_mcu_esm_reset(void)
 {
        /* Set CTRLMMR_MCU_RST_CTRL:MCU_ESM_ERROR_RST_EN_Z  to '0' (low active) 
*/
@@ -134,8 +149,6 @@ void board_init_f(ulong dummy)
         */
        store_boot_info_from_rom();
 
-       ctrl_mmr_unlock();
-
        /* Init DM early */
        spl_early_init();
 

-- 
2.56.0

Reply via email to