Skip to contentSkip to conversation

OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

PATCH New Varadarajan, Charulatha 6 participants 21 messages Sep 30, 2010 – Oct 1, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

With OMAP2PLUS watchdog implemented in hwmod fw way, the module is reset during init.

After a watchdog timer module reset, the WDTs are enabled. The default time for a system reset after a watchdog module reset is ~10s as per the default value of the WDT registers. Hence the system would be reset after 10s, if watchdog is not disabled within 10s.

This patch fixes the above issue by disabling the watchdog timer after reset during initialization of devices.

---
This patch is dependent on the below patch series (wdt hwmod) and is created on top of pm-core branch.
http://www.spinics.net/lists/linux-omap/msg37043.html

 arch/arm/mach-omap2/devices.c |   44 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/devices.c +44 -0
index 8e2f0aa..9f44fc6 100644
@@ -916,11 +916,55 @@ static inline void omap_init_vout(void) {}
 
 /*-------------------------------------------------------------------------*/
 
+/*
+ * WDT mdoule is reset during init which enables the watchdog.
+ * Hence it is required to disable the watchdog after the WDT reset
+ * during init. Otherwise the system would reboot as per the default
+ * watchdog timer registers settings.
+ */
+#define OMAP_WDT_WPS	(0x34)
+#define OMAP_WDT_SPR	(0x48)
+
+static int omap2_disable_wdt(struct omap_hwmod *oh, void *user)
+{
+	void __iomem *base;
+
+	if (!oh)
+		pr_err("Could not look up wdtimer_hwmod\n");
+
+	base = oh->_mpu_rt_va;
+
+	/* Enable the clocks before accessing the WDT registers */
+	omap_hwmod_enable(oh);
+
+	/* sequence required to disable watchdog */
+	__raw_writel(0xAAAA, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
+		cpu_relax();
+
+	__raw_writel(0x5555, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
+		cpu_relax();
+
+	omap_hwmod_idle(oh);
+
+	return 0;
+}
+
+static void __init omap_disable_wdt(void)
+{
+	if (cpu_class_is_omap2())
+		omap_hwmod_for_each_by_class("wd_timer",
+						omap2_disable_wdt, NULL);
+	return;
+}
+
 static int __init omap2_init_devices(void)
 {
 	/* please keep these calls, and their implementations above,
 	 * in alphabetical order so they're easier to sort through.
 	 */
+	omap_disable_wdt();
 	omap_hsmmc_reset();
 	omap_init_camera();
 	omap_init_mbox();
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Hi Charu,

Quoted 2 lines · Charulatha

With OMAP2PLUS watchdog implemented in hwmod fw way, the module is reset during init.

In that case hwmod fw just highlighted the real behavior that was hidden so far by the X-loader.

You should as well add a link to the email thread with Kevin that raised the issue.

Quoted 8 lines

After a watchdog timer module reset, the WDTs are enabled. The default time for a system reset after a watchdog module reset is ~10s as per the default value of the WDT registers. Hence the system would be reset after 10s, if watchdog is not disabled within 10s.

This patch fixes the above issue by disabling the watchdog timer after reset during initialization of devices.

I'm still wondering as well what is the expected behavior of the watchdog in a real product. If it is started by default at boot time, this is probably for a good reason (or maybe not...).
So, disabling it all the time is maybe not the best solution.

Nishanth (M),
Do you have an idea on that topic?

Quoted 16 lines

---
This patch is dependent on the below patch series (wdt hwmod) and is created on top of pm-core branch.
http://www.spinics.net/lists/linux-omap/msg37043.html

  arch/arm/mach-omap2/devices.c |   44 +++++++++++++++++++++++++++++++++++++++++
  1 files changed, 44 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/devices.c +0 -0
index 8e2f0aa..9f44fc6 100644

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 920

Quoted 5 lines
arch/arm/mach-omap2/devices.c +2 -0
@@ -916,11 +916,55 @@ static inline void omap_init_vout(void) {}
 
  /*-------------------------------------------------------------------------*/
 
+/*
+ * WDT mdoule is reset during init which enables the watchdog.

typo: module

The real explanation is that you should not assume anything from the boot loader at that time, so always stop the wdt.

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 928

Quoted 8 lines
arch/arm/mach-omap2/devices.c +8 -0
+ * Hence it is required to disable the watchdog after the WDT reset
+ * during init. Otherwise the system would reboot as per the default
+ * watchdog timer registers settings.
+ */
+#define OMAP_WDT_WPS	(0x34)
+#define OMAP_WDT_SPR	(0x48)
+
+static int omap2_disable_wdt(struct omap_hwmod *oh, void *user)

You should call it unused if the parameter is not used.

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 935

Quoted 7 lines
arch/arm/mach-omap2/devices.c +7 -0
+{
+	void __iomem *base;
+
+	if (!oh)
+		pr_err("Could not look up wdtimer_hwmod\n");
+
+	base = oh->_mpu_rt_va;

Paul added an hwmod API to get that va (something like *_get_mpu_rt_va).

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 938

Quoted 3 lines
arch/arm/mach-omap2/devices.c +3 -0
+
+	/* Enable the clocks before accessing the WDT registers */
+	omap_hwmod_enable(oh);

The enable can fail, so you should check the return value.

Quoted 8 lines
arch/arm/mach-omap2/devices.c +8 -0
+
+	/* sequence required to disable watchdog */
+	__raw_writel(0xAAAA, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS)&  0x10)
+		cpu_relax();
+
+	__raw_writel(0x5555, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS)&  0x10)

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 956

Quoted 10 lines
arch/arm/mach-omap2/devices.c +10 -0
+		cpu_relax();
+
+	omap_hwmod_idle(oh);
+
+	return 0;
+}
+
+static void __init omap_disable_wdt(void)
+{
+	if (cpu_class_is_omap2())

This code is already in mach-omap2/devices.c, so that test should be useless.

Regards,
Benoit

Quoted 14 lines
arch/arm/mach-omap2/devices.c +6 -0
+		omap_hwmod_for_each_by_class("wd_timer",
+						omap2_disable_wdt, NULL);
+	return;
+}
+
  static int __init omap2_init_devices(void)
  {
  	/* please keep these calls, and their implementations above,
  	 * in alphabetical order so they're easier to sort through.
  	 */
+	omap_disable_wdt();
  	omap_hsmmc_reset();
  	omap_init_camera();
  	omap_init_mbox();
#2 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Quoted 18 lines · Benoit

Hi Charu,

Quoted 2 lines · Charulatha

With OMAP2PLUS watchdog implemented in hwmod fw way, the module is reset during init.

In that case hwmod fw just highlighted the real behavior that was hidden so far by the X-loader.

You should as well add a link to the email thread with Kevin that raised the issue.

Quoted 6 lines

After a watchdog timer module reset, the WDTs are enabled. The default time for a system reset after a watchdog module reset is ~10s as per the default value of the WDT registers. Hence the system would be reset after 10s, if watchdog is not disabled within 10s.

Quoted 8 lines
Quoted 2 lines

This patch fixes the above issue by disabling the watchdog timer after reset during initialization of devices.

I'm still wondering as well what is the expected behavior of the watchdog in a real product. If it is started by default at boot time, this is probably for a good reason (or maybe not...).

So, disabling it all the time is maybe not the best solution.

I'm not sure what the other options are. If you don't have a watchdog driver, and the watchdog is armed, it will reboot the system.

The approach in this patch is just to continue the behavior that all bootloaders currently do, but make it explicit in the kernel.

Kevin

Quoted 96 lines

Nishanth (M),
Do you have an idea on that topic?

Quoted 16 lines

---
This patch is dependent on the below patch series (wdt hwmod) and is created on top of pm-core branch.
http://www.spinics.net/lists/linux-omap/msg37043.html

  arch/arm/mach-omap2/devices.c |   44 +++++++++++++++++++++++++++++++++++++++++
  1 files changed, 44 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/devices.c +0 -0
index 8e2f0aa..9f44fc6 100644

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 920

Quoted 5 lines
arch/arm/mach-omap2/devices.c +2 -0
@@ -916,11 +916,55 @@ static inline void omap_init_vout(void) {}
 
  /*-------------------------------------------------------------------------*/
 
+/*
+ * WDT mdoule is reset during init which enables the watchdog.

typo: module

The real explanation is that you should not assume anything from the boot loader at that time, so always stop the wdt.

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 928

Quoted 8 lines
arch/arm/mach-omap2/devices.c +8 -0
+ * Hence it is required to disable the watchdog after the WDT reset
+ * during init. Otherwise the system would reboot as per the default
+ * watchdog timer registers settings.
+ */
+#define OMAP_WDT_WPS	(0x34)
+#define OMAP_WDT_SPR	(0x48)
+
+static int omap2_disable_wdt(struct omap_hwmod *oh, void *user)

You should call it unused if the parameter is not used.

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 935

Quoted 7 lines
arch/arm/mach-omap2/devices.c +7 -0
+{
+	void __iomem *base;
+
+	if (!oh)
+		pr_err("Could not look up wdtimer_hwmod\n");
+
+	base = oh->_mpu_rt_va;

Paul added an hwmod API to get that va (something like *_get_mpu_rt_va).

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 938

Quoted 3 lines
arch/arm/mach-omap2/devices.c +3 -0
+
+	/* Enable the clocks before accessing the WDT registers */
+	omap_hwmod_enable(oh);

The enable can fail, so you should check the return value.

Quoted 8 lines
arch/arm/mach-omap2/devices.c +8 -0
+
+	/* sequence required to disable watchdog */
+	__raw_writel(0xAAAA, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS)&  0x10)
+		cpu_relax();
+
+	__raw_writel(0x5555, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS)&  0x10)

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 956

Quoted 10 lines
arch/arm/mach-omap2/devices.c +10 -0
+		cpu_relax();
+
+	omap_hwmod_idle(oh);
+
+	return 0;
+}
+
+static void __init omap_disable_wdt(void)
+{
+	if (cpu_class_is_omap2())

This code is already in mach-omap2/devices.c, so that test should be useless.

Regards,
Benoit

Quoted 14 lines
arch/arm/mach-omap2/devices.c +6 -0
+		omap_hwmod_for_each_by_class("wd_timer",
+						omap2_disable_wdt, NULL);
+	return;
+}
+
  static int __init omap2_init_devices(void)
  {
  	/* please keep these calls, and their implementations above,
  	 * in alphabetical order so they're easier to sort through.
  	 */
+	omap_disable_wdt();
  	omap_hsmmc_reset();
  	omap_init_camera();
  	omap_init_mbox();
#3 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Quoted 27 lines · Kevin Hilman
Quoted 25 lines · Benoit

Hi Charu,

Quoted 2 lines · Charulatha

With OMAP2PLUS watchdog implemented in hwmod fw way, the module is reset during init.

In that case hwmod fw just highlighted the real behavior that was hidden so far by the X-loader.

You should as well add a link to the email thread with Kevin that raised the issue.

Quoted 8 lines

After a watchdog timer module reset, the WDTs are enabled. The default time for a system reset after a watchdog module reset is ~10s as per the default value of the WDT registers. Hence the system would be reset after 10s, if watchdog is not disabled within 10s.

This patch fixes the above issue by disabling the watchdog timer after reset during initialization of devices.

I'm still wondering as well what is the expected behavior of the watchdog in a real product. If it is started by default at boot time, this is probably for a good reason (or maybe not...).

Quoted 7 lines
Quoted 1 line

So, disabling it all the time is maybe not the best solution.

I'm not sure what the other options are. If you don't have a watchdog driver, and the watchdog is armed, it will reboot the system.

The approach in this patch is just to continue the behavior that all bootloaders currently do, but make it explicit in the kernel.

Yes, because we are not a building a product, and for us watchdog is a pain. But I'm not sure that a real product will disable that at all during the boot process.

I think that disabling it should be done only if the CONFIG_OMAP_WDT is not set.

But since I don't have a clue about a product can use that, it will be good to have such inputs to understand the usecase.

Benoit

Quoted 98 lines

Kevin

Quoted 96 lines

Nishanth (M),
Do you have an idea on that topic?

Quoted 16 lines

---
This patch is dependent on the below patch series (wdt hwmod) and is created on top of pm-core branch.
http://www.spinics.net/lists/linux-omap/msg37043.html

   arch/arm/mach-omap2/devices.c |   44 +++++++++++++++++++++++++++++++++++++++++
   1 files changed, 44 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/devices.c +0 -0
index 8e2f0aa..9f44fc6 100644

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 920

Quoted 5 lines
arch/arm/mach-omap2/devices.c +2 -0
@@ -916,11 +916,55 @@ static inline void omap_init_vout(void) {}
 
   /*-------------------------------------------------------------------------*/
 
+/*
+ * WDT mdoule is reset during init which enables the watchdog.

typo: module

The real explanation is that you should not assume anything from the boot loader at that time, so always stop the wdt.

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 928

Quoted 8 lines
arch/arm/mach-omap2/devices.c +8 -0
+ * Hence it is required to disable the watchdog after the WDT reset
+ * during init. Otherwise the system would reboot as per the default
+ * watchdog timer registers settings.
+ */
+#define OMAP_WDT_WPS	(0x34)
+#define OMAP_WDT_SPR	(0x48)
+
+static int omap2_disable_wdt(struct omap_hwmod *oh, void *user)

You should call it unused if the parameter is not used.

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 935

Quoted 7 lines
arch/arm/mach-omap2/devices.c +7 -0
+{
+	void __iomem *base;
+
+	if (!oh)
+		pr_err("Could not look up wdtimer_hwmod\n");
+
+	base = oh->_mpu_rt_va;

Paul added an hwmod API to get that va (something like *_get_mpu_rt_va).

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 938

Quoted 3 lines
arch/arm/mach-omap2/devices.c +3 -0
+
+	/* Enable the clocks before accessing the WDT registers */
+	omap_hwmod_enable(oh);

The enable can fail, so you should check the return value.

Quoted 8 lines
arch/arm/mach-omap2/devices.c +8 -0
+
+	/* sequence required to disable watchdog */
+	__raw_writel(0xAAAA, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS)&   0x10)
+		cpu_relax();
+
+	__raw_writel(0x5555, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS)&   0x10)

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 956

