Skip to content

Commit

Permalink
sunxi: Cleanup the reset code and add meaningful registers defines
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
  • Loading branch information
Maxime Ripard authored and Olof Johansson committed Feb 5, 2013
1 parent b28eaac commit b60deca
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions arch/arm/mach-sunxi/sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
#include "sunxi.h"

#define WATCHDOG_CTRL_REG 0x00
#define WATCHDOG_CTRL_RESTART (1 << 0)
#define WATCHDOG_MODE_REG 0x04
#define WATCHDOG_MODE_ENABLE (1 << 0)
#define WATCHDOG_MODE_RESET_ENABLE (1 << 1)

static void __iomem *wdt_base;

Expand All @@ -48,11 +51,19 @@ static void sunxi_restart(char mode, const char *cmd)
return;

/* Enable timer and set reset bit in the watchdog */
writel(3, wdt_base + WATCHDOG_MODE_REG);
writel(0xa57 << 1 | 1, wdt_base + WATCHDOG_CTRL_REG);
while(1) {
writel(WATCHDOG_MODE_ENABLE | WATCHDOG_MODE_RESET_ENABLE,
wdt_base + WATCHDOG_MODE_REG);

/*
* Restart the watchdog. The default (and lowest) interval
* value for the watchdog is 0.5s.
*/
writel(WATCHDOG_CTRL_RESTART, wdt_base + WATCHDOG_CTRL_REG);

while (1) {
mdelay(5);
writel(3, wdt_base + WATCHDOG_MODE_REG);
writel(WATCHDOG_MODE_ENABLE | WATCHDOG_MODE_RESET_ENABLE,
wdt_base + WATCHDOG_MODE_REG);
}
}

Expand Down

0 comments on commit b60deca

Please sign in to comment.