Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Minkyu Kang | 047ece7 | 2012-01-18 15:55:05 +0900 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2012 Samsung Electronics |
| 4 | * Minkyu Kang <mk7.kang@samsung.com> |
Minkyu Kang | 047ece7 | 2012-01-18 15:55:05 +0900 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <asm/io.h> |
| 9 | #include <asm/arch/watchdog.h> |
| 10 | |
| 11 | #define PRESCALER_VAL 255 |
| 12 | |
| 13 | void wdt_stop(void) |
| 14 | { |
| 15 | struct s5p_watchdog *wdt = |
| 16 | (struct s5p_watchdog *)samsung_get_base_watchdog(); |
| 17 | unsigned int wtcon; |
| 18 | |
| 19 | wtcon = readl(&wdt->wtcon); |
| 20 | wtcon &= ~(WTCON_EN | WTCON_INT | WTCON_RESET); |
| 21 | |
| 22 | writel(wtcon, &wdt->wtcon); |
| 23 | } |
| 24 | |
| 25 | void wdt_start(unsigned int timeout) |
| 26 | { |
| 27 | struct s5p_watchdog *wdt = |
| 28 | (struct s5p_watchdog *)samsung_get_base_watchdog(); |
| 29 | unsigned int wtcon; |
| 30 | |
| 31 | wdt_stop(); |
| 32 | |
| 33 | wtcon = readl(&wdt->wtcon); |
| 34 | wtcon |= (WTCON_EN | WTCON_CLK(WTCON_CLK_128)); |
| 35 | wtcon &= ~WTCON_INT; |
| 36 | wtcon |= WTCON_RESET; |
| 37 | wtcon |= WTCON_PRESCALER(PRESCALER_VAL); |
| 38 | |
| 39 | writel(timeout, &wdt->wtdat); |
| 40 | writel(timeout, &wdt->wtcnt); |
| 41 | writel(wtcon, &wdt->wtcon); |
| 42 | } |