Skip to contentSkip to conversation

macb: fix PHY reset

PATCH Applied Sergei Shtylyov 3 participants 6 messages Mar 22, 2016 – Mar 23, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 macb: fix PHY reset

The driver calls gpiod_set_value() with GPIOD_OUT_* instead of 0 and 1, as a result the PHY isn't really put back into reset state in macb_remove(). Moreover, the driver assumes that something else has set the GPIO direction to output, so if it has not, the PHY wouldn't be taken out of reset in macb_probe() either...

---
The patch is against David Miller's 'net.git' repo.

 drivers/net/ethernet/cadence/macb.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/cadence/macb.c +2 -2
Index: net/drivers/net/ethernet/cadence/macb.c
===================================================================
@@ -2959,7 +2959,7 @@ static int macb_probe(struct platform_de
 		int gpio = of_get_named_gpio(phy_node, "reset-gpios", 0);
 		if (gpio_is_valid(gpio))
 			bp->reset_gpio = gpio_to_desc(gpio);
-		gpiod_set_value(bp->reset_gpio, GPIOD_OUT_HIGH);
+		gpiod_direction_output(bp->reset_gpio, 1);
 	}
 	of_node_put(phy_node);
 
@@ -3029,7 +3029,7 @@ static int macb_remove(struct platform_d
 		mdiobus_free(bp->mii_bus);
 
 		/* Shutdown the PHY if there is a GPIO reset */
-		gpiod_set_value(bp->reset_gpio, GPIOD_OUT_LOW);
+		gpiod_set_value(bp->reset_gpio, 0);
 
 		unregister_netdev(dev);
 		clk_disable_unprepare(bp->tx_clk);
#1 lore raw
Quoted 4 lines · Sergei Shtylyov

The driver calls gpiod_set_value() with GPIOD_OUT_* instead of 0 and 1, as a result the PHY isn't really put back into reset state in macb_remove(). Moreover, the driver assumes that something else has set the GPIO direction to output, so if it has not, the PHY wouldn't be taken out of reset in

s/wouldn't/may not/, sorry. Do I need to resend?

Quoted 3 lines

macb_probe() either...

MBR, Sergei

Applied
#2 lore raw

From: Sergei Shtylyov <[email protected]>
Date: Tue, 22 Mar 2016 22:34:05 +0300

Quoted 11 lines · Sergei Shtylyov
Quoted 8 lines

The driver calls gpiod_set_value() with GPIOD_OUT_* instead of 0 and 1, as
a result the PHY isn't really put back into reset state in macb_remove().
Moreover, the driver assumes that something else has set the GPIO direction
to output, so if it has not, the PHY wouldn't be taken out of reset in

s/wouldn't/may not/, sorry. Do I need to resend?

No need, I fixed it up by hand.

Applied, thanks.

#3 lore raw
Quoted 8 lines · David Miller
Quoted 8 lines
Quoted 7 lines

The driver calls gpiod_set_value() with GPIOD_OUT_* instead of 0 and 1, as
a result the PHY isn't really put back into reset state in macb_remove().
Moreover, the driver assumes that something else has set the GPIO direction
to output, so if it has not, the PHY wouldn't be taken out of reset in

Quoted 5 lines
Quoted 1 line

s/wouldn't/may not/, sorry. Do I need to resend?

No need, I fixed it up by hand.

Applied, thanks.

Thank you! gpio_request() or smth of that sort wouldn't hurt too (the pin
won't be switched to the GPIO mode on the pin function controller that I have here...
Anyway, this code is doomed if my phylib reset GPIO patch (to be posted
yet) is accepted ...

MBR, Sergei

#4 lore raw
In reply to David Miller
Quoted 10 lines · David Miller
Quoted 10 lines · Sergei Shtylyov
Quoted 8 lines

The driver calls gpiod_set_value() with GPIOD_OUT_* instead of 0 and 1, as
a result the PHY isn't really put back into reset state in macb_remove().
Moreover, the driver assumes that something else has set the GPIO direction
to output, so if it has not, the PHY wouldn't be taken out of reset in

Quoted 5 lines
Quoted 1 line

s/wouldn't/may not/, sorry. Do I need to resend?

No need, I fixed it up by hand.

Applied, thanks.

Oops, forgot another tag:

Fixes 270c499f0993 ("net/macb: Update device tree binding for resetting PHY using GPIO")

Too late probably... :-(

MBR, Sergei

Acked-by
#5 lore raw
Quoted 16 lines · Sergei Shtylyov
Quoted 14 lines · David Miller
Quoted 11 lines · Sergei Shtylyov
Quoted 8 lines

The driver calls gpiod_set_value() with GPIOD_OUT_* instead of 0 and 1, as
a result the PHY isn't really put back into reset state in macb_remove().
Moreover, the driver assumes that something else has set the GPIO direction
to output, so if it has not, the PHY wouldn't be taken out of reset in

s/wouldn't/may not/, sorry. Do I need to resend?

No need, I fixed it up by hand.

Quoted 8 lines
Quoted 1 line

Applied, thanks.

Oops, forgot another tag:

Fixes 270c499f0993 ("net/macb: Update device tree binding for resetting PHY

using GPIO")

   Too late probably... :-(

Too late also:

Thanks Sergei!

Bye,

Signature · 1 line
Nicolas Ferre