]> git.ipfire.org Git - thirdparty/u-boot.git/blame - drivers/watchdog/s5p_wdt.c
arm: fsl-layerscape: add 0x3040 serdes1 settings for LS1046A
[thirdparty/u-boot.git] / drivers / watchdog / s5p_wdt.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
851db35e
MK
2/*
3 * Copyright (C) 2012 Samsung Electronics
4 * Minkyu Kang <mk7.kang@samsung.com>
851db35e
MK
5 */
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}