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

Merge branch 'series-to-deliver-ethernet-for-stm32mp25'

Christophe Roullier says:

====================
Series to deliver Ethernet for STM32MP25

STM32MP25 is STM32 SOC with 2 GMACs instances.
GMAC IP version is SNPS 5.3x.
GMAC IP configure with 2 RX and 4 TX queue.
DMA HW capability register supported
RX Checksum Offload Engine supported
TX Checksum insertion supported
Wake-Up On Lan supported
TSO supported
====================

Link: https://lore.kernel.org/r/20240624071052.118042-1-christophe.roullier@foss.st.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

+84 -4
+7 -1
Documentation/devicetree/bindings/net/stm32-dwmac.yaml
··· 23 23 - st,stm32-dwmac 24 24 - st,stm32mp1-dwmac 25 25 - st,stm32mp13-dwmac 26 + - st,stm32mp25-dwmac 26 27 required: 27 28 - compatible 28 29 29 30 properties: 30 31 compatible: 31 32 oneOf: 33 + - items: 34 + - enum: 35 + - st,stm32mp25-dwmac 36 + - const: snps,dwmac-5.20 32 37 - items: 33 38 - enum: 34 39 - st,stm32mp1-dwmac ··· 126 121 compatible: 127 122 contains: 128 123 enum: 129 - - st,stm32mp1-dwmac 130 124 - st,stm32-dwmac 125 + - st,stm32mp1-dwmac 126 + - st,stm32mp25-dwmac 131 127 then: 132 128 properties: 133 129 st,syscon:
+77 -3
drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
··· 53 53 #define SYSCFG_MCU_ETH_SEL_MII 0 54 54 #define SYSCFG_MCU_ETH_SEL_RMII 1 55 55 56 - /* STM32MP1 register definitions 56 + /* STM32MP2 register definitions */ 57 + #define SYSCFG_MP2_ETH_MASK GENMASK(31, 0) 58 + 59 + #define SYSCFG_ETHCR_ETH_PTP_CLK_SEL BIT(2) 60 + #define SYSCFG_ETHCR_ETH_CLK_SEL BIT(1) 61 + #define SYSCFG_ETHCR_ETH_REF_CLK_SEL BIT(0) 62 + 63 + #define SYSCFG_ETHCR_ETH_SEL_MII 0 64 + #define SYSCFG_ETHCR_ETH_SEL_RGMII BIT(4) 65 + #define SYSCFG_ETHCR_ETH_SEL_RMII BIT(6) 66 + 67 + /* STM32MPx register definitions 57 68 * 58 69 * Below table summarizes the clock requirement and clock sources for 59 70 * supported phy interface modes. ··· 115 104 int (*parse_data)(struct stm32_dwmac *dwmac, 116 105 struct device *dev); 117 106 bool clk_rx_enable_in_suspend; 118 - bool is_mp13; 107 + bool is_mp13, is_mp2; 119 108 u32 syscfg_clr_off; 120 109 }; 121 110 ··· 288 277 dwmac->mode_mask, val); 289 278 } 290 279 280 + static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat) 281 + { 282 + struct stm32_dwmac *dwmac = plat_dat->bsp_priv; 283 + u32 reg = dwmac->mode_reg; 284 + int val = 0; 285 + 286 + switch (plat_dat->mac_interface) { 287 + case PHY_INTERFACE_MODE_MII: 288 + /* ETH_REF_CLK_SEL bit in SYSCFG register is not applicable in MII mode */ 289 + break; 290 + case PHY_INTERFACE_MODE_RMII: 291 + val = SYSCFG_ETHCR_ETH_SEL_RMII; 292 + if (dwmac->enable_eth_ck) { 293 + /* Internal clock ETH_CLK of 50MHz from RCC is used */ 294 + val |= SYSCFG_ETHCR_ETH_REF_CLK_SEL; 295 + } 296 + break; 297 + case PHY_INTERFACE_MODE_RGMII: 298 + case PHY_INTERFACE_MODE_RGMII_ID: 299 + case PHY_INTERFACE_MODE_RGMII_RXID: 300 + case PHY_INTERFACE_MODE_RGMII_TXID: 301 + val = SYSCFG_ETHCR_ETH_SEL_RGMII; 302 + fallthrough; 303 + case PHY_INTERFACE_MODE_GMII: 304 + if (dwmac->enable_eth_ck) { 305 + /* Internal clock ETH_CLK of 125MHz from RCC is used */ 306 + val |= SYSCFG_ETHCR_ETH_CLK_SEL; 307 + } 308 + break; 309 + default: 310 + dev_err(dwmac->dev, "Mode %s not supported", 311 + phy_modes(plat_dat->mac_interface)); 312 + /* Do not manage others interfaces */ 313 + return -EINVAL; 314 + } 315 + 316 + dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->mac_interface)); 317 + 318 + /* Select PTP (IEEE1588) clock selection from RCC (ck_ker_ethxptp) */ 319 + val |= SYSCFG_ETHCR_ETH_PTP_CLK_SEL; 320 + 321 + /* Update ETHCR (set register) */ 322 + return regmap_update_bits(dwmac->regmap, reg, 323 + SYSCFG_MP2_ETH_MASK, val); 324 + } 325 + 291 326 static int stm32mp1_set_mode(struct plat_stmmacenet_data *plat_dat) 292 327 { 328 + struct stm32_dwmac *dwmac = plat_dat->bsp_priv; 293 329 int ret; 294 330 295 331 ret = stm32mp1_select_ethck_external(plat_dat); ··· 347 289 if (ret) 348 290 return ret; 349 291 350 - return stm32mp1_configure_pmcr(plat_dat); 292 + if (!dwmac->ops->is_mp2) 293 + return stm32mp1_configure_pmcr(plat_dat); 294 + else 295 + return stm32mp2_configure_syscfg(plat_dat); 351 296 } 352 297 353 298 static int stm32mcu_set_mode(struct plat_stmmacenet_data *plat_dat) ··· 425 364 dev_err(dev, "Can't get sysconfig mode offset (%d)\n", err); 426 365 return err; 427 366 } 367 + 368 + if (dwmac->ops->is_mp2) 369 + return 0; 428 370 429 371 dwmac->mode_mask = SYSCFG_MP1_ETH_MASK; 430 372 err = of_property_read_u32_index(np, "st,syscon", 2, &dwmac->mode_mask); ··· 650 586 .clk_rx_enable_in_suspend = true 651 587 }; 652 588 589 + static struct stm32_ops stm32mp25_dwmac_data = { 590 + .set_mode = stm32mp1_set_mode, 591 + .suspend = stm32mp1_suspend, 592 + .resume = stm32mp1_resume, 593 + .parse_data = stm32mp1_parse_data, 594 + .is_mp2 = true, 595 + .clk_rx_enable_in_suspend = true 596 + }; 597 + 653 598 static const struct of_device_id stm32_dwmac_match[] = { 654 599 { .compatible = "st,stm32-dwmac", .data = &stm32mcu_dwmac_data}, 655 600 { .compatible = "st,stm32mp1-dwmac", .data = &stm32mp1_dwmac_data}, 656 601 { .compatible = "st,stm32mp13-dwmac", .data = &stm32mp13_dwmac_data}, 602 + { .compatible = "st,stm32mp25-dwmac", .data = &stm32mp25_dwmac_data}, 657 603 { } 658 604 }; 659 605 MODULE_DEVICE_TABLE(of, stm32_dwmac_match);