Skip to content

Commit ecbbc51

Browse files
committed
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] espressif/esp-idf@0738314 [2] espressif/esp-eth-drivers#28 Signed-off-by: Elvis Pfutzenreuter <[email protected]>
1 parent 90aeac8 commit ecbbc51

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

docs/esp32/quickref.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Required keyword arguments for the constructor:
148148
- ``mdc`` and ``mdio`` - :class:`machine.Pin` objects (or integers) specifying
149149
the MDC and MDIO pins.
150150
- ``phy_type`` - Select the PHY device type. Supported devices are
151+
``PHY_GENERIC``,
151152
``PHY_LAN8710``, ``PHY_LAN8720``, ``PHY_IP101``, ``PHY_RTL8201``,
152153
``PHY_DP83848``, ``PHY_KSZ8041`` and ``PHY_KSZ8081``. These values are all
153154
constants defined in the ``network`` module.

ports/esp32/modnetwork.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,22 @@
3535
#define PHY_LAN867X_ENABLED (0)
3636
#endif
3737

38+
// PHY_GENERIC support requires newer IDF version
39+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) && CONFIG_IDF_TARGET_ESP32
40+
#define PHY_GENERIC_ENABLED (1)
41+
#else
42+
#define PHY_GENERIC_ENABLED (0)
43+
#endif
44+
3845
enum {
3946
// PHYs supported by the internal Ethernet MAC:
4047
PHY_LAN8710, PHY_LAN8720, PHY_IP101, PHY_RTL8201, PHY_DP83848, PHY_KSZ8041, PHY_KSZ8081,
4148
#if PHY_LAN867X_ENABLED
4249
PHY_LAN8670,
4350
#endif
51+
#if PHY_GENERIC_ENABLED
52+
PHY_GENERIC,
53+
#endif
4454
// PHYs which are actually SPI Ethernet MAC+PHY chips:
4555
PHY_KSZ8851SNL = 100, PHY_DM9051, PHY_W5500
4656
};

ports/esp32/modnetwork_globals.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
#if PHY_LAN867X_ENABLED
5151
{ MP_ROM_QSTR(MP_QSTR_PHY_LAN8670), MP_ROM_INT(PHY_LAN8670) },
5252
#endif
53+
#if PHY_GENERIC_ENABLED
54+
{ MP_ROM_QSTR(MP_QSTR_PHY_GENERIC), MP_ROM_INT(PHY_GENERIC) },
55+
#endif
5356

5457
#if CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL
5558
{ MP_ROM_QSTR(MP_QSTR_PHY_KSZ8851SNL), MP_ROM_INT(PHY_KSZ8851SNL) },

ports/esp32/network_lan.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
163163
#if PHY_LAN867X_ENABLED
164164
args[ARG_phy_type].u_int != PHY_LAN8670 &&
165165
#endif
166+
#if PHY_GENERIC_ENABLED
167+
args[ARG_phy_type].u_int != PHY_GENERIC &&
168+
#endif
166169
#if CONFIG_ETH_USE_SPI_ETHERNET
167170
#if CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL
168171
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
243246
self->phy = esp_eth_phy_new_lan867x(&phy_config);
244247
break;
245248
#endif
249+
#if PHY_GENERIC_ENABLED
250+
case PHY_GENERIC:
251+
self->phy = esp_eth_phy_new_generic(&phy_config);
252+
break;
253+
#endif
246254
#endif // CONFIG_IDF_TARGET_ESP32
247255
#if CONFIG_ETH_USE_SPI_ETHERNET
248256
#if CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL

0 commit comments

Comments
 (0)