blob: 5ad7d2609f041610c04d18462e3a2f98ba5681c7 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Minkyu Kang047ece72012-01-18 15:55:05 +09002/*
3 * Copyright (C) 2012 Samsung Electronics
4 * Minkyu Kang <mk7.kang@samsung.com>
Minkyu Kang047ece72012-01-18 15:55:05 +09005 */
6
7#include <common.h>
8#include <asm/io.h>
9#include <asm/arch/watchdog.h>
10
11#define PRESCALER_VAL 255
12
13void 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
25void 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}