public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] Nios: WATCHDOG preparation
@ 2004-02-16  9:09 Stephan Linz
  2004-02-16  9:30 ` [U-Boot-Users] " Wolfgang Denk
  0 siblings, 1 reply; 5+ messages in thread
From: Stephan Linz @ 2004-02-16  9:09 UTC (permalink / raw)
  To: u-boot

Hi all,

attached patch includes the WATCHDOG_RESET() macro at some more points in 
U-Boot so I can use it in my upcoming new Nios board support. Please, merge 
it with current CVS tree -- thanks.


--
Best regards,
Stephan Linz
-------------- next part --------------
diff -purN -x CVS u-boot-20040210cvs-prepare_post/cpu/nios/serial.c u-boot-20040210cvs-prepare_watchdog/cpu/nios/serial.c
--- u-boot-20040210cvs-prepare_post/cpu/nios/serial.c	2003-10-08 23:26:14.000000000 +0000
+++ u-boot-20040210cvs-prepare_watchdog/cpu/nios/serial.c	2004-02-15 02:57:28.000000000 +0000
@@ -24,6 +24,8 @@
 
 #include <common.h>
 #include <nios-io.h>
+#include <watchdog.h>
+#include <common.h>
 
 
 static nios_uart_t *uart = (nios_uart_t *)CFG_NIOS_CONSOLE;
@@ -62,7 +64,7 @@ void serial_putc( char c )
 	if (c == '\n')
 		serial_putc('\r');
 	while( (uart->status & NIOS_UART_TRDY) == 0 )
-		;
+		WATCHDOG_RESET ();
 	uart->txdata = (unsigned char)c;
 }
 
@@ -81,6 +83,6 @@ int serial_tstc( void )
 int serial_getc( void )
 {
 	while( serial_tstc() == 0 )
-		;
+		WATCHDOG_RESET ();
 	return( uart->rxdata & 0x00ff );
 }
diff -purN -x CVS u-boot-20040210cvs-prepare_post/drivers/smc91111.c u-boot-20040210cvs-prepare_watchdog/drivers/smc91111.c
--- u-boot-20040210cvs-prepare_post/drivers/smc91111.c	2003-12-06 23:20:42.000000000 +0000
+++ u-boot-20040210cvs-prepare_watchdog/drivers/smc91111.c	2004-02-15 02:57:28.000000000 +0000
@@ -61,6 +61,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <watchdog.h>
 #include "smc91111.h"
 #include <net.h>
 
@@ -1174,7 +1175,11 @@ static void smc_write_phy_register (byte
 #ifndef CONFIG_SMC91111_EXT_PHY
 static void smc_wait_ms(unsigned int ms)
 {
+	/* B E   W A R N E D :
+	 * DON'T EXCEED YOUR WATCHDOG TIMOUT WITH ARGUMENT 'ms' */
+	WATCHDOG_RESET ();
 	udelay(ms*1000);
+	WATCHDOG_RESET ();
 }
 #endif /* !CONFIG_SMC91111_EXT_PHY */
 
diff -purN -x CVS u-boot-20040210cvs-prepare_post/lib_nios/board.c u-boot-20040210cvs-prepare_watchdog/lib_nios/board.c
--- u-boot-20040210cvs-prepare_post/lib_nios/board.c	2004-02-09 23:12:26.000000000 +0000
+++ u-boot-20040210cvs-prepare_watchdog/lib_nios/board.c	2004-02-15 02:57:28.000000000 +0000
@@ -139,13 +139,16 @@ void board_init (void)
 	bd->bi_baudrate	= CONFIG_BAUDRATE;
 
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
+		WATCHDOG_RESET ();
 		if ((*init_fnc_ptr) () != 0) {
 			hang ();
 		}
 	}
 
+	WATCHDOG_RESET ();
 	bd->bi_flashsize = flash_init();
 
+	WATCHDOG_RESET ();
 	mem_malloc_init();
 	malloc_bin_reloc();
 	env_relocate();
@@ -157,12 +160,14 @@ void board_init (void)
 		if (s) s = (*e) ? e + 1 : e;
 	}
 
+	WATCHDOG_RESET ();
 	devices_init();
 	jumptable_init();
 	console_init_r();
 	/*
 	 */
 
+	WATCHDOG_RESET ();
 	interrupt_init ();
 
 #ifdef CONFIG_STATUS_LED
-------------- next part --------------
* Patch by Stephan Linz, 15 Feb 2004
  - prepare WATCHDOG framework support for NIOS targets;
    (add WATCHDOG_RESET() macros)

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

* [U-Boot-Users] Re: [PATCH] Nios: WATCHDOG preparation
  2004-02-16  9:09 [U-Boot-Users] [PATCH] Nios: WATCHDOG preparation Stephan Linz
@ 2004-02-16  9:30 ` Wolfgang Denk
  2004-02-16 10:07   ` Stephan Linz
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Denk @ 2004-02-16  9:30 UTC (permalink / raw)
  To: u-boot

Dear Stephan,,

in message <0402161009090A.00467@pcj86> you wrote:
> 
Dear Stephan,,

> attached patch includes the WATCHDOG_RESET() macro at some more points in 
> U-Boot so I can use it in my upcoming new Nios board support. Please, merge 
> it with current CVS tree -- thanks.

I would like to ask you to modify your patch.

> @@ -1174,7 +1175,11 @@ static void smc_write_phy_register (byte
>  #ifndef CONFIG_SMC91111_EXT_PHY
>  static void smc_wait_ms(unsigned int ms)
>  {
> +	/* B E   W A R N E D :
> +	 * DON'T EXCEED YOUR WATCHDOG TIMOUT WITH ARGUMENT 'ms' */
> +	WATCHDOG_RESET ();
>  	udelay(ms*1000);
> +	WATCHDOG_RESET ();

This should never be  necessary.  The  udelay()  function  itself  is
expected to trigger the waitchdog as necessary.

If this is not the case on NIOS, then please fix this first. It might
make some more of your modifications redundand, too.



Best regards,

Wolfgang Denk

-- 
See us @ Embedded World, Nuremberg, Feb 17 - 19,  Hall 12.0 Booth 440
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
"Why waste negative entropy on comments, when you could use the  same
entropy to create bugs instead?"                        - Steve Elias

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

* [U-Boot-Users] Re: [PATCH] Nios: WATCHDOG preparation
  2004-02-16  9:30 ` [U-Boot-Users] " Wolfgang Denk
