Skip to content

Commit 3238878

Browse files
committedMar 27, 2025
drivers: ethernet: Integrate GRMII and RMII interfaces
Added macros `STM32_ETH_PHY_MODE` to determine the PHY mode (RGMII, GMII, RMII, and MII) from the `phy_connection_type` property in the device tree. Signed-off-by: IBEN EL HADJ MESSAOUD Marwa <marwa.ibenelhadjmessaoud-ext@st.com>
1 parent add20e4 commit 3238878

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed
 

‎drivers/ethernet/eth_stm32_hal.c

+18-2
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,18 @@ static const struct device *eth_stm32_phy_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0,
8080

8181
#define MAC_NODE DT_NODELABEL(mac)
8282

83+
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32n6_ethernet)
84+
#define STM32_ETH_PHY_MODE(node_id) \
85+
((DT_ENUM_HAS_VALUE(node_id, phy_connection_type, mii) ? HAL_ETH_MII_MODE : \
86+
(DT_ENUM_HAS_VALUE(node_id, phy_connection_type, rmii) ? HAL_ETH_RMII_MODE : \
87+
(DT_ENUM_HAS_VALUE(node_id, phy_connection_type, gmii) ? HAL_ETH_GMII_MODE : \
88+
(DT_ENUM_HAS_VALUE(node_id, phy_connection_type, rgmii) ? HAL_ETH_RGMII_MODE : \
89+
HAL_ETH_RMII_MODE)))))
90+
#else
8391
#define STM32_ETH_PHY_MODE(node_id) \
8492
(DT_ENUM_HAS_VALUE(node_id, phy_connection_type, mii) ? \
8593
ETH_MEDIA_INTERFACE_MII : ETH_MEDIA_INTERFACE_RMII)
94+
#endif
8695

8796
#define ETH_DMA_TX_TIMEOUT_MS 20U /* transmit timeout in milliseconds */
8897

@@ -1138,7 +1147,12 @@ static void set_mac_config(const struct device *dev, struct phy_link_state *stat
11381147
mac_config.DuplexMode =
11391148
PHY_LINK_IS_FULL_DUPLEX(state->speed) ? ETH_FULLDUPLEX_MODE : ETH_HALFDUPLEX_MODE;
11401149

1141-
mac_config.Speed = PHY_LINK_IS_SPEED_100M(state->speed) ? ETH_SPEED_100M : ETH_SPEED_10M;
1150+
mac_config.Speed =
1151+
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32n6_ethernet)
1152+
PHY_LINK_IS_SPEED_1000M(state->speed) ? ETH_SPEED_1000M :
1153+
#endif
1154+
PHY_LINK_IS_SPEED_100M(state->speed) ? ETH_SPEED_100M : ETH_SPEED_10M;
1155+
11421156

11431157
hal_ret = HAL_ETH_SetMACConfig(heth, &mac_config);
11441158
if (hal_ret != HAL_OK) {
@@ -1476,7 +1490,9 @@ static const struct eth_stm32_hal_dev_cfg eth0_config = {
14761490
};
14771491

14781492
BUILD_ASSERT(DT_ENUM_HAS_VALUE(MAC_NODE, phy_connection_type, mii) ||
1479-
DT_ENUM_HAS_VALUE(MAC_NODE, phy_connection_type, rmii),
1493+
DT_ENUM_HAS_VALUE(MAC_NODE, phy_connection_type, rmii) ||
1494+
DT_ENUM_HAS_VALUE(MAC_NODE, phy_connection_type, rgmii) ||
1495+
DT_ENUM_HAS_VALUE(MAC_NODE, phy_connection_type, gmii),
14801496
"Unsupported PHY connection type selected");
14811497

14821498
static struct eth_stm32_hal_dev_data eth0_data = {

0 commit comments

Comments
 (0)