Skip to contentSkip to conversation

board: freescale: p1_p2_rdb_pc: Delete watchdog max6370 node in load_default mode

PATCH Applied Pali Rohár 2 participants 5 messages Aug 1, 2022 – Sep 7, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 board: freescale: p1_p2_rdb_pc: Delete watchdog max6370 node in load_default mode

CPLD in load_default mode ignores watchdog reset signal. It does not reset board when watchdog triggers reset signal.

Detect load_default mode by GPIO7 - LOAD_DEFAULT_N and delete watchdog max6370 node from device to prevent registering driver for non-working watchdog.

---
 board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 28 +++++++++++++++++++++
 1 file changed, 28 insertions(+)
board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c +28 -0
index a71952dcf399..06cab729e4ab 100644
@@ -368,6 +368,24 @@ int board_eth_init(struct bd_info *bis)
 }
 #endif
 
+#if defined(CONFIG_OF_BOARD_SETUP) || defined(CONFIG_OF_BOARD_FIXUP)
+static void fix_max6370_watchdog(void *blob)
+{
+	int off = fdt_node_offset_by_compatible(blob, -1, "maxim,max6370");
+	ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
+	u32 gpioval = in_be32(&pgpio->gpdat);
+
+	/*
+	 * Delete watchdog max6370 node in load_default mode (detected by
+	 * GPIO7 - LOAD_DEFAULT_N) because CPLD in load_default mode ignores
+	 * watchdog reset signal. CPLD in load_default mode does not reset
+	 * board when watchdog triggers reset signal.
+	 */
+	if (!(gpioval & BIT(31-7)) && off >= 0)
+		fdt_del_node(blob, off);
+}
+#endif
+
 #ifdef CONFIG_OF_BOARD_SETUP
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
@@ -393,6 +411,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 			sizeof("okay"), 0);
 #endif
 
+	fix_max6370_watchdog(blob);
+
 #if defined(CONFIG_HAS_FSL_DR_USB)
 	fsl_fdt_fixup_dr_usb(blob, bd);
 #endif
@@ -444,3 +464,11 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 	return 0;
 }
 #endif
+
+#ifdef CONFIG_OF_BOARD_FIXUP
+int board_fix_fdt(void *blob)
+{
+	fix_max6370_watchdog(blob);
+	return 0;
+}
+#endif
Signature · 1 line
2.20.1
#1 lore raw

PING? (This change applies also for Turris 1.x boards; which use same CPLD firmware code)

Quoted 65 lines · On Monday 01 August 2022 15:35:43 Pali Rohár wrote:

CPLD in load_default mode ignores watchdog reset signal. It does not reset board when watchdog triggers reset signal.

Detect load_default mode by GPIO7 - LOAD_DEFAULT_N and delete watchdog max6370 node from device to prevent registering driver for non-working watchdog.

---
 board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 28 +++++++++++++++++++++
 1 file changed, 28 insertions(+)
board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c +28 -0
index a71952dcf399..06cab729e4ab 100644
@@ -368,6 +368,24 @@ int board_eth_init(struct bd_info *bis)
 }
 #endif
 
+#if defined(CONFIG_OF_BOARD_SETUP) || defined(CONFIG_OF_BOARD_FIXUP)
+static void fix_max6370_watchdog(void *blob)
+{
+	int off = fdt_node_offset_by_compatible(blob, -1, "maxim,max6370");
+	ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
+	u32 gpioval = in_be32(&pgpio->gpdat);
+
+	/*
+	 * Delete watchdog max6370 node in load_default mode (detected by
+	 * GPIO7 - LOAD_DEFAULT_N) because CPLD in load_default mode ignores
+	 * watchdog reset signal. CPLD in load_default mode does not reset
+	 * board when watchdog triggers reset signal.
+	 */
+	if (!(gpioval & BIT(31-7)) && off >= 0)
+		fdt_del_node(blob, off);
+}
+#endif
+
 #ifdef CONFIG_OF_BOARD_SETUP
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
@@ -393,6 +411,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 			sizeof("okay"), 0);
 #endif
 