Quoted 10 lines
arch/arm/mach-omap2/devices.c +10 -0
+		cpu_relax();
+
+	omap_hwmod_idle(oh);
+
+	return 0;
+}
+
+static void __init omap_disable_wdt(void)
+{
+	if (cpu_class_is_omap2())

This code is already in mach-omap2/devices.c, so that test should be useless.

Regards,
Benoit

Quoted 14 lines
arch/arm/mach-omap2/devices.c +6 -0
+		omap_hwmod_for_each_by_class("wd_timer",
+						omap2_disable_wdt, NULL);
+	return;
+}
+
   static int __init omap2_init_devices(void)
   {
   	/* please keep these calls, and their implementations above,
   	 * in alphabetical order so they're easier to sort through.
   	 */
+	omap_disable_wdt();
   	omap_hsmmc_reset();
   	omap_init_camera();
   	omap_init_mbox();
#4 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Quoted 33 lines · Benoit
Quoted 32 lines · Kevin Hilman
Quoted 18 lines · Benoit

Hi Charu,

Quoted 2 lines · Charulatha

With OMAP2PLUS watchdog implemented in hwmod fw way, the module is reset during init.

In that case hwmod fw just highlighted the real behavior that was hidden so far by the X-loader.

You should as well add a link to the email thread with Kevin that raised the issue.

Quoted 6 lines

After a watchdog timer module reset, the WDTs are enabled. The default time for a system reset after a watchdog module reset is ~10s as per the default value of the WDT registers. Hence the system would be reset after 10s, if watchdog is not disabled within 10s.

Quoted 8 lines
Quoted 2 lines

This patch fixes the above issue by disabling the watchdog timer after reset during initialization of devices.

I'm still wondering as well what is the expected behavior of the watchdog in a real product. If it is started by default at boot time, this is probably for a good reason (or maybe not...).

So, disabling it all the time is maybe not the best solution.

I'm not sure what the other options are. If you don't have a watchdog driver, and the watchdog is armed, it will reboot the system.

Quoted 6 lines
Quoted 2 lines

The approach in this patch is just to continue the behavior that all bootloaders currently do, but make it explicit in the kernel.

Yes, because we are not a building a product, and for us watchdog is a pain. But I'm not sure that a real product will disable that at all during the boot process.

Maybe not. But wouldn't a product just ensure the real watchdog driver is loaded?

Or more likely, in addition to the hundreds of other out-of-tree patches, they would just remove $SUBJECT patch. ;)

