]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
usb: dwc3: Use the devm_gpiod_get_optional() API for reset gpio
authorVenkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>
Fri, 13 Jan 2023 05:12:02 +0000 (10:42 +0530)
committerMarek Vasut <marex@denx.de>
Tue, 21 Feb 2023 23:28:05 +0000 (00:28 +0100)
As the "reset-gpios" property is optional, don't return the
error and just skip the gpio reset sequence.

Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>
drivers/usb/dwc3/dwc3-generic.c

index 78966718d01d1e5053179a8c34dea8c88742ceda..ed1b9b630eba0a436f34c0f4dc014c817237dd36 100644 (file)
@@ -44,7 +44,7 @@ struct dwc3_generic_priv {
        void *base;
        struct dwc3 dwc3;
        struct phy_bulk phys;
-       struct gpio_desc ulpi_reset;
+       struct gpio_desc *ulpi_reset;
 };
 
 struct dwc3_generic_host_priv {
@@ -91,23 +91,23 @@ static int dwc3_generic_probe(struct udevice *dev,
 
        if (CONFIG_IS_ENABLED(DM_GPIO) &&
            device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3")) {
-               rc = gpio_request_by_name(dev->parent, "reset-gpios", 0,
-                                         &priv->ulpi_reset, GPIOD_ACTIVE_LOW);
-               if (rc)
-                       return rc;
-
-               /* Toggle ulpi to reset the phy. */
-               rc = dm_gpio_set_value(&priv->ulpi_reset, 1);
-               if (rc)
-                       return rc;
-
-               mdelay(5);
-
-               rc = dm_gpio_set_value(&priv->ulpi_reset, 0);
-               if (rc)
-                       return rc;
-
-               mdelay(5);
+               priv->ulpi_reset = devm_gpiod_get_optional(dev->parent, "reset",
+                                                               GPIOD_ACTIVE_LOW);
+               /* property is optional, don't return error! */
+               if (priv->ulpi_reset) {
+                       /* Toggle ulpi to reset the phy. */
+                       rc = dm_gpio_set_value(priv->ulpi_reset, 1);
+                       if (rc)
+                               return rc;
+
+                       mdelay(5);
+
+                       rc = dm_gpio_set_value(priv->ulpi_reset, 0);
+                       if (rc)
+                               return rc;
+
+                       mdelay(5);
+               }
        }
 
        if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3"))
@@ -133,7 +133,7 @@ static int dwc3_generic_remove(struct udevice *dev,
 
        if (CONFIG_IS_ENABLED(DM_GPIO) &&
            device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3")) {
-               struct gpio_desc *ulpi_reset = &priv->ulpi_reset;
+               struct gpio_desc *ulpi_reset = priv->ulpi_reset;
 
                dm_gpio_free(ulpi_reset->dev, ulpi_reset);
        }