From d139d84338a241a0b771117507e71f49d501065c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fin=20Maa=C3=9F?= Date: Wed, 26 Mar 2025 07:40:06 +0100 Subject: [PATCH] drivers: ethernet: stm32: make mac a child like the mdio node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mac and mdio are now on the same level, this way phy-handle can be used. Signed-off-by: Fin Maaß --- drivers/ethernet/eth_stm32_hal.c | 2 +- dts/arm/st/f1/stm32f107.dtsi | 20 +++++++------ dts/arm/st/f2/stm32f207.dtsi | 22 +++++++------- dts/arm/st/f4/stm32f407.dtsi | 22 +++++++------- dts/arm/st/f7/stm32f745.dtsi | 22 +++++++------- dts/arm/st/f7/stm32f765.dtsi | 29 ++++++++++++------- dts/arm/st/h5/stm32h5.dtsi | 18 +++++++----- dts/arm/st/h7/stm32h7.dtsi | 18 +++++++----- dts/arm/st/n6/stm32n6.dtsi | 22 +++++++------- .../ethernet/st,stm32-ethernet-common.yaml | 2 -- soc/st/stm32/Kconfig.defconfig | 4 --- 11 files changed, 99 insertions(+), 82 deletions(-) diff --git a/drivers/ethernet/eth_stm32_hal.c b/drivers/ethernet/eth_stm32_hal.c index a52869bd2c4..56dcc25444a 100644 --- a/drivers/ethernet/eth_stm32_hal.c +++ b/drivers/ethernet/eth_stm32_hal.c @@ -1585,7 +1585,7 @@ BUILD_ASSERT(DT_ENUM_HAS_VALUE(MAC_NODE, phy_connection_type, mii) || static struct eth_stm32_hal_dev_data eth0_data = { .heth = { - .Instance = (ETH_TypeDef *)DT_INST_REG_ADDR(0), + .Instance = (ETH_TypeDef *)DT_REG_ADDR(DT_INST_PARENT(0)), .Init = { #if !defined(CONFIG_ETH_STM32_HAL_API_V2) #if defined(CONFIG_ETH_STM32_AUTO_NEGOTIATION_ENABLE) diff --git a/dts/arm/st/f1/stm32f107.dtsi b/dts/arm/st/f1/stm32f107.dtsi index b4c6c119f5a..8407919515a 100644 --- a/dts/arm/st/f1/stm32f107.dtsi +++ b/dts/arm/st/f1/stm32f107.dtsi @@ -19,16 +19,18 @@ status = "disabled"; }; - mac: ethernet@40028000 { - compatible = "st,stm32-ethernet"; + ethernet@40028000 { reg = <0x40028000 0x2000>; - interrupts = <61 0>; - clock-names = "stmmaceth", "mac-clk-tx", - "mac-clk-rx"; - clocks = <&rcc STM32_CLOCK(AHB1, 14U)>, - <&rcc STM32_CLOCK(AHB1, 15U)>, - <&rcc STM32_CLOCK(AHB1, 16U)>; - status = "disabled"; + mac: ethernet { + compatible = "st,stm32-ethernet"; + interrupts = <61 0>; + clock-names = "stmmaceth", "mac-clk-tx", + "mac-clk-rx"; + clocks = <&rcc STM32_CLOCK(AHB1, 14)>, + <&rcc STM32_CLOCK(AHB1, 15)>, + <&rcc STM32_CLOCK(AHB1, 16)>; + status = "disabled"; + }; mdio: mdio { compatible = "st,stm32-mdio"; diff --git a/dts/arm/st/f2/stm32f207.dtsi b/dts/arm/st/f2/stm32f207.dtsi index 8aa817cedf4..07c38ad646b 100644 --- a/dts/arm/st/f2/stm32f207.dtsi +++ b/dts/arm/st/f2/stm32f207.dtsi @@ -10,17 +10,19 @@ soc { compatible = "st,stm32f207", "st,stm32f2", "simple-bus"; - mac: ethernet@40028000 { - compatible = "st,stm32-ethernet"; + ethernet@40028000 { reg = <0x40028000 0x8000>; - interrupts = <61 0>; - clock-names = "stmmaceth", "mac-clk-tx", - "mac-clk-rx", "mac-clk-ptp"; - clocks = <&rcc STM32_CLOCK(AHB1, 25U)>, - <&rcc STM32_CLOCK(AHB1, 26U)>, - <&rcc STM32_CLOCK(AHB1, 27U)>, - <&rcc STM32_CLOCK(AHB1, 28U)>; - status = "disabled"; + mac: ethernet { + compatible = "st,stm32-ethernet"; + interrupts = <61 0>; + clock-names = "stmmaceth", "mac-clk-tx", + "mac-clk-rx", "mac-clk-ptp"; + clocks = <&rcc STM32_CLOCK(AHB1, 25)>, + <&rcc STM32_CLOCK(AHB1, 26)>, + <&rcc STM32_CLOCK(AHB1, 27)>, + <&rcc STM32_CLOCK(AHB1, 28)>; + status = "disabled"; + }; mdio: mdio { compatible = "st,stm32-mdio"; diff --git a/dts/arm/st/f4/stm32f407.dtsi b/dts/arm/st/f4/stm32f407.dtsi index 0e28fcaef0d..948d917717c 100644 --- a/dts/arm/st/f4/stm32f407.dtsi +++ b/dts/arm/st/f4/stm32f407.dtsi @@ -10,17 +10,19 @@ soc { compatible = "st,stm32f407", "st,stm32f4", "simple-bus"; - mac: ethernet@40028000 { - compatible = "st,stm32-ethernet"; + ethernet@40028000 { reg = <0x40028000 0x8000>; - interrupts = <61 0>; - clock-names = "stmmaceth", "mac-clk-tx", - "mac-clk-rx", "mac-clk-ptp"; - clocks = <&rcc STM32_CLOCK(AHB1, 25U)>, - <&rcc STM32_CLOCK(AHB1, 26U)>, - <&rcc STM32_CLOCK(AHB1, 27U)>, - <&rcc STM32_CLOCK(AHB1, 28U)>; - status = "disabled"; + mac: ethernet { + compatible = "st,stm32-ethernet"; + interrupts = <61 0>; + clock-names = "stmmaceth", "mac-clk-tx", + "mac-clk-rx", "mac-clk-ptp"; + clocks = <&rcc STM32_CLOCK(AHB1, 25)>, + <&rcc STM32_CLOCK(AHB1, 26)>, + <&rcc STM32_CLOCK(AHB1, 27)>, + <&rcc STM32_CLOCK(AHB1, 28)>; + status = "disabled"; + }; mdio: mdio { compatible = "st,stm32-mdio"; diff --git a/dts/arm/st/f7/stm32f745.dtsi b/dts/arm/st/f7/stm32f745.dtsi index 25f6cf87a40..d9e1bac89f0 100644 --- a/dts/arm/st/f7/stm32f745.dtsi +++ b/dts/arm/st/f7/stm32f745.dtsi @@ -75,17 +75,19 @@ status = "disabled"; }; - mac: ethernet@40028000 { - compatible = "st,stm32-ethernet"; + ethernet@40028000 { reg = <0x40028000 0x8000>; - interrupts = <61 0>; - clock-names = "stmmaceth", "mac-clk-tx", - "mac-clk-rx", "mac-clk-ptp"; - clocks = <&rcc STM32_CLOCK(AHB1, 25U)>, - <&rcc STM32_CLOCK(AHB1, 26U)>, - <&rcc STM32_CLOCK(AHB1, 27U)>, - <&rcc STM32_CLOCK(AHB1, 28U)>; - status = "disabled"; + mac: ethernet { + compatible = "st,stm32-ethernet"; + interrupts = <61 0>; + clock-names = "stmmaceth", "mac-clk-tx", + "mac-clk-rx", "mac-clk-ptp"; + clocks = <&rcc STM32_CLOCK(AHB1, 25)>, + <&rcc STM32_CLOCK(AHB1, 26)>, + <&rcc STM32_CLOCK(AHB1, 27)>, + <&rcc STM32_CLOCK(AHB1, 28)>; + status = "disabled"; + }; mdio: mdio { compatible = "st,stm32-mdio"; diff --git a/dts/arm/st/f7/stm32f765.dtsi b/dts/arm/st/f7/stm32f765.dtsi index d8c62d3bf27..625bda190ca 100644 --- a/dts/arm/st/f7/stm32f765.dtsi +++ b/dts/arm/st/f7/stm32f765.dtsi @@ -68,17 +68,26 @@ status = "disabled"; }; - mac: ethernet@40028000 { - compatible = "st,stm32-ethernet"; + ethernet@40028000 { reg = <0x40028000 0x8000>; - interrupts = <61 0>; - clock-names = "stmmaceth", "mac-clk-tx", - "mac-clk-rx", "mac-clk-ptp"; - clocks = <&rcc STM32_CLOCK(AHB1, 25U)>, - <&rcc STM32_CLOCK(AHB1, 26U)>, - <&rcc STM32_CLOCK(AHB1, 27U)>, - <&rcc STM32_CLOCK(AHB1, 28U)>; - status = "disabled"; + mac: ethernet { + compatible = "st,stm32-ethernet"; + interrupts = <61 0>; + clock-names = "stmmaceth", "mac-clk-tx", + "mac-clk-rx", "mac-clk-ptp"; + clocks = <&rcc STM32_CLOCK(AHB1, 25)>, + <&rcc STM32_CLOCK(AHB1, 26)>, + <&rcc STM32_CLOCK(AHB1, 27)>, + <&rcc STM32_CLOCK(AHB1, 28)>; + status = "disabled"; + }; + + mdio: mdio { + compatible = "st,stm32-mdio"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; }; sdmmc2: sdmmc@40011c00 { diff --git a/dts/arm/st/h5/stm32h5.dtsi b/dts/arm/st/h5/stm32h5.dtsi index 3dc4237933c..2f42e93e5a4 100644 --- a/dts/arm/st/h5/stm32h5.dtsi +++ b/dts/arm/st/h5/stm32h5.dtsi @@ -538,15 +538,17 @@ status = "disabled"; }; - mac: ethernet@40028000 { - compatible = "st,stm32h7-ethernet", "st,stm32-ethernet"; + ethernet@40028000 { reg = <0x40028000 0x8000>; - interrupts = <106 0>; - clock-names = "stmmaceth", "mac-clk-tx", "mac-clk-rx"; - clocks = <&rcc STM32_CLOCK(AHB1, 19U)>, - <&rcc STM32_CLOCK(AHB1, 20U)>, - <&rcc STM32_CLOCK(AHB1, 21U)>; - status = "disabled"; + mac: ethernet { + compatible = "st,stm32h7-ethernet", "st,stm32-ethernet"; + interrupts = <106 0>; + clock-names = "stmmaceth", "mac-clk-tx", "mac-clk-rx"; + clocks = <&rcc STM32_CLOCK(AHB1, 19)>, + <&rcc STM32_CLOCK(AHB1, 20)>, + <&rcc STM32_CLOCK(AHB1, 21)>; + status = "disabled"; + }; mdio: mdio { compatible = "st,stm32-mdio"; diff --git a/dts/arm/st/h7/stm32h7.dtsi b/dts/arm/st/h7/stm32h7.dtsi index cd43eb9bfce..e8ac3c53968 100644 --- a/dts/arm/st/h7/stm32h7.dtsi +++ b/dts/arm/st/h7/stm32h7.dtsi @@ -1025,15 +1025,17 @@ status = "disabled"; }; - mac: ethernet@40028000 { - compatible = "st,stm32h7-ethernet", "st,stm32-ethernet"; + ethernet@40028000 { reg = <0x40028000 0x8000>; - interrupts = <61 0>; - clock-names = "stmmaceth", "mac-clk-tx", "mac-clk-rx"; - clocks = <&rcc STM32_CLOCK(AHB1, 15U)>, - <&rcc STM32_CLOCK(AHB1, 16U)>, - <&rcc STM32_CLOCK(AHB1, 17U)>; - status = "disabled"; + mac: ethernet { + compatible = "st,stm32h7-ethernet", "st,stm32-ethernet"; + interrupts = <61 0>; + clock-names = "stmmaceth", "mac-clk-tx", "mac-clk-rx"; + clocks = <&rcc STM32_CLOCK(AHB1, 15)>, + <&rcc STM32_CLOCK(AHB1, 16)>, + <&rcc STM32_CLOCK(AHB1, 17)>; + status = "disabled"; + }; mdio: mdio { compatible = "st,stm32-mdio"; diff --git a/dts/arm/st/n6/stm32n6.dtsi b/dts/arm/st/n6/stm32n6.dtsi index efa4165560a..5363c423c0e 100644 --- a/dts/arm/st/n6/stm32n6.dtsi +++ b/dts/arm/st/n6/stm32n6.dtsi @@ -643,17 +643,19 @@ status = "disabled"; }; - mac: ethernet@58036000 { - compatible = "st,stm32n6-ethernet", "st,stm32h7-ethernet", - "st,stm32-ethernet"; + ethernet@58036000 { reg = <0x58036000 0x8000>; - interrupts = <179 0>; - clock-names = "stmmaceth", "mac-clk-tx", - "mac-clk-rx"; - clocks = <&rcc STM32_CLOCK(AHB5, 22)>, - <&rcc STM32_CLOCK(AHB5, 23)>, - <&rcc STM32_CLOCK(AHB5, 24)>; - status = "disabled"; + mac: ethernet { + compatible = "st,stm32n6-ethernet", "st,stm32h7-ethernet", + "st,stm32-ethernet"; + interrupts = <179 0>; + clock-names = "stmmaceth", "mac-clk-tx", + "mac-clk-rx"; + clocks = <&rcc STM32_CLOCK(AHB5, 22)>, + <&rcc STM32_CLOCK(AHB5, 23)>, + <&rcc STM32_CLOCK(AHB5, 24)>; + status = "disabled"; + }; mdio: mdio { compatible = "st,stm32-mdio"; diff --git a/dts/bindings/ethernet/st,stm32-ethernet-common.yaml b/dts/bindings/ethernet/st,stm32-ethernet-common.yaml index 92ff7484283..69af89f252f 100644 --- a/dts/bindings/ethernet/st,stm32-ethernet-common.yaml +++ b/dts/bindings/ethernet/st,stm32-ethernet-common.yaml @@ -6,8 +6,6 @@ include: [ethernet-controller.yaml, pinctrl-device.yaml] properties: - reg: - required: true interrupts: required: true clocks: diff --git a/soc/st/stm32/Kconfig.defconfig b/soc/st/stm32/Kconfig.defconfig index 67879e6cf62..b34e0c775be 100644 --- a/soc/st/stm32/Kconfig.defconfig +++ b/soc/st/stm32/Kconfig.defconfig @@ -63,10 +63,6 @@ config CLOCK_CONTROL_INIT_PRIORITY default 1 depends on CLOCK_CONTROL -config PHY_INIT_PRIORITY - default 81 - depends on NET_L2_ETHERNET && ETH_DRIVER - # Get flash configuration for NS image from dts flash partition config USE_DT_CODE_PARTITION default y if TRUSTED_EXECUTION_NONSECURE