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> |
Sam Protsenko | a753229 | 2023-10-20 16:46:33 -0500 | [diff] [blame] | 9 | #include <asm/arch/cpu.h> |
Minkyu Kang | 047ece7 | 2012-01-18 15:55:05 +0900 | [diff] [blame] | 10 | #include <asm/arch/watchdog.h> |
| 11 | |
| 12 | #define PRESCALER_VAL 255 |
| 13 | |
| 14 | void wdt_stop(void) |
| 15 | { |
| 16 | struct s5p_watchdog *wdt = |
| 17 | (struct s5p_watchdog *)samsung_get_base_watchdog(); |
| 18 | unsigned int wtcon; |
| 19 | |
| 20 | wtcon = readl(&wdt->wtcon); |
| 21 | wtcon &= ~(WTCON_EN | WTCON_INT | WTCON_RESET); |
| 22 | |
| 23 | writel(wtcon, &wdt->wtcon); |
| 24 | } |
| 25 | |
| 26 | void wdt_start(unsigned int timeout) |
| 27 | { |
| 28 | struct s5p_watchdog *wdt = |
| 29 | (struct s5p_watchdog *)samsung_get_base_watchdog(); |
| 30 | unsigned int wtcon; |
| 31 | |
| 32 | wdt_stop(); |
| 33 | |
| 34 | wtcon = readl(&wdt->wtcon); |
| 35 | wtcon |= (WTCON_EN | WTCON_CLK(WTCON_CLK_128)); |
| 36 | wtcon &= ~WTCON_INT; |
| 37 | wtcon |= WTCON_RESET; |
| 38 | wtcon |= WTCON_PRESCALER(PRESCALER_VAL); |
| 39 | |
| 40 | writel(timeout, &wdt->wtdat); |
| 41 | writel(timeout, &wdt->wtcnt); |
| 42 | writel(wtcon, &wdt->wtcon); |
| 43 | } |