summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2013-12-24 12:16:01 -0200
committerDavid S. Miller <davem@davemloft.net>2013-12-29 22:27:00 -0500
commit7a399e3a2e05bc580a78ea72371b3896827f72e1 (patch)
tree32a7733f73cdeec7b90fd29b725134e48787ccdf
parent84602761ca4495dd409be936dfa93ed20c946684 (diff)
fec: Do not assume that PHY reset is active low
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> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 50bb71c663e2..45b8b22b9987 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2049,6 +2049,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;
@@ -2058,18 +2060,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)