Skip to contentSkip to conversation

prevent undesired de-assertion of phy-reset

PATCH In review Tim Harvey 4 participants 10 messages Mar 1, 2022 – Apr 10, 2022 Network drivers

lore
Share & tools
lore

Tim Harvey

author
#0 lore raw

cover prevent undesired de-assertion of phy-reset

Some PHY's have strict requirements on reset timings which can be violated if the PHY is taken out of reset before a proper reset pulse is performed.

When gpio_request_by_name is used for reset gpios without GPIOD_IS_OUT_ACTIVE the GPIO will be de-asserted when requested taking the PHY out of reset. Resolve this by adding the GPIOD_IS_OUT_ACTIVE flag.

There are 42 occurances of gpio_request_by_name in U-Boot for gpio's with 'reset' in their name yet the only one that uses GPIOD_IS_OUT_ACTIVE is drivers/net/dwc_eth_qos.c. While I think setting GPIOD_IS_OUT_ACTIVE is the right thing to do, I'm only changing the ones that I have run into issues with:
drivers/net/eth-phy-uclass.c
drivers/net/fec_mxc.c

Both of these have functions that are called that assert, delay, de-assert, delay such that I know they will properly be taken out of reset.

The Linux kernel had a similar issue [1]

Tim Harvey (2):
net: fec: prevent undesired de-assertion of phy-reset on request
net: eth-phy: prevent undesired de-assertion of phy-reset on request

 drivers/net/eth-phy-uclass.c | 2 +-
 drivers/net/fec_mxc.c        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 3 lines
[1]
https://lore.kernel.org/all/[email protected]/
2.17.1
author
#1 lore raw

PATCH 1/2 net: fec: prevent undesired de-assertion of phy-reset on request

When gpio_request_by_name allocates a gpio output it by default will de-assert the gpio which for phy-reset will take the PHY out of reset. As this occurs before fec_gpio_reset is called to assert the reset line it can cause undesired affects if reset timings are not properly met.

Configure the gpio with GPIOD_IS_OUT_ACTIVE so that reset is kept active (reset asserted) to avoid this.

Cc Sean Anderson <[email protected]>
---
 drivers/net/fec_mxc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/fec_mxc.c +1 -1
index 985b03844739..c1f4930172cf 100644
@@ -1579,7 +1579,7 @@ static int fecmxc_of_to_plat(struct udevice *dev)
 
 #if CONFIG_IS_ENABLED(DM_GPIO)
 	ret = gpio_request_by_name(dev, "phy-reset-gpios", 0,
-				   &priv->phy_reset_gpio, GPIOD_IS_OUT);
+				   &priv->phy_reset_gpio, GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
 	if (ret < 0)
 		return 0; /* property is optional, don't return error! */
 
Signature · 1 line
2.17.1
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] net: fec: prevent undesired de-assertion of phy-reset on request

Quoted 7 lines · Tim Harvey

When gpio_request_by_name allocates a gpio output it by default will de-assert the gpio which for phy-reset will take the PHY out of reset. As this occurs before fec_gpio_reset is called to assert the reset line it can cause undesired affects if reset timings are not properly met.

Quoted 5 lines

Configure the gpio with GPIOD_IS_OUT_ACTIVE so that reset is kept active (reset asserted) to avoid this.

Cc Sean Anderson <[email protected]>
Tested-by
#3 lore raw

Re: [PATCH 1/2] net: fec: prevent undesired de-assertion of phy-reset on request

Quoted 9 lines · Joe Hershberger
Quoted 7 lines · Tim Harvey

When gpio_request_by_name allocates a gpio output it by default will de-assert the gpio which for phy-reset will take the PHY out of reset. As this occurs before fec_gpio_reset is called to assert the reset line it can cause undesired affects if reset timings are not properly met.

Quoted 7 lines
Quoted 5 lines

Configure the gpio with GPIOD_IS_OUT_ACTIVE so that reset is kept active (reset asserted) to avoid this.

Cc Sean Anderson <[email protected]>
Reviewed-by
#4 lore raw

Re: [PATCH 1/2] net: fec: prevent undesired de-assertion of phy-reset on request

Quoted 14 lines · Adam Ford
Quoted 12 lines · Joe Hershberger
Quoted 10 lines · Tim Harvey

