stmmac: rework get_hw_feature function
authorAlexandre TORGUE <alexandre.torgue@st.com>
Fri, 1 Apr 2016 09:37:25 +0000 (11:37 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 3 Apr 2016 00:23:07 +0000 (20:23 -0400)
On next GMAC IP generation (4.xx), the way to get hw feature
is not the same than on previous 3.xx. As it is hardware
dependent, the way to get hw capabilities should be defined in dma ops of
each MAC IP. It will avoid also a huge computation of hw capabilities in
stmmac_main.

Signed-off-by: Alexandre TORGUE <alexandre.torgue@st.com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/common.h
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index f96d257308b0f5e1c22ab37c0e551fe5d3847b0f..797a913ef618d772eae23504cfaeae22839a3b3c 100644 (file)
@@ -412,7 +412,8 @@ struct stmmac_dma_ops {
        int (*dma_interrupt) (void __iomem *ioaddr,
                              struct stmmac_extra_stats *x);
        /* If supported then get the optional core features */
-       unsigned int (*get_hw_feature) (void __iomem *ioaddr);
+       void (*get_hw_feature)(void __iomem *ioaddr,
+                              struct dma_features *dma_cap);
        /* Program the HW RX Watchdog */
        void (*rx_watchdog) (void __iomem *ioaddr, u32 riwt);
 };
index da32d6037e3e4baacfe2d9ef4723029873d641e7..9907469552169094a2fea15812021dde40b4e8e8 100644 (file)
@@ -215,9 +215,40 @@ static void dwmac1000_dump_dma_regs(void __iomem *ioaddr)
        }
 }
 
-static unsigned int dwmac1000_get_hw_feature(void __iomem *ioaddr)
+static void dwmac1000_get_hw_feature(void __iomem *ioaddr,
+                                    struct dma_features *dma_cap)
 {
-       return readl(ioaddr + DMA_HW_FEATURE);
+       u32 hw_cap = readl(ioaddr + DMA_HW_FEATURE);
+
+       dma_cap->mbps_10_100 = (hw_cap & DMA_HW_FEAT_MIISEL);
+       dma_cap->mbps_1000 = (hw_cap & DMA_HW_FEAT_GMIISEL) >> 1;
+       dma_cap->half_duplex = (hw_cap & DMA_HW_FEAT_HDSEL) >> 2;
+       dma_cap->hash_filter = (hw_cap & DMA_HW_FEAT_HASHSEL) >> 4;
+       dma_cap->multi_addr = (hw_cap & DMA_HW_FEAT_ADDMAC) >> 5;
+       dma_cap->pcs = (hw_cap & DMA_HW_FEAT_PCSSEL) >> 6;
+       dma_cap->sma_mdio = (hw_cap & DMA_HW_FEAT_SMASEL) >> 8;
+       dma_cap->pmt_remote_wake_up = (hw_cap & DMA_HW_FEAT_RWKSEL) >> 9;
+       dma_cap->pmt_magic_frame = (hw_cap & DMA_HW_FEAT_MGKSEL) >> 10;
+       /* MMC */
+       dma_cap->rmon = (hw_cap & DMA_HW_FEAT_MMCSEL) >> 11;
+       /* IEEE 1588-2002 */
+       dma_cap->time_stamp =
+           (hw_cap & DMA_HW_FEAT_TSVER1SEL) >> 12;
+       /* IEEE 1588-2008 */
+       dma_cap->atime_stamp = (hw_cap & DMA_HW_FEAT_TSVER2SEL) >> 13;
+       /* 802.3az - Energy-Efficient Ethernet (EEE) */
+       dma_cap->eee = (hw_cap & DMA_HW_FEAT_EEESEL) >> 14;
+       dma_cap->av = (hw_cap & DMA_HW_FEAT_AVSEL) >> 15;
+       /* TX and RX csum */
+       dma_cap->tx_coe = (hw_cap & DMA_HW_FEAT_TXCOESEL) >> 16;
+       dma_cap->rx_coe_type1 = (hw_cap & DMA_HW_FEAT_RXTYP1COE) >> 17;
+       dma_cap->rx_coe_type2 = (hw_cap & DMA_HW_FEAT_RXTYP2COE) >> 18;
+       dma_cap->rxfifo_over_2048 = (hw_cap & DMA_HW_FEAT_RXFIFOSIZE) >> 19;
+       /* TX and RX number of channels */
+       dma_cap->number_rx_channel = (hw_cap & DMA_HW_FEAT_RXCHCNT) >> 20;
+       dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
+       /* Alternate (enhanced) DESC mode */
+       dma_cap->enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;
 }
 
 static void dwmac1000_rx_watchdog(void __iomem *ioaddr, u32 riwt)