Quoted 2 lines

I think that disabling it should be done only if the CONFIG_OMAP_WDT is not set.

That's not easy either, as the watchdog driver can be built as a module, and may (or may not) be loaded some unknown time from the kernel boot, resulting in a likely

Kevin

Quoted 2 lines

But since I don't have a clue about a product can use that, it will be good to have such inputs to understand the usecase.

maintainer
#5 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

In reply to Cousson, Benoit
Quoted 3 lines · Cousson, Benoit

I think that disabling it should be done only if the CONFIG_OMAP_WDT is not set.

How about disabling is done always unless CONFIG_WATCHDOG_NOWAYOUT is set? That way product kernels can set CONFIG_WATCHDOG_NOWAYOUT and for the rest of us we can let fsck run the standard Linux way.

Tony

#6 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Tony/ Benoit,

Quoted 6 lines
Quoted 3 lines

I think that disabling it should be done only if the CONFIG_OMAP_WDT is not set.

How about disabling is done always unless CONFIG_WATCHDOG_NOWAYOUT is set?

As given in the patch description, this patch does a disable of watchdog timer, during init, to avoid the system rebooting that happens due to enabling of watchdog timer after a reset of the module (during hwmod init).

According to the default WDT registers values, the system reboot would happen in ~10s if watchdog is enabled with default values. Hence, after a WDT module reset during init, the watchdog has to be disabled within 10s otherwise the system will keep rebooting.

