* [PATCH] net: phy: support C45 phys in SIOCGMIIREG/SIOCSMIIREG ioctls
@ 2019-05-31 7:47 Nikita Yushchenko
2019-05-31 12:20 ` Andrew Lunn
0 siblings, 1 reply; 2+ messages in thread
From: Nikita Yushchenko @ 2019-05-31 7:47 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli
Cc: Heiner Kallweit, David S. Miller, netdev, linux-kernel,
Chris Healy, Nikita Yushchenko
This change allows phytool [1] and similar tools to read and write C45 phy
registers from userspace.
This is useful for debugging and for porting vendor phy diagnostics tools.
[1] https://github.com/wkz/phytool
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
drivers/net/phy/phy.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index e8885429293a..3d991958bde0 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -407,6 +407,7 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
struct mii_ioctl_data *mii_data = if_mii(ifr);
u16 val = mii_data->val_in;
bool change_autoneg = false;
+ int ret;
switch (cmd) {
case SIOCGMIIPHY:
@@ -414,12 +415,28 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
/* fall through */
case SIOCGMIIREG:
+ if (mdio_phy_id_is_c45(mii_data->phy_id)) {
+ ret = phy_read_mmd(phydev,
+ mdio_phy_id_devad(mii_data->phy_id),
+ mii_data->reg_num);
+ if (ret < 0)
+ return ret;
+ mii_data->val_out = ret;
+ return 0;
+ }
mii_data->val_out = mdiobus_read(phydev->mdio.bus,
mii_data->phy_id,
mii_data->reg_num);
return 0;
case SIOCSMIIREG:
+ if (mdio_phy_id_is_c45(mii_data->phy_id)) {
+ ret = phy_write_mmd(phydev,
+ mdio_phy_id_devad(mii_data->phy_id),
+ mii_data->reg_num,
+ mii_data->val_in);
+ return ret;
+ }
if (mii_data->phy_id == phydev->mdio.addr) {
switch (mii_data->reg_num) {
case MII_BMCR:
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] net: phy: support C45 phys in SIOCGMIIREG/SIOCSMIIREG ioctls
2019-05-31 7:47 [PATCH] net: phy: support C45 phys in SIOCGMIIREG/SIOCSMIIREG ioctls Nikita Yushchenko
@ 2019-05-31 12:20 ` Andrew Lunn
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2019-05-31 12:20 UTC (permalink / raw)
To: Nikita Yushchenko, Florian Fainelli
Cc: Florian Fainelli, Heiner Kallweit, David S. Miller, netdev,
linux-kernel, Chris Healy
On Fri, May 31, 2019 at 10:47:27AM +0300, Nikita Yushchenko wrote:
> This change allows phytool [1] and similar tools to read and write C45 phy
> registers from userspace.
>
> This is useful for debugging and for porting vendor phy diagnostics tools.
>
> [1] https://github.com/wkz/phytool
Hi Nikita
Russell King submitted a similar patch a couple of days ago.
https://patchwork.ozlabs.org/patch/1102091/
Since he was first, we should probably take his, once he respins the
series.
Florian: Could you take a second look at
[net-next,1/4] net: phylink: support for link gpio interrupt
https://patchwork.ozlabs.org/patch/1102090/
Everything else in that patchset is good to go.
Thanks
Andrew
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-31 12:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-31 7:47 [PATCH] net: phy: support C45 phys in SIOCGMIIREG/SIOCSMIIREG ioctls Nikita Yushchenko
2019-05-31 12:20 ` Andrew Lunn
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).