Skip to content

Commit

Permalink
Add ethernet PHY clock enable GPIO settings
Browse files Browse the repository at this point in the history
  • Loading branch information
whc2001 committed Jun 8, 2024
1 parent e789d97 commit 08b96b3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
16 changes: 16 additions & 0 deletions components/eth_interface/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,20 @@ menu "Snapclient Ethernet Configuration"
help
Set the second SPI Ethernet module PHY address according your board schematic.
endif # SNAPCLIENT_USE_SPI_ETHERNET

config SNAPCLIENT_ETH_CLOCK_ENABLE_GPIO
depends on SNAPCLIENT_USE_INTERNAL_ETHERNET || SNAPCLIENT_USE_SPI_ETHERNET
int "PHY Clock Enable GPIO"
default 5
help
GPIO number to control ethernet PHY's clock.
Some PHY may have constant clock output even during reset, which might cause boot failure when using clock input
mode with GPIO0. This GPIO will be configured after boot.

config SNAPCLIENT_ETH_CLOCK_ENABLE_ACTIVE_LOW
depends on SNAPCLIENT_USE_INTERNAL_ETHERNET || SNAPCLIENT_USE_SPI_ETHERNET
bool "PHY Clock Enable active LOW"
default false
help
Output LOW instead of HIGH on eithernet PHY clock enable pin for enable state.
endmenu
17 changes: 12 additions & 5 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2758,8 +2758,9 @@ void app_main(void) {
esp_log_level_set("wifi", ESP_LOG_WARN);
esp_log_level_set("wifi_init", ESP_LOG_WARN);

#if CONFIG_SNAPCLIENT_USE_INTERNAL_ETHERNET || \
CONFIG_SNAPCLIENT_USE_SPI_ETHERNET
#if (CONFIG_SNAPCLIENT_USE_INTERNAL_ETHERNET || \
CONFIG_SNAPCLIENT_USE_SPI_ETHERNET) && \
(CONFIG_SNAPCLIENT_ETH_CLOCK_ENABLE_GPIO > -1)
// clang-format off
// nINT/REFCLKO Function Select Configuration Strap
// • When nINTSEL is floated or pulled to
Expand All @@ -2777,12 +2778,18 @@ void app_main(void) {
// for MAC unit.
//
// clang-format on
gpio_config_t cfg = {.pin_bit_mask = BIT64(GPIO_NUM_5),
.mode = GPIO_MODE_DEF_INPUT,
ESP_LOGI(TAG, "Setting ethernet clock enable GPIO");
gpio_config_t cfg = {.pin_bit_mask = BIT64(CONFIG_SNAPCLIENT_ETH_CLOCK_ENABLE_GPIO),
.mode = GPIO_MODE_DEF_OUTPUT,
.pull_up_en = GPIO_PULLUP_DISABLE,
.pull_down_en = GPIO_PULLDOWN_ENABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE,
.intr_type = GPIO_INTR_DISABLE};
gpio_config(&cfg);
#if CONFIG_SNAPCLIENT_ETH_CLOCK_ENABLE_ACTIVE_LOW
gpio_set_level((gpio_num_t)CONFIG_SNAPCLIENT_ETH_CLOCK_ENABLE_GPIO, 0);
#else
gpio_set_level((gpio_num_t)CONFIG_SNAPCLIENT_ETH_CLOCK_ENABLE_GPIO, 1);
#endif
#endif

#if CONFIG_AUDIO_BOARD_CUSTOM && CONFIG_DAC_ADAU1961
Expand Down

0 comments on commit 08b96b3

Please sign in to comment.