Hence irrespective of CONFIG_WATCHDOG_NOWAYOUT/ CONFIG_OMAP_WDT, the watchdog timer needs to be disabled after a WDT reset has happened.

Later on, the watchdog timer probe would be called (if CONFIG_OMAP_WDT is defined) which takes care of doing the regular the watchdog timer settings. After this, normal operations like open, close, ioctl operations are supported (if CONFIG_OMAP_WDT is defined).
Based on CONFIG_WATCHDOG_NOWAYOUT definition, disabling the watchdog may/may not be supported.

Hence omap2_disable_wdt() introduced in this patch is not going to affect the watchdog operations in anyway execpt that it is fixing the reboot issue observed due to a watchdog timer reset. And this has to be done irrespective of any OMAP watchdog timer related flags.

I guess, omap_wdt_disable() call during the WDT probe might be due to similar reasons.

Quoted 4 lines

That way product kernels can set CONFIG_WATCHDOG_NOWAYOUT and for the rest of us we can let fsck run the standard Linux way.

Tony

#7 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Benoit,

<<snip>>

Quoted 5 lines
Quoted 2 lines

With OMAP2PLUS watchdog implemented in hwmod fw way, the module is reset during init.

In that case hwmod fw just highlighted the real behavior that was hidden so far by the X-loader.

Yes.

Quoted 3 lines

You should as well add a link to the email thread with Kevin that raised the issue.

Okay.

<<snip>>

Quoted 6 lines
Quoted 6 lines
arch/arm/mach-omap2/devices.c +0 -0
index 8e2f0aa..9f44fc6 100644
@@ -916,11 +916,55 @@ static inline void omap_init_vout(void) {}
 
Quoted 6 lines

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 920

Quoted 4 lines
arch/arm/mach-omap2/devices.c +2 -0
  /*-------------------------------------------------------------------------*/
 
+/*
+ * WDT mdoule is reset during init which enables the watchdog.

typo: module

Okay will correct it.

Quoted 3 lines

The real explanation is that you should not assume anything from the boot loader at that time, so always stop the wdt.

It is not an assumption from bootloader. After the WDT reset, the WDT is enabled and the reset values of WDT registers makes the system to reboot (in ~10s) as WDT is enabled.

Quoted 11 lines

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 928

Quoted 9 lines
arch/arm/mach-omap2/devices.c +8 -0
+ * Hence it is required to disable the watchdog after the WDT reset
+ * during init. Otherwise the system would reboot as per the default
+ * watchdog timer registers settings.
+ */
+#define OMAP_WDT_WPS	(0x34)
+#define OMAP_WDT_SPR	(0x48)
+
+static int omap2_disable_wdt(struct omap_hwmod *oh, void *user)

You should call it unused if the parameter is not used.

Okay.

Quoted 10 lines

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 935

Quoted 8 lines
arch/arm/mach-omap2/devices.c +7 -0
+{
+	void __iomem *base;
+
+	if (!oh)
+		pr_err("Could not look up wdtimer_hwmod\n");
+
+	base = oh->_mpu_rt_va;

Paul added an hwmod API to get that va (something like *_get_mpu_rt_va).

Okay. Will use that.

Quoted 6 lines

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 938

Quoted 4 lines
arch/arm/mach-omap2/devices.c +3 -0
+
+	/* Enable the clocks before accessing the WDT registers */
+	omap_hwmod_enable(oh);

The enable can fail, so you should check the return value.

Okay.

Quoted 14 lines
Quoted 14 lines
arch/arm/mach-omap2/devices.c +13 -0
+
+	/* sequence required to disable watchdog */
+	__raw_writel(0xAAAA, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS)&  0x10)
+		cpu_relax();
+
+	__raw_writel(0x5555, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS)&  0x10)
+		cpu_relax();
+
+	omap_hwmod_idle(oh);
+
+	return 0;
Quoted 8 lines

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 956

