diff mbox

[U-Boot,v3,04/10] sunxi: Implement reset_cpu

Message ID 1402306622-18485-5-git-send-email-hdegoede@redhat.com
State Accepted
Delegated to: Ian Campbell
Headers show

Commit Message

Hans de Goede June 9, 2014, 9:36 a.m. UTC
There is no way to reset the cpu, so use the watchdog for this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
---
 arch/arm/cpu/armv7/sunxi/board.c        | 7 +++++++
 arch/arm/include/asm/arch-sunxi/timer.h | 5 +++++
 2 files changed, 12 insertions(+)

Comments

Siarhei Siamashka July 23, 2014, 5:45 p.m. UTC | #1
On Mon,  9 Jun 2014 11:36:56 +0200
Hans de Goede <hdegoede@redhat.com> wrote:

> There is no way to reset the cpu, so use the watchdog for this.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Acked-by: Ian Campbell <ijc@hellion.org.uk>

Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>

However shouldn't this be squashed with
   http://patchwork.ozlabs.org/patch/359692/ ?

Otherwise there is a range of commits, where reset is
broken on sun5i hardware in the middle of the patch set.
Hans de Goede July 26, 2014, 1:09 p.m. UTC | #2
Hi,

On 07/23/2014 07:45 PM, Siarhei Siamashka wrote:
> On Mon,  9 Jun 2014 11:36:56 +0200
> Hans de Goede <hdegoede@redhat.com> wrote:
>
>> There is no way to reset the cpu, so use the watchdog for this.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> Acked-by: Ian Campbell <ijc@hellion.org.uk>
>
> Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
>
> However shouldn't this be squashed with
>     http://patchwork.ozlabs.org/patch/359692/ ?

Good point, unfortunately the pull-req has already gone out.

> Otherwise there is a range of commits, where reset is
> broken on sun5i hardware in the middle of the patch set.

True, but what are the chances people will be testing reset
in a bisect? Other then for a bisect this should not be an
issue as this is all part of a single pull-req.

Regards,

Hans
diff mbox

Patch

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..58e14fd 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>