summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorElvis Pfutzenreuter <epxx@epxx.co>2025-05-01 14:30:04 -0300
committerElvis Pfutzenreuter <epxx@epxx.co>2025-05-16 15:34:20 -0300
commitecbbc512b2083c472f7bec45e8fae521e7af22aa (patch)
tree81a3dc444878c6228f9b7d7bb9b3f88ed483ab25
parent90aeac800a0ac861c64dda4b99db1a3f0ed91cea (diff)
downloadmicropython-ecbbc512b2083c472f7bec45e8fae521e7af22aa.tar.gz
micropython-ecbbc512b2083c472f7bec45e8fae521e7af22aa.zip
esp32/network_lan: Add PHY_GENERIC device type.
Support the new PHY_GENERIC device type, added in ESP-IDF v5.4.0 [1]. This PHY driver was added to ESP-IDF to support "generic"/oddball PHY LAN chips like the JL1101, which offer no features beyond the bare 802.3 PHY standard and don't actually need a chip-specific driver (see discussion at [2]). [1] https://github.com/espressif/esp-idf/commit/0738314308ad36a73601ddb8bb82f1dcbfe1f550 [2] https://github.com/espressif/esp-eth-drivers/pull/28 Signed-off-by: Elvis Pfutzenreuter <epxx@epxx.co>
-rw-r--r--docs/esp32/quickref.rst1
-rw-r--r--ports/esp32/modnetwork.h10
-rw-r--r--ports/esp32/modnetwork_globals.h3
-rw-r--r--ports/esp32/network_lan.c8
4 files changed, 22 insertions, 0 deletions
diff --git a/docs/esp32/quickref.rst b/docs/esp32/quickref.rst
index 56d8b0e4f6..4e70ff255e 100644
--- a/docs/esp32/quickref.rst
+++ b/docs/esp32/quickref.rst
@@ -148,6 +148,7 @@ Required keyword arguments for the constructor:
- ``mdc`` and ``mdio`` - :class:`machine.Pin` objects (or integers) specifying
the MDC and MDIO pins.
- ``phy_type`` - Select the PHY device type. Supported devices are
+ ``PHY_GENERIC``,
``PHY_LAN8710``, ``PHY_LAN8720``, ``PHY_IP101``, ``PHY_RTL8201``,
``PHY_DP83848``, ``PHY_KSZ8041`` and ``PHY_KSZ8081``. These values are all
constants defined in the ``network`` module.
diff --git a/ports/esp32/modnetwork.h b/ports/esp32/modnetwork.h
index 4debea1114..ba69d5cc0f 100644
--- a/ports/esp32/modnetwork.h
+++ b/ports/esp32/modnetwork.h
@@ -35,12 +35,22 @@
#define PHY_LAN867X_ENABLED (0)
#endif
+// PHY_GENERIC support requires newer IDF version
+#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) && CONFIG_IDF_TARGET_ESP32
+#define PHY_GENERIC_ENABLED (1)
+#else
+#define PHY_GENERIC_ENABLED (0)
+#endif
+
enum {
// PHYs supported by the internal Ethernet MAC:
PHY_LAN8710, PHY_LAN8720, PHY_IP101, PHY_RTL8201, PHY_DP83848, PHY_KSZ8041, PHY_KSZ8081,
#if PHY_LAN867X_ENABLED
PHY_LAN8670,
#endif
+ #if PHY_GENERIC_ENABLED
+ PHY_GENERIC,
+ #endif
// PHYs which are actually SPI Ethernet MAC+PHY chips:
PHY_KSZ8851SNL = 100, PHY_DM9051, PHY_W5500
};
diff --git a/ports/esp32/modnetwork_globals.h b/ports/esp32/modnetwork_globals.h
index 9909e7c056..12252ddbc5 100644
--- a/ports/esp32/modnetwork_globals.h
+++ b/ports/esp32/modnetwork_globals.h
@@ -50,6 +50,9 @@
#if PHY_LAN867X_ENABLED
{ MP_ROM_QSTR(MP_QSTR_PHY_LAN8670), MP_ROM_INT(PHY_LAN8670) },
#endif
+#if PHY_GENERIC_ENABLED
+{ MP_ROM_QSTR(MP_QSTR_PHY_GENERIC), MP_ROM_INT(PHY_GENERIC) },
+#endif
#if CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL
{ MP_ROM_QSTR(MP_QSTR_PHY_KSZ8851SNL), MP_ROM_INT(PHY_KSZ8851SNL) },
diff --git a/ports/esp32/network_lan.c b/ports/esp32/network_lan.c
index bf6b565e8c..309ee0b14a 100644
--- a/ports/esp32/network_lan.c
+++ b/ports/esp32/network_lan.c
@@ -163,6 +163,9 @@ static mp_obj_t get_lan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar
#if PHY_LAN867X_ENABLED
args[ARG_phy_type].u_int != PHY_LAN8670 &&
#endif
+ #if PHY_GENERIC_ENABLED
+ args[ARG_phy_type].u_int != PHY_GENERIC &&
+ #endif
#if CONFIG_ETH_USE_SPI_ETHERNET
#if CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL
args[ARG_phy_type].u_int != PHY_KSZ8851SNL &&
@@ -243,6 +246,11 @@ static mp_obj_t get_lan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar
self->phy = esp_eth_phy_new_lan867x(&phy_config);
break;
#endif
+ #if PHY_GENERIC_ENABLED
+ case PHY_GENERIC:
+ self->phy = esp_eth_phy_new_generic(&phy_config);
+ break;
+ #endif
#endif // CONFIG_IDF_TARGET_ESP32
#if CONFIG_ETH_USE_SPI_ETHERNET
#if CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL