blob: c244f15a8952ec0c6ac19d043ee17ef0dc8974ec [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
Minkyu Kang047ece72012-01-18 15:55:05 +09007#include <asm/io.h>
Sam Protsenkoa7532292023-10-20 16:46:33 -05008#include <asm/arch/cpu.h>
Minkyu Kang047ece72012-01-18 15:55:05 +09009#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}