+	fix_max6370_watchdog(blob);
+
 #if defined(CONFIG_HAS_FSL_DR_USB)
 	fsl_fdt_fixup_dr_usb(blob, bd);
 #endif
@@ -444,3 +464,11 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 	return 0;
 }
 #endif
+
+#ifdef CONFIG_OF_BOARD_FIXUP
+int board_fix_fdt(void *blob)
+{
+	fix_max6370_watchdog(blob);
+	return 0;
+}
+#endif
Signature · 1 line
2.20.1
#2 lore raw

Hi Pali,

Quoted 2 lines · Pali Rohár

PING? (This change applies also for Turris 1.x boards; which use same CPLD firmware code)

Since your patches not show in my patchwork, I missed to pick up your patches. BTW, is this a fix to need flow into 2022.10? or could wait next?

Thanks,
Peng.

Quoted 66 lines · On Monday 01 August 2022 15:35:43 Pali Rohár wrote:
Quoted 65 lines

CPLD in load_default mode ignores watchdog reset signal. It does not reset board when watchdog triggers reset signal.

Detect load_default mode by GPIO7 - LOAD_DEFAULT_N and delete watchdog max6370 node from device to prevent registering driver for non-working watchdog.

---
  board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 28 +++++++++++++++++++++
  1 file changed, 28 insertions(+)
board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c +28 -0
index a71952dcf399..06cab729e4ab 100644
@@ -368,6 +368,24 @@ int board_eth_init(struct bd_info *bis)
  }
  #endif
 
+#if defined(CONFIG_OF_BOARD_SETUP) || defined(CONFIG_OF_BOARD_FIXUP)
+static void fix_max6370_watchdog(void *blob)
+{
+	int off = fdt_node_offset_by_compatible(blob, -1, "maxim,max6370");
+	ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
+	u32 gpioval = in_be32(&pgpio->gpdat);
+
+	/*
+	 * Delete watchdog max6370 node in load_default mode (detected by
+	 * GPIO7 - LOAD_DEFAULT_N) because CPLD in load_default mode ignores
+	 * watchdog reset signal. CPLD in load_default mode does not reset
+	 * board when watchdog triggers reset signal.
+	 */
+	if (!(gpioval & BIT(31-7)) && off >= 0)
+		fdt_del_node(blob, off);
+}
+#endif
+
  #ifdef CONFIG_OF_BOARD_SETUP
  int ft_board_setup(void *blob, struct bd_info *bd)
  {
@@ -393,6 +411,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  			sizeof("okay"), 0);
  #endif
 
+	fix_max6370_watchdog(blob);
+
  #if defined(CONFIG_HAS_FSL_DR_USB)
  	fsl_fdt_fixup_dr_usb(blob, bd);
  #endif
@@ -444,3 +464,11 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  	return 0;
  }
  #endif
+
+#ifdef CONFIG_OF_BOARD_FIXUP
+int board_fix_fdt(void *blob)
+{
+	fix_max6370_watchdog(blob);
+	return 0;
+}
+#endif
Signature · 1 line
2.20.1
Applied
#3 lore raw
In reply to Pali Rohár
Quoted 11 lines · Pali Rohár

PING? (This change applies also for Turris 1.x boards; which use same CPLD firmware code)

Quoted 8 lines · On Monday 01 August 2022 15:35:43 Pali Rohár wrote:

CPLD in load_default mode ignores watchdog reset signal. It does not reset board when watchdog triggers reset signal.

Detect load_default mode by GPIO7 - LOAD_DEFAULT_N and delete watchdog max6370 node from device to prevent registering driver for non-working watchdog.

Applied, sorry for late.

If possible, please help assign your patch in patchwork to me[freenix], that would help a lot.

Thanks,
Peng.

Quoted 57 lines
Quoted 57 lines
---
  board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 28 +++++++++++++++++++++
  1 file changed, 28 insertions(+)
board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c +28 -0
index a71952dcf399..06cab729e4ab 100644
@@ -368,6 +368,24 @@ int board_eth_init(struct bd_info *bis)
  }
  #endif
 
