]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
imx: soc: Get watchdog base addresses from device tree
authorAlice Guo <alice.guo@nxp.com>
Tue, 19 May 2026 06:22:06 +0000 (14:22 +0800)
committerFabio Estevam <festevam@gmail.com>
Fri, 5 Jun 2026 11:58:00 +0000 (08:58 -0300)
Replace hardcoded watchdog base addresses with dynamic address lookup
from device tree for i.MX7ULP, i.MX8ULP, i.MX91, i.MX93, i.MX943, i.MX95
and i.MX952.

Move i.MX7ULP watchdog initialization from s_init() to
arch_cpu_init() because ofnode_* APIs depend on FDT, which is not
available during s_init().

Signed-off-by: Alice Guo <alice.guo@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
arch/arm/mach-imx/imx8ulp/soc.c
arch/arm/mach-imx/imx9/scmi/soc.c
arch/arm/mach-imx/imx9/soc.c
arch/arm/mach-imx/mx7ulp/soc.c

index 1ee483065e85e223438f83e9625fd237f3c5ebdb..ccdb949a9da8255c0ec6be22f362e9f4940cc6c5 100644 (file)
@@ -343,7 +343,17 @@ static void disable_wdog(void __iomem *wdog_base)
 
 void init_wdog(void)
 {
-       disable_wdog((void __iomem *)WDG3_RBASE);
+       ofnode node;
+
+       ofnode_for_each_compatible_node(node, "fsl,imx8ulp-wdt") {
+               phys_addr_t base;
+
+               base = ofnode_get_addr(node);
+               if (base == FDT_ADDR_T_NONE)
+                       continue;
+
+               disable_wdog((void __iomem *)base);
+       }
 }
 
 static struct mm_region imx8ulp_arm64_mem_map[] = {
index 7c107c88bb49bd24e007e0dc86a425a3477599d9..8a295baf5a219312bd5f16ba4910d8497f83b415 100644 (file)
@@ -833,9 +833,16 @@ static void gpio_reset(ulong gpio_base)
 int arch_cpu_init(void)
 {
        if (IS_ENABLED(CONFIG_SPL_BUILD)) {
-               if (!IS_ENABLED(CONFIG_IMX952)) {
-                       disable_wdog((void __iomem *)WDG3_BASE_ADDR);
-                       disable_wdog((void __iomem *)WDG4_BASE_ADDR);
+               ofnode node;
+
+               ofnode_for_each_compatible_node(node, "fsl,imx93-wdt") {
+                       phys_addr_t base;
+
+                       base = ofnode_get_addr(node);
+                       if (base == FDT_ADDR_T_NONE)
+                               continue;
+
+                       disable_wdog((void __iomem *)base);
                }
 
                gpio_reset(GPIO2_BASE_ADDR);
index ec0cb18e9545961fb7094b6a00f6398f4f4c80dd..6576ecefd5f95103a0ada91bc1319f18fcb83137 100644 (file)
@@ -270,9 +270,17 @@ static void disable_wdog(void __iomem *wdog_base)
 
 void init_wdog(void)
 {
-       disable_wdog((void __iomem *)WDG3_BASE_ADDR);
-       disable_wdog((void __iomem *)WDG4_BASE_ADDR);
-       disable_wdog((void __iomem *)WDG5_BASE_ADDR);
+       ofnode node;
+
+       ofnode_for_each_compatible_node(node, "fsl,imx93-wdt") {
+               phys_addr_t base;
+
+               base = ofnode_get_addr(node);
+               if (base == FDT_ADDR_T_NONE)
+                       continue;
+
+               disable_wdog((void __iomem *)base);
+       }
 }
 
 static struct mm_region imx93_mem_map[] = {
index 5306e76223f3078c190aafbcae6ec1096f502f4c..ca1cf759fe14016503592f61811f62c467832336 100644 (file)
@@ -83,8 +83,12 @@ enum bt_mode get_boot_mode(void)
        return LOW_POWER_BOOT;
 }
 
+static void init_wdog(void);
 int arch_cpu_init(void)
 {
+       /* Disable wdog */
+       init_wdog();
+
        enable_ca7_smp();
        return 0;
 }
@@ -146,7 +150,7 @@ static void disable_wdog(u32 wdog_base)
        while (!(readl(wdog_base + 0x00) & 0x400));
 }
 
-void init_wdog(void)
+static void init_wdog(void)
 {
        /*
         * ROM will configure WDOG1, disable it or enable it
@@ -161,8 +165,17 @@ void init_wdog(void)
         * In this function, we will disable both WDOG1 and WDOG2,
         * and set update bit for both. So that kernel can reconfigure them.
         */
-       disable_wdog(WDG1_RBASE);
-       disable_wdog(WDG2_RBASE);
+       ofnode node;
+
+       ofnode_for_each_compatible_node(node, "fsl,imx7ulp-wdt") {
+               phys_addr_t base;
+
+               base = ofnode_get_addr(node);
+               if (base == FDT_ADDR_T_NONE)
+                       continue;
+
+               disable_wdog((u32)base);
+       }
 }
 
 static bool ldo_mode_is_enabled(void)
@@ -221,9 +234,6 @@ static void init_ldo_mode(void)
 
 void s_init(void)
 {
-       /* Disable wdog */
-       init_wdog();
-
        /* clock configuration. */
        clock_init();