* [PATCH v2 0/3] net: add reset-controller driven PHY reset
@ 2019-04-17 11:00 David Bauer
2019-04-17 11:00 ` [PATCH v2 1/3] dt-bindings: net: add PHY reset controller binding David Bauer
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: David Bauer @ 2019-04-17 11:00 UTC (permalink / raw)
To: devicetree, netdev
This patchset adds support for a PHY reset driven by a reset-controller.
Currently, only GPIO driven resets are supported by the PHY subsystem.
v2:
- fixed missed rename of "reset" in at803x.c
- move initial reset to mdio_device_reset
David Bauer (3):
dt-bindings: net: add PHY reset controller binding
net: phy: add support for reset-controller
net: mdio: rename mdio_device reset to reset_gpio
Documentation/devicetree/bindings/net/phy.txt | 6 ++++
drivers/net/phy/at803x.c | 2 +-
drivers/net/phy/mdio_bus.c | 32 ++++++++++++++++---
drivers/net/phy/mdio_device.c | 13 ++++++--
include/linux/mdio.h | 3 +-
5 files changed, 47 insertions(+), 9 deletions(-)
--
2.21.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/3] dt-bindings: net: add PHY reset controller binding
2019-04-17 11:00 [PATCH v2 0/3] net: add reset-controller driven PHY reset David Bauer
@ 2019-04-17 11:00 ` David Bauer
2019-04-17 14:10 ` Andrew Lunn
2019-04-17 11:00 ` [PATCH v2 2/3] net: phy: add support for reset-controller David Bauer
2019-04-17 11:00 ` [PATCH v2 3/3] net: mdio: rename mdio_device reset to reset_gpio David Bauer
2 siblings, 1 reply; 6+ messages in thread
From: David Bauer @ 2019-04-17 11:00 UTC (permalink / raw)
To: devicetree, netdev; +Cc: Andrew Lunn
Add the documentation for PHY reset lines controlled by a reset controller.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David Bauer <mail@david-bauer.net>
---
Documentation/devicetree/bindings/net/phy.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/phy.txt b/Documentation/devicetree/bindings/net/phy.txt
index 17c1d2bd00f6..9b9e5b1765dd 100644
--- a/Documentation/devicetree/bindings/net/phy.txt
+++ b/Documentation/devicetree/bindings/net/phy.txt
@@ -51,6 +51,10 @@ Optional Properties:
to ensure the integrated PHY is used. The absence of this property indicates
the muxers should be configured so that the external PHY is used.
+- resets: The reset-controller phandle and specifier for the PHY reset signal.
+
+- reset-names: Must be "phy" for the PHY reset signal.
+
- reset-gpios: The GPIO phandle and specifier for the PHY reset signal.
- reset-assert-us: Delay after the reset was asserted in microseconds.
@@ -67,6 +71,8 @@ ethernet-phy@0 {
interrupts = <35 IRQ_TYPE_EDGE_RISING>;
reg = <0>;
+ resets = <&rst 8>;
+ reset-names = "phy";
reset-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
reset-assert-us = <1000>;
reset-deassert-us = <2000>;
--
2.21.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] net: phy: add support for reset-controller
2019-04-17 11:00 [PATCH v2 0/3] net: add reset-controller driven PHY reset David Bauer
2019-04-17 11:00 ` [PATCH v2 1/3] dt-bindings: net: add PHY reset controller binding David Bauer
@ 2019-04-17 11:00 ` David Bauer
2019-04-17 14:12 ` Andrew Lunn
2019-04-17 11:00 ` [PATCH v2 3/3] net: mdio: rename mdio_device reset to reset_gpio David Bauer
2 siblings, 1 reply; 6+ messages in thread
From: David Bauer @ 2019-04-17 11:00 UTC (permalink / raw)
To: devicetree, netdev; +Cc: Andrew Lunn
This commit adds support for PHY reset pins handled by a reset controller.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David Bauer <mail@david-bauer.net>
---
drivers/net/phy/mdio_bus.c | 26 ++++++++++++++++++++++++--
drivers/net/phy/mdio_device.c | 13 +++++++++++--
include/linux/mdio.h | 1 +
3 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 4be4cc09eb90..e5428951dfe1 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,12 @@ 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;
diff --git a/drivers/net/phy/mdio_device.c b/drivers/net/phy/mdio_device.c
index 887076292e50..57668e0f9256 100644
--- a/drivers/net/phy/mdio_device.c
+++ b/drivers/net/phy/mdio_device.c
@@ -16,6 +16,7 @@
#include <linux/mii.h>
#include <linux/module.h>
#include <linux/phy.h>
+#include <linux/reset.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/unistd.h>
@@ -116,10 +117,18 @@ void mdio_device_reset(struct mdio_device *mdiodev, int value)
{
unsigned int d;
- if (!mdiodev->reset)
+ if (!mdiodev->reset && !mdiodev->reset_ctrl)
return;
- gpiod_set_value(mdiodev->reset, value);
+ if (mdiodev->reset)
+ gpiod_set_value(mdiodev->reset, value);
+
+ if (mdiodev->reset_ctrl) {
+ if (value)
+ reset_control_assert(mdiodev->reset_ctrl);
+ else
+ reset_control_deassert(mdiodev->reset_ctrl);
+ }
d = value ? mdiodev->reset_assert_delay : mdiodev->reset_deassert_delay;
if (d)
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index 3e99ae3ed87f..6eaf71500ef6 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -40,6 +40,7 @@ struct mdio_device {
int addr;
int flags;
struct gpio_desc *reset;
+ struct reset_control *reset_ctrl;
unsigned int reset_assert_delay;
unsigned int reset_deassert_delay;
};
--
2.21.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] net: mdio: rename mdio_device reset to reset_gpio
2019-04-17 11:00 [PATCH v2 0/3] net: add reset-controller driven PHY reset David Bauer
2019-04-17 11:00 ` [PATCH v2 1/3] dt-bindings: net: add PHY reset controller binding David Bauer
2019-04-17 11:00 ` [PATCH v2 2/3] net: phy: add support for reset-controller David Bauer
@ 2019-04-17 11:00 ` David Bauer
2 siblings, 0 replies; 6+ messages in thread
From: David Bauer @ 2019-04-17 11:00 UTC (permalink / raw)
To: devicetree, netdev; +Cc: Andrew Lunn
This renames the GPIO reset of mdio devices from 'reset' to
'reset_gpio' to better differentiate between GPIO and
reset-controller driven reset line.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David Bauer <mail@david-bauer.net>
---
drivers/net/phy/at803x.c | 2 +-
drivers/net/phy/mdio_bus.c | 6 +++---
drivers/net/phy/mdio_device.c | 6 +++---
include/linux/mdio.h | 2 +-
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index f3e96191eb6f..16c5a83e2a60 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -334,7 +334,7 @@ static void at803x_link_change_notify(struct phy_device *phydev)
* cannot recover from by software.
*/
if (phydev->state == PHY_NOLINK) {
- if (phydev->mdio.reset && !priv->phy_reset) {
+ if (phydev->mdio.reset_gpio && !priv->phy_reset) {
struct at803x_context context;
at803x_context_save(phydev, &context);
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index e5428951dfe1..5fd2295cf621 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -56,7 +56,7 @@ static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
return PTR_ERR(gpiod);
}
- mdiodev->reset = gpiod;
+ mdiodev->reset_gpio = gpiod;
return 0;
}
@@ -468,8 +468,8 @@ void mdiobus_unregister(struct mii_bus *bus)
if (!mdiodev)
continue;
- if (mdiodev->reset)
- gpiod_put(mdiodev->reset);
+ if (mdiodev->reset_gpio)
+ gpiod_put(mdiodev->reset_gpio);
mdiodev->device_remove(mdiodev);
mdiodev->device_free(mdiodev);
diff --git a/drivers/net/phy/mdio_device.c b/drivers/net/phy/mdio_device.c
index 57668e0f9256..e282600bd83e 100644
--- a/drivers/net/phy/mdio_device.c
+++ b/drivers/net/phy/mdio_device.c
@@ -117,11 +117,11 @@ void mdio_device_reset(struct mdio_device *mdiodev, int value)
{
unsigned int d;
- if (!mdiodev->reset && !mdiodev->reset_ctrl)
+ if (!mdiodev->reset_gpio && !mdiodev->reset_ctrl)
return;
- if (mdiodev->reset)
- gpiod_set_value(mdiodev->reset, value);
+ if (mdiodev->reset_gpio)
+ gpiod_set_value(mdiodev->reset_gpio, value);
if (mdiodev->reset_ctrl) {
if (value)
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index 6eaf71500ef6..9dc16d5705a1 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -39,7 +39,7 @@ struct mdio_device {
/* Bus address of the MDIO device (0-31) */
int addr;
int flags;
- struct gpio_desc *reset;
+ struct gpio_desc *reset_gpio;
struct reset_control *reset_ctrl;
unsigned int reset_assert_delay;
unsigned int reset_deassert_delay;
--
2.21.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/3] dt-bindings: net: add PHY reset controller binding
2019-04-17 11:00 ` [PATCH v2 1/3] dt-bindings: net: add PHY reset controller binding David Bauer
@ 2019-04-17 14:10 ` Andrew Lunn
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2019-04-17 14:10 UTC (permalink / raw)
To: David Bauer; +Cc: devicetree, netdev
On Wed, Apr 17, 2019 at 01:00:30PM +0200, David Bauer wrote:
> Add the documentation for PHY reset lines controlled by a reset controller.
Hi David
You are missing the 0/3 patch containing the cover note, what this
patchset is all about.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/3] net: phy: add support for reset-controller
2019-04-17 11:00 ` [PATCH v2 2/3] net: phy: add support for reset-controller David Bauer
@ 2019-04-17 14:12 ` Andrew Lunn
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2019-04-17 14:12 UTC (permalink / raw)
To: David Bauer; +Cc: devicetree, netdev
> @@ -74,6 +90,12 @@ int mdiobus_register_device(struct mdio_device *mdiodev)
> err = mdiobus_register_gpiod(mdiodev);
> if (err)
> return err;
Hi David
The general style in this file is to put a blank line after returning
err.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-04-17 14:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-17 11:00 [PATCH v2 0/3] net: add reset-controller driven PHY reset David Bauer
2019-04-17 11:00 ` [PATCH v2 1/3] dt-bindings: net: add PHY reset controller binding David Bauer
2019-04-17 14:10 ` Andrew Lunn
2019-04-17 11:00 ` [PATCH v2 2/3] net: phy: add support for reset-controller David Bauer
2019-04-17 14:12 ` Andrew Lunn
2019-04-17 11:00 ` [PATCH v2 3/3] net: mdio: rename mdio_device reset to reset_gpio David Bauer
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).