net: stmmac: add support for platform specific reset
Subsystems (5)
PATCH v4 1/2 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 macro 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.
--- drivers/net/ethernet/stmicro/stmmac/hwif.c | 10 ++++++++++ drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 +-- include/linux/stmmac.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/hwif.c +10 -0
@@ -87,6 +87,16 @@ static int stmmac_dwxlgmac_quirks(struct stmmac_priv *priv)return 0 ; } +int stmmac_reset (struct stmmac_priv *priv,void __iomem *ioaddr) +{ +struct plat_stmmacenet_data *plat = priv ? priv->plat :NULL ; + +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 { bool gmac; bool gmac4;
drivers/net/ethernet/stmicro/stmmac/hwif.h +1 -2
@@ -214,8 +214,6 @@ struct stmmac_dma_ops {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...) \ stmmac_do_void_callback(__priv, dma, init, __args) #define stmmac_init_chan(__priv, __args...) \
@@ -640,6 +638,7 @@ extern const struct stmmac_mmc_ops dwxgmac_mmc_ops;#define GMAC_VERSION 0x00000020/* GMAC CORE Version */ #define GMAC4_VERSION 0x00000110/* GMAC4+ CORE Version */ +int stmmac_reset (struct stmmac_priv *priv,void *ioaddr);int stmmac_hwif_init (struct stmmac_priv *priv);#endif /* __STMMAC_HWIF_H__ */
include/linux/stmmac.h +1 -0
@@ -223,6 +223,7 @@ struct plat_stmmacenet_data {struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES ];struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES ];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);void (*serdes_powerdown)(struct net_device *ndev,void *priv);void (*speed_mode_2500)(struct net_device *ndev,void *priv);
--
2.34.1
PATCH v4 2/2 net: stmmac: dwmac-imx: use platform specific reset for imx93 SoCs
The patch addresses an issue with the reset logic on the i.MX93 SoC, which requires configuration of the correct interface speed under RMII mode to complete the reset. The patch implements a fix_soc_reset function and uses it specifically for the i.MX93 SoCs.
--- .../net/ethernet/stmicro/stmmac/dwmac-imx.c | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +27 -0
@@ -37,10 +37,15 @@#define MX93_GPR_ENET_QOS_INTF_SEL_RGMII (0x1 << 1)#define MX93_GPR_ENET_QOS_CLK_GEN_EN (0x1 << 0) +#define DMA_BUS_MODE 0x00001000 +#define DMA_BUS_MODE_SFT_RESET (0x1 << 0) +#define RMII_RESET_SPEED (0x3 << 14) +struct imx_dwmac_ops {u32 addr_width;bool mac_rgmii_txclk_auto_adj; +int (*fix_soc_reset)(void *priv,void __iomem *ioaddr);int (*set_intf_mode)(struct plat_stmmacenet_data *plat_dat); };
@@ -207,6 +212,25 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed)dev_err (dwmac->dev,"failed to set tx rate %lu\n" , rate); } +static int imx_dwmac_mx93_reset (void *priv,void __iomem *ioaddr) +{ +u32 value =readl (ioaddr +DMA_BUS_MODE ); +struct plat_stmmacenet_data *plat_dat = priv; + +/* DMA SW reset */ + value |=DMA_BUS_MODE_SFT_RESET ; +writel (value, ioaddr +DMA_BUS_MODE ); + +if (plat_dat->interface ==PHY_INTERFACE_MODE_RMII ) { +usleep_range (100 ,200 ); +writel (RMII_RESET_SPEED , ioaddr +MAC_CTRL_REG ); + } + +return readl_poll_timeout (ioaddr +DMA_BUS_MODE , value, + !(value &DMA_BUS_MODE_SFT_RESET ), +10000 ,1000000 ); +} +static int imx_dwmac_parse_dt (struct imx_priv_data *dwmac,struct device *dev) {
@@ -305,6 +329,8 @@ static int imx_dwmac_probe(struct platform_device *pdev)if (ret) goto err_dwmac_init; + dwmac->plat_dat->fix_soc_reset = dwmac->ops->fix_soc_reset; + ret =stmmac_dvr_probe (&pdev->dev, plat_dat, &stmmac_res);if (ret) goto err_drv_probe;
@@ -338,6 +364,7 @@ static struct imx_dwmac_ops imx93_dwmac_data = { .addr_width = 32, .mac_rgmii_txclk_auto_adj = true, .set_intf_mode = imx93_set_intf_mode, + .fix_soc_reset = imx_dwmac_mx93_reset, };static const struct of_device_id imx_dwmac_match[] = {
--
2.34.1
Jakub Kicinski
maintainerQuoted 14 lines · On Fri, 31 Mar 2023 16:22:49 -0500 Shenwei Wang wrote:
drivers/net/ethernet/stmicro/stmmac/hwif.h +0
-2@@ -214,8 +214,6 @@ struct stmmac_dma_ops {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...) \ stmmac_do_void_callback(__priv, dma, init, __args) #define stmmac_init_chan(__priv, __args...) \
drivers/net/ethernet/stmicro/stmmac/hwif.h extern const struct stmmac_mmc_ops dwxgmac_mmc_ops; · line 641
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/hwif.h +1
-0@@ -640,6 +638,7 @@ extern const struct stmmac_mmc_ops dwxgmac_mmc_ops;#define GMAC_VERSION 0x00000020/* GMAC CORE Version */ #define GMAC4_VERSION 0x00000110/* GMAC4+ CORE Version */ +int stmmac_reset (struct stmmac_priv *priv,void *ioaddr);
sparse reports missing annotation, I think it's this line. It should have a __iomem tag. Try building with C=1 Also please take a look at:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html
Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/hwif.h +0
-0int stmmac_hwif_init (struct stmmac_priv *priv);
Quoted 43 lines
-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Friday, March 31, 2023 11:58 PM
To: Shenwei Wang <[email protected]>
Cc: David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Paolo Abeni <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Maxime Coquelin <[email protected]>; Giuseppe Cavallaro <[email protected]>; Alexandre Torgue <[email protected]>; Jose Abreu <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Wong Vee Khee <[email protected]>; Kurt Kanzenbach <[email protected]>; Revanth Kumar Uppala <[email protected]>; Andrey Konovalov <[email protected]>; Tan Tee Min <[email protected]>; [email protected]; linux-arm- [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v4 1/2] net: stmmac: add support for platform specific resetCaution: EXT Email
Quoted 12 lines · On Fri, 31 Mar 2023 16:22:49 -0500 Shenwei Wang wrote:
drivers/net/ethernet/stmicro/stmmac/hwif.h +0
-2@@ -214,8 +214,6 @@ struct stmmac_dma_ops {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...) \ stmmac_do_void_callback(__priv, dma, init, __args) #defineQuoted 4 lines
stmmac_init_chan(__priv, __args...)\ @@ -640,6 +638,7 @@ extern const structstmmac_mmc_opsdwxgmac_mmc_ops;
#defineGMAC_VERSION0x00000020/* GMAC CORE Version */
#defineGMAC4_VERSION0x00000110/* GMAC4+ CORE Version*/
Quoted 1 line
Quoted 4 lines
Quoted 1 line
+int
stmmac_reset(struct stmmac_priv *priv, void *ioaddr);sparse reports missing annotation, I think it's this line.
It should have a__iomemtag. Try building with C=1 Also please take a look at:
Tried to rebuild with C=1 but didn't reproduce the missing annotation issue. However, the __iomem should be added here.
Thanks,
Shenwei
Quoted 10 lines
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ker
nel.org%2Fdoc%2Fhtml%2Fnext%2Fprocess%2Fmaintainer- netdev.html&data=05%7C01%7Cshenwei.wang%40nxp.com%7Cb0c66303819f4 c5c2eec08db326db89d%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7 C638159219052564995%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM DAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C &sdata=0j58wSNzzTirX%2FqaJKPxYEDZn6ezs7qC39trHa72YRA%3D&reserved=0Quoted 1 line
int
stmmac_hwif_init(struct stmmac_priv *priv);