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 <ccai...@baylibre.com> --- cmd/mdio.c | 51 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/cmd/mdio.c b/cmd/mdio.c index 184868063a..f4ae4541e7 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,12 +51,14 @@ 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) - err = bus->write(bus, addr, devad, - reg, data); - else + if (mmd) + err = phy_write_mmd(phydev, devad, reg, data); + else if (extended) err = phydev->drv->writeext(phydev, addr, devad, reg, data); + else + err = bus->write(bus, addr, devad, + reg, data); if (err) goto err_out; @@ -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,11 +85,13 @@ static int mdio_read_ranges(struct phy_device *phydev, struct mii_dev *bus, for (reg = reglo; reg <= reghi; reg++) { int val; - if (!extended) - val = bus->read(bus, addr, devad, reg); - else + if (mmd) + val = phy_read_mmd(phydev, devad, reg); + else if (extended) val = phydev->drv->readext(phydev, addr, devad, reg); + else + val = bus->read(bus, addr, devad, reg); if (val < 0) { printf("Error\n"); @@ -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; @@ -222,14 +227,26 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) bus = phydev->bus; extended = 1; } else { - return -1; + return CMD_RET_FAILURE; } if (!phydev->drv || (!phydev->drv->writeext && (op[0] == 'w')) || (!phydev->drv->readext && (op[0] == 'r'))) { puts("PHY does not have extended functions\n"); - return -1; + return CMD_RET_FAILURE; + } + } + 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 CMD_RET_FAILURE; } } } @@ -242,13 +259,13 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (pos > 1) if (extract_reg_range(argv[pos--], &devadlo, &devadhi, ®lo, ®hi)) - return -1; + return CMD_RET_FAILURE; default: if (pos > 1) if (extract_phy_range(&argv[2], pos - 1, &bus, &phydev, &addrlo, &addrhi)) - return -1; + return CMD_RET_FAILURE; break; } @@ -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 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot