Skip to content

Commit da47b45

Browse files
Uwe Kleine-Königdavem330
authored andcommitted
phy: add support for a reset-gpio specification
The framework only asserts (for now) that the reset gpio is not active. Signed-off-by: Uwe Kleine-König <[email protected]> Reviewed-by: Roger Quadros <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f23e0f6 commit da47b45

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Documentation/devicetree/bindings/net/phy.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ Optional Properties:
3535
- broken-turn-around: If set, indicates the PHY device does not correctly
3636
release the turn around line low at the end of a MDIO transaction.
3737

38+
- reset-gpios: Reference to a GPIO used to reset the phy.
39+
3840
Example:
3941

4042
ethernet-phy@0 {
4143
compatible = "ethernet-phy-id0141.0e90", "ethernet-phy-ieee802.3-c22";
4244
interrupt-parent = <40000>;
4345
interrupts = <35 1>;
4446
reg = <0>;
47+
reset-gpios = <&gpio1 17 GPIO_ACTIVE_LOW>;
4548
};

drivers/net/phy/phy_device.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/io.h>
3535
#include <linux/uaccess.h>
3636
#include <linux/of.h>
37+
#include <linux/gpio/consumer.h>
3738

3839
#include <asm/irq.h>
3940

@@ -1570,9 +1571,16 @@ static int phy_probe(struct device *dev)
15701571
struct device_driver *drv = phydev->mdio.dev.driver;
15711572
struct phy_driver *phydrv = to_phy_driver(drv);
15721573
int err = 0;
1574+
struct gpio_descs *reset_gpios;
15731575

15741576
phydev->drv = phydrv;
15751577

1578+
/* take phy out of reset */
1579+
reset_gpios = devm_gpiod_get_array_optional(dev, "reset",
1580+
GPIOD_OUT_LOW);
1581+
if (IS_ERR(reset_gpios))
1582+
return PTR_ERR(reset_gpios);
1583+
15761584
/* Disable the interrupt if the PHY doesn't support it
15771585
* but the interrupt is still a valid one
15781586
*/

0 commit comments

Comments
 (0)