From 9c1ad8a18ac1a20aee7a617964bcae3e90dac700 Mon Sep 17 00:00:00 2001
From: Enrico Mioso <mrkiko.rs@gmail.com>
Date: Wed, 23 Oct 2024 17:46:35 +0200
Subject: [PATCH] uboot-mediatek: initialized the watchdog subsystem later

Initialize the watchdog subsystem later during initialization, to allow for
the gpio-wdt driver to work.

Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
---
 common/board_r.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

--- a/common/board_r.c
+++ b/common/board_r.c
@@ -706,19 +706,13 @@ static void initcall_run_r(void)
 	INITCALL(serial_initialize);
 	INITCALL(initr_announce);
 	INITCALL(dm_announce);
-#if CONFIG_IS_ENABLED(WDT)
-	INITCALL(initr_watchdog);
-#endif
-	WATCHDOG_RESET();
 	INITCALL(arch_initr_trap);
 #if CONFIG_IS_ENABLED(BOARD_EARLY_INIT_R)
 	INITCALL(board_early_init_r);
 #endif
-	WATCHDOG_RESET();
 #if CONFIG_IS_ENABLED(POST)
 	INITCALL(post_output_backlog);
 #endif
-	WATCHDOG_RESET();
 #if CONFIG_IS_ENABLED(PCI_INIT_R) && CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT)
 	/*
 	 * Do early PCI configuration _before_ the flash gets initialised,
@@ -733,7 +727,6 @@ static void initcall_run_r(void)
 #if CONFIG_IS_ENABLED(MTD_NOR_FLASH)
 	INITCALL(initr_flash);
 #endif
-	WATCHDOG_RESET();
 #if CONFIG_IS_ENABLED(PPC) || CONFIG_IS_ENABLED(M68K) || CONFIG_IS_ENABLED(X86)
 	/* initialize higher level parts of CPU like time base and timers */
 	INITCALL(cpu_init_r);
@@ -762,6 +755,10 @@ static void initcall_run_r(void)
 #if CONFIG_IS_ENABLED(PVBLOCK)
 	INITCALL(initr_pvblock);
 #endif
+#if CONFIG_IS_ENABLED(WDT)
+	INITCALL(initr_watchdog);
+#endif
+	WATCHDOG_RESET();
 	INITCALL(initr_env);
 #if CONFIG_IS_ENABLED(SYS_MALLOC_BOOTPARAMS)
 	INITCALL(initr_malloc_bootparams);
