openeth ethernet / qemu support (#7020)

This commit is contained in:
Andrey Bodrov 2024-09-19 07:07:39 +03:00 committed by GitHub
parent 1596a85e4f
commit 9699719305
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 0 deletions

View file

@ -59,6 +59,7 @@ ETHERNET_TYPES = {
"KSZ8081": EthernetType.ETHERNET_TYPE_KSZ8081,
"KSZ8081RNA": EthernetType.ETHERNET_TYPE_KSZ8081RNA,
"W5500": EthernetType.ETHERNET_TYPE_W5500,
"OPENETH": EthernetType.ETHERNET_TYPE_OPENETH,
}
SPI_ETHERNET_TYPES = ["W5500"]
@ -171,6 +172,7 @@ CONFIG_SCHEMA = cv.All(
"KSZ8081": RMII_SCHEMA,
"KSZ8081RNA": RMII_SCHEMA,
"W5500": SPI_SCHEMA,
"OPENETH": BASE_SCHEMA,
},
upper=True,
),
@ -240,6 +242,9 @@ async def to_code(config):
if CORE.using_esp_idf:
add_idf_sdkconfig_option("CONFIG_ETH_USE_SPI_ETHERNET", True)
add_idf_sdkconfig_option("CONFIG_ETH_SPI_ETHERNET_W5500", True)
elif config[CONF_TYPE] == "OPENETH":
cg.add_define("USE_ETHERNET_OPENETH")
add_idf_sdkconfig_option("CONFIG_ETH_USE_OPENETH", True)
else:
cg.add(var.set_phy_addr(config[CONF_PHY_ADDR]))
cg.add(var.set_mdc_pin(config[CONF_MDC_PIN]))

View file

@ -120,6 +120,8 @@ void EthernetComponent::setup() {
phy_config.reset_gpio_num = this->reset_pin_;
esp_eth_mac_t *mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
#elif defined(USE_ETHERNET_OPENETH)
esp_eth_mac_t *mac = esp_eth_mac_new_openeth(&mac_config);
#else
phy_config.phy_addr = this->phy_addr_;
phy_config.reset_gpio_num = this->power_pin_;
@ -143,6 +145,13 @@ void EthernetComponent::setup() {
#endif
switch (this->type_) {
#ifdef USE_ETHERNET_OPENETH
case ETHERNET_TYPE_OPENETH: {
phy_config.autonego_timeout_ms = 1000;
this->phy_ = esp_eth_phy_new_dp83848(&phy_config);
break;
}
#endif
#if CONFIG_ETH_USE_ESP32_EMAC
case ETHERNET_TYPE_LAN8720: {
this->phy_ = esp_eth_phy_new_lan87xx(&phy_config);
@ -302,6 +311,10 @@ void EthernetComponent::dump_config() {
eth_type = "W5500";
break;
case ETHERNET_TYPE_OPENETH:
eth_type = "OPENETH";
break;
default:
eth_type = "Unknown";
break;

View file

@ -25,6 +25,7 @@ enum EthernetType {
ETHERNET_TYPE_KSZ8081,
ETHERNET_TYPE_KSZ8081RNA,
ETHERNET_TYPE_W5500,
ETHERNET_TYPE_OPENETH,
};
struct ManualIP {

View file

@ -0,0 +1,2 @@
ethernet:
type: OPENETH

View file

@ -0,0 +1 @@
<<: !include common-openeth.yaml