1 // SPDX-License-Identifier: GPL-2.0+
3 * Watchdog driver for the FTWDT010 Watch Dog Driver
5 * (c) Copyright 2004 Faraday Technology Corp. (www.faraday-tech.com)
6 * Based on sa1100_wdt.c by Oleg Drokin <green@crimea.edu>
7 * Based on SoftDog driver by Alan Cox <alan@redhat.com>
9 * Copyright (C) 2011 Andes Technology Corporation
10 * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
12 * 27/11/2004 Initial release, Faraday.
13 * 12/01/2011 Port to u-boot, Macpaul Lin.
19 #include <faraday/ftwdt010_wdt.h>
22 * Set the watchdog time interval.
25 int ftwdt010_wdt_settimeout(unsigned int timeout)
29 struct ftwdt010_wdt *wd = (struct ftwdt010_wdt *)CONFIG_FTWDT010_BASE;
31 debug("Activating WDT..\n");
33 /* Check if disabled */
34 if (readl(&wd->wdcr) & ~FTWDT010_WDCR_ENABLE) {
35 printf("sorry, watchdog is disabled\n");
41 * if you set WDLOAD as 0x03EF1480 (66000000)
42 * the reset timer is 1 second.
44 reg = FTWDT010_WDLOAD(timeout * FTWDT010_TIMEOUT_FACTOR);
46 writel(reg, &wd->wdload);
51 void ftwdt010_wdt_reset(void)
53 struct ftwdt010_wdt *wd = (struct ftwdt010_wdt *)CONFIG_FTWDT010_BASE;
55 /* clear control register */
58 /* Write Magic number */
59 writel(FTWDT010_WDRESTART_MAGIC, &wd->wdrestart);
62 writel((FTWDT010_WDCR_RST | FTWDT010_WDCR_ENABLE), &wd->wdcr);
65 void ftwdt010_wdt_disable(void)
67 struct ftwdt010_wdt *wd = (struct ftwdt010_wdt *)CONFIG_FTWDT010_BASE;
69 debug("Deactivating WDT..\n");
72 * It was defined with CONFIG_WATCHDOG_NOWAYOUT in Linux
75 * Lock it in if it's a module and we defined ...NOWAYOUT
80 #if defined(CONFIG_HW_WATCHDOG)
81 void hw_watchdog_reset(void)
86 void hw_watchdog_init(void)
89 ftwdt010_wdt_settimeout(CONFIG_FTWDT010_HW_TIMEOUT * 1000);