Commit 10739ea3 authored by Shenwei Wang's avatar Shenwei Wang Committed by Jakub Kicinski

net: stmmac: add support for platform specific reset

This patch adds support for platform-specific reset logic in the
stmmac driver. Some SoCs require a different reset mechanism than
the standard dwmac IP reset. To support these platforms, a new function
pointer 'fix_soc_reset' is added to the plat_stmmacenet_data structure.
The stmmac_reset in hwif.h is modified to call the 'fix_soc_reset'
function if it exists. This enables the driver to use the platform-specific
reset logic when necessary.
Signed-off-by: default avatarShenwei Wang <shenwei.wang@nxp.com>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230403222302.328262-1-shenwei.wang@nxp.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 8b0f2565
...@@ -87,6 +87,19 @@ static int stmmac_dwxlgmac_quirks(struct stmmac_priv *priv) ...@@ -87,6 +87,19 @@ static int stmmac_dwxlgmac_quirks(struct stmmac_priv *priv)
return 0; return 0;
} }
int stmmac_reset(struct stmmac_priv *priv, void __iomem *ioaddr)
{
struct plat_stmmacenet_data *plat = priv ? priv->plat : NULL;
if (!priv)
return -EINVAL;
if (plat && plat->fix_soc_reset)
return plat->fix_soc_reset(plat, ioaddr);
return stmmac_do_callback(priv, dma, reset, ioaddr);
}
static const struct stmmac_hwif_entry { static const struct stmmac_hwif_entry {
bool gmac; bool gmac;
bool gmac4; bool gmac4;
......
...@@ -214,8 +214,6 @@ struct stmmac_dma_ops { ...@@ -214,8 +214,6 @@ struct stmmac_dma_ops {
int (*enable_tbs)(void __iomem *ioaddr, bool en, u32 chan); int (*enable_tbs)(void __iomem *ioaddr, bool en, u32 chan);
}; };
#define stmmac_reset(__priv, __args...) \
stmmac_do_callback(__priv, dma, reset, __args)
#define stmmac_dma_init(__priv, __args...) \ #define stmmac_dma_init(__priv, __args...) \
stmmac_do_void_callback(__priv, dma, init, __args) stmmac_do_void_callback(__priv, dma, init, __args)
#define stmmac_init_chan(__priv, __args...) \ #define stmmac_init_chan(__priv, __args...) \
...@@ -640,6 +638,7 @@ extern const struct stmmac_mmc_ops dwxgmac_mmc_ops; ...@@ -640,6 +638,7 @@ extern const struct stmmac_mmc_ops dwxgmac_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 */
int stmmac_reset(struct stmmac_priv *priv, void __iomem *ioaddr);
int stmmac_hwif_init(struct stmmac_priv *priv); int stmmac_hwif_init(struct stmmac_priv *priv);
#endif /* __STMMAC_HWIF_H__ */ #endif /* __STMMAC_HWIF_H__ */
...@@ -223,6 +223,7 @@ struct plat_stmmacenet_data { ...@@ -223,6 +223,7 @@ struct plat_stmmacenet_data {
struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES]; struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];
struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES]; struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES];
void (*fix_mac_speed)(void *priv, unsigned int speed); void (*fix_mac_speed)(void *priv, unsigned int speed);
int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
int (*serdes_powerup)(struct net_device *ndev, void *priv); int (*serdes_powerup)(struct net_device *ndev, void *priv);
void (*serdes_powerdown)(struct net_device *ndev, void *priv); void (*serdes_powerdown)(struct net_device *ndev, void *priv);
void (*speed_mode_2500)(struct net_device *ndev, void *priv); void (*speed_mode_2500)(struct net_device *ndev, void *priv);
......
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