[U-Boot] [PATCH] mii: dump: parameter choice

Stephan Bauroth stephan.bauroth at iav.de
Mon Aug 12 13:05:05 CEST 2013


Hi all,

since no one commented on my prior mail, i just took the liberty to write 
a little patch that chooses regs 0-5 if none are specified for 'mii dump'. 
Also fixes some alignment issues, typos and introduces the 'Selector 
Field' to the register description of PHY regs 4 and 5. On top, 'mii dump' 
now prints the PHY address in front of a register dump.

this is my first patch, if anything is wrong, plese tell me :)

diff --git a/common/cmd_mii.c b/common/cmd_mii.c
index d3dd6b1..1856c5b 100644
--- a/common/cmd_mii.c
+++ b/common/cmd_mii.c
@@ -78,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"              },
@@ -88,7 +88,7 @@ static const MII_field_desc_t reg_4_desc_tbl[] = {
        {  7,  7, 0x01, "100BASE-TX able"              },
        {  6,  6, 0x01, "10BASE-T   full duplex able"  },
        {  5,  5, 0x01, "10BASE-T   able"              },
-       {  4,  0, 0x1f, "xxx to do"                    },
+       {  4,  0, 0x1f, "Selector Field"               },
 };
 
 static const MII_field_desc_t reg_5_desc_tbl[] = {
@@ -103,7 +103,7 @@ static const MII_field_desc_t reg_5_desc_tbl[] = {
        {  7,  7, 0x01, "100BASE-TX able"              },
        {  6,  6, 0x01, "10BASE-T full duplex able"    },
        {  5,  5, 0x01, "10BASE-T able"                },
-       {  4,  0, 0x1f, "xxx to do"                    },
+       {  4,  0, 0x1f, "Selctor Field"                },
 };
 typedef struct _MII_field_desc_and_len_t {
        const MII_field_desc_t *pdesc;
@@ -130,6 +130,7 @@ static int special_field(
        ushort regval);
 
 static void MII_dump_0_to_5(
+       unsigned char addr,
        ushort regvals[6],
        uchar reglo,
        uchar reghi)
@@ -138,6 +139,7 @@ static void MII_dump_0_to_5(
 
        for (i = 0; i < 6; i++) {
                if ((reglo <= i) && (i <= reghi))
+                       printf("%02x.", addr);
                        dump_reg(regvals[i], &reg_0_5_desc_tbl[i],
                                &desc_and_len_tbl[i]);
        }
@@ -218,7 +220,7 @@ static int special_field(
 
        else if ((regno == MII_ADVERTISE) && (pdesc->lo == 0)) {
                ushort sel_bits = (regval >> pdesc->lo) & pdesc->mask;
-               printf("%2u-%2u = %5u    selector = %s",
+               printf("%2u-%2u = %5u    Selector Field = %s",
                        pdesc->hi, pdesc->lo, sel_bits,
                        sel_bits == PHY_ANLPAR_PSB_802_3 ?
                                "IEEE 802.3" :
@@ -230,7 +232,7 @@ static int special_field(
 
        else if ((regno == MII_LPA) && (pdesc->lo == 0)) {
                ushort sel_bits = (regval >> pdesc->lo) & pdesc->mask;
-               printf("%2u-%2u =     %u    selector = %s",
+               printf("%2u-%2u = %5u    Selector Field = %s",
                        pdesc->hi, pdesc->lo, sel_bits,
                        sel_bits == PHY_ANLPAR_PSB_802_3 ?
                                "IEEE 802.3" :
@@ -384,6 +386,10 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int 
argc, char * const argv[])
                                "standard MII registers, 0-5.\n");
                        return 1;
                }
+               if (argc < 4){  /* no reg-range given -> dump 0 to 5 */
+                       reglo = 0;
+                       reghi = 5;
+               }
                for (addr = addrlo; addr <= addrhi; addr++) {
                        for (reg = reglo; reg < reghi + 1; reg++) {
                                if (miiphy_read(devname, addr, reg, 
&regs[reg]) != 0) {
@@ -394,8 +400,9 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int 
argc, char * const argv[])
                                        rcode = 1;
                                }
                        }
-                       if (ok)
-                               MII_dump_0_to_5(regs, reglo, reghi);
+                       if (ok) {
+                               MII_dump_0_to_5(addr, regs, reglo, reghi);
+                       }
                        printf("\n");
                }
        } else if (strncmp(op, "de", 2) == 0) { 


More information about the U-Boot mailing list