netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fec: Do not assume that PHY reset is active low
@ 2013-12-24 14:16 Fabio Estevam
  2013-12-30  3:27 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2013-12-24 14:16 UTC (permalink / raw)
  To: davem; +Cc: Frank.Li, shawn.guo, p.zabel, netdev, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

We should not assume that the PHY reset is always active low.

Retrieve this information from the device tree instead, so that the PHY reset
can work on both cases.

Reported-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 6530177..4b9976a0 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2053,6 +2053,8 @@ static void fec_reset_phy(struct platform_device *pdev)
 	int err, phy_reset;
 	int msec = 1;
 	struct device_node *np = pdev->dev.of_node;
+	enum of_gpio_flags flags;
+	bool port;
 
 	if (!np)
 		return;
@@ -2062,18 +2064,22 @@ static void fec_reset_phy(struct platform_device *pdev)
 	if (msec > 1000)
 		msec = 1;
 
-	phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
+	phy_reset = of_get_named_gpio_flags(np, "phy-reset-gpios", 0, &flags);
 	if (!gpio_is_valid(phy_reset))
 		return;
 
-	err = devm_gpio_request_one(&pdev->dev, phy_reset,
-				    GPIOF_OUT_INIT_LOW, "phy-reset");
+	if (flags & OF_GPIO_ACTIVE_LOW)
+		port = GPIOF_OUT_INIT_LOW;
+	else
+		port = GPIOF_OUT_INIT_HIGH;
+
+	err = devm_gpio_request_one(&pdev->dev, phy_reset, port, "phy-reset");
 	if (err) {
 		dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err);
 		return;
 	}
 	msleep(msec);
-	gpio_set_value(phy_reset, 1);
+	gpio_set_value(phy_reset, !port);
 }
 #else /* CONFIG_OF */
 static void fec_reset_phy(struct platform_device *pdev)
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fec: Do not assume that PHY reset is active low
  2013-12-24 14:16 [PATCH] fec: Do not assume that PHY reset is active low Fabio Estevam
@ 2013-12-30  3:27 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-12-30  3:27 UTC (permalink / raw)
  To: festevam; +Cc: Frank.Li, shawn.guo, p.zabel, netdev, fabio.estevam

From: Fabio Estevam <festevam@gmail.com>
Date: Tue, 24 Dec 2013 12:16:01 -0200

> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> We should not assume that the PHY reset is always active low.
> 
> Retrieve this information from the device tree instead, so that the PHY reset
> can work on both cases.
> 
> Reported-by: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Applied, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-12-30  3:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-24 14:16 [PATCH] fec: Do not assume that PHY reset is active low Fabio Estevam
2013-12-30  3:27 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).