summaryrefslogtreecommitdiff
path: root/board/alliedtelesis
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2019-04-11 15:58:44 +0200
committerStefan Roese <sr@denx.de>2019-04-26 09:16:32 +0200
commit06985289d452ad2423145cfed8cece61a7f8cec6 (patch)
treea07d411de6bc792c34d20abe00efb440b4b5b92c /board/alliedtelesis
parent5edb9b2d713736d82e6529ecf04d8a44227944b5 (diff)
watchdog: Implement generic watchdog_reset() version
This patch tries to implement a generic watchdog_reset() function that can be used by all boards that want to service the watchdog device in U-Boot. This watchdog servicing is enabled via CONFIG_WATCHDOG. Without this approach, new boards or platforms needed to implement a board specific version of this functionality, mostly copy'ing the same code over and over again into their board or platforms code base. With this new generic function, the scattered other functions are now removed to be replaced by the generic one. The new version also enables the configuration of the watchdog timeout via the DT "timeout-sec" property (if enabled via CONFIG_OF_CONTROL). This patch also adds a new flag to the GD flags, to flag that the watchdog is ready to use and adds the pointer to the watchdog device to the GD. This enables us to remove the global "watchdog_dev" variable, which was prone to cause problems because of its potentially very early use in watchdog_reset(), even before the BSS is cleared. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Heiko Schocher <hs@denx.de> Cc: Tom Rini <trini@konsulko.com> Cc: Michal Simek <michal.simek@xilinx.com> Cc: "Marek Behún" <marek.behun@nic.cz> Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Cc: Maxim Sloyko <maxims@google.com> Cc: Erik van Luijk <evanluijk@interact.nl> Cc: Ryder Lee <ryder.lee@mediatek.com> Cc: Weijie Gao <weijie.gao@mediatek.com> Cc: Simon Glass <sjg@chromium.org> Cc: "Álvaro Fernández Rojas" <noltari@gmail.com> Cc: Philippe Reynes <philippe.reynes@softathome.com> Cc: Christophe Leroy <christophe.leroy@c-s.fr> Reviewed-by: Michal Simek <michal.simek@xilinx.com> Tested-by: Michal Simek <michal.simek@xilinx.com> (on zcu100)
Diffstat (limited to 'board/alliedtelesis')
-rw-r--r--board/alliedtelesis/x530/x530.c36
1 files changed, 1 insertions, 35 deletions
diff --git a/board/alliedtelesis/x530/x530.c b/board/alliedtelesis/x530/x530.c
index 6934fd8017..97dbed79dd 100644
--- a/board/alliedtelesis/x530/x530.c
+++ b/board/alliedtelesis/x530/x530.c
@@ -25,10 +25,6 @@ DECLARE_GLOBAL_DATA_PTR;
#define CONFIG_NVS_LOCATION 0xf4800000
#define CONFIG_NVS_SIZE (512 << 10)
-#ifdef CONFIG_WATCHDOG
-static struct udevice *watchdog_dev;
-#endif
-
static struct serdes_map board_serdes_map[] = {
{PEX0, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0},
{DEFAULT_SERDES, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0},
@@ -80,10 +76,6 @@ struct mv_ddr_topology_map *mv_ddr_topology_map_get(void)
int board_early_init_f(void)
{
-#ifdef CONFIG_WATCHDOG
- watchdog_dev = NULL;
-#endif
-
/* Configure MPP */
writel(0x00001111, MVEBU_MPP_BASE + 0x00);
writel(0x00000000, MVEBU_MPP_BASE + 0x04);
@@ -99,13 +91,6 @@ int board_early_init_f(void)
void spl_board_init(void)
{
-#ifdef CONFIG_WATCHDOG
- int ret;
-
- ret = uclass_get_device(UCLASS_WDT, 0, &watchdog_dev);
- if (!ret)
- wdt_start(watchdog_dev, 120000, 0);
-#endif
}
int board_init(void)
@@ -128,29 +113,10 @@ int board_init(void)
void arch_preboot_os(void)
{
#ifdef CONFIG_WATCHDOG
- wdt_stop(watchdog_dev);
+ wdt_stop(gd->watchdog_dev);
#endif
}
-#ifdef CONFIG_WATCHDOG
-void watchdog_reset(void)
-{
- static ulong next_reset = 0;
- ulong now;
-
- if (!watchdog_dev)
- return;
-
- now = timer_get_us();
-
- /* Do not reset the watchdog too often */
- if (now > next_reset) {
- wdt_reset(watchdog_dev);
- next_reset = now + 1000;
- }
-}
-#endif
-
static int led_7seg_init(unsigned int segments)
{
int node;