]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
Xilinx: ARM: net: Add xgmac support for the mii command
authorJoe Hershberger <joe.hershberger@ni.com>
Thu, 23 Feb 2012 16:08:07 +0000 (10:08 -0600)
committerJagan <jaganna@xilinx.com>
Thu, 31 May 2012 07:39:58 +0000 (13:09 +0530)
This allows the MII command to access phys connected to the xgmac

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
board/xilinx/dfe/xgmac.c

index e6effda6152a4751dc33d738be071e18ed7b98bb..152ee9a0be0e9ffefd747f639f0a7a64213d4600 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <common.h>
 #include <malloc.h>
+#include <miiphy.h>
 #include <net.h>
 
 #include "xemacpss.h"
@@ -63,6 +64,26 @@ int Xgmac_phy_mgmt_idle(XEmacPss * EmacPssInstancePtr)
                 & XEMACPSS_NWSR_MDIOIDLE_MASK) == XEMACPSS_NWSR_MDIOIDLE_MASK);
 }
 
+#if defined(CONFIG_CMD_MII) && !defined(CONFIG_BITBANGMII)
+static int Xgmac_mii_read(const char *devname, unsigned char addr,
+               unsigned char reg, unsigned short *value)
+{
+       phy_spinwait(&EmacPssInstance);
+       XEmacPss_PhyRead(&EmacPssInstance, addr, reg, value);
+       phy_spinwait(&EmacPssInstance);
+       return 0;
+}
+
+static int Xgmac_mii_write(const char *devname, unsigned char addr,
+               unsigned char reg, unsigned short value)
+{
+       phy_spinwait(&EmacPssInstance);
+       XEmacPss_PhyWrite(&EmacPssInstance, addr, reg, value);
+       phy_spinwait(&EmacPssInstance);
+       return 0;
+}
+#endif
+
 static u32 phy_rd(XEmacPss * e, u32 a)
 {
        u16 PhyData;
@@ -484,6 +505,9 @@ int Xgmac_register(bd_t * bis)
 
        eth_register(dev);
 
+#if defined(CONFIG_CMD_MII) && !defined(CONFIG_BITBANGMII)
+       miiphy_register(dev->name, Xgmac_mii_read, Xgmac_mii_write);
+#endif
        return 0;
 }