Quoted 5 lines
arch/arm/mach-omap2/devices.c +5 -0
+}
+
+static void __init omap_disable_wdt(void)
+{
+	if (cpu_class_is_omap2())

This code is already in mach-omap2/devices.c, so that test should be useless.

I do not see a cpu_class_is_omap2() check in omap2_init_devices(). Please point out where this check is done while/before calling omap_disable_wdt()?

Quoted 2 lines

<<snip>>

#8 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Hello Charu,

Quoted 12 lines · Charulatha
Quoted 11 lines

arch/arm/mach-omap2/devices.c

Quoted 8 lines
arch/arm/mach-omap2/devices.c +4 -0
index 8e2f0aa..9f44fc6 100644
+
+static void __init omap_disable_wdt(void)
+{
+	if (cpu_class_is_omap2())

This code is already in mach-omap2/devices.c, so that test should be useless.

Quoted 2 lines

I do not see a cpu_class_is_omap2() check in omap2_init_devices(). Please point out where this check is done while/before calling omap_disable_wdt()?

It's implicit, due to the directory arch/arm/mach-omap2/ -- code in that directory is only built for OMAP2+ systems -- and right now there are no plans for OMAP1+ multi-arch booting. So it's safe to assume that any code in arch/arm/mach-omap2 will only run on OMAP2+ boards.

- Paul

maintainer
#9 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Quoted 16 lines · Paul Walmsley

Hello Charu,

Quoted 12 lines · Charulatha
Quoted 11 lines

arch/arm/mach-omap2/devices.c

Quoted 8 lines
arch/arm/mach-omap2/devices.c +4 -0
index 8e2f0aa..9f44fc6 100644
+
+static void __init omap_disable_wdt(void)
+{
+	if (cpu_class_is_omap2())

This code is already in mach-omap2/devices.c, so that test should be useless.

Quoted 7 lines
Quoted 2 lines

I do not see a cpu_class_is_omap2() check in omap2_init_devices(). Please point out where this check is done while/before calling omap_disable_wdt()?

It's implicit, due to the directory arch/arm/mach-omap2/ -- code in that directory is only built for OMAP2+ systems -- and right now there are no plans for OMAP1+ multi-arch booting. So it's safe to assume that any code in arch/arm/mach-omap2 will only run on OMAP2+ boards.

That might change pretty fast though. There are already experimental patches to build in multiple ARM archs into a single kernel binary.

So we should already have these checks in place to avoid the initcalls running on other ARM archs.

Regards,

Tony

#10 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

In reply to Varadarajan, Charulatha
Quoted 36 lines · Charulatha

Benoit,

<<snip>>

Quoted 5 lines
Quoted 2 lines

With OMAP2PLUS watchdog implemented in hwmod fw way, the module is reset during init.

In that case hwmod fw just highlighted the real behavior that was hidden so far by the X-loader.

Yes.

Quoted 3 lines

You should as well add a link to the email thread with Kevin that raised the issue.

Okay.

<<snip>>

Quoted 6 lines
Quoted 6 lines
arch/arm/mach-omap2/devices.c +0 -0
index 8e2f0aa..9f44fc6 100644
@@ -916,11 +916,55 @@ static inline void omap_init_vout(void) {}
 
Quoted 6 lines

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 920

Quoted 4 lines
arch/arm/mach-omap2/devices.c +2 -0
   /*-------------------------------------------------------------------------*/
 
+/*
+ * WDT mdoule is reset during init which enables the watchdog.

typo: module

Okay will correct it.

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

The real explanation is that you should not assume anything from the boot loader at that time, so always stop the wdt.

It is not an assumption from bootloader. After the WDT reset, the WDT is enabled and the reset values of WDT registers makes the system to reboot (in ~10s) as WDT is enabled.

The implicit assumption in the previous code is that the bootloader already stopped it. That exactly for that reason that hwmod is reseting every IPs, because we don't have a clue about what X-loader / u-boot can do between a cold-reset and the kernel boot.

Quoted 60 lines
Quoted 12 lines

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 928

Quoted 10 lines
arch/arm/mach-omap2/devices.c +8 -0
+ * Hence it is required to disable the watchdog after the WDT reset
+ * during init. Otherwise the system would reboot as per the default
+ * watchdog timer registers settings.
+ */
+#define OMAP_WDT_WPS	(0x34)
+#define OMAP_WDT_SPR	(0x48)
+
+static int omap2_disable_wdt(struct omap_hwmod *oh, void *user)

You should call it unused if the parameter is not used.

Okay.

Quoted 10 lines

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 935

Quoted 8 lines
arch/arm/mach-omap2/devices.c +7 -0
+{
+	void __iomem *base;
+
+	if (!oh)
+		pr_err("Could not look up wdtimer_hwmod\n");
+
+	base = oh->_mpu_rt_va;

Paul added an hwmod API to get that va (something like *_get_mpu_rt_va).

Okay. Will use that.

Quoted 6 lines

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 938

Quoted 4 lines
arch/arm/mach-omap2/devices.c +3 -0
+
+	/* Enable the clocks before accessing the WDT registers */
+	omap_hwmod_enable(oh);

The enable can fail, so you should check the return value.

Okay.

Quoted 14 lines
Quoted 14 lines
arch/arm/mach-omap2/devices.c +13 -0
+
+	/* sequence required to disable watchdog */
+	__raw_writel(0xAAAA, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS)&   0x10)
+		cpu_relax();
+
+	__raw_writel(0x5555, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS)&   0x10)
+		cpu_relax();
+
+	omap_hwmod_idle(oh);
+
+	return 0;
Quoted 8 lines

arch/arm/mach-omap2/devices.c static inline void omap_init_vout(void) {} · line 956

Quoted 5 lines
arch/arm/mach-omap2/devices.c +5 -0
+}
+
+static void __init omap_disable_wdt(void)
+{
+	if (cpu_class_is_omap2())

This code is already in mach-omap2/devices.c, so that test should be useless.

Quoted 3 lines

I do not see a cpu_class_is_omap2() check in omap2_init_devices(). Please point out where this check is done while/before calling omap_disable_wdt()?

And Paul has just answered that one...

Benoit

#11 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

In reply to Varadarajan, Charulatha
Quoted 13 lines · Charulatha

Tony/ Benoit,

Quoted 6 lines
Quoted 3 lines

I think that disabling it should be done only if the CONFIG_OMAP_WDT is not set.

How about disabling is done always unless CONFIG_WATCHDOG_NOWAYOUT is set?

As given in the patch description, this patch does a disable of watchdog timer, during init, to avoid the system rebooting that happens due to enabling of watchdog timer after a reset of the module (during hwmod init).

Quoted 7 lines

According to the default WDT registers values, the system reboot would happen in ~10s if watchdog is enabled with default values. Hence, after a WDT module reset during init, the watchdog has to be disabled within 10s otherwise the system will keep rebooting.

Hence irrespective of CONFIG_WATCHDOG_NOWAYOUT/ CONFIG_OMAP_WDT, the watchdog timer needs to be disabled after a WDT reset has happened.

No, not necessarily, this is the whole point about a watchdog, you need just need to ping it to prove that the system is alive.

In case you didn't notice, every watchdogs are started during a cold reset since OMAP1610. Even Phoenix contains a watchdog that is started by default.
This is by construction... and this is done like that for a good reason. So stopping a watchdog just after the reset in a bootloader is not necessarily the behavior that user of a watchdog are expecting, otherwise it will not be started by default at boot time.

In your description, it looks like this behavior is a HW bug that we have to fix... It is just the way it is supposed to work.

Regards,
Benoit

Quoted 20 lines

Later on, the watchdog timer probe would be called (if CONFIG_OMAP_WDT is defined) which takes care of doing the regular the watchdog timer settings. After this, normal operations like open, close, ioctl operations are supported (if CONFIG_OMAP_WDT is defined).
Based on CONFIG_WATCHDOG_NOWAYOUT definition, disabling the watchdog may/may not be supported.

Hence omap2_disable_wdt() introduced in this patch is not going to affect the watchdog operations in anyway execpt that it is fixing the reboot issue observed due to a watchdog timer reset. And this has to be done irrespective of any OMAP watchdog timer related flags.

I guess, omap_wdt_disable() call during the WDT probe might be due to similar reasons.

Quoted 4 lines

That way product kernels can set CONFIG_WATCHDOG_NOWAYOUT and for the rest of us we can let fsck run the standard Linux way.

Tony

#12 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Quoted 18 lines
Quoted 18 lines

Tony/ Benoit,

Quoted 6 lines
Quoted 3 lines

I think that disabling it should be done only if the CONFIG_OMAP_WDT is not set.

How about disabling is done always unless CONFIG_WATCHDOG_NOWAYOUT is set?

As given in the patch description, this patch does a disable of watchdog timer, during init, to avoid the system rebooting that happens due to enabling of watchdog timer after a reset of the module (during hwmod init).

According to the default WDT registers values, the system reboot would happen in ~10s if watchdog is enabled with default values. Hence, after a WDT module reset during init, the watchdog has to be disabled within 10s otherwise the system will keep rebooting.

Quoted 6 lines
Quoted 2 lines

Hence irrespective of CONFIG_WATCHDOG_NOWAYOUT/ CONFIG_OMAP_WDT, the watchdog timer needs to be disabled after a WDT reset has happened.

No, not necessarily, this is the whole point about a watchdog, you need just need to ping it to prove that the system is alive.

Agreed

Quoted 4 lines

In case you didn't notice, every watchdogs are started during a cold reset since OMAP1610. Even Phoenix contains a watchdog that is started by default.
This is by construction... and this is done like that for a good reason.

Yes.

Quoted 3 lines

So stopping a watchdog just after the reset in a bootloader is not necessarily the behavior that user of a watchdog are expecting, otherwise it will not be started by default at boot time.

But, how do we handle this? enable INIT_NO_RESET flag?

Quoted 3 lines

In your description, it looks like this behavior is a HW bug that we have to fix...

Sorry if it sounded like that.

Quoted 1 line

It is just the way it is supposed to work.

Yes. That's correct

Regards,
Benoit

#13 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

In reply to Varadarajan, Charulatha
Quoted 24 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-
owner at vger.kernel.org] On Behalf Of Varadarajan, Charulatha
Sent: Thursday, September 30, 2010 9:25 PM
To: Tony Lindgren; Cousson, Benoit
Cc: Kevin Hilman; Menon, Nishanth; wim at iguana.be; linux-
omap at vger.kernel.org; linux-watchdog at vger.kernel.org; linux-arm- kernel at lists.infradead.org; paul at pwsan.com; Nayak, Rajendra; Basak, Partha
Subject: RE: [PATCH] OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Tony/ Benoit,

Quoted 6 lines
Quoted 3 lines

I think that disabling it should be done only if the CONFIG_OMAP_WDT is not set.

How about disabling is done always unless CONFIG_WATCHDOG_NOWAYOUT is set?

As given in the patch description, this patch does a disable of watchdog timer, during init, to avoid the system rebooting that happens due to enabling of watchdog timer after a reset of the module (during hwmod init).

Quoted 8 lines

According to the default WDT registers values, the system reboot would happen in ~10s if watchdog is enabled with default values. Hence, after a WDT module reset during init, the watchdog has to be disabled within 10s otherwise the system will keep rebooting.

Hence irrespective of CONFIG_WATCHDOG_NOWAYOUT/ CONFIG_OMAP_WDT, the watchdog timer needs to be disabled after a WDT reset has happened.

One more option is to avoid the software reset using the CONFIG_OMAP_WDT flag. Something like below.

--------------

static struct omap_hwmod omap44xx_wd_timer2_hwmod = {
	.name		= "wd_timer2",
	.class		= &omap44xx_wd_timer_hwmod_class,
	.mpu_irqs	= omap44xx_wd_timer2_irqs,

+ #ifndef CONFIG_OMAP_WDT,
+ .flags = HWMOD_INIT_NO_RESET,
+ #endif

	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_wd_timer2_irqs),
	.main_clk	= "wd_timer2_fck",
	.prcm = {
		.omap4 = {
			.clkctrl_reg = OMAP4430_CM_WKUP_WDT2_CLKCTRL,
		},
	},
	.slaves		= omap44xx_wd_timer2_slaves,
	.slaves_cnt	= ARRAY_SIZE(omap44xx_wd_timer2_slaves),
	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
};

