[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CY4PR1701MB1878D8AA63E4EBB99759B838DF160@CY4PR1701MB1878.namprd17.prod.outlook.com>
Date: Tue, 27 Oct 2020 23:28:45 +0000
From: "Badel, Laurent" <LaurentBadel@...on.com>
To: "davem@...emloft.net" <davem@...emloft.net>,
"m.felsch@...gutronix.de" <m.felsch@...gutronix.de>,
"fugang.duan@....com" <fugang.duan@....com>,
"kuba@...nel.org" <kuba@...nel.org>,
"andrew@...n.ch" <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
"linux@...linux.org.uk" <linux@...linux.org.uk>,
"p.zabel@...gutronix.de" <p.zabel@...gutronix.de>,
"lgirdwood@...il.com" <lgirdwood@...il.com>,
"broonie@...nel.org" <broonie@...nel.org>,
"robh+dt@...nel.org" <robh+dt@...nel.org>,
"richard.leitner@...data.com" <richard.leitner@...data.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"f.fainelli@...il.com" <f.fainelli@...il.com>
CC: "Quette, Arnaud" <ArnaudQuette@...on.com>
Subject: [PATCH net 3/4] net:phy: add phy_device_reset_status() support
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@...on.com>
---
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
-----------------------------
Powered by blists - more mailing lists