diff options
author | David Bauer <mail@david-bauer.net> | 2019-04-18 00:59:21 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-19 03:41:51 +0300 |
commit | 71dd6c0dff51b5f1fef2e9dfa6f6a948aac975f3 (patch) | |
tree | 8e6ec717ab9a043688ddab421f2518cd0095f246 /drivers/net/phy/mdio_bus.c | |
parent | b54dd90cab00f5b64ed8ce533991c20bf781a3cd (diff) | |
download | linux-71dd6c0dff51b5f1fef2e9dfa6f6a948aac975f3.tar.xz |
net: phy: add support for reset-controller
This commit adds support for PHY reset pins handled by a reset controller.
Signed-off-by: David Bauer <mail@david-bauer.net>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/mdio_bus.c')
-rw-r--r-- | drivers/net/phy/mdio_bus.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 4be4cc09eb90..ba3d2523808b 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -24,6 +24,7 @@ #include <linux/of_gpio.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> +#include <linux/reset.h> #include <linux/skbuff.h> #include <linux/spinlock.h> #include <linux/mm.h> @@ -57,8 +58,23 @@ static int mdiobus_register_gpiod(struct mdio_device *mdiodev) mdiodev->reset = gpiod; - /* Assert the reset signal again */ - mdio_device_reset(mdiodev, 1); + return 0; +} + +static int mdiobus_register_reset(struct mdio_device *mdiodev) +{ + struct reset_control *reset = NULL; + + if (mdiodev->dev.of_node) + reset = devm_reset_control_get_exclusive(&mdiodev->dev, + "phy"); + if (PTR_ERR(reset) == -ENOENT || + PTR_ERR(reset) == -ENOTSUPP) + reset = NULL; + else if (IS_ERR(reset)) + return PTR_ERR(reset); + + mdiodev->reset_ctrl = reset; return 0; } @@ -74,6 +90,13 @@ int mdiobus_register_device(struct mdio_device *mdiodev) err = mdiobus_register_gpiod(mdiodev); if (err) return err; + + err = mdiobus_register_reset(mdiodev); + if (err) + return err; + + /* Assert the reset signal */ + mdio_device_reset(mdiodev, 1); } mdiodev->bus->mdio_map[mdiodev->addr] = mdiodev; |