summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/cmd_mii.c10
-rw-r--r--common/miiphyutil.c13
2 files changed, 13 insertions, 10 deletions
diff --git a/common/cmd_mii.c b/common/cmd_mii.c
index 18fad1e34f..94874ddfe0 100644
--- a/common/cmd_mii.c
+++ b/common/cmd_mii.c
@@ -81,7 +81,7 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
* check info/read/write.
*/
if (op == 'i') {
- int j;
+ unsigned char j, start, end;
unsigned int oui;
unsigned char model;
unsigned char rev;
@@ -89,7 +89,13 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
/*
* Look for any and all PHYs. Valid addresses are 0..31.
*/
- for (j = 0; j < 32; j++) {
+ if (argc >= 3) {
+ start = addr; end = addr + 1;
+ } else {
+ start = 0; end = 32;
+ }
+
+ for (j = start; j < end; j++) {
if (miiphy_info (j, &oui, &model, &rev) == 0) {
printf ("PHY 0x%02X: "
"OUI = 0x%04X, "
diff --git a/common/miiphyutil.c b/common/miiphyutil.c
index 75c2df5cae..af8c7c7a31 100644
--- a/common/miiphyutil.c
+++ b/common/miiphyutil.c
@@ -47,19 +47,15 @@ int miiphy_info (unsigned char addr,
unsigned char *model, unsigned char *rev)
{
unsigned int reg = 0;
+ unsigned short tmp;
- /*
- * Trick: we are reading two 16 registers into a 32 bit variable
- * so we do a 16 read into the high order bits of the variable (big
- * endian, you know), shift it down 16 bits, and the read the rest.
- */
- if (miiphy_read (addr, PHY_PHYIDR2, (unsigned short *) &reg) != 0) {
+ if (miiphy_read (addr, PHY_PHYIDR2, &tmp) != 0) {
#ifdef DEBUG
printf ("PHY ID register 2 read failed\n");
#endif
return (-1);
}
- reg >>= 16;
+ reg = tmp;
#ifdef DEBUG
printf ("PHY_PHYIDR2 @ 0x%x = 0x%04x\n", addr, reg);
@@ -69,12 +65,13 @@ int miiphy_info (unsigned char addr,
return (-1);
}
- if (miiphy_read (addr, PHY_PHYIDR1, (unsigned short *) &reg) != 0) {
+ if (miiphy_read (addr, PHY_PHYIDR1, &tmp) != 0) {
#ifdef DEBUG
printf ("PHY ID register 1 read failed\n");
#endif
return (-1);
}
+ reg |= tmp << 16;
#ifdef DEBUG
printf ("PHY_PHYIDR[1,2] @ 0x%x = 0x%08x\n", addr, reg);
#endif
OpenPOWER on IntegriCloud