Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'update-stmmac-fix_mac_speed'

Shenwei Wang says:

====================
update stmmac fix_mac_speed
====================

Link: https://lore.kernel.org/r/20230807160716.259072-1-shenwei.wang@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+61 -18
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
··· 178 178 #define AUTO_CAL_STATUS 0x880c 179 179 #define AUTO_CAL_STATUS_ACTIVE BIT(31) 180 180 181 - static void tegra_eqos_fix_speed(void *priv, unsigned int speed) 181 + static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mode) 182 182 { 183 183 struct tegra_eqos *eqos = priv; 184 184 unsigned long rate = 125000000;
+44 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
··· 31 31 #define GPR_ENET_QOS_RGMII_EN (0x1 << 21) 32 32 33 33 #define MX93_GPR_ENET_QOS_INTF_MODE_MASK GENMASK(3, 0) 34 + #define MX93_GPR_ENET_QOS_INTF_MASK GENMASK(3, 1) 34 35 #define MX93_GPR_ENET_QOS_INTF_SEL_MII (0x0 << 1) 35 36 #define MX93_GPR_ENET_QOS_INTF_SEL_RMII (0x4 << 1) 36 37 #define MX93_GPR_ENET_QOS_INTF_SEL_RGMII (0x1 << 1) ··· 40 39 #define DMA_BUS_MODE 0x00001000 41 40 #define DMA_BUS_MODE_SFT_RESET (0x1 << 0) 42 41 #define RMII_RESET_SPEED (0x3 << 14) 42 + #define CTRL_SPEED_MASK GENMASK(15, 14) 43 43 44 44 struct imx_dwmac_ops { 45 45 u32 addr_width; ··· 49 47 50 48 int (*fix_soc_reset)(void *priv, void __iomem *ioaddr); 51 49 int (*set_intf_mode)(struct plat_stmmacenet_data *plat_dat); 50 + void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode); 52 51 }; 53 52 54 53 struct imx_priv_data { ··· 59 56 struct regmap *intf_regmap; 60 57 u32 intf_reg_off; 61 58 bool rmii_refclk_ext; 59 + void __iomem *base_addr; 62 60 63 61 const struct imx_dwmac_ops *ops; 64 62 struct plat_stmmacenet_data *plat_dat; ··· 182 178 /* nothing to do now */ 183 179 } 184 180 185 - static void imx_dwmac_fix_speed(void *priv, unsigned int speed) 181 + static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode) 186 182 { 187 183 struct plat_stmmacenet_data *plat_dat; 188 184 struct imx_priv_data *dwmac = priv; ··· 214 210 err = clk_set_rate(dwmac->clk_tx, rate); 215 211 if (err < 0) 216 212 dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate); 213 + } 214 + 215 + static void imx93_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode) 216 + { 217 + struct imx_priv_data *dwmac = priv; 218 + unsigned int iface; 219 + int ctrl, old_ctrl; 220 + 221 + imx_dwmac_fix_speed(priv, speed, mode); 222 + 223 + if (!dwmac || mode != MLO_AN_FIXED) 224 + return; 225 + 226 + if (regmap_read(dwmac->intf_regmap, dwmac->intf_reg_off, &iface)) 227 + return; 228 + 229 + iface &= MX93_GPR_ENET_QOS_INTF_MASK; 230 + if (iface != MX93_GPR_ENET_QOS_INTF_SEL_RGMII) 231 + return; 232 + 233 + old_ctrl = readl(dwmac->base_addr + MAC_CTRL_REG); 234 + ctrl = old_ctrl & ~CTRL_SPEED_MASK; 235 + regmap_update_bits(dwmac->intf_regmap, dwmac->intf_reg_off, 236 + MX93_GPR_ENET_QOS_INTF_MODE_MASK, 0); 237 + writel(ctrl, dwmac->base_addr + MAC_CTRL_REG); 238 + 239 + /* Ensure the settings for CTRL are applied. */ 240 + readl(dwmac->base_addr + MAC_CTRL_REG); 241 + 242 + usleep_range(10, 20); 243 + iface |= MX93_GPR_ENET_QOS_CLK_GEN_EN; 244 + regmap_update_bits(dwmac->intf_regmap, dwmac->intf_reg_off, 245 + MX93_GPR_ENET_QOS_INTF_MODE_MASK, iface); 246 + 247 + writel(old_ctrl, dwmac->base_addr + MAC_CTRL_REG); 217 248 } 218 249 219 250 static int imx_dwmac_mx93_reset(void *priv, void __iomem *ioaddr) ··· 361 322 plat_dat->fix_mac_speed = imx_dwmac_fix_speed; 362 323 plat_dat->bsp_priv = dwmac; 363 324 dwmac->plat_dat = plat_dat; 325 + dwmac->base_addr = stmmac_res.addr; 364 326 365 327 ret = imx_dwmac_clks_config(dwmac, true); 366 328 if (ret) ··· 371 331 if (ret) 372 332 goto err_dwmac_init; 373 333 334 + if (dwmac->ops->fix_mac_speed) 335 + plat_dat->fix_mac_speed = dwmac->ops->fix_mac_speed; 374 336 dwmac->plat_dat->fix_soc_reset = dwmac->ops->fix_soc_reset; 375 337 376 338 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); ··· 410 368 .mac_rgmii_txclk_auto_adj = true, 411 369 .set_intf_mode = imx93_set_intf_mode, 412 370 .fix_soc_reset = imx_dwmac_mx93_reset, 371 + .fix_mac_speed = imx93_dwmac_fix_speed, 413 372 }; 414 373 415 374 static const struct of_device_id imx_dwmac_match[] = {
+2 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
··· 22 22 }; 23 23 24 24 struct intel_dwmac_data { 25 - void (*fix_mac_speed)(void *priv, unsigned int speed); 25 + void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode); 26 26 unsigned long ptp_ref_clk_rate; 27 27 unsigned long tx_clk_rate; 28 28 bool tx_clk_en; 29 29 }; 30 30 31 - static void kmb_eth_fix_mac_speed(void *priv, unsigned int speed) 31 + static void kmb_eth_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 32 32 { 33 33 struct intel_dwmac *dwmac = priv; 34 34 unsigned long rate;
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
··· 257 257 return PTR_ERR_OR_ZERO(gmac->qsgmii_csr); 258 258 } 259 259 260 - static void ipq806x_gmac_fix_mac_speed(void *priv, unsigned int speed) 260 + static void ipq806x_gmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 261 261 { 262 262 struct ipq806x_gmac *gmac = priv; 263 263
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
··· 22 22 void __iomem *reg; 23 23 }; 24 24 25 - static void meson6_dwmac_fix_mac_speed(void *priv, unsigned int speed) 25 + static void meson6_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 26 26 { 27 27 struct meson_dwmac *dwmac = priv; 28 28 unsigned int val;
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
··· 630 630 return ethqos->configure_func(ethqos); 631 631 } 632 632 633 - static void ethqos_fix_mac_speed(void *priv, unsigned int speed) 633 + static void ethqos_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 634 634 { 635 635 struct qcom_ethqos *ethqos = priv; 636 636
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
··· 1785 1785 gmac_clk_enable(gmac, false); 1786 1786 } 1787 1787 1788 - static void rk_fix_speed(void *priv, unsigned int speed) 1788 + static void rk_fix_speed(void *priv, unsigned int speed, unsigned int mode) 1789 1789 { 1790 1790 struct rk_priv_data *bsp_priv = priv; 1791 1791 struct device *dev = &bsp_priv->pdev->dev;
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
··· 61 61 struct mdio_device *pcs_mdiodev; 62 62 }; 63 63 64 - static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed) 64 + static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 65 65 { 66 66 struct socfpga_dwmac *dwmac = (struct socfpga_dwmac *)priv; 67 67 void __iomem *splitter_base = dwmac->splitter_base;
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
··· 24 24 struct clk *clk_tx; 25 25 }; 26 26 27 - static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed) 27 + static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 28 28 { 29 29 struct starfive_dwmac *dwmac = priv; 30 30 unsigned long rate;
+4 -4
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
··· 103 103 struct regmap *regmap; 104 104 bool gmac_en; 105 105 u32 speed; 106 - void (*fix_retime_src)(void *priv, unsigned int speed); 106 + void (*fix_retime_src)(void *priv, unsigned int speed, unsigned int mode); 107 107 }; 108 108 109 109 struct sti_dwmac_of_data { 110 - void (*fix_retime_src)(void *priv, unsigned int speed); 110 + void (*fix_retime_src)(void *priv, unsigned int speed, unsigned int mode); 111 111 }; 112 112 113 113 static u32 phy_intf_sels[] = { ··· 135 135 | STIH4XX_ETH_SEL_INTERNAL_NOTEXT_PHYCLK, 136 136 }; 137 137 138 - static void stih4xx_fix_retime_src(void *priv, u32 spd) 138 + static void stih4xx_fix_retime_src(void *priv, u32 spd, unsigned int mode) 139 139 { 140 140 struct sti_dwmac *dwmac = priv; 141 141 u32 src = dwmac->tx_retime_src; ··· 187 187 val = (iface == PHY_INTERFACE_MODE_REVMII) ? 0 : ENMII; 188 188 regmap_update_bits(regmap, reg, ENMII_MASK, val); 189 189 190 - dwmac->fix_retime_src(dwmac, dwmac->speed); 190 + dwmac->fix_retime_src(dwmac, dwmac->speed, 0); 191 191 192 192 return 0; 193 193 }
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
··· 72 72 regulator_disable(gmac->regulator); 73 73 } 74 74 75 - static void sun7i_fix_speed(void *priv, unsigned int speed) 75 + static void sun7i_fix_speed(void *priv, unsigned int speed, unsigned int mode) 76 76 { 77 77 struct sunxi_priv_data *gmac = priv; 78 78
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
··· 54 54 spinlock_t lock; /* lock to protect register update */ 55 55 }; 56 56 57 - static void visconti_eth_fix_mac_speed(void *priv, unsigned int speed) 57 + static void visconti_eth_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 58 58 { 59 59 struct visconti_eth *dwmac = priv; 60 60 struct net_device *netdev = dev_get_drvdata(dwmac->dev);
+1 -1
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 1064 1064 priv->speed = speed; 1065 1065 1066 1066 if (priv->plat->fix_mac_speed) 1067 - priv->plat->fix_mac_speed(priv->plat->bsp_priv, speed); 1067 + priv->plat->fix_mac_speed(priv->plat->bsp_priv, speed, mode); 1068 1068 1069 1069 if (!duplex) 1070 1070 ctrl &= ~priv->hw->link.duplex;
+1 -1
include/linux/stmmac.h
··· 256 256 u8 tx_sched_algorithm; 257 257 struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES]; 258 258 struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES]; 259 - void (*fix_mac_speed)(void *priv, unsigned int speed); 259 + void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode); 260 260 int (*fix_soc_reset)(void *priv, void __iomem *ioaddr); 261 261 int (*serdes_powerup)(struct net_device *ndev, void *priv); 262 262 void (*serdes_powerdown)(struct net_device *ndev, void *priv);