+#if defined(CONFIG_OF_BOARD_SETUP) || defined(CONFIG_OF_BOARD_FIXUP)
+static void fix_max6370_watchdog(void *blob)
+{
+	int off = fdt_node_offset_by_compatible(blob, -1, "maxim,max6370");
+	ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
+	u32 gpioval = in_be32(&pgpio->gpdat);
+
+	/*
+	 * Delete watchdog max6370 node in load_default mode (detected by
+	 * GPIO7 - LOAD_DEFAULT_N) because CPLD in load_default mode ignores
+	 * watchdog reset signal. CPLD in load_default mode does not reset
+	 * board when watchdog triggers reset signal.
+	 */
+	if (!(gpioval & BIT(31-7)) && off >= 0)
+		fdt_del_node(blob, off);
+}
+#endif
+
  #ifdef CONFIG_OF_BOARD_SETUP
  int ft_board_setup(void *blob, struct bd_info *bd)
  {
@@ -393,6 +411,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  			sizeof("okay"), 0);
  #endif
 
+	fix_max6370_watchdog(blob);
+
  #if defined(CONFIG_HAS_FSL_DR_USB)
  	fsl_fdt_fixup_dr_usb(blob, bd);
  #endif
@@ -444,3 +464,11 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  	return 0;
  }
  #endif
+
+#ifdef CONFIG_OF_BOARD_FIXUP
+int board_fix_fdt(void *blob)
+{
+	fix_max6370_watchdog(blob);
+	return 0;
+}
+#endif
Signature · 1 line
2.20.1
Applied
#4 lore raw
In reply to Pali Rohár
Quoted 11 lines · Pali Rohár

PING? (This change applies also for Turris 1.x boards; which use same CPLD firmware code)

Quoted 8 lines · On Monday 01 August 2022 15:35:43 Pali Rohár wrote:

CPLD in load_default mode ignores watchdog reset signal. It does not reset board when watchdog triggers reset signal.

Detect load_default mode by GPIO7 - LOAD_DEFAULT_N and delete watchdog max6370 node from device to prevent registering driver for non-working watchdog.

Applied, sorry for late.

If possible, please help assign your patch in patchwork to me[freenix], that would help a lot.

Thanks,
Peng.

Quoted 57 lines
Quoted 57 lines
---
  board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 28 +++++++++++++++++++++
  1 file changed, 28 insertions(+)
board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c +28 -0
index a71952dcf399..06cab729e4ab 100644
@@ -368,6 +368,24 @@ int board_eth_init(struct bd_info *bis)
  }
  #endif
 
+#if defined(CONFIG_OF_BOARD_SETUP) || defined(CONFIG_OF_BOARD_FIXUP)
+static void fix_max6370_watchdog(void *blob)
+{
+	int off = fdt_node_offset_by_compatible(blob, -1, "maxim,max6370");
+	ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
+	u32 gpioval = in_be32(&pgpio->gpdat);
+
+	/*
+	 * Delete watchdog max6370 node in load_default mode (detected by
+	 * GPIO7 - LOAD_DEFAULT_N) because CPLD in load_default mode ignores
+	 * watchdog reset signal. CPLD in load_default mode does not reset
+	 * board when watchdog triggers reset signal.
+	 */
+	if (!(gpioval & BIT(31-7)) && off >= 0)
+		fdt_del_node(blob, off);
+}
+#endif
+
  #ifdef CONFIG_OF_BOARD_SETUP
  int ft_board_setup(void *blob, struct bd_info *bd)
  {
@@ -393,6 +411,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  			sizeof("okay"), 0);
  #endif
 
+	fix_max6370_watchdog(blob);
+
  #if defined(CONFIG_HAS_FSL_DR_USB)
  	fsl_fdt_fixup_dr_usb(blob, bd);
  #endif
@@ -444,3 +464,11 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  	return 0;
  }
  #endif
+
+#ifdef CONFIG_OF_BOARD_FIXUP
+int board_fix_fdt(void *blob)
+{
+	fix_max6370_watchdog(blob);
+	return 0;
+}
+#endif
Signature · 1 line
2.20.1