[PATCH v1 03/10] imx: soc: Get watchdog base addresses from device tree

alice.guo
2026-03-10T13:13:40Z

Replace hardcoded watchdog base addresses with dynamic address lookup
from device tree.

Signed-off-by: Alice Guo <alice.guo@nxp.com>
---
arch/arm/mach-imx/imx8ulp/soc.c | 15 ++++++++++++++-
arch/arm/mach-imx/imx9/scmi/soc.c | 16 ++++++++++++++--
arch/arm/mach-imx/imx9/soc.c | 17 ++++++++++++++---
arch/arm/mach-imx/mx7ulp/soc.c | 16 ++++++++++++++--
4 files changed, 56 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-imx/imx8ulp/soc.c b/arch/arm/mach-imx/imx8ulp/soc.c
index 1ee483065e8..081ba9d60b6 100644
--- a/arch/arm/mach-imx/imx8ulp/soc.c
+++ b/arch/arm/mach-imx/imx8ulp/soc.c
@@ -341,9 +341,22 @@ static void disable_wdog(void __iomem *wdog_base)
;
}

+static char *wdog_list[] = {"wdog3"};
+
void init_wdog(void)
{
- disable_wdog((void __iomem *)WDG3_RBASE);
+ fdt_addr_t addr;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(wdog_list); i++) {
+ addr = imx_wdog_alias_to_addr(wdog_list[i], false);
+ if (addr == FDT_ADDR_T_NONE) {
+ debug("watchdog alias %s not found\n", wdog_list[i]);
+ continue;
+ }
+
+ disable_wdog((void __iomem *)addr);
+ }
}

static struct mm_region imx8ulp_arm64_mem_map[] = {
diff --git a/arch/arm/mach-imx/imx9/scmi/soc.c b/arch/arm/mach-imx/imx9/scmi/soc.c
index c1458ccca3c..692c6743418 100644
--- a/arch/arm/mach-imx/imx9/scmi/soc.c
+++ b/arch/arm/mach-imx/imx9/scmi/soc.c
@@ -734,11 +734,23 @@ static void gpio_reset(ulong gpio_base)
writel(0, gpio_base + 0x1c);
}

+static char *wdog_list[] = {"wdog3", "wdog4"};
+
int arch_cpu_init(void)
{
if (IS_ENABLED(CONFIG_SPL_BUILD)) {
- disable_wdog((void __iomem *)WDG3_BASE_ADDR);
- disable_wdog((void __iomem *)WDG4_BASE_ADDR);
+ fdt_addr_t addr;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(wdog_list); i++) {
+ addr = imx_wdog_alias_to_addr(wdog_list[i], false);
+ if (addr == FDT_ADDR_T_NONE) {
+ debug("watchdog alias %s not found\n", wdog_list[i]);
+ continue;
+ }
+
+ disable_wdog((void __iomem *)addr);
+ }

gpio_reset(GPIO2_BASE_ADDR);
gpio_reset(GPIO3_BASE_ADDR);
diff --git a/arch/arm/mach-imx/imx9/soc.c b/arch/arm/mach-imx/imx9/soc.c
index 583c3a5a464..031226ec97f 100644
--- a/arch/arm/mach-imx/imx9/soc.c
+++ b/arch/arm/mach-imx/imx9/soc.c
@@ -279,11 +279,22 @@ static void disable_wdog(void __iomem *wdog_base)
;
}

+static char *wdog_list[] = {"wdog3", "wdog4", "wdog5"};
+
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);
+ fdt_addr_t addr;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(wdog_list); i++) {
+ addr = imx_wdog_alias_to_addr(wdog_list[i], false);
+ if (addr == FDT_ADDR_T_NONE) {
+ debug("watchdog alias %s not found\n", wdog_list[i]);
+ continue;
+ }
+
+ disable_wdog((void __iomem *)addr);
+ }
}

static struct mm_region imx93_mem_map[] = {
diff --git a/arch/arm/mach-imx/mx7ulp/soc.c b/arch/arm/mach-imx/mx7ulp/soc.c
index 5306e76223f..27ba8a37162 100644
--- a/arch/arm/mach-imx/mx7ulp/soc.c
+++ b/arch/arm/mach-imx/mx7ulp/soc.c
@@ -146,6 +146,8 @@ static void disable_wdog(u32 wdog_base)
while (!(readl(wdog_base + 0x00) & 0x400));
}

+static char *wdog_list[] = {"wdog1", "wdog2"};
+
void init_wdog(void)
{
/*
@@ -161,8 +163,18 @@ 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);
+ fdt_addr_t addr;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(wdog_list); i++) {
+ addr = imx_wdog_alias_to_addr(wdog_list[i], false);
+ if (addr == FDT_ADDR_T_NONE) {
+ debug("watchdog alias %s not found\n", wdog_list[i]);
+ continue;
+ }
+
+ disable_wdog((u32)addr);
+ }
}

static bool ldo_mode_is_enabled(void)

--
2.43.0