[U-Boot] [PATCH v2 3/3] cmd: mdio: Add new parameter to access MMD PHY registers
Carlo Caione
ccaione at baylibre.com
Wed Jan 23 13:13:14 UTC 2019
Two new parameters (rmmd and wmmd) are added to allow the `mdio` command
to access the content of the MMD PHY registers.
Signed-off-by: Carlo Caione <ccaione at baylibre.com>
---
cmd/mdio.c | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/cmd/mdio.c b/cmd/mdio.c
index 184868063a..010632b562 100644
--- a/cmd/mdio.c
+++ b/cmd/mdio.c
@@ -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"
--
2.19.1
More information about the U-Boot
mailing list