Commit 7a399e3a authored by Fabio Estevam's avatar Fabio Estevam Committed by David S. Miller

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: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 84602761
...@@ -2049,6 +2049,8 @@ static void fec_reset_phy(struct platform_device *pdev) ...@@ -2049,6 +2049,8 @@ static void fec_reset_phy(struct platform_device *pdev)
int err, phy_reset; int err, phy_reset;
int msec = 1; int msec = 1;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
enum of_gpio_flags flags;
bool port;
if (!np) if (!np)
return; return;
...@@ -2058,18 +2060,22 @@ static void fec_reset_phy(struct platform_device *pdev) ...@@ -2058,18 +2060,22 @@ static void fec_reset_phy(struct platform_device *pdev)
if (msec > 1000) if (msec > 1000)
msec = 1; 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)) if (!gpio_is_valid(phy_reset))
return; return;
err = devm_gpio_request_one(&pdev->dev, phy_reset, if (flags & OF_GPIO_ACTIVE_LOW)
GPIOF_OUT_INIT_LOW, "phy-reset"); 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) { if (err) {
dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err); dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err);
return; return;
} }
msleep(msec); msleep(msec);
gpio_set_value(phy_reset, 1); gpio_set_value(phy_reset, !port);
} }
#else /* CONFIG_OF */ #else /* CONFIG_OF */
static void fec_reset_phy(struct platform_device *pdev) static void fec_reset_phy(struct platform_device *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment