net: stmmac: dwmac100: Add MAC loopback support
authorJose Abreu <Jose.Abreu@synopsys.com>
Fri, 24 May 2019 08:20:10 +0000 (10:20 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 24 May 2019 20:45:56 +0000 (13:45 -0700)
In preparation for the addition of stmmac selftests we implement the MAC
loopback callback in dwmac100 core.

Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c

index b735143987e143cc636ce06488d46423b0200bdb..d621b5189c41e6816d92ffc59e96d4ba3dd881f1 100644 (file)
@@ -160,6 +160,18 @@ static void dwmac100_pmt(struct mac_device_info *hw, unsigned long mode)
        return;
 }
 
+static void dwmac100_set_mac_loopback(void __iomem *ioaddr, bool enable)
+{
+       u32 value = readl(ioaddr + MAC_CONTROL);
+
+       if (enable)
+               value |= MAC_CONTROL_OM;
+       else
+               value &= ~MAC_CONTROL_OM;
+
+       writel(value, ioaddr + MAC_CONTROL);
+}
+
 const struct stmmac_ops dwmac100_ops = {
        .core_init = dwmac100_core_init,
        .set_mac = stmmac_set_mac,
@@ -171,6 +183,7 @@ const struct stmmac_ops dwmac100_ops = {
        .pmt = dwmac100_pmt,
        .set_umac_addr = dwmac100_set_umac_addr,
        .get_umac_addr = dwmac100_get_umac_addr,
+       .set_mac_loopback = dwmac100_set_mac_loopback,
 };
 
 int dwmac100_setup(struct stmmac_priv *priv)