@ 2004-02-16 10:07   ` Stephan Linz
  2004-02-17 17:34     ` [U-Boot-Users] " Stephan Linz
  0 siblings, 1 reply; 5+ messages in thread
From: Stephan Linz @ 2004-02-16 10:07 UTC (permalink / raw)
  To: u-boot

> --snip--
>
> > @@ -1174,7 +1175,11 @@ static void smc_write_phy_register (byte
> >  #ifndef CONFIG_SMC91111_EXT_PHY
> >  static void smc_wait_ms(unsigned int ms)
> >  {
> > +	/* B E   W A R N E D :
> > +	 * DON'T EXCEED YOUR WATCHDOG TIMOUT WITH ARGUMENT 'ms' */
> > +	WATCHDOG_RESET ();
> >  	udelay(ms*1000);
> > +	WATCHDOG_RESET ();
>
> This should never be  necessary.  The  udelay()  function  itself  is
> expected to trigger the waitchdog as necessary.
>
> If this is not the case on NIOS, then please fix this first. It might
> make some more of your modifications redundand, too.

Hu, you're right. It isn't the case on NIOS. OK, I'll fix it up and try out 
this afternoon. You'll get a new patch tomorrow.


Best regards,
Stephan Linz

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

* [U-Boot-Users] Re: Re: [PATCH] Nios: WATCHDOG preparation
  2004-02-16 10:07   ` Stephan Linz
@ 2004-02-17 17:34     ` Stephan Linz
  2004-02-23 23:19       ` [U-Boot-Users] " Wolfgang Denk
  0 siblings, 1 reply; 5+ messages in thread
From: Stephan Linz @ 2004-02-17 17:34 UTC (permalink / raw)
  To: u-boot

Am Montag, 16. Februar 2004 11:07 schrieb Stephan Linz:
> > --snip--
> >
> > > @@ -1174,7 +1175,11 @@ static void smc_write_phy_register (byte
> > >  #ifndef CONFIG_SMC91111_EXT_PHY
> > >  static void smc_wait_ms(unsigned int ms)
> > >  {
> > > +	/* B E   W A R N E D :
> > > +	 * DON'T EXCEED YOUR WATCHDOG TIMOUT WITH ARGUMENT 'ms' */
> > > +	WATCHDOG_RESET ();
> > >  	udelay(ms*1000);
> > > +	WATCHDOG_RESET ();
> >
> > This should never be  necessary.  The  udelay()  function  itself  is
> > expected to trigger the waitchdog as necessary.
> >
> > If this is not the case on NIOS, then please fix this first. It might
> > make some more of your modifications redundand, too.
>
> Hu, you're right. It isn't the case on NIOS. OK, I'll fix it up and try out
> this afternoon. You'll get a new patch tomorrow.

OK, here is the correct patch. Sorry for the delay :-)

Note: In my opinion this is the first stage. In second stage we should move 
the WATCHDOG_RESET macro from within udelay() C function into the underlayed 
assembly function dly_clks(). I've tried it out but without success, so I try 
again.


Best regards,
Stephan Linz
-------------- next part --------------
diff -purN -x CVS u-boot-20040210cvs-prepare_post/cpu/nios/interrupts.c u-boot-20040210cvs-prepare_watchdog/cpu/nios/interrupts.c
--- u-boot-20040210cvs-prepare_post/cpu/nios/interrupts.c	2004-02-16 21:50:23.000000000 +0000
+++ u-boot-20040210cvs-prepare_watchdog/cpu/nios/interrupts.c	2004-02-16 23:42:15.000000000 +0000
@@ -30,6 +30,7 @@
 #include <asm/ptrace.h>
 #include <common.h>
 #include <command.h>
+#include <watchdog.h>
 #ifdef CONFIG_STATUS_LED
 #include <status_led.h>
 #endif
@@ -54,6 +55,7 @@ void reset_timer (void)
 
 ulong get_timer (ulong base)
 {
+	WATCHDOG_RESET ();
 	return (timestamp - base);
 }
 
diff -purN -x CVS u-boot-20040210cvs-prepare_post/cpu/nios/serial.c u-boot-20040210cvs-prepare_watchdog/cpu/nios/serial.c
--- u-boot-20040210cvs-prepare_post/cpu/nios/serial.c	2003-10-08 23:26:14.000000000 +0000
+++ u-boot-20040210cvs-prepare_watchdog/cpu/nios/serial.c	2004-02-16 23:42:15.000000000 +0000
@@ -23,6 +23,7 @@
 
 
 #include <common.h>
+#include <watchdog.h>
 #include <nios-io.h>
 
 
@@ -62,7 +63,7 @@ void serial_putc( char c )
 	if (c == '\n')
 		serial_putc('\r');
 	while( (uart->status & NIOS_UART_TRDY) == 0 )
-		;
+		WATCHDOG_RESET ();
 	uart->txdata = (unsigned char)c;
 }
 
@@ -81,6 +82,6 @@ int serial_tstc( void )
 int serial_getc( void )
 {
 	while( serial_tstc() == 0 )
-		;
+		WATCHDOG_RESET ();
 	return( uart->rxdata & 0x00ff );
 }
diff -purN -x CVS u-boot-20040210cvs-prepare_post/include/watchdog.h u-boot-20040210cvs-prepare_watchdog/include/watchdog.h
--- u-boot-20040210cvs-prepare_post/include/watchdog.h	2003-08-29 10:05:54.000000000 +0000
+++ u-boot-20040210cvs-prepare_watchdog/include/watchdog.h	2004-02-16 23:42:15.000000000 +0000
@@ -31,6 +31,10 @@
 #  error "Configuration error: CONFIG_HW_WATCHDOG and CONFIG_WATCHDOG can't be used together."
 #endif
 
+#if defined(__ASSEMBLY__) && defined(__NIOS__)
+#  error "Configuration error: WATCHDOG_RESET inside assembler not supported for Nios platforms."
+#endif
+
 /*
  * Hardware watchdog
  */
diff -purN -x CVS u-boot-20040210cvs-prepare_post/lib_nios/board.c u-boot-20040210cvs-prepare_watchdog/lib_nios/board.c
--- u-boot-20040210cvs-prepare_post/lib_nios/board.c	2004-02-09 23:12:26.000000000 +0000
+++ u-boot-20040210cvs-prepare_watchdog/lib_nios/board.c	2004-02-16 23:42:15.000000000 +0000
@@ -139,13 +139,16 @@ void board_init (void)
 	bd->bi_baudrate	= CONFIG_BAUDRATE;
 
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
+		WATCHDOG_RESET ();
 		if ((*init_fnc_ptr) () != 0) {
 			hang ();
 		}
 	}
 
+	WATCHDOG_RESET ();
 	bd->bi_flashsize = flash_init();
 
+	WATCHDOG_RESET ();
 	mem_malloc_init();
 	malloc_bin_reloc();
 	env_relocate();
@@ -157,12 +160,14 @@ void board_init (void)
 		if (s) s = (*e) ? e + 1 : e;
 	}
 
+	WATCHDOG_RESET ();
 	devices_init();
 	jumptable_init();
 	console_init_r();
 	/*
 	 */
 
+	WATCHDOG_RESET ();
 	interrupt_init ();
 
 #ifdef CONFIG_STATUS_LED
diff -purN -x CVS u-boot-20040210cvs-prepare_post/lib_nios/time.c u-boot-20040210cvs-prepare_watchdog/lib_nios/time.c
--- u-boot-20040210cvs-prepare_post/lib_nios/time.c	2003-10-08 23:26:15.000000000 +0000
+++ u-boot-20040210cvs-prepare_watchdog/lib_nios/time.c	2004-02-16 23:42:15.000000000 +0000
@@ -22,6 +22,7 @@
  */
 
 #include <common.h>
+#include <watchdog.h>
 
 
 extern void dly_clks( unsigned long ticks );
@@ -33,5 +34,6 @@ void udelay(unsigned long usec)
 	 * cpu clocks.
 	 */
 	unsigned long cnt = (CONFIG_SYS_CLK_FREQ/1000000) * usec;
+	WATCHDOG_RESET ();	/* trigger watchdog if needed */
 	dly_clks (cnt);
 }
diff -purN -x CVS u-boot-20040210cvs-prepare_post/nios_config.mk u-boot-20040210cvs-prepare_watchdog/nios_config.mk
--- u-boot-20040210cvs-prepare_post/nios_config.mk	2003-10-08 23:26:14.000000000 +0000
+++ u-boot-20040210cvs-prepare_watchdog/nios_config.mk	2004-02-16 23:42:15.000000000 +0000
@@ -22,4 +22,4 @@
 # MA 02111-1307 USA
 #
 
-PLATFORM_CPPFLAGS += -m32 -DCONFIG_NIOS -ffixed-g7
+PLATFORM_CPPFLAGS += -m32 -DCONFIG_NIOS -D__NIOS__ -ffixed-g7
-------------- next part --------------
* Patch by Stephan Linz, 16 Feb 2004
  - prepare WATCHDOG framework support for NIOS targets;
    (add WATCHDOG_RESET() macros)

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

* [U-Boot-Users] Re: [PATCH] Nios: WATCHDOG preparation
  2004-02-17 17:34     ` [U-Boot-Users] " Stephan Linz
@ 2004-02-23 23:19       ` Wolfgang Denk
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Denk @ 2004-02-23 23:19 UTC (permalink / raw)
  To: u-boot

In message <0402171834420D.00467@pcj86> you wrote:
> 
> > > This should never be  necessary.  The  udelay()  function  itself  is
> > > expected to trigger the waitchdog as necessary.
...
> OK, here is the correct patch. Sorry for the delay :-)

Added.

> Note: In my opinion this is the first stage. In second stage we should move 
> the WATCHDOG_RESET macro from within udelay() C function into the underlayed 
> assembly function dly_clks(). I've tried it out but without success, so I try 
> again.

Umm... I think we can keep this in udelay().

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
If there are self-made purgatories, then we all have to live in them.
	-- Spock, "This Side of Paradise", stardate 3417.7

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

end of thread, other threads:[~2004-02-23 23:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-16  9:09 [U-Boot-Users] [PATCH] Nios: WATCHDOG preparation Stephan Linz
2004-02-16  9:30 ` [U-Boot-Users] " Wolfgang Denk
2004-02-16 10:07   ` Stephan Linz
2004-02-17 17:34     ` [U-Boot-Users] " Stephan Linz
2004-02-23 23:19       ` [U-Boot-Users] " Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox