Replies: 3 comments 6 replies
-
Thanks for trying to address this issue. Likely, what we miss is a way to bind the node with its phy. Using this new property eth node, we could do something like (quick attempt, to be verified): #define PHY_ADDR DT_REG_ADDR(DT_INST_PHANDLE(0, phy_handle)))
#if defined(CONFIG_MDIO)
static const struct device *eth_stm32_phy_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0, phy_handle));
#endif Note that it would also require some protection for the parts that don't declare this property, but it should be the correct way to go. |
Beta Was this translation helpful? Give feedback.
-
Indeed, you're right @erwango, the Following the numerous examples that can be found, I've followed this implementation: Unfortunately I have a device tree node token error at compile time... To reproduce:Board: boards/st/stm32h573i_dk/stm32h573i_dk.dts &mac {
status = "okay";
pinctrl-0 = <ð_rxd0_pc4
ð_rxd1_pc5
ð_ref_clk_pa1
ð_crs_dv_pa7
ð_tx_en_pg11
ð_txd0_pg13
ð_txd1_pg12>;
pinctrl-names = "default";
+ phy-handle = <&phy>;
};
&mdio {
status = "okay";
pinctrl-0 = <ð_mdio_pa2 ð_mdc_pc1>;
pinctrl-names = "default";
- ethernet-phy@0 {
+ phy: ethernet-phy@0 {
compatible = "ethernet-phy";
reg = <0x00>;
status = "okay";
};
}; drivers/ethernet/eth_stm32_hal.c - #define PHY_ADDR CONFIG_ETH_STM32_HAL_PHY_ADDRESS
+ #define PHY_ADDR DT_REG_ADDR(DT_INST_PHANDLE(0, phy_handle))
#if defined(CONFIG_MDIO)
- #define DEVICE_PHY_BY_NAME(n) \
- DEVICE_DT_GET(DT_CHILD(DT_INST_CHILD(n, mdio), _CONCAT(ethernet_phy_, PHY_ADDR)))
- static const struct device *eth_stm32_phy_dev = DEVICE_PHY_BY_NAME(0);
+ static const struct device *eth_stm32_phy_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0, phy_handle)); west build -b stm32h573i_dk samples/net/ipv4_autoconf/ |
Beta Was this translation helpful? Give feedback.
-
Ok, so I'm not able to dig much into this right now, indeed the actual issue would be the negative value provided as ordinal ( will output in -4 as ordinal for the node and this is due to phy-handle = <&phy>; introduction, for some reason
|
Beta Was this translation helpful? Give feedback.
-
Introduction
The objective of this discussion is to find a way to simplify ethernet PHY address resolution inside ST's HAL.
The problem
Currently there are two distinct settings that define the PHY address that the HAL has to use:
CONFIG_ETH_STM32_HAL_PHY_ADDRESS
.ethernet-phy
and itsreg
field.drivers/ethernet/eth_stm32_hal.c
Propositions
Resolve with node label
Adding a node label that indicates in the device tree the physical line used by the HAL.
This solution allows a board to have multiple PHY connected, and the one used by the HAL is clearly identified.
drivers/ethernet/eth_stm32_hal.c
Beta Was this translation helpful? Give feedback.
All reactions