2 * Watchdog driver for the FTWDT010 Watch Dog Driver
4 * (c) Copyright 2004 Faraday Technology Corp. (www.faraday-tech.com)
5 * Based on sa1100_wdt.c by Oleg Drokin <green@crimea.edu>
6 * Based on SoftDog driver by Alan Cox <alan@redhat.com>
8 * Copyright (C) 2011 Andes Technology Corporation
9 * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * 27/11/2004 Initial release, Faraday.
26 * 12/01/2011 Port to u-boot, Macpaul Lin.
32 #include <faraday/ftwdt010_wdt.h>
35 * Set the watchdog time interval.
38 int ftwdt010_wdt_settimeout(unsigned int timeout)
42 struct ftwdt010_wdt *wd = (struct ftwdt010_wdt *)CONFIG_FTWDT010_BASE;
44 debug("Activating WDT..\n");
46 /* Check if disabled */
47 if (readl(&wd->wdcr) & ~FTWDT010_WDCR_ENABLE) {
48 printf("sorry, watchdog is disabled\n");
54 * if you set WDLOAD as 0x03EF1480 (66000000)
55 * the reset timer is 1 second.
57 reg = FTWDT010_WDLOAD(timeout * FTWDT010_TIMEOUT_FACTOR);
59 writel(reg, &wd->wdload);
64 void ftwdt010_wdt_reset(void)
66 struct ftwdt010_wdt *wd = (struct ftwdt010_wdt *)CONFIG_FTWDT010_BASE;
68 /* clear control register */
71 /* Write Magic number */
72 writel(FTWDT010_WDRESTART_MAGIC, &wd->wdrestart);
75 writel((FTWDT010_WDCR_RST | FTWDT010_WDCR_ENABLE), &wd->wdcr);
78 void ftwdt010_wdt_disable(void)
80 struct ftwdt010_wdt *wd = (struct ftwdt010_wdt *)CONFIG_FTWDT010_BASE;
82 debug("Deactivating WDT..\n");
85 * It was defined with CONFIG_WATCHDOG_NOWAYOUT in Linux
88 * Lock it in if it's a module and we defined ...NOWAYOUT
93 #if defined(CONFIG_HW_WATCHDOG)
94 void hw_watchdog_reset(void)
99 void hw_watchdog_init(void)
101 /* set timer in ms */
102 ftwdt010_wdt_settimeout(CONFIG_FTWDT010_HW_TIMEOUT * 1000);