[U-Boot] [PATCH v2 3/3] cmd: mdio: Add new parameter to access MMD PHY registers
Joe Hershberger
joe.hershberger at ni.com
Wed Jan 23 14:01:24 UTC 2019
On Wed, Jan 23, 2019 at 7:15 AM Carlo Caione <ccaione at baylibre.com> wrote:
>
> 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)
Please don't keep the negative logic and switch these last two.
> 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)
Please don't keep the negative logic and switch these last two.
> 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;
Please use a valid command response macro. CMD_RET_FAILURE in this
case. Feel free to fix it in the other places in this command as well.
> + }
> + }
> }
>
> 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
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot
More information about the U-Boot
mailing list