All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@oss.nxp.com>
To: alice.guo@oss.nxp.com
Cc: "NXP i.MX U-Boot Team" <uboot-imx@nxp.com>,
	u-boot@lists.denx.de, "Christoph Stoidner" <c.stoidner@phytec.de>,
	upstream@lists.phytec.de, "Joseph Guo" <qijian.guo@nxp.com>,
	"Stefano Babic" <sbabic@nabladev.com>,
	"Fabio Estevam" <festevam@gmail.com>,
	"Tom Rini" <trini@konsulko.com>, "Peng Fan" <peng.fan@nxp.com>,
	"Ye Li" <ye.li@nxp.com>,
	"Ranjani Vaidyanathan" <ranjani.vaidyanathan@nxp.com>,
	"Ji Luo" <ji.luo@nxp.com>, "Marek Vasut" <marex@nabladev.com>,
	"Jacky Bai" <ping.bai@nxp.com>,
	"Stefan Roese" <stefan.roese@mailbox.org>,
	"Marek Vasut" <marek.vasut+renesas@mailbox.org>,
	"David Zang" <davidzangcs@gmail.com>,
	"Simon Glass" <sjg@chromium.org>,
	"João Paulo Gonçalves" <joao.goncalves@toradex.com>,
	"Rasmus Villemoes" <ravi@prevas.dk>,
	"Primoz Fiser" <primoz.fiser@norik.com>,
	"Frieder Schrempf" <frieder.schrempf@kontron.de>,
	"Jérémie Dautheribes (Schneider Electric)"
	<jeremie.dautheribes@bootlin.com>,
	"Mathieu Othacehe" <m.othacehe@gmail.com>,
	"Francesco Dolcini" <francesco.dolcini@toradex.com>,
	"Jindong Yue" <jindong.yue@nxp.com>,
	"Frank Li" <Frank.Li@nxp.com>,
	"Max Krummenacher" <max.krummenacher@toradex.com>,
	"Ernest Van Hoecke" <ernest.vanhoecke@toradex.com>,
	"Emanuele Ghidoli" <emanuele.ghidoli@toradex.com>,
	"Alice Guo" <alice.guo@nxp.com>
Subject: Re: [PATCH v1 03/10] imx: soc: Get watchdog base addresses from device tree
Date: Thu, 12 Mar 2026 17:01:55 +0800	[thread overview]
Message-ID: <abKBA7LTRIWqUIL7@shlinux89> (raw)
In-Reply-To: <20260310-wdog-v1-3-2ee21e890634@nxp.com>

On Tue, Mar 10, 2026 at 03:53:37PM +0800, alice.guo@oss.nxp.com wrote:
>From: Alice Guo <alice.guo@nxp.com>
>
>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);
>+	}

It should be better to use
fdt_for_each_comaptible_node or ofnode_for_each_compatible_node


Regards
Peng

> }
> 
> static bool ldo_mode_is_enabled(void)
>
>-- 
>2.43.0
>

  reply	other threads:[~2026-03-12 12:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10  7:53 [PATCH 00/10] imx: Switch watchdog addressing from macros to devicetree alice.guo
2026-03-10  7:53 ` [PATCH v1 01/10] imx: Add helper to get watchdog base address from DT alias alice.guo
2026-03-12  7:17   ` Peng Fan
2026-03-12  9:52     ` Rasmus Villemoes
2026-03-10  7:53 ` [PATCH v1 02/10] watchdog: ulp_wdog: Get watchdog base address from device tree alice.guo
2026-03-12  7:19   ` Peng Fan
2026-03-10  7:53 ` [PATCH v1 03/10] imx: soc: Get watchdog base addresses " alice.guo
2026-03-12  9:01   ` Peng Fan [this message]
2026-03-10  7:53 ` [PATCH v1 04/10] imx7ulp: dtsi: Add wdog1 and wdog2 nodes with aliases alice.guo
2026-03-10  7:53 ` [PATCH v1 05/10] imx8ulp: dtsi: Add wdog3 alias and bootph-all property alice.guo
2026-03-10  7:53 ` [PATCH v1 06/10] imx93: dtsi: Add wdog3/wdog4/wdog5 " alice.guo
2026-03-10  7:53 ` [PATCH v1 07/10] imx91: " alice.guo
2026-03-10  7:53 ` [PATCH v1 08/10] imx943: dtsi: Add wdog3 and wdog4 nodes with aliases alice.guo
2026-03-10  7:53 ` [PATCH v1 09/10] imx95: " alice.guo
2026-03-10  7:53 ` [PATCH v1 10/10] imx: Remove hardcoded watchdog base address macros alice.guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=abKBA7LTRIWqUIL7@shlinux89 \
    --to=peng.fan@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=alice.guo@nxp.com \
    --cc=alice.guo@oss.nxp.com \
    --cc=c.stoidner@phytec.de \
    --cc=davidzangcs@gmail.com \
    --cc=emanuele.ghidoli@toradex.com \
    --cc=ernest.vanhoecke@toradex.com \
    --cc=festevam@gmail.com \
    --cc=francesco.dolcini@toradex.com \
    --cc=frieder.schrempf@kontron.de \
    --cc=jeremie.dautheribes@bootlin.com \
    --cc=ji.luo@nxp.com \
    --cc=jindong.yue@nxp.com \
    --cc=joao.goncalves@toradex.com \
    --cc=m.othacehe@gmail.com \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=marex@nabladev.com \
    --cc=max.krummenacher@toradex.com \
    --cc=peng.fan@nxp.com \
    --cc=ping.bai@nxp.com \
    --cc=primoz.fiser@norik.com \
    --cc=qijian.guo@nxp.com \
    --cc=ranjani.vaidyanathan@nxp.com \
    --cc=ravi@prevas.dk \
    --cc=sbabic@nabladev.com \
    --cc=sjg@chromium.org \
    --cc=stefan.roese@mailbox.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.com \
    --cc=upstream@lists.phytec.de \
    --cc=ye.li@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.