Merge branches 'clk-mvebu', 'clk-const', 'clk-imx' and 'clk-rockchip' into clk-next
[linux-2.6-microblaze.git] / drivers / net / ethernet / stmicro / stmmac / stmmac_ethtool.c
index 164dff5..abfb3cd 100644 (file)
 #include "dwxgmac2.h"
 
 #define REG_SPACE_SIZE 0x1060
+#define GMAC4_REG_SPACE_SIZE   0x116C
 #define MAC100_ETHTOOL_NAME    "st_mac100"
 #define GMAC_ETHTOOL_NAME      "st_gmac"
 #define XGMAC_ETHTOOL_NAME     "st_xgmac"
 
+/* Same as DMA_CHAN_BASE_ADDR defined in dwmac4_dma.h
+ *
+ * It is here because dwmac_dma.h and dwmac4_dam.h can not be included at the
+ * same time due to the conflicting macro names.
+ */
+#define GMAC4_DMA_CHAN_BASE_ADDR  0x00001100
+
 #define ETHTOOL_DMA_OFFSET     55
 
 struct stmmac_stats {
@@ -434,6 +442,8 @@ static int stmmac_ethtool_get_regs_len(struct net_device *dev)
 
        if (priv->plat->has_xgmac)
                return XGMAC_REGSIZE * 4;
+       else if (priv->plat->has_gmac4)
+               return GMAC4_REG_SPACE_SIZE;
        return REG_SPACE_SIZE;
 }
 
@@ -446,8 +456,13 @@ static void stmmac_ethtool_gregs(struct net_device *dev,
        stmmac_dump_mac_regs(priv, priv->hw, reg_space);
        stmmac_dump_dma_regs(priv, priv->ioaddr, reg_space);
 
-       if (!priv->plat->has_xgmac) {
-               /* Copy DMA registers to where ethtool expects them */
+       /* Copy DMA registers to where ethtool expects them */
+       if (priv->plat->has_gmac4) {
+               /* GMAC4 dumps its DMA registers at its DMA_CHAN_BASE_ADDR */
+               memcpy(&reg_space[ETHTOOL_DMA_OFFSET],
+                      &reg_space[GMAC4_DMA_CHAN_BASE_ADDR / 4],
+                      NUM_DWMAC4_DMA_REGS * 4);
+       } else if (!priv->plat->has_xgmac) {
                memcpy(&reg_space[ETHTOOL_DMA_OFFSET],
                       &reg_space[DMA_BUS_MODE / 4],
                       NUM_DWMAC1000_DMA_REGS * 4);