All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] mx7ulp: Update wdog disable sequence
@ 2021-09-23 14:01 Oleksandr Suvorov
  2021-09-23 14:01 ` [PATCH 1/1] " Oleksandr Suvorov
  0 siblings, 1 reply; 3+ messages in thread
From: Oleksandr Suvorov @ 2021-09-23 14:01 UTC (permalink / raw)
  To: u-boot
  Cc: Oleksandr Suvorov, Fabio Estevam, Harald Seiler,
	Jorge Ramirez-Ortiz, NXP i.MX U-Boot Team, Ricardo Salveti,
	Simon Glass, Stefano Babic, Ye Li


This patch was originally picked up from the NXP repo and improved
in Foundries.IO. It is needed to proper work of watchdog on iMX7ULP.



Ye Li (1):
  mx7ulp: Update wdog disable sequence

 arch/arm/mach-imx/mx7ulp/soc.c | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] mx7ulp: Update wdog disable sequence
  2021-09-23 14:01 [PATCH 0/1] mx7ulp: Update wdog disable sequence Oleksandr Suvorov
@ 2021-09-23 14:01 ` Oleksandr Suvorov
  2021-10-07 14:13   ` sbabic
  0 siblings, 1 reply; 3+ messages in thread
From: Oleksandr Suvorov @ 2021-09-23 14:01 UTC (permalink / raw)
  To: u-boot
  Cc: Ye Li, Jorge Ramirez-Ortiz, Ricardo Salveti, Oleksandr Suvorov,
	Fabio Estevam, Harald Seiler, NXP i.MX U-Boot Team, Simon Glass,
	Stefano Babic

From: Ye Li <ye.li@nxp.com>

Update the mx7ulp wdog disable sequence to avoid potential reset
issue in unlock or refresh sequence. Both sequence need two words
write to wdog CNT register in 16 bus clocks window, if miss the
window, the write will cause violation in wdog and reset the chip.

Current u-boot code is using writel() function which has a DMB
barrier to order the memory access. The DMB between two words write
may introduce some delay in certain circumstance, causing the wdog
reset due to 16 bus clock window requirement.

Also, WDOG1 might have been enabled already depending on FUSE hence
we need to be as close as possible to its reconfiguration timing
requirement of 128 bus clock limit.

This patch replaces writel() function by __raw_writel() to avoid such
issue, and improve to check if watchdog is already disabled or
unlocked.

Signed-off-by: Ye Li <ye.li@nxp.com>
Co-developed-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Co-developed-by: Ricardo Salveti <ricardo@foundries.io>
Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
---

 arch/arm/mach-imx/mx7ulp/soc.c | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-imx/mx7ulp/soc.c b/arch/arm/mach-imx/mx7ulp/soc.c
index 320f24dd29..7f097d6850 100644
--- a/arch/arm/mach-imx/mx7ulp/soc.c
+++ b/arch/arm/mach-imx/mx7ulp/soc.c
@@ -93,14 +93,31 @@ int board_postclk_init(void)
 
 static void disable_wdog(u32 wdog_base)
 {
-	writel(UNLOCK_WORD0, (wdog_base + 0x04));
-	writel(UNLOCK_WORD1, (wdog_base + 0x04));
-	writel(0x0, (wdog_base + 0x0C)); /* Set WIN to 0 */
-	writel(0x400, (wdog_base + 0x08)); /* Set timeout to default 0x400 */
-	writel(0x120, (wdog_base + 0x00)); /* Disable it and set update */
+	u32 val_cs = readl(wdog_base + 0x00);
 
-	writel(REFRESH_WORD0, (wdog_base + 0x04)); /* Refresh the CNT */
-	writel(REFRESH_WORD1, (wdog_base + 0x04));
+	if (!(val_cs & 0x80))
+		return;
+
+	dmb();
+	__raw_writel(REFRESH_WORD0, (wdog_base + 0x04)); /* Refresh the CNT */
+	__raw_writel(REFRESH_WORD1, (wdog_base + 0x04));
+	dmb();
+
+	if (!(val_cs & 800)) {
+		dmb();
+		__raw_writel(UNLOCK_WORD0, (wdog_base + 0x04));
+		__raw_writel(UNLOCK_WORD1, (wdog_base + 0x04));
+		dmb();
+
+		while (!(readl(wdog_base + 0x00) & 0x800));
+	}
+	dmb();
+	__raw_writel(0x0, wdog_base + 0x0C); /* Set WIN to 0 */
+	__raw_writel(0x400, wdog_base + 0x08); /* Set timeout to default 0x400 */
+	__raw_writel(0x120, wdog_base + 0x00); /* Disable it and set update */
+	dmb();
+
+	while (!(readl(wdog_base + 0x00) & 0x400));
 }
 
 void init_wdog(void)
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 1/1] mx7ulp: Update wdog disable sequence
  2021-09-23 14:01 ` [PATCH 1/1] " Oleksandr Suvorov
@ 2021-10-07 14:13   ` sbabic
  0 siblings, 0 replies; 3+ messages in thread
From: sbabic @ 2021-10-07 14:13 UTC (permalink / raw)
  To: Oleksandr Suvorov, U-Boot

> From: Ye Li <ye.li@nxp.com>
> Update the mx7ulp wdog disable sequence to avoid potential reset
> issue in unlock or refresh sequence. Both sequence need two words
> write to wdog CNT register in 16 bus clocks window, if miss the
> window, the write will cause violation in wdog and reset the chip.
> Current u-boot code is using writel() function which has a DMB
> barrier to order the memory access. The DMB between two words write
> may introduce some delay in certain circumstance, causing the wdog
> reset due to 16 bus clock window requirement.
> Also, WDOG1 might have been enabled already depending on FUSE hence
> we need to be as close as possible to its reconfiguration timing
> requirement of 128 bus clock limit.
> This patch replaces writel() function by __raw_writel() to avoid such
> issue, and improve to check if watchdog is already disabled or
> unlocked.
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Co-developed-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
> Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
> Co-developed-by: Ricardo Salveti <ricardo@foundries.io>
> Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
> Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-07 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-23 14:01 [PATCH 0/1] mx7ulp: Update wdog disable sequence Oleksandr Suvorov
2021-09-23 14:01 ` [PATCH 1/1] " Oleksandr Suvorov
2021-10-07 14:13   ` sbabic

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.