]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/cmd_mii.c
bootstage: powerpc: support fdt stash and reporting
[karo-tx-uboot.git] / common / cmd_mii.c
index 3fb0795c3f6911855f4031333d6e2f8d257d671e..b82a7ce612c2a23df0bf24823025c5955a7401ff 100644 (file)
@@ -2,23 +2,7 @@
  * (C) Copyright 2001
  * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
@@ -35,12 +19,12 @@ typedef struct _MII_reg_desc_t {
 } MII_reg_desc_t;
 
 static const MII_reg_desc_t reg_0_5_desc_tbl[] = {
-       { 0,   "PHY control register"                },
-       { 1,   "PHY status register"                 },
-       { 2,   "PHY ID 1 register"                   },
-       { 3,   "PHY ID 2 register"                   },
-       { 4,   "Autonegotiation advertisement register" },
-       { 5,   "Autonegotiation partner abilities register" },
+       { MII_BMCR,      "PHY control register" },
+       { MII_BMSR,      "PHY status register" },
+       { MII_PHYSID1,   "PHY ID 1 register" },
+       { MII_PHYSID2,   "PHY ID 2 register" },
+       { MII_ADVERTISE, "Autonegotiation advertisement register" },
+       { MII_LPA,       "Autonegotiation partner abilities register" },
 };
 
 typedef struct _MII_field_desc_t {
@@ -94,9 +78,9 @@ static const MII_field_desc_t reg_3_desc_tbl[] = {
 
 static const MII_field_desc_t reg_4_desc_tbl[] = {
        { 15, 15, 0x01, "next page able"               },
-       { 14, 14, 0x01, "reserved"                     },
+       { 14, 14, 0x01, "(reserved)"                   },
        { 13, 13, 0x01, "remote fault"                 },
-       { 12, 12, 0x01, "reserved"                     },
+       { 12, 12, 0x01, "(reserved)"                   },
        { 11, 11, 0x01, "asymmetric pause"             },
        { 10, 10, 0x01, "pause enable"                 },
        {  9,  9, 0x01, "100BASE-T4 able"              },
@@ -212,20 +196,19 @@ static int special_field(
        const MII_field_desc_t *pdesc,
        ushort regval)
 {
-       if ((regno == 0) && (pdesc->lo == 6)) {
-               ushort speed_bits = regval & PHY_BMCR_SPEED_MASK;
+       if ((regno == MII_BMCR) && (pdesc->lo == 6)) {
+               ushort speed_bits = regval & (BMCR_SPEED1000 | BMCR_SPEED100);
                printf("%2u,%2u =   b%u%u    speed selection = %s Mbps",
                        6, 13,
                        (regval >>  6) & 1,
                        (regval >> 13) & 1,
-                       speed_bits == PHY_BMCR_1000_MBPS ? "1000" :
-                       speed_bits == PHY_BMCR_100_MBPS  ? "100" :
-                       speed_bits == PHY_BMCR_10_MBPS   ? "10" :
-                       "???");
+                       speed_bits == BMCR_SPEED1000 ? "1000" :
+                       speed_bits == BMCR_SPEED100  ? "100" :
+                       "10");
                return 1;
        }
 
-       else if ((regno == 0) && (pdesc->lo == 8)) {
+       else if ((regno == MII_BMCR) && (pdesc->lo == 8)) {
                printf("%2u    = %5u    duplex = %s",
                        pdesc->lo,
                        (regval >>  pdesc->lo) & 1,
@@ -233,7 +216,7 @@ static int special_field(
                return 1;
        }
 
-       else if ((regno == 4) && (pdesc->lo == 0)) {
+       else if ((regno == MII_ADVERTISE) && (pdesc->lo == 0)) {
                ushort sel_bits = (regval >> pdesc->lo) & pdesc->mask;
                printf("%2u-%2u = %5u    selector = %s",
                        pdesc->hi, pdesc->lo, sel_bits,
@@ -245,7 +228,7 @@ static int special_field(
                return 1;
        }
 
-       else if ((regno == 5) && (pdesc->lo == 0)) {
+       else if ((regno == MII_LPA) && (pdesc->lo == 0)) {
                ushort sel_bits = (regval >> pdesc->lo) & pdesc->mask;
                printf("%2u-%2u =     %u    selector = %s",
                        pdesc->hi, pdesc->lo, sel_bits,
@@ -294,7 +277,7 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        const char      *devname;
 
        if (argc < 2)
-               return cmd_usage(cmdtp);
+               return CMD_RET_USAGE;
 
 #if defined(CONFIG_MII_INIT)
        mii_init ();
@@ -421,7 +404,7 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                else
                        miiphy_set_current_dev (argv[2]);
        } else {
-               return cmd_usage(cmdtp);
+               return CMD_RET_USAGE;
        }
 
        /*