Add MMD PHY helpers
Subsystems (2)
cover Add MMD PHY helpers
Introduce phy_(read|write)_mmd() generic 802.3 clause 45 register accessors for Clause 22 PHYs, using the indirect method. Allow this behaviour to be overriden by PHY drivers where necessary.
Carlo Caione (2):
net: phy: Add support for accessing MMD PHY registers
cmd: mdio: Add new parameter to access MMD PHY registers
cmd/mdio.c | 33 ++++++++++++++++++----- drivers/net/phy/phy.c | 4 +++ include/phy.h | 62 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 6 deletions(-)
Signature · 1 line
2.19.1
PATCH 1/2 net: phy: Add support for accessing MMD PHY registers
Two new helper functions (phy_read_mmd() and phy_write_mmd()) are added to allow access to the MMD PHY registers.
The MMD PHY registers can be accessed by two means:
1. Using two new MMD access function hooks in the PHY driver. These functions can be implemented when the PHY driver does not support the standard IEEE Compatible clause 45 access mechanism described in clause 22 or if the PHY uses its own non-standard access mechanism.
2. The standard clause 45 access extensions to the MMD registers through the indirection registers (clause 22) in all the other cases.
--- drivers/net/phy/phy.c | 4 +++ include/phy.h | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+)
drivers/net/phy/phy.c +4 -0
@@ -549,6 +549,10 @@ int phy_register(struct phy_driver *drv) drv->readext += gd->reloc_off;if (drv->writeext) drv->writeext += gd->reloc_off; +if (drv->read_mmd) + drv->read_mmd += gd->reloc_off; +if (drv->write_mmd) + drv->write_mmd += gd->reloc_off;#endif return 0 ; }
include/phy.h +62 -0
74 lines not on this page · raw message
Signature · 1 line
2.19.1
PATCH 1/2 net: phy: Add support for accessing MMD PHY registers
Quoted 11 lines · Carlo Caione
Two new helper functions (
phy_read_mmd()andphy_write_mmd()) are added to allow access to the MMD PHY registers.The MMD PHY registers can be accessed by two means:
1. Using two new MMD access function hooks in the PHY driver. These functions can be implemented when the PHY driver does not support the standard IEEE Compatible clause 45 access mechanism described in clause 22 or if the PHY uses its own non-standard access mechanism.
Quoted 4 lines
2. The standard clause 45 access extensions to the MMD registers through the indirection registers (clause 22) in all the other cases.
Signed-off-by Carlo Caione <[email protected]>
This seems like a duplicate of https://patchwork.ozlabs.org/patch/1015782/
The command patch should probably be adapted to use that.
Thanks,
-Joe
PATCH 1/2 net: phy: Add support for accessing MMD PHY registers
Quoted 12 lines · Joe Hershberger
Quoted 11 lines · Carlo Caione
Two new helper functions (
phy_read_mmd()andphy_write_mmd()) are added to allow access to the MMD PHY registers.The MMD PHY registers can be accessed by two means:
1. Using two new MMD access function hooks in the PHY driver. These functions can be implemented when the PHY driver does not support the standard IEEE Compatible clause 45 access mechanism described in clause 22 or if the PHY uses its own non-standard access mechanism.
Quoted 6 lines
Quoted 4 lines
2. The standard clause 45 access extensions to the MMD registers through the indirection registers (clause 22) in all the other cases.
Signed-off-by Carlo Caione <[email protected]>This seems like a duplicate of https://patchwork.ozlabs.org/patch/1015782/
Well, I should have looked better. Interestingly I was going to use my patch to fix the exact same issue on a different PHY.
The problem I see with that patch is that it is assuming that all the PHY devices support clause 45 access extension using the clause 22 registers. This is not always true (see for example [0]). That's why I added two new hooks in the PHY driver.
On a side note looking at that patch it seems that 'addr' (documented as the PHY address in the same patch) is being passed to 'phy_write' where we should have the 'devad' parameter instead (MDIO_DEVAD_NONE)?
Quoted 1 line
The command patch should probably be adapted to use that.
Let me know if you think it is valuable still to add the two hooks on top of that patch.
Thanks,
[0] https://patchwork.ozlabs.org/patch/351634/
Signature · 1 line
Carlo Caione
PATCH 1/2 net: phy: Add support for accessing MMD PHY registers
Quoted 21 lines · Carlo Caione
Quoted 12 lines · Joe Hershberger
Quoted 11 lines · Carlo Caione
Two new helper functions (
phy_read_mmd()andphy_write_mmd()) are added to allow access to the MMD PHY registers.The MMD PHY registers can be accessed by two means:
1. Using two new MMD access function hooks in the PHY driver. These functions can be implemented when the PHY driver does not support the standard IEEE Compatible clause 45 access mechanism described in clause 22 or if the PHY uses its own non-standard access mechanism.
Quoted 6 lines
Quoted 4 lines
2. The standard clause 45 access extensions to the MMD registers through the indirection registers (clause 22) in all the other cases.
Signed-off-by Carlo Caione <[email protected]>This seems like a duplicate of https://patchwork.ozlabs.org/patch/1015782/
Quoted 7 lines
Well, I should have looked better. Interestingly I was going to use my patch to fix the exact same issue on a different PHY.
The problem I see with that patch is that it is assuming that all the PHY devices support clause 45 access extension using the clause 22 registers. This is not always true (see for example [0]). That's why I added two new hooks in the PHY driver.
Ah, I didn't realize there were other ways to access it.
Quoted 3 lines
On a side note looking at that patch it seems that 'addr' (documented as the PHY address in the same patch) is being passed to '
phy_write' where we should have the 'devad' parameter instead (MDIO_DEVAD_NONE)?
That is peculiar... Vlad, that wasn't your intent, was it?
Quoted 4 lines
Quoted 1 line
The command patch should probably be adapted to use that.
Let me know if you think it is valuable still to add the two hooks on top of that patch.
If we have to override the access then probably so. Maybe it would make more sense to have a v2 from you that removes the duplicate code from the ti phy driver and then have Vlad's smartEEE patch be rebased on that.
I have not yet pushed Vlad's patches so we have an opportunity to do it more cleanly potentially.
Thoughts from each of you?
Quoted 10 lines
Thanks,
[0] https://patchwork.ozlabs.org/patch/351634/
--
Carlo Caione
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 1/2 net: phy: Add support for accessing MMD PHY registers
Quoted 10 lines · Joe Hershberger
If we have to override the access then probably so. Maybe it would make more sense to have a v2 from you that removes the duplicate code from the ti phy driver and then have Vlad's smartEEE patch be rebased on that.
I have not yet pushed Vlad's patches so we have an opportunity to do it more cleanly potentially.
Thoughts from each of you?
I'll rebase that patch on top of my set and I'll let Vlad submit the smartEEE patch on top.
Signature · 1 line
Carlo Caione
PATCH 1/2 net: phy: Add support for accessing MMD PHY registers
Quoted 7 lines · Carlo Caione
Quoted 6 lines · Joe Hershberger
If we have to override the access then probably so. Maybe it would make more sense to have a v2 from you that removes the duplicate code from the ti phy driver and then have Vlad's smartEEE patch be rebased on that.
Quoted 8 lines
Quoted 4 lines
I have not yet pushed Vlad's patches so we have an opportunity to do it more cleanly potentially.
Thoughts from each of you?
I'll rebase that patch on top of my set and I'll let Vlad submit the smartEEE patch on top.
Hi Carlo, good if you could take care of the TI driver and I will resend the Atheros SmartEEE patch to use phy_read_mmd/phy_write_mmd.
Thanks,
-Vladimir
PATCH 1/2 net: phy: Add support for accessing MMD PHY registers
Quoted 12 lines · Vladimir Oltean
Quoted 10 lines · Carlo Caione
Quoted 9 lines · Joe Hershberger
If we have to override the access then probably so. Maybe it would make more sense to have a v2 from you that removes the duplicate code from the ti phy driver and then have Vlad's smartEEE patch be rebased on that.
I have not yet pushed Vlad's patches so we have an opportunity to do it more cleanly potentially.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Thoughts from each of you?
I'll rebase that patch on top of my set and I'll let Vlad submit the smartEEE patch on top.
Hi Carlo, good if you could take care of the TI driver and I will resend the Atheros SmartEEE patch to use phy_read_mmd/phy_write_mmd.
He's already sent a V1 that you could base off of. The changes I requested should not make it incompatible with your Atheros change.
Thanks,
-Joe
Quoted 7 lines
Thanks,
-Vladimir
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 2/2 cmd: mdio: Add new parameter to access MMD PHY registers
In reply to Carlo CaioneTwo new parameters (rmmd and wmmd) are added to allow the mdio command to access the content of the MMD PHY registers.
--- cmd/mdio.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-)
cmd/mdio.c +27 -6
@@ -43,7 +43,7 @@ static int mdio_write_ranges(struct phy_device *phydev, struct mii_dev *bus,int addrlo, int addrhi, int devadlo, int devadhi, int reglo, int reghi, unsigned short data, - int extended) + int extended, int mmd) { int addr, devad, reg;int err =0 ;
@@ -51,7 +51,9 @@ static int mdio_write_ranges(struct phy_device *phydev, struct mii_dev *bus,for (addr = addrlo; addr <= addrhi; addr++) {for (devad = devadlo; devad <= devadhi; devad++) {for (reg = reglo; reg <= reghi; reg++) { -if (!extended) +if (mmd) + err =phy_write_mmd (phydev, devad, reg, data); +else if (!extended) err = bus->write (bus, addr, devad, reg, data);else
@@ -71,7 +73,7 @@ err_out:static int mdio_read_ranges (struct phy_device *phydev,struct mii_dev *bus,int addrlo,int addrhi,int devadlo,int devadhi, -int reglo,int reghi,int extended) +int reglo,int reghi,int extended,int mmd) {int addr, devad, reg;
@@ -83,7 +85,9 @@ static int mdio_read_ranges(struct phy_device *phydev, struct mii_dev *bus,for (reg = reglo; reg <= reghi; reg++) {int val; -if (!extended) +if (mmd) + val =phy_read_mmd (phydev, devad, reg); +else if (!extended) val = bus->read (bus, addr, devad, reg);else val = phydev->drv->readext(phydev, addr,
@@ -189,6 +193,7 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])struct mii_dev *bus;struct phy_device *phydev =NULL ;int extended =0 ; +int mmd =0 ;if (argc <2 )return CMD_RET_USAGE ;
@@ -232,6 +237,18 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return -1 ; } } +if (op[1 ] =='m' ) { + phydev =mdio_phydev_for_ethname (argv[2 ]); + +if (phydev) { + addrlo = phydev->addr; + addrhi = addrlo; + bus = phydev->bus; + mmd =1 ; + }else { +return -1 ; + } + } }switch (op[0 ]) {
@@ -265,12 +282,12 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])switch (op[0 ]) {case 'w' :mdio_write_ranges (phydev, bus, addrlo, addrhi, devadlo, devadhi, - reglo, reghi, data, extended); + reglo, reghi, data, extended, mmd);break ;case 'r' :mdio_read_ranges (phydev, bus, addrlo, addrhi, devadlo, devadhi, - reglo, reghi, extended); + reglo, reghi, extended, mmd);break ; }
@@ -303,6 +320,10 @@ U_BOOT_CMD("read PHY's extended register at <devad>.<reg>\n" "mdio wx <phydev> [<devad>.]<reg> <data> - " "write PHY's extended register at <devad>.<reg>\n" +"mdio rmmd <phydev> [<devad>.]<reg> - " +"read PHY's extended register at <devad>.<reg>\n" +"mdio wmmd <phydev> [<devad>.]<reg> <data> - " +"write PHY's extended register at <devad>.<reg>\n" "<phydev> may be:\n" " <busname> <addr>\n" " <addr>\n"
Signature · 1 line
2.19.1