From dae81c58ed159f97591b78dede9f1caccce2978a Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 16 Sep 2025 11:47:49 +0300 Subject: [PATCH 1/2] feat(eth): Add support for LAN867X ETH PHY --- idf_component.yml | 4 ++++ libraries/Ethernet/src/ETH.cpp | 6 ++++++ libraries/Ethernet/src/ETH.h | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/idf_component.yml b/idf_component.yml index eac9eaa4da5..9cbe8aac52c 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -125,6 +125,10 @@ dependencies: chmorgan/esp-libhelix-mp3: version: "1.0.3" require: public + espressif/lan867x: + version: "^2.0.0" + rules: + - if: "target in [esp32, esp32p4]" examples: - path: ./idf_component_examples/hello_world - path: ./idf_component_examples/hw_cdc_hello_world diff --git a/libraries/Ethernet/src/ETH.cpp b/libraries/Ethernet/src/ETH.cpp index 3dfba37c684..5dd973fdfc2 100644 --- a/libraries/Ethernet/src/ETH.cpp +++ b/libraries/Ethernet/src/ETH.cpp @@ -34,6 +34,9 @@ #if defined __has_include && __has_include("soc/emac_ext_struct.h") #include "soc/emac_ext_struct.h" #endif /* __has_include("soc/emac_ext_struct.h" */ +#if ETH_PHY_LAN867X_SUPPORTED +#include "esp_eth_phy_lan867x.h" +#endif #include "soc/rtc.h" #endif /* CONFIG_ETH_USE_ESP32_EMAC */ #include "esp32-hal-periman.h" @@ -292,6 +295,9 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i case ETH_PHY_DP83848: _phy = esp_eth_phy_new_dp83848(&phy_config); break; case ETH_PHY_KSZ8041: _phy = esp_eth_phy_new_ksz80xx(&phy_config); break; case ETH_PHY_KSZ8081: _phy = esp_eth_phy_new_ksz80xx(&phy_config); break; +#if ETH_PHY_LAN867X_SUPPORTED + case ETH_PHY_LAN867X: _phy = esp_eth_phy_new_lan867x(&phy_config); break; +#endif default: log_e("Unsupported PHY %d", type); break; } if (_phy == NULL) { diff --git a/libraries/Ethernet/src/ETH.h b/libraries/Ethernet/src/ETH.h index 6ceb43f316d..f609c651102 100644 --- a/libraries/Ethernet/src/ETH.h +++ b/libraries/Ethernet/src/ETH.h @@ -78,6 +78,9 @@ #include "esp_netif.h" #if CONFIG_ETH_USE_ESP32_EMAC +#if defined __has_include && __has_include("esp_eth_phy_lan867x.h") +#define ETH_PHY_LAN867X_SUPPORTED 1 +#endif #define ETH_PHY_IP101 ETH_PHY_TLK110 #if CONFIG_IDF_TARGET_ESP32 typedef enum { @@ -138,6 +141,9 @@ typedef enum { ETH_PHY_DP83848, ETH_PHY_KSZ8041, ETH_PHY_KSZ8081, +#if ETH_PHY_LAN867X_SUPPORTED + ETH_PHY_LAN867X, +#endif #endif /* CONFIG_ETH_USE_ESP32_EMAC */ #if CONFIG_ETH_SPI_ETHERNET_DM9051 ETH_PHY_DM9051, From 065f920f1c40855e05842646b53707da96bce07f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 16 Sep 2025 12:03:42 +0000 Subject: [PATCH 2/2] ci(pre-commit): Apply automatic fixes --- libraries/Ethernet/src/ETH.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Ethernet/src/ETH.cpp b/libraries/Ethernet/src/ETH.cpp index 5dd973fdfc2..7d808c620d8 100644 --- a/libraries/Ethernet/src/ETH.cpp +++ b/libraries/Ethernet/src/ETH.cpp @@ -298,7 +298,7 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i #if ETH_PHY_LAN867X_SUPPORTED case ETH_PHY_LAN867X: _phy = esp_eth_phy_new_lan867x(&phy_config); break; #endif - default: log_e("Unsupported PHY %d", type); break; + default: log_e("Unsupported PHY %d", type); break; } if (_phy == NULL) { log_e("esp_eth_phy_new failed");