]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: emaclite: Auto-detect phy address when default phy address is wrong
authorJason Wu <jason.wu@petalogix.com>
Mon, 21 May 2012 01:44:48 +0000 (11:44 +1000)
committerMichal Simek <monstr@monstr.eu>
Thu, 27 Sep 2012 07:12:21 +0000 (09:12 +0200)
this feature is not been tested

Signed-off-by: Jason Wu <jason.wu@petalogix.com>
drivers/net/xilinx_emaclite.c

index d0d98932174f3292d56dd1373eef07e2a54a3608..33b47a8f588458aae7c773e1e94dbc80648f2d3b 100644 (file)
@@ -244,6 +244,18 @@ static int setup_phy(struct eth_device *dev)
                        SUPPORTED_100baseT_Half |
                        SUPPORTED_100baseT_Full;
 
+       if (emaclite->phyaddr != -1 ) {
+               phyread(dev, emaclite->phyaddr, PHY_DETECT_REG, &phyreg);
+               if ((phyreg != 0xFFFF) &&
+               ((phyreg & PHY_DETECT_MASK) == PHY_DETECT_MASK)) {
+                       /* Found a valid PHY address */
+                       debug("Default phy address %d is valid\n", emaclite->phyaddr);
+               } else {
+                       debug("PHY address is not setup correctly %d\n", emaclite->phyaddr);
+                       emaclite->phyaddr = -1;
+               }
+       }
+
        if (emaclite->phyaddr == -1) {
                /* detect the PHY address */
                for (i = 31; i >= 0; i--) {