Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 1 | /* |
| 2 | * watchdog.c - driver for Blackfin on-chip watchdog |
| 3 | * |
Mike Frysinger | 313e8aa | 2009-11-12 18:42:07 -0500 | [diff] [blame] | 4 | * Copyright (c) 2007-2009 Analog Devices Inc. |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 5 | * |
| 6 | * Licensed under the GPL-2 or later. |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <watchdog.h> |
| 11 | #include <asm/blackfin.h> |
Vasili Galka | 0519e80 | 2014-06-30 12:59:56 +0300 | [diff] [blame^] | 12 | #include <asm/clock.h> |
Sonic Zhang | e9a389a | 2013-04-07 18:02:37 +0800 | [diff] [blame] | 13 | #include <asm/mach-common/bits/watchdog.h> |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 14 | |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 15 | void hw_watchdog_reset(void) |
| 16 | { |
| 17 | bfin_write_WDOG_STAT(0); |
| 18 | } |
| 19 | |
| 20 | void hw_watchdog_init(void) |
| 21 | { |
Sonic Zhang | e9a389a | 2013-04-07 18:02:37 +0800 | [diff] [blame] | 22 | bfin_write_WDOG_CTL(WDDIS); |
| 23 | SSYNC(); |
| 24 | bfin_write_WDOG_CNT(CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000 * get_sclk()); |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 25 | hw_watchdog_reset(); |
Sonic Zhang | e9a389a | 2013-04-07 18:02:37 +0800 | [diff] [blame] | 26 | bfin_write_WDOG_CTL(WDEN); |
Mike Frysinger | 9171fc8 | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 27 | } |