|
@@ -5,20 +5,22 @@
|
|
|
|
|
|
#include <common.h>
|
|
|
#include <dm.h>
|
|
|
+#include <dm/device-internal.h>
|
|
|
#include <errno.h>
|
|
|
+#include <malloc.h>
|
|
|
#include <sysreset.h>
|
|
|
#include <wdt.h>
|
|
|
|
|
|
-struct wdt_reboot_priv {
|
|
|
+struct wdt_reboot_plat {
|
|
|
struct udevice *wdt;
|
|
|
};
|
|
|
|
|
|
static int wdt_reboot_request(struct udevice *dev, enum sysreset_t type)
|
|
|
{
|
|
|
- struct wdt_reboot_priv *priv = dev_get_priv(dev);
|
|
|
+ struct wdt_reboot_plat *plat = dev_get_plat(dev);
|
|
|
int ret;
|
|
|
|
|
|
- ret = wdt_expire_now(priv->wdt, 0);
|
|
|
+ ret = wdt_expire_now(plat->wdt, 0);
|
|
|
if (ret)
|
|
|
return ret;
|
|
|
|
|
@@ -29,13 +31,13 @@ static struct sysreset_ops wdt_reboot_ops = {
|
|
|
.request = wdt_reboot_request,
|
|
|
};
|
|
|
|
|
|
-int wdt_reboot_probe(struct udevice *dev)
|
|
|
+static int wdt_reboot_of_to_plat(struct udevice *dev)
|
|
|
{
|
|
|
- struct wdt_reboot_priv *priv = dev_get_priv(dev);
|
|
|
+ struct wdt_reboot_plat *plat = dev_get_plat(dev);
|
|
|
int err;
|
|
|
|
|
|
err = uclass_get_device_by_phandle(UCLASS_WDT, dev,
|
|
|
- "wdt", &priv->wdt);
|
|
|
+ "wdt", &plat->wdt);
|
|
|
if (err) {
|
|
|
pr_err("unable to find wdt device\n");
|
|
|
return err;
|
|
@@ -53,7 +55,29 @@ U_BOOT_DRIVER(wdt_reboot) = {
|
|
|
.name = "wdt_reboot",
|
|
|
.id = UCLASS_SYSRESET,
|
|
|
.of_match = wdt_reboot_ids,
|
|
|
+ .of_to_plat = wdt_reboot_of_to_plat,
|
|
|
+ .plat_auto = sizeof(struct wdt_reboot_plat),
|
|
|
.ops = &wdt_reboot_ops,
|
|
|
- .priv_auto = sizeof(struct wdt_reboot_priv),
|
|
|
- .probe = wdt_reboot_probe,
|
|
|
};
|
|
|
+
|
|
|
+#if IS_ENABLED(CONFIG_SYSRESET_WATCHDOG_AUTO)
|
|
|
+int sysreset_register_wdt(struct udevice *dev)
|
|
|
+{
|
|
|
+ struct wdt_reboot_plat *plat = malloc(sizeof(*plat));
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ if (!plat)
|
|
|
+ return -ENOMEM;
|
|
|
+
|
|
|
+ plat->wdt = dev;
|
|
|
+
|
|
|
+ ret = device_bind(dev, DM_DRIVER_GET(wdt_reboot),
|
|
|
+ dev->name, plat, ofnode_null(), NULL);
|
|
|
+ if (ret) {
|
|
|
+ free(plat);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+#endif
|