Regards,
Santosh

#14 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Quoted 29 lines · Santosh
Quoted 29 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap-
owner at vger.kernel.org] On Behalf Of Varadarajan, Charulatha
Sent: Thursday, September 30, 2010 9:25 PM
To: Tony Lindgren; Cousson, Benoit
Cc: Kevin Hilman; Menon, Nishanth; wim at iguana.be; linux-
omap at vger.kernel.org; linux-watchdog at vger.kernel.org; linux-arm- kernel at lists.infradead.org; paul at pwsan.com; Nayak, Rajendra; Basak, Partha
Subject: RE: [PATCH] OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Tony/ Benoit,

Quoted 6 lines
Quoted 3 lines

I think that disabling it should be done only if the CONFIG_OMAP_WDT is not set.

How about disabling is done always unless CONFIG_WATCHDOG_NOWAYOUT is set?

As given in the patch description, this patch does a disable of watchdog timer, during init, to avoid the system rebooting that happens due to enabling of watchdog timer after a reset of the module (during hwmod init).

According to the default WDT registers values, the system reboot would happen in ~10s if watchdog is enabled with default values. Hence, after a WDT module reset during init, the watchdog has to be disabled within 10s otherwise the system will keep rebooting.

Quoted 5 lines
Quoted 3 lines

Hence irrespective of CONFIG_WATCHDOG_NOWAYOUT/ CONFIG_OMAP_WDT, the watchdog timer needs to be disabled after a WDT reset has happened.

One more option is to avoid the software reset using the CONFIG_OMAP_WDT flag. Something like below.

This was already proposed by Charu, and rejected.

