Bind the USB VBUS regulator driver under the USB PHY reset driver for
the Renesas RZ/G2L and related SoCs. This additional bind is needed as
the corresponding device tree node does not contain a compatible string.

Signed-off-by: Paul Barker <paul.barker...@bp.renesas.com>
---
 drivers/reset/Kconfig                   |  1 +
 drivers/reset/reset-rzg2l-usbphy-ctrl.c | 28 +++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index 80e83a40bdff..5edbb3c25b41 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -239,6 +239,7 @@ config RESET_AT91
 config RESET_RZG2L_USBPHY_CTRL
        bool "Enable support for Renesas RZ/G2L USB 2.0 PHY control"
        depends on DM_RESET
+       select REGULATOR_RZG2L_USBPHY
        help
          Enable support for controlling USB 2.0 PHY resets on the Renesas
          RZ/G2L SoC. This is required for USB 2.0 functionality to work on this
diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c 
b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
index b1492631b97c..d0c97ffffcd2 100644
--- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
+++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
@@ -107,10 +107,38 @@ static const struct udevice_id rzg2l_usbphy_ctrl_ids[] = {
        { /* sentinel */ }
 };
 
+static int rzg2l_usbphy_ctrl_bind(struct udevice *dev)
+{
+       struct driver *drv;
+       ofnode node;
+       int ret;
+
+       node = ofnode_find_subnode(dev_ofnode(dev), "regulator-vbus");
+       if (!ofnode_valid(node)) {
+               dev_err(dev, "Failed to find vbus regulator devicetree node\n");
+               return -ENOENT;
+       }
+
+       drv = lists_driver_lookup_name("rzg2l_usbphy_regulator");
+       if (!drv) {
+               dev_err(dev, "Failed to find vbus regulator driver\n");
+               return -ENOENT;
+       }
+
+       ret = device_bind(dev, drv, dev->name, NULL, node, NULL);
+       if (ret) {
+               dev_err(dev, "Failed to bind vbus regulator: %d\n", ret);
+               return ret;
+       }
+
+       return 0;
+}
+
 U_BOOT_DRIVER(rzg2l_usbphy_ctrl) = {
        .name           = "rzg2l_usbphy_ctrl",
        .id             = UCLASS_RESET,
        .of_match       = rzg2l_usbphy_ctrl_ids,
+       .bind           = rzg2l_usbphy_ctrl_bind,
        .probe          = rzg2l_usbphy_ctrl_probe,
        .ops            = &rzg2l_usbphy_ctrl_ops,
        .priv_auto      = sizeof(struct rzg2l_usbphy_ctrl_priv),
-- 
2.43.0

Reply via email to