netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Badel, Laurent" <LaurentBadel@eaton.com>
To: "davem@davemloft.net" <davem@davemloft.net>,
	"m.felsch@pengutronix.de" <m.felsch@pengutronix.de>,
	"fugang.duan@nxp.com" <fugang.duan@nxp.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"andrew@lunn.ch" <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"richard.leitner@skidata.com" <richard.leitner@skidata.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"f.fainelli@gmail.com" <f.fainelli@gmail.com>
Cc: "Quette, Arnaud" <ArnaudQuette@Eaton.com>
Subject: [PATCH net 3/4] net:phy: add phy_device_reset_status() support
Date: Tue, 27 Oct 2020 23:28:45 +0000	[thread overview]
Message-ID: <CY4PR1701MB1878D8AA63E4EBB99759B838DF160@CY4PR1701MB1878.namprd17.prod.outlook.com> (raw)

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@eaton.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 

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


                 reply	other threads:[~2020-10-28  1:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CY4PR1701MB1878D8AA63E4EBB99759B838DF160@CY4PR1701MB1878.namprd17.prod.outlook.com \
    --to=laurentbadel@eaton.com \
    --cc=ArnaudQuette@Eaton.com \
    --cc=andrew@lunn.ch \
    --cc=broonie@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=fugang.duan@nxp.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux@armlinux.org.uk \
    --cc=m.felsch@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=richard.leitner@skidata.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).