blob: 8e3e51b7a92356b8be6e039bb4e50cf481a03c38 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2019 Oleksij Rempel <o.rempel@pengutronix.de>, Pengutronix
*/
#include <common.h>
#include <init.h>
#include <driver.h>
#include <efi.h>
#include <efi/efi.h>
#include <watchdog.h>
struct efi_wdt_priv {
struct watchdog wd;
struct device_d *dev;
};
#define to_efi_wdt(h) container_of(h, struct efi_wdt_priv, wd)
static int efi_wdt_set_timeout(struct watchdog *wd, unsigned timeout)
{
struct efi_wdt_priv *priv = to_efi_wdt(wd);
efi_status_t efiret;
efiret = BS->set_watchdog_timer(timeout, 0, 0, NULL);
if (EFI_ERROR(efiret)) {
dev_err(priv->dev, "filed to set EFI watchdog: %lx\n", efiret);
return -EINVAL;
}
return 0;
}
static int efi_wdt_probe(struct device_d *dev)
{
struct efi_wdt_priv *priv;
int ret;
priv = xzalloc(sizeof(*priv));
priv->wd.set_timeout = efi_wdt_set_timeout;
priv->wd.hwdev = dev;
priv->dev = dev;
dev->priv = priv;
priv->wd.timeout_max = U32_MAX;
ret = watchdog_register(&priv->wd);
if (ret)
goto on_error;
return 0;
on_error:
free(priv);
return ret;
}
static struct driver_d efi_wdt_driver = {
.name = "efi-wdt",
.probe = efi_wdt_probe,
};
device_platform_driver(efi_wdt_driver);
|