When gpio_request_by_name allocates a gpio output it by default will de-assert the gpio which for phy-reset will take the PHY out of reset. As this occurs before fec_gpio_reset is called to assert the reset line it can cause undesired affects if reset timings are not properly met.

Configure the gpio with GPIOD_IS_OUT_ACTIVE so that reset is kept active (reset asserted) to avoid this.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Cc Sean Anderson <[email protected]>
#5 lore raw

Re: [PATCH 1/2] net: fec: prevent undesired de-assertion of phy-reset on request

Quoted 16 lines · Ramon Fried
Quoted 14 lines · Adam Ford
Quoted 12 lines · Joe Hershberger
Quoted 10 lines · Tim Harvey

When gpio_request_by_name allocates a gpio output it by default will de-assert the gpio which for phy-reset will take the PHY out of reset. As this occurs before fec_gpio_reset is called to assert the reset line it can cause undesired affects if reset timings are not properly met.

Configure the gpio with GPIOD_IS_OUT_ACTIVE so that reset is kept active (reset asserted) to avoid this.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Cc Sean Anderson <[email protected]>

Applied to u-boot-net/next
Thanks,
Ramon

author
#6 lore raw

PATCH 2/2 net: eth-phy: prevent undesired de-assertion of phy-reset on request

In reply to Tim Harvey

When gpio_request_by_name allocates a gpio output it by default will de-assert the gpio which for phy-reset will take the PHY out of reset. As this occurs before eth_phy_reset is called to assert the reset line it can cause undesired affects if reset timings are not properly met.

Configure the gpio with GPIOD_IS_OUT_ACTIVE so that reset is kept active (reset asserted) to avoid this.

Cc Sean Anderson <[email protected]>
---
 drivers/net/eth-phy-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/eth-phy-uclass.c +1 -1
index 1f285f7afd20..27b77444a0c5 100644
@@ -137,7 +137,7 @@ static int eth_phy_of_to_plat(struct udevice *dev)
 	/* search "reset-gpios" in phy node */
 	ret = gpio_request_by_name(dev, "reset-gpios", 0,
 				   &uc_priv->reset_gpio,
-				   GPIOD_IS_OUT);
+				   GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
 	if (ret && ret != -ENOENT)
 		return ret;
 
Signature · 1 line
2.17.1
Acked-by on v1 2/2
#7 lore raw

Re: [PATCH 2/2] net: eth-phy: prevent undesired de-assertion of phy-reset on request

Quoted 7 lines · Tim Harvey

When gpio_request_by_name allocates a gpio output it by default will de-assert the gpio which for phy-reset will take the PHY out of reset. As this occurs before eth_phy_reset is called to assert the reset line it can cause undesired affects if reset timings are not properly met.

Quoted 5 lines

Configure the gpio with GPIOD_IS_OUT_ACTIVE so that reset is kept active (reset asserted) to avoid this.

Cc Sean Anderson <[email protected]>
Reviewed-by
#8 lore raw

Re: [PATCH 2/2] net: eth-phy: prevent undesired de-assertion of phy-reset on request

Quoted 9 lines · Joe Hershberger
Quoted 7 lines · Tim Harvey

When gpio_request_by_name allocates a gpio output it by default will de-assert the gpio which for phy-reset will take the PHY out of reset. As this occurs before eth_phy_reset is called to assert the reset line it can cause undesired affects if reset timings are not properly met.

Quoted 7 lines
Quoted 5 lines

Configure the gpio with GPIOD_IS_OUT_ACTIVE so that reset is kept active (reset asserted) to avoid this.

Cc Sean Anderson <[email protected]>
#9 lore raw

Re: [PATCH 2/2] net: eth-phy: prevent undesired de-assertion of phy-reset on request

Quoted 11 lines · Ramon Fried
Quoted 9 lines · Joe Hershberger
Quoted 7 lines · Tim Harvey

When gpio_request_by_name allocates a gpio output it by default will de-assert the gpio which for phy-reset will take the PHY out of reset. As this occurs before eth_phy_reset is called to assert the reset line it can cause undesired affects if reset timings are not properly met.

Quoted 8 lines
Quoted 7 lines
Quoted 5 lines

Configure the gpio with GPIOD_IS_OUT_ACTIVE so that reset is kept active (reset asserted) to avoid this.

Cc Sean Anderson <[email protected]>

Applied to u-boot-net/next
Thanks,
Ramon