#include <debug.h>
#include <io.h>
#include <util.h>
#include <watchdog.h>
#include <chip/clk.h>

Go to the source code of this file.
Defines | |
| #define | WDT_CTRL 0x00 |
| Control Register. | |
| #define | WDT_CTRL_KEY1 (0x55 << 24) |
| 1st write key | |
| #define | WDT_CTRL_KEY2 (0xaa << 24) |
| 2nd write key | |
| #define | WDT_CTRL_PSEL(x) ((x) << 8) |
| Prescale Select. | |
| #define | WDT_CTRL_EN (1 << 0) |
| WDT Enable. | |
| #define | WDT_CLR 0x04 |
| Clear Register. | |
| #define | wdt_read_reg(reg) mmio_read32((void *)(WDT_BASE + WDT_##reg)) |
| Return the value of WDT register reg. | |
| #define | wdt_write_reg(reg, val) mmio_write32((void *)(WDT_BASE + WDT_##reg), val) |
| Write the value val to WDT register reg. | |
Functions | |
| void | watchdog_set_timeout (unsigned long timeout_ms) |
| Initialize the watchdog. | |
| void | watchdog_enable (void) |
| Enable the watchdog. | |
| void | watchdog_disable (void) |
| Enable the watchdog. | |
| void | watchdog_reset (void) |
| Reset the watchdog. | |
Definition in file wdt.c.
| #define WDT_CTRL_EN (1 << 0) |
WDT Enable.
Definition at line 51 of file wdt.c.
Referenced by watchdog_disable(), and watchdog_enable().
| #define WDT_CTRL_KEY1 (0x55 << 24) |
1st write key
Definition at line 48 of file wdt.c.
Referenced by watchdog_disable(), watchdog_enable(), and watchdog_set_timeout().
| #define WDT_CTRL_KEY2 (0xaa << 24) |
2nd write key
Definition at line 49 of file wdt.c.
Referenced by watchdog_disable(), watchdog_enable(), and watchdog_set_timeout().
| #define WDT_CTRL_PSEL | ( | x | ) | ((x) << 8) |
| #define wdt_read_reg | ( | reg | ) | mmio_read32((void *)(WDT_BASE + WDT_##reg)) |
Return the value of WDT register reg.
For internal use only.
Definition at line 58 of file wdt.c.
Referenced by watchdog_disable(), and watchdog_enable().
| #define wdt_write_reg | ( | reg, | |||
| val | ) | mmio_write32((void *)(WDT_BASE + WDT_##reg), val) |
Write the value val to WDT register reg.
For internal use only.
Definition at line 65 of file wdt.c.
Referenced by watchdog_disable(), watchdog_enable(), watchdog_reset(), and watchdog_set_timeout().
| void watchdog_disable | ( | void | ) |
Enable the watchdog.
After calling this function, the watchdog will stop counting and will not reset the chip even if watchdog_reset() isn't called regularly.
Definition at line 115 of file wdt.c.
References WDT_CTRL_EN, WDT_CTRL_KEY1, WDT_CTRL_KEY2, wdt_read_reg, and wdt_write_reg.
| void watchdog_enable | ( | void | ) |
Enable the watchdog.
After calling this function, the watchdog will be counting and the chip will be reset if watchdog_reset() isn't called regularly before the timeout expires.
Definition at line 100 of file wdt.c.
References WDT_CTRL_EN, WDT_CTRL_KEY1, WDT_CTRL_KEY2, wdt_read_reg, and wdt_write_reg.
| void watchdog_reset | ( | void | ) |
Reset the watchdog.
This function will reset the watchdog counter and must be called regularly while the watchdog is running. If the counter reaches the configured timeout, the chip will be reset.
Definition at line 131 of file wdt.c.
References wdt_write_reg.
| void watchdog_set_timeout | ( | unsigned long | timeout_ms | ) |
Initialize the watchdog.
| timeout_ms | The minimum timeout in milliseconds after which the watchdog will expire. |
Definition at line 77 of file wdt.c.
References dbg_info, ilog2(), WDT_CTRL_KEY1, WDT_CTRL_KEY2, WDT_CTRL_PSEL, and wdt_write_reg.

1.5.8