Doing this means we have a dependency on particular bootloader init, and we'd like to get rid of *all* assumptions about what the bootloader does (or does not do.)

Kevin

#15 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Quoted 51 lines

-----Original Message-----
From: Kevin Hilman [mailto:khilman at deeprootsystems.com]
Sent: Thursday, September 30, 2010 10:42 PM
To: Shilimkar, Santosh
Cc: Varadarajan, Charulatha; Tony Lindgren; Cousson, Benoit; Menon, Nishanth; wim at iguana.be; linux-omap at vger.kernel.org; linux- watchdog at vger.kernel.org; linux-arm-kernel at lists.infradead.org; paul at pwsan.com; Nayak, Rajendra; Basak, Partha
Subject: Re: [PATCH] OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Quoted 8 lines · Santosh
Quoted 8 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap- owner at vger.kernel.org] On Behalf Of Varadarajan, Charulatha
Sent: Thursday, September 30, 2010 9:25 PM
To: Tony Lindgren; Cousson, Benoit
Cc: Kevin Hilman; Menon, Nishanth; wim at iguana.be; linux- omap at vger.kernel.org; linux-watchdog at vger.kernel.org; linux-arm- kernel at lists.infradead.org; paul at pwsan.com; Nayak, Rajendra; Basak,

Partha

Quoted 1 line
Quoted 1 line

Subject: RE: [PATCH] OMAP2PLUS: WDT: Fix: Disable WDT after reset

during

Quoted 6 lines
Quoted 6 lines

init

Tony/ Benoit,

Quoted 2 lines
Quoted 2 lines

I think that disabling it should be done only if the

CONFIG_OMAP_WDT

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

is not set.

How about disabling is done always unless CONFIG_WATCHDOG_NOWAYOUT is set?

As given in the patch description, this patch does a disable of

watchdog

Quoted 2 lines
Quoted 2 lines

timer, during init, to avoid the system rebooting that happens due to enabling of watchdog timer after a reset of the module (during hwmod

init).

Quoted 4 lines
Quoted 4 lines

According to the default WDT registers values, the system reboot would happen in ~10s if watchdog is enabled with default values. Hence, after a WDT module reset during init, the watchdog has to be disabled within

10s

Quoted 5 lines
Quoted 5 lines

otherwise the system will keep rebooting.

Hence irrespective of CONFIG_WATCHDOG_NOWAYOUT/ CONFIG_OMAP_WDT, the watchdog timer needs to be disabled after a WDT reset has happened.

Quoted 9 lines
Quoted 2 lines

One more option is to avoid the software reset using the CONFIG_OMAP_WDT flag. Something like below.

This was already proposed by Charu, and rejected.

Doing this means we have a dependency on particular bootloader init, and we'd like to get rid of *all* assumptions about what the bootloader does (or does not do.)

you mean is not depeding on bootloader to disable WDT. Make sense.

Thanks

Regards,
Santosh

#16 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Tony, Benoit, Kevin,

Quoted 31 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I think that disabling it should be done only if the

CONFIG_OMAP_WDT

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

is not set.

Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

How about disabling is done always unless CONFIG_WATCHDOG_NOWAYOUT is set?

As given in the patch description, this patch does a disable of

watchdog

Quoted 2 lines
Quoted 2 lines

timer, during init, to avoid the system rebooting that happens due to enabling of watchdog timer after a reset of the module (during hwmod

init).

Quoted 2 lines
Quoted 2 lines

According to the default WDT registers values, the system reboot

would

Quoted 1 line
Quoted 1 line
Quoted 1 line

happen in ~10s if watchdog is enabled with default values. Hence,

after

Quoted 1 line
Quoted 1 line
Quoted 1 line

a WDT module reset during init, the watchdog has to be disabled

within

Quoted 5 lines

10s

Quoted 4 lines
Quoted 4 lines

otherwise the system will keep rebooting.

Hence irrespective of CONFIG_WATCHDOG_NOWAYOUT/ CONFIG_OMAP_WDT, the watchdog timer needs to be disabled after a WDT reset has

happened.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

One more option is to avoid the software reset using the

CONFIG_OMAP_WDT

Quoted 2 lines
Quoted 1 line

flag. Something like below.

Quoted 8 lines
Quoted 6 lines

This was already proposed by Charu, and rejected.

Doing this means we have a dependency on particular bootloader init, and we'd like to get rid of *all* assumptions about what the bootloader does (or does not do.)

you mean is not depeding on bootloader to disable WDT. Make sense.

Let me know your opinion on how to handle this issue.

- V Charulatha

#17 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Quoted 35 lines · Charulatha

Tony, Benoit, Kevin,

Quoted 33 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I think that disabling it should be done only if the

CONFIG_OMAP_WDT

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

is not set.

Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

How about disabling is done always unless CONFIG_WATCHDOG_NOWAYOUT is set?

As given in the patch description, this patch does a disable of

watchdog

Quoted 2 lines
Quoted 2 lines

timer, during init, to avoid the system rebooting that happens due to enabling of watchdog timer after a reset of the module (during hwmod

init).

Quoted 2 lines
Quoted 2 lines

According to the default WDT registers values, the system reboot

would

Quoted 1 line
Quoted 1 line
Quoted 1 line

happen in ~10s if watchdog is enabled with default values. Hence,

after

Quoted 1 line
Quoted 1 line
Quoted 1 line

a WDT module reset during init, the watchdog has to be disabled

within

Quoted 5 lines

10s

Quoted 4 lines
Quoted 4 lines

otherwise the system will keep rebooting.

Hence irrespective of CONFIG_WATCHDOG_NOWAYOUT/ CONFIG_OMAP_WDT, the watchdog timer needs to be disabled after a WDT reset has

happened.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

One more option is to avoid the software reset using the

CONFIG_OMAP_WDT

Quoted 4 lines
Quoted 1 line

flag. Something like below.

This was already proposed by Charu, and rejected.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Doing this means we have a dependency on particular bootloader init, and we'd like to get rid of *all* assumptions about what the bootloader does (or does not do.)

you mean is not depeding on bootloader to disable WDT. Make sense.

