[PATCH net 3/4] net:phy: add phy_device_reset_status() support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Subject: [PATCH net 3/4] net:phy: add phy_device_reset_status() support

Description: add support to query the status of the reset line of an MDIO 
device. 

Signed-off-by: Laurent Badel <laurentbadel@xxxxxxxxx>
---
 drivers/net/phy/mdio_device.c | 18 ++++++++++++++++++
 include/linux/mdio.h          |  1 +
 include/linux/phy.h           |  5 +++++
 3 files changed, 24 insertions(+)

diff --git a/drivers/net/phy/mdio_device.c b/drivers/net/phy/mdio_device.c
index 0837319a52d7..4909feb57027 100644
--- a/drivers/net/phy/mdio_device.c
+++ b/drivers/net/phy/mdio_device.c
@@ -136,6 +136,24 @@ void mdio_device_reset(struct mdio_device *mdiodev, int value)
 }
 EXPORT_SYMBOL(mdio_device_reset);
 
+/**
+ * mdio_device_reset_status - returns the reset status of an MDIO device
+ *
+ * Returns >0 if the reset line is asserted, 0 if it is not asserted
+   and <0 on error.
+ */
+int mdio_device_reset_status(struct mdio_device *mdiodev)
+{
+	if (mdiodev->reset_gpio)
+		return gpiod_get_value_cansleep(mdiodev->reset_gpio);
+
+	if (mdiodev->reset_ctrl)
+		return reset_control_status(mdiodev->reset_ctrl);
+
+	return -EOPNOTSUPP;
+}
+EXPORT_SYMBOL(mdio_device_reset_status);
+
 /**
  * mdio_probe - probe an MDIO device
  * @dev: device to probe
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index dbd69b3d170b..179c5bdd90e8 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -92,6 +92,7 @@ struct mdio_device *mdio_device_create(struct mii_bus *bus, int addr);
 int mdio_device_register(struct mdio_device *mdiodev);
 void mdio_device_remove(struct mdio_device *mdiodev);
 void mdio_device_reset(struct mdio_device *mdiodev, int value);
+int mdio_device_reset_status(struct mdio_device *mdiodev);
 int mdio_driver_register(struct mdio_driver *drv);
 void mdio_driver_unregister(struct mdio_driver *drv);
 int mdio_device_bus_match(struct device *dev, struct device_driver *drv);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index eb3cb1a98b45..e12b90db9852 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1461,6 +1461,11 @@ static inline void phy_device_reset(struct phy_device *phydev, int value)
 	mdio_device_reset(&phydev->mdio, value);
 }
 
+static inline int phy_device_reset_status(struct phy_device *phydev)
+{
+	return mdio_device_reset_status(&phydev->mdio);
+}
+
 #define phydev_err(_phydev, format, args...)	\
 	dev_err(&_phydev->mdio.dev, format, ##args)
 
-- 
2.17.1



-----------------------------
Eaton Industries Manufacturing GmbH ~ Registered place of business: Route de la Longeraie 7, 1110, Morges, Switzerland 

-----------------------------





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux