Commit 3b1dd2c5 authored by Jose Abreu's avatar Jose Abreu Committed by David S. Miller

net: stmmac: Switch MMC functions to HWIF callbacks

XGMAC has a different MMC module. Lets use HWIF callbacks for MMC module
so that correct callbacks are automatically selected.
Signed-off-by: default avatarJose 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: default avatarDavid S. Miller <davem@davemloft.net>
parent 8edb1271
...@@ -424,6 +424,7 @@ struct mac_device_info { ...@@ -424,6 +424,7 @@ struct mac_device_info {
const struct stmmac_mode_ops *mode; const struct stmmac_mode_ops *mode;
const struct stmmac_hwtimestamp *ptp; const struct stmmac_hwtimestamp *ptp;
const struct stmmac_tc_ops *tc; const struct stmmac_tc_ops *tc;
const struct stmmac_mmc_ops *mmc;
struct mii_regs mii; /* MII register Addresses */ struct mii_regs mii; /* MII register Addresses */
struct mac_link link; struct mac_link link;
void __iomem *pcsr; /* vpointer to device CSRs */ void __iomem *pcsr; /* vpointer to device CSRs */
......
...@@ -81,6 +81,7 @@ static const struct stmmac_hwif_entry { ...@@ -81,6 +81,7 @@ static const struct stmmac_hwif_entry {
const void *hwtimestamp; const void *hwtimestamp;
const void *mode; const void *mode;
const void *tc; const void *tc;
const void *mmc;
int (*setup)(struct stmmac_priv *priv); int (*setup)(struct stmmac_priv *priv);
int (*quirks)(struct stmmac_priv *priv); int (*quirks)(struct stmmac_priv *priv);
} stmmac_hw[] = { } stmmac_hw[] = {
...@@ -100,6 +101,7 @@ static const struct stmmac_hwif_entry { ...@@ -100,6 +101,7 @@ static const struct stmmac_hwif_entry {
.hwtimestamp = &stmmac_ptp, .hwtimestamp = &stmmac_ptp,
.mode = NULL, .mode = NULL,
.tc = NULL, .tc = NULL,
.mmc = &dwmac_mmc_ops,
.setup = dwmac100_setup, .setup = dwmac100_setup,
.quirks = stmmac_dwmac1_quirks, .quirks = stmmac_dwmac1_quirks,
}, { }, {
...@@ -117,6 +119,7 @@ static const struct stmmac_hwif_entry { ...@@ -117,6 +119,7 @@ static const struct stmmac_hwif_entry {
.hwtimestamp = &stmmac_ptp, .hwtimestamp = &stmmac_ptp,
.mode = NULL, .mode = NULL,
.tc = NULL, .tc = NULL,
.mmc = &dwmac_mmc_ops,
.setup = dwmac1000_setup, .setup = dwmac1000_setup,
.quirks = stmmac_dwmac1_quirks, .quirks = stmmac_dwmac1_quirks,
}, { }, {
...@@ -134,6 +137,7 @@ static const struct stmmac_hwif_entry { ...@@ -134,6 +137,7 @@ static const struct stmmac_hwif_entry {
.hwtimestamp = &stmmac_ptp, .hwtimestamp = &stmmac_ptp,
.mode = NULL, .mode = NULL,
.tc = &dwmac510_tc_ops, .tc = &dwmac510_tc_ops,
.mmc = &dwmac_mmc_ops,
.setup = dwmac4_setup, .setup = dwmac4_setup,
.quirks = stmmac_dwmac4_quirks, .quirks = stmmac_dwmac4_quirks,
}, { }, {
...@@ -151,6 +155,7 @@ static const struct stmmac_hwif_entry { ...@@ -151,6 +155,7 @@ static const struct stmmac_hwif_entry {
.hwtimestamp = &stmmac_ptp, .hwtimestamp = &stmmac_ptp,
.mode = &dwmac4_ring_mode_ops, .mode = &dwmac4_ring_mode_ops,
.tc = &dwmac510_tc_ops, .tc = &dwmac510_tc_ops,
.mmc = &dwmac_mmc_ops,
.setup = dwmac4_setup, .setup = dwmac4_setup,
.quirks = NULL, .quirks = NULL,
}, { }, {
...@@ -168,6 +173,7 @@ static const struct stmmac_hwif_entry { ...@@ -168,6 +173,7 @@ static const struct stmmac_hwif_entry {
.hwtimestamp = &stmmac_ptp, .hwtimestamp = &stmmac_ptp,
.mode = &dwmac4_ring_mode_ops, .mode = &dwmac4_ring_mode_ops,
.tc = &dwmac510_tc_ops, .tc = &dwmac510_tc_ops,
.mmc = &dwmac_mmc_ops,
.setup = dwmac4_setup, .setup = dwmac4_setup,
.quirks = NULL, .quirks = NULL,
}, { }, {
...@@ -185,6 +191,7 @@ static const struct stmmac_hwif_entry { ...@@ -185,6 +191,7 @@ static const struct stmmac_hwif_entry {
.hwtimestamp = &stmmac_ptp, .hwtimestamp = &stmmac_ptp,
.mode = &dwmac4_ring_mode_ops, .mode = &dwmac4_ring_mode_ops,
.tc = &dwmac510_tc_ops, .tc = &dwmac510_tc_ops,
.mmc = &dwmac_mmc_ops,
.setup = dwmac4_setup, .setup = dwmac4_setup,
.quirks = NULL, .quirks = NULL,
}, { }, {
...@@ -202,6 +209,7 @@ static const struct stmmac_hwif_entry { ...@@ -202,6 +209,7 @@ static const struct stmmac_hwif_entry {
.hwtimestamp = &stmmac_ptp, .hwtimestamp = &stmmac_ptp,
.mode = NULL, .mode = NULL,
.tc = &dwmac510_tc_ops, .tc = &dwmac510_tc_ops,
.mmc = NULL,
.setup = dwxgmac2_setup, .setup = dwxgmac2_setup,
.quirks = NULL, .quirks = NULL,
}, },
...@@ -267,6 +275,7 @@ int stmmac_hwif_init(struct stmmac_priv *priv) ...@@ -267,6 +275,7 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
mac->ptp = mac->ptp ? : entry->hwtimestamp; mac->ptp = mac->ptp ? : entry->hwtimestamp;
mac->mode = mac->mode ? : entry->mode; mac->mode = mac->mode ? : entry->mode;
mac->tc = mac->tc ? : entry->tc; mac->tc = mac->tc ? : entry->tc;
mac->mmc = mac->mmc ? : entry->mmc;
priv->hw = mac; priv->hw = mac;
priv->ptpaddr = priv->ioaddr + entry->regs.ptp_off; priv->ptpaddr = priv->ioaddr + entry->regs.ptp_off;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define __STMMAC_HWIF_H__ #define __STMMAC_HWIF_H__
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/stmmac.h>
#define stmmac_do_void_callback(__priv, __module, __cname, __arg0, __args...) \ #define stmmac_do_void_callback(__priv, __module, __cname, __arg0, __args...) \
({ \ ({ \
...@@ -468,6 +469,21 @@ struct stmmac_tc_ops { ...@@ -468,6 +469,21 @@ struct stmmac_tc_ops {
#define stmmac_tc_setup_cbs(__priv, __args...) \ #define stmmac_tc_setup_cbs(__priv, __args...) \
stmmac_do_callback(__priv, tc, setup_cbs, __args) stmmac_do_callback(__priv, tc, setup_cbs, __args)
struct stmmac_counters;
struct stmmac_mmc_ops {
void (*ctrl)(void __iomem *ioaddr, unsigned int mode);
void (*intr_all_mask)(void __iomem *ioaddr);
void (*read)(void __iomem *ioaddr, struct stmmac_counters *mmc);
};
#define stmmac_mmc_ctrl(__priv, __args...) \
stmmac_do_void_callback(__priv, mmc, ctrl, __args)
#define stmmac_mmc_intr_all_mask(__priv, __args...) \
stmmac_do_void_callback(__priv, mmc, intr_all_mask, __args)
#define stmmac_mmc_read(__priv, __args...) \
stmmac_do_void_callback(__priv, mmc, read, __args)
struct stmmac_regs_off { struct stmmac_regs_off {
u32 ptp_off; u32 ptp_off;
u32 mmc_off; u32 mmc_off;
...@@ -486,6 +502,7 @@ extern const struct stmmac_tc_ops dwmac510_tc_ops; ...@@ -486,6 +502,7 @@ extern const struct stmmac_tc_ops dwmac510_tc_ops;
extern const struct stmmac_ops dwxgmac210_ops; extern const struct stmmac_ops dwxgmac210_ops;
extern const struct stmmac_dma_ops dwxgmac210_dma_ops; extern const struct stmmac_dma_ops dwxgmac210_dma_ops;
extern const struct stmmac_desc_ops dwxgmac210_desc_ops; extern const struct stmmac_desc_ops dwxgmac210_desc_ops;
extern const struct stmmac_mmc_ops dwmac_mmc_ops;
#define GMAC_VERSION 0x00000020 /* GMAC CORE Version */ #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */
#define GMAC4_VERSION 0x00000110 /* GMAC4+ CORE Version */ #define GMAC4_VERSION 0x00000110 /* GMAC4+ CORE Version */
......
...@@ -128,8 +128,4 @@ struct stmmac_counters { ...@@ -128,8 +128,4 @@ struct stmmac_counters {
unsigned int mmc_rx_icmp_err_octets; unsigned int mmc_rx_icmp_err_octets;
}; };
void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode);
void dwmac_mmc_intr_all_mask(void __iomem *ioaddr);
void dwmac_mmc_read(void __iomem *ioaddr, struct stmmac_counters *mmc);
#endif /* __MMC_H__ */ #endif /* __MMC_H__ */
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/io.h> #include <linux/io.h>
#include "hwif.h"
#include "mmc.h" #include "mmc.h"
/* MAC Management Counters register offset */ /* MAC Management Counters register offset */
...@@ -128,7 +129,7 @@ ...@@ -128,7 +129,7 @@
#define MMC_RX_ICMP_GD_OCTETS 0x180 #define MMC_RX_ICMP_GD_OCTETS 0x180
#define MMC_RX_ICMP_ERR_OCTETS 0x184 #define MMC_RX_ICMP_ERR_OCTETS 0x184
void dwmac_mmc_ctrl(void __iomem *mmcaddr, unsigned int mode) static void dwmac_mmc_ctrl(void __iomem *mmcaddr, unsigned int mode)
{ {
u32 value = readl(mmcaddr + MMC_CNTRL); u32 value = readl(mmcaddr + MMC_CNTRL);
...@@ -141,7 +142,7 @@ void dwmac_mmc_ctrl(void __iomem *mmcaddr, unsigned int mode) ...@@ -141,7 +142,7 @@ void dwmac_mmc_ctrl(void __iomem *mmcaddr, unsigned int mode)
} }
/* To mask all all interrupts.*/ /* To mask all all interrupts.*/
void dwmac_mmc_intr_all_mask(void __iomem *mmcaddr) static void dwmac_mmc_intr_all_mask(void __iomem *mmcaddr)
{ {
writel(MMC_DEFAULT_MASK, mmcaddr + MMC_RX_INTR_MASK); writel(MMC_DEFAULT_MASK, mmcaddr + MMC_RX_INTR_MASK);
writel(MMC_DEFAULT_MASK, mmcaddr + MMC_TX_INTR_MASK); writel(MMC_DEFAULT_MASK, mmcaddr + MMC_TX_INTR_MASK);
...@@ -153,7 +154,7 @@ void dwmac_mmc_intr_all_mask(void __iomem *mmcaddr) ...@@ -153,7 +154,7 @@ void dwmac_mmc_intr_all_mask(void __iomem *mmcaddr)
* counter after a read. So all the field of the mmc struct * counter after a read. So all the field of the mmc struct
* have to be incremented. * have to be incremented.
*/ */
void dwmac_mmc_read(void __iomem *mmcaddr, struct stmmac_counters *mmc) static void dwmac_mmc_read(void __iomem *mmcaddr, struct stmmac_counters *mmc)
{ {
mmc->mmc_tx_octetcount_gb += readl(mmcaddr + MMC_TX_OCTETCOUNT_GB); mmc->mmc_tx_octetcount_gb += readl(mmcaddr + MMC_TX_OCTETCOUNT_GB);
mmc->mmc_tx_framecount_gb += readl(mmcaddr + MMC_TX_FRAMECOUNT_GB); mmc->mmc_tx_framecount_gb += readl(mmcaddr + MMC_TX_FRAMECOUNT_GB);
...@@ -266,3 +267,9 @@ void dwmac_mmc_read(void __iomem *mmcaddr, struct stmmac_counters *mmc) ...@@ -266,3 +267,9 @@ void dwmac_mmc_read(void __iomem *mmcaddr, struct stmmac_counters *mmc)
mmc->mmc_rx_icmp_gd_octets += readl(mmcaddr + MMC_RX_ICMP_GD_OCTETS); mmc->mmc_rx_icmp_gd_octets += readl(mmcaddr + MMC_RX_ICMP_GD_OCTETS);
mmc->mmc_rx_icmp_err_octets += readl(mmcaddr + MMC_RX_ICMP_ERR_OCTETS); mmc->mmc_rx_icmp_err_octets += readl(mmcaddr + MMC_RX_ICMP_ERR_OCTETS);
} }
const struct stmmac_mmc_ops dwmac_mmc_ops = {
.ctrl = dwmac_mmc_ctrl,
.intr_all_mask = dwmac_mmc_intr_all_mask,
.read = dwmac_mmc_read,
};
...@@ -537,7 +537,7 @@ static void stmmac_get_ethtool_stats(struct net_device *dev, ...@@ -537,7 +537,7 @@ static void stmmac_get_ethtool_stats(struct net_device *dev,
if (ret) { if (ret) {
/* If supported, for new GMAC chips expose the MMC counters */ /* If supported, for new GMAC chips expose the MMC counters */
if (priv->dma_cap.rmon) { if (priv->dma_cap.rmon) {
dwmac_mmc_read(priv->mmcaddr, &priv->mmc); stmmac_mmc_read(priv, priv->mmcaddr, &priv->mmc);
for (i = 0; i < STMMAC_MMC_STATS_LEN; i++) { for (i = 0; i < STMMAC_MMC_STATS_LEN; i++) {
char *p; char *p;
......
...@@ -2128,10 +2128,10 @@ static void stmmac_mmc_setup(struct stmmac_priv *priv) ...@@ -2128,10 +2128,10 @@ static void stmmac_mmc_setup(struct stmmac_priv *priv)
unsigned int mode = MMC_CNTRL_RESET_ON_READ | MMC_CNTRL_COUNTER_RESET | unsigned int mode = MMC_CNTRL_RESET_ON_READ | MMC_CNTRL_COUNTER_RESET |
MMC_CNTRL_PRESET | MMC_CNTRL_FULL_HALF_PRESET; MMC_CNTRL_PRESET | MMC_CNTRL_FULL_HALF_PRESET;
dwmac_mmc_intr_all_mask(priv->mmcaddr); stmmac_mmc_intr_all_mask(priv, priv->mmcaddr);
if (priv->dma_cap.rmon) { if (priv->dma_cap.rmon) {
dwmac_mmc_ctrl(priv->mmcaddr, mode); stmmac_mmc_ctrl(priv, priv->mmcaddr, mode);
memset(&priv->mmc, 0, sizeof(struct stmmac_counters)); memset(&priv->mmc, 0, sizeof(struct stmmac_counters));
} else } else
netdev_info(priv->dev, "No MAC Management Counters available\n"); netdev_info(priv->dev, "No MAC Management Counters available\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment