Re: [U-Boot] [PATCH u-boot sunxi 01/12] sunxi: Implement reset_cpu

2014-03-22 Thread Hans de Goede
Hi,

On 03/18/2014 11:25 AM, Ian Campbell wrote:
 On Tue, 2014-03-18 at 00:00 +0100, Hans de Goede wrote:
 There is no way to reset the cpu, so use the watchdog for this.
 
 Did you see
 https://www.mail-archive.com/u-boot@lists.denx.de/msg134259.html ?

Ah no, but I've read it now.

I think it would be better to focus on all the other more important bits
for now, and then we can look into adding some sort of generic watchdog
support later.

In the mean time I would like to carry this patch, since having reset
work can be quite useful, and it is just 3 lines (not counting the lines
which we would still need with the generic watchdog support).

Regards,

Hans


 

 Signed-off-by: Hans de Goede hdego...@redhat.com
 ---
  arch/arm/cpu/armv7/sunxi/board.c| 7 +++
  arch/arm/include/asm/arch-sunxi/timer.h | 4 
  2 files changed, 11 insertions(+)

 diff --git a/arch/arm/cpu/armv7/sunxi/board.c 
 b/arch/arm/cpu/armv7/sunxi/board.c
 index e95f4e5..4fd5bcc 100644
 --- a/arch/arm/cpu/armv7/sunxi/board.c
 +++ b/arch/arm/cpu/armv7/sunxi/board.c
 @@ -54,6 +54,13 @@ int gpio_init(void)
  
  void reset_cpu(ulong addr)
  {
 +static const struct sunxi_wdog *wdog =
 + ((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)-wdog;
 +
 +/* Set the watchdog for its shortest interval (.5s) and wait */
 +writel(WDT_MODE_RESET_EN | WDT_MODE_EN, wdog-mode);
 +writel(WDT_CTRL_RESTART, wdog-ctl);
 +while (1);
  }
  
  /* do some early init */
 diff --git a/arch/arm/include/asm/arch-sunxi/timer.h 
 b/arch/arm/include/asm/arch-sunxi/timer.h
 index 6aacfd7..c29d3a0 100644
 --- a/arch/arm/include/asm/arch-sunxi/timer.h
 +++ b/arch/arm/include/asm/arch-sunxi/timer.h
 @@ -11,6 +11,10 @@
  #ifndef _SUNXI_TIMER_H_
  #define _SUNXI_TIMER_H_
  
 +#define WDT_CTRL_RESTART(0x1  0)
 +#define WDT_MODE_EN (0x1  0)
 +#define WDT_MODE_RESET_EN   (0x1  1)
 +
  #ifndef __ASSEMBLY__
  
  #include linux/types.h
 
 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH u-boot sunxi 01/12] sunxi: Implement reset_cpu

2014-03-22 Thread Ian Campbell
On Sat, 2014-03-22 at 17:16 +0100, Hans de Goede wrote:
 Hi,
 
 On 03/18/2014 11:25 AM, Ian Campbell wrote:
  On Tue, 2014-03-18 at 00:00 +0100, Hans de Goede wrote:
  There is no way to reset the cpu, so use the watchdog for this.
  
  Did you see
  https://www.mail-archive.com/u-boot@lists.denx.de/msg134259.html ?
 
 Ah no, but I've read it now.
 
 I think it would be better to focus on all the other more important bits
 for now, and then we can look into adding some sort of generic watchdog
 support later.

OK, I wanted to avoid divergence between the upstreaming effort at
u-boot-sunxi.git as much as possible, but in this case I think the
impact is small enough to be acceptable.

 In the mean time I would like to carry this patch, since having reset
 work can be quite useful, 

Absolutely!

(While I'm here: thanks for applying those other patches)

Ian

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH u-boot sunxi 01/12] sunxi: Implement reset_cpu

2014-03-18 Thread Ian Campbell
On Tue, 2014-03-18 at 00:00 +0100, Hans de Goede wrote:
 There is no way to reset the cpu, so use the watchdog for this.

Did you see
https://www.mail-archive.com/u-boot@lists.denx.de/msg134259.html ?

 
 Signed-off-by: Hans de Goede hdego...@redhat.com
 ---
  arch/arm/cpu/armv7/sunxi/board.c| 7 +++
  arch/arm/include/asm/arch-sunxi/timer.h | 4 
  2 files changed, 11 insertions(+)
 
 diff --git a/arch/arm/cpu/armv7/sunxi/board.c 
 b/arch/arm/cpu/armv7/sunxi/board.c
 index e95f4e5..4fd5bcc 100644
 --- a/arch/arm/cpu/armv7/sunxi/board.c
 +++ b/arch/arm/cpu/armv7/sunxi/board.c
 @@ -54,6 +54,13 @@ int gpio_init(void)
  
  void reset_cpu(ulong addr)
  {
 + static const struct sunxi_wdog *wdog =
 +  ((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)-wdog;
 +
 + /* Set the watchdog for its shortest interval (.5s) and wait */
 + writel(WDT_MODE_RESET_EN | WDT_MODE_EN, wdog-mode);
 + writel(WDT_CTRL_RESTART, wdog-ctl);
 + while (1);
  }
  
  /* do some early init */
 diff --git a/arch/arm/include/asm/arch-sunxi/timer.h 
 b/arch/arm/include/asm/arch-sunxi/timer.h
 index 6aacfd7..c29d3a0 100644
 --- a/arch/arm/include/asm/arch-sunxi/timer.h
 +++ b/arch/arm/include/asm/arch-sunxi/timer.h
 @@ -11,6 +11,10 @@
  #ifndef _SUNXI_TIMER_H_
  #define _SUNXI_TIMER_H_
  
 +#define WDT_CTRL_RESTART(0x1  0)
 +#define WDT_MODE_EN (0x1  0)
 +#define WDT_MODE_RESET_EN   (0x1  1)
 +
  #ifndef __ASSEMBLY__
  
  #include linux/types.h


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH u-boot sunxi 01/12] sunxi: Implement reset_cpu

2014-03-17 Thread Hans de Goede
There is no way to reset the cpu, so use the watchdog for this.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 arch/arm/cpu/armv7/sunxi/board.c| 7 +++
 arch/arm/include/asm/arch-sunxi/timer.h | 4 
 2 files changed, 11 insertions(+)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index e95f4e5..4fd5bcc 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -54,6 +54,13 @@ int gpio_init(void)
 
 void reset_cpu(ulong addr)
 {
+   static const struct sunxi_wdog *wdog =
+((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)-wdog;
+
+   /* Set the watchdog for its shortest interval (.5s) and wait */
+   writel(WDT_MODE_RESET_EN | WDT_MODE_EN, wdog-mode);
+   writel(WDT_CTRL_RESTART, wdog-ctl);
+   while (1);
 }
 
 /* do some early init */
diff --git a/arch/arm/include/asm/arch-sunxi/timer.h 
b/arch/arm/include/asm/arch-sunxi/timer.h
index 6aacfd7..c29d3a0 100644
--- a/arch/arm/include/asm/arch-sunxi/timer.h
+++ b/arch/arm/include/asm/arch-sunxi/timer.h
@@ -11,6 +11,10 @@
 #ifndef _SUNXI_TIMER_H_
 #define _SUNXI_TIMER_H_
 
+#define WDT_CTRL_RESTART(0x1  0)
+#define WDT_MODE_EN (0x1  0)
+#define WDT_MODE_RESET_EN   (0x1  1)
+
 #ifndef __ASSEMBLY__
 
 #include linux/types.h
-- 
1.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot