Skip to content

Commit

Permalink
Merge branch 'feature/esp_emac_improvements_v5.3' into 'release/v5.3'
Browse files Browse the repository at this point in the history
Feature/esp emac improvements (v5.3)

See merge request espressif/esp-idf!31368
  • Loading branch information
david-cermak committed Jun 11, 2024
2 parents 5c61874 + 09cbbaa commit 943dd72
Show file tree
Hide file tree
Showing 66 changed files with 2,273 additions and 1,480 deletions.
38 changes: 19 additions & 19 deletions components/esp_eth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ set(ld_fragments linker.lf)
# As CONFIG_ETH_ENABLED comes from Kconfig, it is not evaluated yet
# when components are being registered.
# Thus, always add the (private) requirements, regardless of Kconfig
set(priv_requires driver log esp_timer)
set(priv_requires log esp_timer esp_driver_spi esp_driver_gpio)

# If Ethernet disabled in Kconfig, this is a config-only component
if(CONFIG_ETH_ENABLED)
set(srcs "src/esp_eth.c" "src/esp_eth_phy_802_3.c")
set(srcs "src/esp_eth.c" "src/phy/esp_eth_phy_802_3.c")
set(include "include")

if(NOT CMAKE_BUILD_EARLY_EXPANSION)
Expand All @@ -27,34 +27,34 @@ if(CONFIG_ETH_ENABLED)
endif()

if(CONFIG_ETH_USE_ESP32_EMAC)
list(APPEND srcs "src/esp_eth_mac_esp.c"
"src/esp_eth_mac_esp_dma.c"
"src/esp_eth_mac_esp_gpio.c"
"src/esp_eth_phy_dp83848.c"
"src/esp_eth_phy_ip101.c"
"src/esp_eth_phy_ksz80xx.c"
"src/esp_eth_phy_lan87xx.c"
"src/esp_eth_phy_rtl8201.c")
list(APPEND srcs "src/mac/esp_eth_mac_esp.c"
"src/mac/esp_eth_mac_esp_dma.c"
"src/mac/esp_eth_mac_esp_gpio.c"
"src/phy/esp_eth_phy_dp83848.c"
"src/phy/esp_eth_phy_ip101.c"
"src/phy/esp_eth_phy_ksz80xx.c"
"src/phy/esp_eth_phy_lan87xx.c"
"src/phy/esp_eth_phy_rtl8201.c")
endif()

if(CONFIG_ETH_SPI_ETHERNET_DM9051)
list(APPEND srcs "src/esp_eth_mac_dm9051.c"
"src/esp_eth_phy_dm9051.c")
list(APPEND srcs "src/spi/dm9051/esp_eth_mac_dm9051.c"
"src/spi/dm9051/esp_eth_phy_dm9051.c")
endif()

if(CONFIG_ETH_SPI_ETHERNET_W5500)
list(APPEND srcs "src/esp_eth_mac_w5500.c"
"src/esp_eth_phy_w5500.c")
list(APPEND srcs "src/spi/w5500/esp_eth_mac_w5500.c"
"src/spi/w5500/esp_eth_phy_w5500.c")
endif()

if(CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL)
list(APPEND srcs "src/esp_eth_mac_ksz8851snl.c"
"src/esp_eth_phy_ksz8851snl.c")
list(APPEND srcs "src/spi/ksz8851snl/esp_eth_mac_ksz8851snl.c"
"src/spi/ksz8851snl/esp_eth_phy_ksz8851snl.c")
endif()

if(CONFIG_ETH_USE_OPENETH)
list(APPEND srcs "src/esp_eth_mac_openeth.c"
"src/esp_eth_phy_dp83848.c")
list(APPEND srcs "src/openeth/esp_eth_mac_openeth.c"
"src/phy/esp_eth_phy_dp83848.c")
endif()
endif()

