forked from espressif/esp-idf
esp_eth: change rtl8201 reset timing to match datasheet
In esp_eth_phy_rtl8201.c: Add 150ms delay after hardware reset, chage reset assertion time to 10ms In esp_eth_phy_802_3.c: Change reset function to use vTaskDelay for long (>=10ms) reset assertion time Change esp_eth_phy_802_3_detect_phy_addr to check range 0-31 instead of 0-15.
This commit is contained in:
@@ -366,7 +366,11 @@ esp_err_t esp_eth_phy_802_3_reset_hw(phy_802_3_t *phy_802_3, uint32_t reset_asse
|
|||||||
esp_rom_gpio_pad_select_gpio(phy_802_3->reset_gpio_num);
|
esp_rom_gpio_pad_select_gpio(phy_802_3->reset_gpio_num);
|
||||||
gpio_set_direction(phy_802_3->reset_gpio_num, GPIO_MODE_OUTPUT);
|
gpio_set_direction(phy_802_3->reset_gpio_num, GPIO_MODE_OUTPUT);
|
||||||
gpio_set_level(phy_802_3->reset_gpio_num, 0);
|
gpio_set_level(phy_802_3->reset_gpio_num, 0);
|
||||||
esp_rom_delay_us(reset_assert_us);
|
if (reset_assert_us < 10000) {
|
||||||
|
esp_rom_delay_us(reset_assert_us);
|
||||||
|
} else {
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(reset_assert_us/1000));
|
||||||
|
}
|
||||||
gpio_set_level(phy_802_3->reset_gpio_num, 1);
|
gpio_set_level(phy_802_3->reset_gpio_num, 1);
|
||||||
}
|
}
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
@@ -380,14 +384,14 @@ esp_err_t esp_eth_phy_802_3_detect_phy_addr(esp_eth_mediator_t *eth, int *detect
|
|||||||
}
|
}
|
||||||
int addr_try = 0;
|
int addr_try = 0;
|
||||||
uint32_t reg_value = 0;
|
uint32_t reg_value = 0;
|
||||||
for (; addr_try < 16; addr_try++) {
|
for (; addr_try < 32; addr_try++) {
|
||||||
eth->phy_reg_read(eth, addr_try, ETH_PHY_IDR1_REG_ADDR, ®_value);
|
eth->phy_reg_read(eth, addr_try, ETH_PHY_IDR1_REG_ADDR, ®_value);
|
||||||
if (reg_value != 0xFFFF && reg_value != 0x00) {
|
if (reg_value != 0xFFFF && reg_value != 0x00) {
|
||||||
*detected_addr = addr_try;
|
*detected_addr = addr_try;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (addr_try < 16) {
|
if (addr_try < 32) {
|
||||||
ESP_LOGD(TAG, "Found PHY address: %d", addr_try);
|
ESP_LOGD(TAG, "Found PHY address: %d", addr_try);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
@@ -9,8 +9,13 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_check.h"
|
#include "esp_check.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
#include "esp_eth_phy_802_3.h"
|
#include "esp_eth_phy_802_3.h"
|
||||||
|
|
||||||
|
#define RTL8201_PHY_RESET_ASSERTION_TIME_US 10000
|
||||||
|
#define RTL8201_PHY_POST_RESET_INIT_TIME_MS 150
|
||||||
|
|
||||||
static const char *TAG = "rtl8201";
|
static const char *TAG = "rtl8201";
|
||||||
|
|
||||||
/***************Vendor Specific Register***************/
|
/***************Vendor Specific Register***************/
|
||||||
@@ -144,6 +149,15 @@ err:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static esp_err_t rtl8201_reset_hw(esp_eth_phy_t *phy)
|
||||||
|
{
|
||||||
|
phy_802_3_t *phy_802_3 = esp_eth_phy_into_phy_802_3(phy);
|
||||||
|
esp_err_t ret = esp_eth_phy_802_3_reset_hw(phy_802_3, RTL8201_PHY_RESET_ASSERTION_TIME_US);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(RTL8201_PHY_POST_RESET_INIT_TIME_MS));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static esp_err_t rtl8201_init(esp_eth_phy_t *phy)
|
static esp_err_t rtl8201_init(esp_eth_phy_t *phy)
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
@@ -177,6 +191,7 @@ esp_eth_phy_t *esp_eth_phy_new_rtl8201(const eth_phy_config_t *config)
|
|||||||
rtl8201->phy_802_3.parent.get_link = rtl8201_get_link;
|
rtl8201->phy_802_3.parent.get_link = rtl8201_get_link;
|
||||||
rtl8201->phy_802_3.parent.autonego_ctrl = rtl8201_autonego_ctrl;
|
rtl8201->phy_802_3.parent.autonego_ctrl = rtl8201_autonego_ctrl;
|
||||||
rtl8201->phy_802_3.parent.loopback = rtl8201_loopback;
|
rtl8201->phy_802_3.parent.loopback = rtl8201_loopback;
|
||||||
|
rtl8201->phy_802_3.parent.reset_hw = rtl8201_reset_hw;
|
||||||
|
|
||||||
return &rtl8201->phy_802_3.parent;
|
return &rtl8201->phy_802_3.parent;
|
||||||
err:
|
err:
|
||||||
|
Reference in New Issue
Block a user