index 78464fa7fe1f2ecfe93fbaa00e9b300f550cfded..b5db7513f36f73cc13fba9750dbc22091a28d325 100644 (file)
@@ -1552,51 +1552,15 @@ static void stmmac_selec_desc_mode(struct stmmac_priv *priv)
  */
 static int stmmac_get_hw_features(struct stmmac_priv *priv)
 {
-       u32 hw_cap = 0;
+       u32 ret = 0;
 
        if (priv->hw->dma->get_hw_feature) {
-               hw_cap = priv->hw->dma->get_hw_feature(priv->ioaddr);
-
-               priv->dma_cap.mbps_10_100 = (hw_cap & DMA_HW_FEAT_MIISEL);
-               priv->dma_cap.mbps_1000 = (hw_cap & DMA_HW_FEAT_GMIISEL) >> 1;
-               priv->dma_cap.half_duplex = (hw_cap & DMA_HW_FEAT_HDSEL) >> 2;
-               priv->dma_cap.hash_filter = (hw_cap & DMA_HW_FEAT_HASHSEL) >> 4;
-               priv->dma_cap.multi_addr = (hw_cap & DMA_HW_FEAT_ADDMAC) >> 5;
-               priv->dma_cap.pcs = (hw_cap & DMA_HW_FEAT_PCSSEL) >> 6;
-               priv->dma_cap.sma_mdio = (hw_cap & DMA_HW_FEAT_SMASEL) >> 8;
-               priv->dma_cap.pmt_remote_wake_up =
-                   (hw_cap & DMA_HW_FEAT_RWKSEL) >> 9;
-               priv->dma_cap.pmt_magic_frame =
-                   (hw_cap & DMA_HW_FEAT_MGKSEL) >> 10;
-               /* MMC */
-               priv->dma_cap.rmon = (hw_cap & DMA_HW_FEAT_MMCSEL) >> 11;
-               /* IEEE 1588-2002 */
-               priv->dma_cap.time_stamp =
-                   (hw_cap & DMA_HW_FEAT_TSVER1SEL) >> 12;
-               /* IEEE 1588-2008 */
-               priv->dma_cap.atime_stamp =
-                   (hw_cap & DMA_HW_FEAT_TSVER2SEL) >> 13;
-               /* 802.3az - Energy-Efficient Ethernet (EEE) */
-               priv->dma_cap.eee = (hw_cap & DMA_HW_FEAT_EEESEL) >> 14;
-               priv->dma_cap.av = (hw_cap & DMA_HW_FEAT_AVSEL) >> 15;
-               /* TX and RX csum */
-               priv->dma_cap.tx_coe = (hw_cap & DMA_HW_FEAT_TXCOESEL) >> 16;
-               priv->dma_cap.rx_coe_type1 =
-                   (hw_cap & DMA_HW_FEAT_RXTYP1COE) >> 17;
-               priv->dma_cap.rx_coe_type2 =
-                   (hw_cap & DMA_HW_FEAT_RXTYP2COE) >> 18;
-               priv->dma_cap.rxfifo_over_2048 =
-                   (hw_cap & DMA_HW_FEAT_RXFIFOSIZE) >> 19;
-               /* TX and RX number of channels */
-               priv->dma_cap.number_rx_channel =
-                   (hw_cap & DMA_HW_FEAT_RXCHCNT) >> 20;
-               priv->dma_cap.number_tx_channel =
-                   (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
-               /* Alternate (enhanced) DESC mode */
-               priv->dma_cap.enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;
-       }
-
-       return hw_cap;
+               priv->hw->dma->get_hw_feature(priv->ioaddr,
+                                             &priv->dma_cap);
+               ret = 1;
+       }
+
+       return ret;
 }
 
 /**