mmc: fsl_esdhc: workaround for hardware 3.3v IO reliability issue
[oweals/u-boot.git] / drivers / reset / reset-socfpga.c
index ee4cbcb02ff9ccbcafe6071fa4a3508aad061f5c..830eda9430ecf8718c1cfee768e44a8f32638a24 100644 (file)
 
 #include <common.h>
 #include <dm.h>
+#include <log.h>
+#include <malloc.h>
+#include <dm/lists.h>
 #include <dm/of_access.h>
+#include <env.h>
 #include <reset-uclass.h>
+#include <wait_bit.h>
 #include <linux/bitops.h>
 #include <linux/io.h>
 #include <linux/sizes.h>
@@ -78,7 +83,10 @@ static int socfpga_reset_deassert(struct reset_ctl *reset_ctl)
        int offset = id % (reg_width * BITS_PER_BYTE);
 
        clrbits_le32(data->modrst_base + (bank * BANK_INCREMENT), BIT(offset));
-       return 0;
+
+       return wait_for_bit_le32(data->modrst_base + (bank * BANK_INCREMENT),
+                                BIT(offset),
+                                false, 500, false);
 }
 
 static int socfpga_reset_request(struct reset_ctl *reset_ctl)
@@ -99,7 +107,7 @@ static int socfpga_reset_free(struct reset_ctl *reset_ctl)
 
 static const struct reset_ops socfpga_reset_ops = {
        .request = socfpga_reset_request,
-       .free = socfpga_reset_free,
+       .rfree = socfpga_reset_free,
        .rst_assert = socfpga_reset_assert,
        .rst_deassert = socfpga_reset_deassert,
 };
@@ -130,6 +138,23 @@ static int socfpga_reset_remove(struct udevice *dev)
        return 0;
 }
 
+static int socfpga_reset_bind(struct udevice *dev)
+{
+       int ret;
+       struct udevice *sys_child;
+
+       /*
+        * The sysreset driver does not have a device node, so bind it here.
+        * Bind it to the node, too, so that it can get its base address.
+        */
+       ret = device_bind_driver_to_node(dev, "socfpga_sysreset", "sysreset",
+                                        dev->node, &sys_child);
+       if (ret)
+               debug("Warning: No sysreset driver: ret=%d\n", ret);
+
+       return 0;
+}
+
 static const struct udevice_id socfpga_reset_match[] = {
        { .compatible = "altr,rst-mgr" },
        { /* sentinel */ },
@@ -139,6 +164,7 @@ U_BOOT_DRIVER(socfpga_reset) = {
        .name = "socfpga-reset",
        .id = UCLASS_RESET,
        .of_match = socfpga_reset_match,
+       .bind = socfpga_reset_bind,
        .probe = socfpga_reset_probe,
        .priv_auto_alloc_size = sizeof(struct socfpga_reset_data),
        .ops = &socfpga_reset_ops,