-
Notifications
You must be signed in to change notification settings - Fork 189
/
wdt.c
44 lines (33 loc) · 834 Bytes
/
wdt.c
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
/* SPDX-License-Identifier: MIT */
#include "wdt.h"
#include "adt.h"
#include "types.h"
#include "utils.h"
#define WDT_COUNT 0x10
#define WDT_ALARM 0x14
#define WDT_CTL 0x1c
static u64 wdt_base = 0;
void wdt_disable(void)
{
int path[8];
int node = adt_path_offset_trace(adt, "/arm-io/wdt", path);
if (node < 0) {
printf("WDT node not found!\n");
return;
}
if (adt_get_reg(adt, path, "reg", 0, &wdt_base, NULL)) {
printf("Failed to get WDT reg property!\n");
return;
}
printf("WDT registers @ 0x%lx\n", wdt_base);
write32(wdt_base + WDT_CTL, 0);
printf("WDT disabled\n");
}
void wdt_reboot(void)
{
if (!wdt_base)
return;
write32(wdt_base + WDT_ALARM, 0x100000);
write32(wdt_base + WDT_COUNT, 0);
write32(wdt_base + WDT_CTL, 4);
}