diff --git a/boards/xtensa/esp32_ethernet_kit/esp32_ethernet_kit.dts b/boards/xtensa/esp32_ethernet_kit/esp32_ethernet_kit.dts index d772cd817d3..b0c3bf9e2b2 100644 --- a/boards/xtensa/esp32_ethernet_kit/esp32_ethernet_kit.dts +++ b/boards/xtensa/esp32_ethernet_kit/esp32_ethernet_kit.dts @@ -115,7 +115,10 @@ }; }; -ð { +&mdio { + pinctrl-0 = <&mdio_default>; + pinctrl-names = "default"; + phy: phy { compatible = "ethernet-phy"; status = "disabled"; @@ -124,7 +127,6 @@ }; }; -&mdio { - pinctrl-0 = <&mdio_default>; - pinctrl-names = "default"; +ð { + phy-handle = <&phy>; }; diff --git a/drivers/ethernet/eth_esp32.c b/drivers/ethernet/eth_esp32.c index ca02d013ee7..0b1744efe6c 100644 --- a/drivers/ethernet/eth_esp32.c +++ b/drivers/ethernet/eth_esp32.c @@ -47,6 +47,9 @@ struct eth_esp32_dev_data { struct k_thread rx_thread; }; +static const struct device *eth_esp32_phy_dev = DEVICE_DT_GET( + DT_INST_PHANDLE(0, phy_handle)); + static enum ethernet_hw_caps eth_esp32_caps(const struct device *dev) { ARG_UNUSED(dev); @@ -278,7 +281,6 @@ static void eth_esp32_iface_init(struct net_if *iface) { const struct device *dev = net_if_get_device(iface); struct eth_esp32_dev_data *dev_data = dev->data; - const struct device *phy_dev = DEVICE_DT_GET(DT_INST_CHILD(0, phy)); dev_data->iface = iface; @@ -288,8 +290,9 @@ static void eth_esp32_iface_init(struct net_if *iface) ethernet_init(iface); - if (device_is_ready(phy_dev)) { - phy_link_callback_set(phy_dev, phy_link_state_changed, (void *)dev); + if (device_is_ready(eth_esp32_phy_dev)) { + phy_link_callback_set(eth_esp32_phy_dev, phy_link_state_changed, + (void *)dev); } else { LOG_ERR("PHY device not ready"); } diff --git a/dts/bindings/ethernet/espressif,esp32-eth.yaml b/dts/bindings/ethernet/espressif,esp32-eth.yaml index b3021da7ca3..3ffd12cdc50 100644 --- a/dts/bindings/ethernet/espressif,esp32-eth.yaml +++ b/dts/bindings/ethernet/espressif,esp32-eth.yaml @@ -19,3 +19,5 @@ properties: Phy connection type define the physical interface connection between PHY and MAC. The default value uses Reduced Media-Independent Interface (RMII) mode. + phy-handle: + required: true