Let me know your opinion on how to handle this issue.

IMO, we should do what your original patch did: always disable the WDT, just like most/all bootloaders do.

If we want to make changes later to support product needs (like no disable on boot, etc.) that is a separate issue and should be done in a separate patch.

Kevin

#18 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Quoted 44 lines · Kevin Hilman
Quoted 42 lines · Charulatha

Tony, Benoit, Kevin,

Quoted 39 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I think that disabling it should be done only if the

CONFIG_OMAP_WDT

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

is not set.

Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

How about disabling is done always unless CONFIG_WATCHDOG_NOWAYOUT is set?

As given in the patch description, this patch does a disable of

watchdog

Quoted 2 lines
Quoted 2 lines

timer, during init, to avoid the system rebooting that happens due to enabling of watchdog timer after a reset of the module (during hwmod

init).

Quoted 2 lines
Quoted 2 lines

According to the default WDT registers values, the system reboot

would

Quoted 1 line
Quoted 1 line
Quoted 1 line

happen in ~10s if watchdog is enabled with default values. Hence,

after

Quoted 1 line
Quoted 1 line
Quoted 1 line

a WDT module reset during init, the watchdog has to be disabled

within

Quoted 5 lines

10s

Quoted 4 lines
Quoted 4 lines

otherwise the system will keep rebooting.

Hence irrespective of CONFIG_WATCHDOG_NOWAYOUT/ CONFIG_OMAP_WDT, the watchdog timer needs to be disabled after a WDT reset has

happened.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

One more option is to avoid the software reset using the

CONFIG_OMAP_WDT

Quoted 8 lines
Quoted 1 line

flag. Something like below.

This was already proposed by Charu, and rejected.

Doing this means we have a dependency on particular bootloader init, and we'd like to get rid of *all* assumptions about what the bootloader does (or does not do.)

you mean is not depeding on bootloader to disable WDT. Make sense.

Quoted 8 lines
Quoted 1 line

Let me know your opinion on how to handle this issue.

IMO, we should do what your original patch did: always disable the WDT, just like most/all bootloaders do.

If we want to make changes later to support product needs (like no disable on boot, etc.) that is a separate issue and should be done in a separate patch.

Let's do that, since we still don't have a clue how it is supposed to be used by a product. If someone find out the answer, he'll fix that.

Benoit

#19 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

In reply to Varadarajan, Charulatha
Quoted 2 lines · Charulatha

With OMAP2PLUS watchdog implemented in hwmod fw way, the module is reset during init.

Please drop this sentence, as it's not directly related to hwmod, but related to hardware reset, and was previously masked by most bootloaders.

Quoted 8 lines

After a watchdog timer module reset, the WDTs are enabled. The default time for a system reset after a watchdog module reset is ~10s as per the default value of the WDT registers. Hence the system would be reset after 10s, if watchdog is not disabled within 10s.

This patch fixes the above issue by disabling the watchdog timer after reset during initialization of devices.

Should also describe what happends if/when the watchdog driver is loaded.

Kevin

Quoted 70 lines

---
This patch is dependent on the below patch series (wdt hwmod) and is created on top of pm-core branch.
http://www.spinics.net/lists/linux-omap/msg37043.html

 arch/arm/mach-omap2/devices.c |   44 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/devices.c +44 -0
index 8e2f0aa..9f44fc6 100644
@@ -916,11 +916,55 @@ static inline void omap_init_vout(void) {}
 
 /*-------------------------------------------------------------------------*/
 
+/*
+ * WDT mdoule is reset during init which enables the watchdog.
+ * Hence it is required to disable the watchdog after the WDT reset
+ * during init. Otherwise the system would reboot as per the default
+ * watchdog timer registers settings.
+ */
+#define OMAP_WDT_WPS	(0x34)
+#define OMAP_WDT_SPR	(0x48)
+
+static int omap2_disable_wdt(struct omap_hwmod *oh, void *user)
+{
+	void __iomem *base;
+
+	if (!oh)
+		pr_err("Could not look up wdtimer_hwmod\n");
+
+	base = oh->_mpu_rt_va;
+
+	/* Enable the clocks before accessing the WDT registers */
+	omap_hwmod_enable(oh);
+
+	/* sequence required to disable watchdog */
+	__raw_writel(0xAAAA, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
+		cpu_relax();
+
+	__raw_writel(0x5555, base + OMAP_WDT_SPR);	/* TIMER_MODE */
+	while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
+		cpu_relax();
+
+	omap_hwmod_idle(oh);
+
+	return 0;
+}
+
+static void __init omap_disable_wdt(void)
+{
+	if (cpu_class_is_omap2())
+		omap_hwmod_for_each_by_class("wd_timer",
+						omap2_disable_wdt, NULL);
+	return;
+}
+
 static int __init omap2_init_devices(void)
 {
 	/* please keep these calls, and their implementations above,
 	 * in alphabetical order so they're easier to sort through.
 	 */
+	omap_disable_wdt();
 	omap_hsmmc_reset();
 	omap_init_camera();
 	omap_init_mbox();
#20 lore raw

PATCH 1/1 OMAP2PLUS: WDT: Fix: Disable WDT after reset during init

Kevin,

Quoted 2 lines

"Varadarajan, Charulatha" <[email protected]> writes:

<<snip>>

Quoted 6 lines
Quoted 2 lines

With OMAP2PLUS watchdog implemented in hwmod fw way, the module is reset during init.

Please drop this sentence, as it's not directly related to hwmod, but related to hardware reset, and was previously masked by most bootloaders.

Okay, will modify accordingly.

Quoted 11 lines
Quoted 8 lines

After a watchdog timer module reset, the WDTs are enabled. The default time for a system reset after a watchdog module reset is ~10s as per the default value of the WDT registers. Hence the system would be reset after 10s, if watchdog is not disabled within 10s.

This patch fixes the above issue by disabling the watchdog timer after reset during initialization of devices.

Should also describe what happends if/when the watchdog driver is loaded.

Okay. Will add it to the description.

Quoted 5 lines

Kevin

Quoted 2 lines

<<snip>>