[U-Boot] [PATCH 04/12] sunxi: Implement reset_cpu

2014-05-30 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 | 5 +
 2 files changed, 12 insertions(+)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index 49c9448..c80b421 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -56,6 +56,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_KEY | 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..4a43ed9 100644
--- a/arch/arm/include/asm/arch-sunxi/timer.h
+++ b/arch/arm/include/asm/arch-sunxi/timer.h
@@ -11,6 +11,11 @@
 #ifndef _SUNXI_TIMER_H_
 #define _SUNXI_TIMER_H_
 
+#define WDT_CTRL_RESTART(0x1  0)
+#define WDT_CTRL_KEY   (0x0a57  1)
+#define WDT_MODE_EN (0x1  0)
+#define WDT_MODE_RESET_EN   (0x1  1)
+
 #ifndef __ASSEMBLY__
 
 #include linux/types.h
-- 
1.9.3

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


Re: [U-Boot] [PATCH 04/12] sunxi: Implement reset_cpu

2014-05-30 Thread Ian Campbell
On Fri, 2014-05-30 at 11:06 +0200, Hans de Goede wrote:
 There is no way to reset the cpu, so use the watchdog for this.
 
 Signed-off-by: Hans de Goede hdego...@redhat.com

Acked-by: Ian Campbell i...@hellion.org.uk

One nit 
 +#define WDT_CTRL_RESTART(0x1  0)
 +#define WDT_CTRL_KEY (0x0a57  1)

Some sort of whitespace snafuu I think.

 +#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 04/12] sunxi: Implement reset_cpu

2014-05-30 Thread Hans de Goede
Hi,

On 05/30/2014 11:48 AM, Ian Campbell wrote:
 On Fri, 2014-05-30 at 11:06 +0200, Hans de Goede wrote:
 There is no way to reset the cpu, so use the watchdog for this.

 Signed-off-by: Hans de Goede hdego...@redhat.com
 
 Acked-by: Ian Campbell i...@hellion.org.uk
 
 One nit 
 +#define WDT_CTRL_RESTART(0x1  0)
 +#define WDT_CTRL_KEY(0x0a57  1)
 
 Some sort of whitespace snafuu I think.

Yeah I somehow ended up using spaces for some of the indents,
fixed in my local tree and personal git repo.

Regards,

Hans


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