blob: e8f5b5c3f9d39be18ec351468cae2b6224f25b1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Watchdog driver */
#include "common.h"
#include "hooks.h"
#include "registers.h"
#include "scp_watchdog.h"
#include "watchdog.h"
void watchdog_reload(void)
{
SCP_CORE0_WDT_KICK = BIT(0);
}
DECLARE_HOOK(HOOK_TICK, watchdog_reload, HOOK_PRIO_DEFAULT);
void watchdog_disable(void)
{
/* disable watchdog */
SCP_CORE0_WDT_CFG &= ~WDT_EN;
/* clear watchdog irq */
SCP_CORE0_WDT_IRQ |= BIT(0);
}
void watchdog_enable(void)
{
const uint32_t timeout = WDT_PERIOD(CONFIG_WATCHDOG_PERIOD_MS);
/* disable watchdog */
SCP_CORE0_WDT_CFG &= ~WDT_EN;
/* clear watchdog irq */
SCP_CORE0_WDT_IRQ |= BIT(0);
/* enable watchdog */
SCP_CORE0_WDT_CFG = WDT_EN | timeout;
/* reload watchdog */
watchdog_reload();
}
int watchdog_init(void)
{
watchdog_enable();
return EC_SUCCESS;
}
|