Skip to contentSkip to conversation

phy: nop-phy: Fix phy reset if no reset-gpio defined

PATCH In review Tim Harvey 2 participants 3 messages Feb 28, 2022 – Mar 1, 2022 Generic PHY framework

lore
Share & tools
lore

Tim Harvey

author
#0 lore raw

PATCH 1/1 phy: nop-phy: Fix phy reset if no reset-gpio defined

Ensure there is a valid reset-gpio defined before using it.

Fixes f9852acdce02 ("phy: nop-phy: Fix enabling reset")
Cc Adam Ford <[email protected]>
---
 drivers/phy/nop-phy.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/phy/nop-phy.c +7 -5
index e2ee6e92068e..d0904f4f075b 100644
@@ -45,11 +45,13 @@ static int nop_phy_init(struct phy *phy)
 
 #if CONFIG_IS_ENABLED(DM_GPIO)
 	/* Take phy out of reset */
-	ret = dm_gpio_set_value(&priv->reset_gpio, false);
-	if (ret) {
-		if (CONFIG_IS_ENABLED(CLK))
-			clk_disable_bulk(&priv->bulk);
-		return ret;
+	if (dm_gpio_is_valid(&priv->reset_gpio)) {
+		ret = dm_gpio_set_value(&priv->reset_gpio, false);
+		if (ret) {
+			if (CONFIG_IS_ENABLED(CLK))
+				clk_disable_bulk(&priv->bulk);
+			return ret;
+		}
 	}
 #endif
 	return 0;
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Tim Harvey

Ensure there is a valid reset-gpio defined before using it.

Fixes f9852acdce02 ("phy: nop-phy: Fix enabling reset")
Cc Adam Ford <[email protected]>
Quoted 9 lines
---
 drivers/phy/nop-phy.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/phy/nop-phy.c +0 -0
index e2ee6e92068e..d0904f4f075b 100644

drivers/phy/nop-phy.c static int nop_phy_init(struct phy *phy) · line 48

Quoted 9 lines
drivers/phy/nop-phy.c +1 -5
@@ -45,11 +45,13 @@ static int nop_phy_init(struct phy *phy)
 
 #if CONFIG_IS_ENABLED(DM_GPIO)
        /* Take phy out of reset */
-       ret = dm_gpio_set_value(&priv->reset_gpio, false);
-       if (ret) {
-               if (CONFIG_IS_ENABLED(CLK))
-                       clk_disable_bulk(&priv->bulk);
-               return ret;
+       if (dm_gpio_is_valid(&priv->reset_gpio)) {

I didn't realize this was necessary. Sorry if I broke your board. Thanks for fixing it.

adam

Quoted 12 lines
drivers/phy/nop-phy.c +6 -1
+               ret = dm_gpio_set_value(&priv->reset_gpio, false);
+               if (ret) {
+                       if (CONFIG_IS_ENABLED(CLK))
+                               clk_disable_bulk(&priv->bulk);
+                       return ret;
+               }
        }
 #endif
        return 0;
--

2.17.1

author
#2 lore raw
Quoted 21 lines · Adam Ford
Quoted 6 lines · Tim Harvey

Ensure there is a valid reset-gpio defined before using it.

Fixes f9852acdce02 ("phy: nop-phy: Fix enabling reset")
Cc Adam Ford <[email protected]>
Quoted 10 lines
---
 drivers/phy/nop-phy.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/phy/nop-phy.c +0 -0
index e2ee6e92068e..d0904f4f075b 100644
@@ -45,11 +45,13 @@ static int nop_phy_init(struct phy *phy)
 
Quoted 12 lines

drivers/phy/nop-phy.c static int nop_phy_init(struct phy *phy) · line 48

Quoted 8 lines
drivers/phy/nop-phy.c +1 -5
 #if CONFIG_IS_ENABLED(DM_GPIO)
        /* Take phy out of reset */
-       ret = dm_gpio_set_value(&priv->reset_gpio, false);
-       if (ret) {
-               if (CONFIG_IS_ENABLED(CLK))
-                       clk_disable_bulk(&priv->bulk);
-               return ret;
+       if (dm_gpio_is_valid(&priv->reset_gpio)) {

I didn't realize this was necessary. Sorry if I broke your board. Thanks for fixing it.

No worries... it's not broken yet as I only recently submitted the patch to enable USB for imx8mm/imx8mn venice boards and just yesterday I realized I needed this as well. Maybe this patch will get merged before the imx one but either way USB won't work for venice until they are both merged :)

I think it was the imx8mm-beacon board that you did the nopphy reset-gpios for. On that board you have usbotg1 with a vbus-supply and usbotg2 with a reset-gpios on its phy node - is usbotg2 routed to a hub with HUB_RST as that gpio? I have some boards like that but I've always setup the dt as if the HUB reset was a gpio-controlled voltage regulator. It looks like now with the nopphy having reset control that is a more proper way to describe this in dt.

Best Regards,

Tim