]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
common: miiphyutil: Work and report phy address in hex in mdio cmd
authorMichal Simek <michal.simek@xilinx.com>
Wed, 16 Nov 2016 07:41:01 +0000 (08:41 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Fri, 2 Dec 2016 13:36:02 +0000 (14:36 +0100)
It is confusing that mdio commands work and report phy id as
decimal value when mii is working with hex values.

For example:
ZynqMP> mdio list
gem:
21 - TI DP83867 <--> ethernet@ff0e0000
ZynqMP> mdio read ethernet@ff0e0000 0
Reading from bus gem
PHY at address 21:
0 - 0x1140
ZynqMP> mii dump 21 0
Incorrect PHY address. Range should be 0-31
...
ZynqMP> mii dump 15
0.     (1140)                 -- PHY control register --
  (8000:0000) 0.15    =     0    reset

U-Boot normally takes hex values that's why this patch is changing mdio
command to handle hex instead of changing mii command to handle decimal
values.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
cmd/mdio.c
common/miiphyutil.c
drivers/net/zynq_gem.c

index fb13d050752a7f2abeb615101e76046257477fe5..21dc103736e7f8bbc67b6dfea2a240ecd34662a3 100644 (file)
@@ -27,12 +27,12 @@ static uint last_reg_hi;
 static int extract_range(char *input, int *plo, int *phi)
 {
        char *end;
-       *plo = simple_strtol(input, &end, 0);
+       *plo = simple_strtol(input, &end, 16);
        if (end == input)
                return -1;
 
        if ((*end == '-') && *(++end))
-               *phi = simple_strtol(end, NULL, 0);
+               *phi = simple_strtol(end, NULL, 16);
        else if (*end == '\0')
                *phi = *plo;
        else
@@ -79,7 +79,7 @@ static int mdio_read_ranges(struct phy_device *phydev, struct mii_dev *bus,
 
        printf("Reading from bus %s\n", bus->name);
        for (addr = addrlo; addr <= addrhi; addr++) {
-               printf("PHY at address %d:\n", addr);
+               printf("PHY at address %x:\n", addr);
 
                for (devad = devadlo; devad <= devadhi; devad++) {
                        for (reg = reglo; reg <= reghi; reg++) {
index d8ebb384dbfa82012284edea1999fd6ddc0c325f..aca18db52a008baaf9b393625f7bfebe1e2abf9a 100644 (file)
@@ -135,7 +135,7 @@ void mdio_list_devices(void)
                        struct phy_device *phydev = bus->phymap[i];
 
                        if (phydev) {
-                               printf("%d - %s", i, phydev->drv->name);
+                               printf("%x - %s", i, phydev->drv->name);
 
                                if (phydev->dev)
                                        printf(" <--> %s\n", phydev->dev->name);
index 3319e10467d0a36c29e0d962428bf01a542c6684..526eac658ac5da5b382575b2d41c5e209cc3b997 100644 (file)
@@ -706,7 +706,7 @@ static int zynq_gem_ofdata_to_platdata(struct udevice *dev)
 
        priv->emio = fdtdec_get_bool(gd->fdt_blob, dev->of_offset, "xlnx,emio");
 
-       printf("ZYNQ GEM: %lx, phyaddr %d, interface %s\n", (ulong)priv->iobase,
+       printf("ZYNQ GEM: %lx, phyaddr %x, interface %s\n", (ulong)priv->iobase,
               priv->phyaddr, phy_string_for_interface(priv->interface));
 
        return 0;