
24 Mar
2014
24 Mar
'14
12:53 a.m.
sön 2014-03-16 klockan 14:53 +0100 skrev Hans de Goede:
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);
This code is incomplete and do not reload the watchdog if already running. wdog->ctl is locked by a magic key. Should use
writel(WDT_CTRL_KEY | WDT_CTRL_RESTART, &wdog->ctl);
where
#define WDT_CTRL_KEY (0x0a57 << 1)
Unfortunatley Allwinner kindly omitted this little detail from the User Manual.
Found out while trying to use the watchdog as a watchdog and not only reset. Asked Tom while he still was at Allwinner and got clarification on how to use the watchdog control register.
Regards Henrik