Expand All @@ -66,7 +66,7 @@ idf_component_register(SRCS "${srcs}"

if(CONFIG_ETH_ENABLED)
if(CONFIG_ETH_USE_SPI_ETHERNET)
idf_component_optional_requires(PUBLIC driver esp_driver_gpio)
idf_component_optional_requires(PUBLIC esp_driver_spi)
endif()
idf_component_optional_requires(PRIVATE esp_netif esp_pm)
if(CONFIG_SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE)
Expand Down
2 changes: 1 addition & 1 deletion components/esp_eth/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ menu "Ethernet"
endchoice

if ETH_PHY_INTERFACE_RMII
choice ETH_RMII_CLK_MODE
choice ETH_RMII_CLK_MODE # IDF-9724
depends on IDF_TARGET_ESP32
prompt "RMII clock mode"
default ETH_RMII_CLK_INPUT
Expand Down
13 changes: 12 additions & 1 deletion components/esp_eth/include/esp_eth_com.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -14,6 +14,17 @@
extern "C" {
#endif

/**
* @brief Offset for start of MAC custom ioctl commands
*
*/
#define ETH_CMD_CUSTOM_MAC_CMDS_OFFSET 0x0FFF
/**
* @brief Offset for start of PHY custom ioctl commands
*
*/
#define ETH_CMD_CUSTOM_PHY_CMDS_OFFSET 0x1FFF

/**
* @brief Ethernet driver state
*
Expand Down
42 changes: 36 additions & 6 deletions components/esp_eth/include/esp_eth_driver.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once

#include "esp_eth_com.h"
#include "esp_eth_mac.h"
#if CONFIG_ETH_USE_SPI_ETHERNET
#include "esp_eth_mac_spi.h"
#endif // CONFIG_ETH_USE_SPI_ETHERNET
#if CONFIG_ETH_USE_ESP32_EMAC
#include "esp_eth_mac_esp.h"
#endif // CONFIG_ETH_USE_ESP32_EMAC
#if CONFIG_ETH_USE_OPENETH
#include "esp_eth_mac_openeth.h"
#endif // CONFIG_ETH_USE_OPENETH
#include "esp_eth_phy.h"

#ifdef __cplusplus
Expand Down Expand Up @@ -151,8 +159,8 @@ typedef enum {
ETH_CMD_READ_PHY_REG, /*!< Read PHY register */
ETH_CMD_WRITE_PHY_REG, /*!< Write PHY register */

ETH_CMD_CUSTOM_MAC_CMDS = 0x0FFF, // Offset for start of MAC custom commands
ETH_CMD_CUSTOM_PHY_CMDS = 0x1FFF, // Offset for start of PHY custom commands
ETH_CMD_CUSTOM_MAC_CMDS = ETH_CMD_CUSTOM_MAC_CMDS_OFFSET, // Offset for start of MAC custom commands
ETH_CMD_CUSTOM_PHY_CMDS = ETH_CMD_CUSTOM_PHY_CMDS_OFFSET, // Offset for start of PHY custom commands
} esp_eth_io_cmd_t;

/**
Expand Down Expand Up @@ -272,15 +280,15 @@ esp_err_t esp_eth_transmit(esp_eth_handle_t hdl, void *buf, size_t length);
* @param[in] argc number variable arguments
* @param ... variable arguments
* @return
* - ESP_OK: transmit successfull
* - ESP_OK: transmit successful
* - ESP_ERR_INVALID_STATE: invalid driver state (e.i. driver is not started)
* - ESP_ERR_TIMEOUT: transmit frame buffer failed because HW was not get available in predefined period
* - ESP_FAIL: transmit frame buffer failed because some other error occurred
*/
esp_err_t esp_eth_transmit_vargs(esp_eth_handle_t hdl, uint32_t argc, ...);

/**
* @brief Misc IO function of Etherent driver
* @brief Misc IO function of Ethernet driver
*
* @param[in] hdl: handle of Ethernet driver
* @param[in] cmd: IO control command
Expand Down Expand Up @@ -314,6 +322,28 @@ esp_err_t esp_eth_transmit_vargs(esp_eth_handle_t hdl, uint32_t argc, ...);
*/
esp_err_t esp_eth_ioctl(esp_eth_handle_t hdl, esp_eth_io_cmd_t cmd, void *data);

/**
* @brief Get PHY instance memory address
*
* @param[in] hdl handle of Ethernet driver
* @param[out] phy pointer to memory to store the instance
* @return esp_err_t
* - ESP_OK: success
* - ESP_ERR_INVALID_ARG: failed because of some invalid argument
*/
esp_err_t esp_eth_get_phy_instance(esp_eth_handle_t hdl, esp_eth_phy_t **phy);

/**
* @brief Get MAC instance memory address
*
* @param[in] hdl handle of Ethernet driver
* @param[out] mac pointer to memory to store the instance
* @return esp_err_t
* - ESP_OK: success
* - ESP_ERR_INVALID_ARG: failed because of some invalid argument
*/
esp_err_t esp_eth_get_mac_instance(esp_eth_handle_t hdl, esp_eth_mac_t **mac);

/**
* @brief Increase Ethernet driver reference
* @note Ethernet driver handle can be obtained by os timer, netif, etc.
Expand Down
Loading

0 comments on commit 943dd72

Please sign in to comment.