Merge branch 'master' of git://git.denx.de/u-boot-socfpga
[oweals/u-boot.git] / drivers / watchdog / wdt-uclass.c
index bb9ae808666f577bef796ab277f1ea8a8e20d6e8..23b7e3360d32fa0cd896b98583aeb5f514db79b9 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2017 Google, Inc
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 
-DECLARE_GLOBAL_DATA_PTR;
-
-int wdt_start(struct udevice *dev, u64 timeout, ulong flags)
+int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
 {
        const struct wdt_ops *ops = device_get_ops(dev);
 
        if (!ops->start)
                return -ENOSYS;
 
-       return ops->start(dev, timeout, flags);
+       return ops->start(dev, timeout_ms, flags);
 }
 
 int wdt_stop(struct udevice *dev)
@@ -66,7 +63,31 @@ int wdt_expire_now(struct udevice *dev, ulong flags)
        return ret;
 }
 
+static int wdt_post_bind(struct udevice *dev)
+{
+#if defined(CONFIG_NEEDS_MANUAL_RELOC)
+       struct wdt_ops *ops = (struct wdt_ops *)device_get_ops(dev);
+       static int reloc_done;
+
+       if (!reloc_done) {
+               if (ops->start)
+                       ops->start += gd->reloc_off;
+               if (ops->stop)
+                       ops->stop += gd->reloc_off;
+               if (ops->reset)
+                       ops->reset += gd->reloc_off;
+               if (ops->expire_now)
+                       ops->expire_now += gd->reloc_off;
+
+               reloc_done++;
+       }
+#endif
+       return 0;
+}
+
 UCLASS_DRIVER(wdt) = {
        .id             = UCLASS_WDT,
-       .name           = "wdt",
+       .name           = "watchdog",
+       .flags          = DM_UC_FLAG_SEQ_ALIAS,
+       .post_bind      = wdt_post_bind,
 };