esp-idf/components/esp_eth/include/eth_phy_802_3_regs.h
Bogdan Kolendovskyy 224ba396f1 esp_eth: add loopback test, change chip drivers to reflect chip specific behaviour
In esp_eth_test_apps.c:
Add test of loopback functionality. Change speed/duplex/autonegotiation test - remove need to enable loopback (required
for it to work on some phys supported by ESP-IDF)

In Kconfig.projbuild:
Add parameters to select which configuration is used - standard or custom.
Add for custom configuration parameters to select MDC and MDIO pins (required to work with WESP-32 and other boards that
use non-standard pin assignments).

In esp_eth_test_common.c:
Add code to support changes made in Kconfig

In sdkconfig.ci.default_rtl8201:
Change config which is used. Now custom is used and MDC is gpio 16, MDIO is gpio 17. Reuqired to work with WESP-32

In esp_eth_phy_802_3.h:
Make 802.3 API public.

In esp_eth_phy_802_3.c:
Add loopback check in eth_phy_802_3_set_duplex(). Now ESP_ERR_INVALID_STATE is invoked on attempt to set duplex to half
when loopback is enabled.
Remove static property from esp_eth_phy_802_3_autonego_ctrl and esp_eth_phy_802_3_loopback.

In esp_eth_phy_dm9051.c:
Add dm9051_loopback() because DM9051 requires setting additional bit to enable auto-negotiation loopback for data to be
received. Add dm9051_set_speed() which invokes ESP_ERR_INVALID_STATE on attempt to set speed to 10 Mbps when loopback is
enabled because such speed configuration is unsupported.

In esp_eth_phy_ksz80xx.c:
Add ksz80xx_set_speed() which invokes ESP_ERR_INVALID_STATE on attempt to set speed to 10 Mbps when loopback is enabled
because such speed configuration is unsupported.

In esp_eth_phy_ksz8851snl.c:
Change phy_ksz8851_set_duplex() to invoke ESP_ERR_INVALID_STATE on attempt to set duplex to half when loopback is enabled.

In  esp_eth_phy_dp83848.c, esp_eth_phy_rtl8201.c:
Add autonego_ctrl implementation which prevents enabling autonegotiation when loopback is enabled.
Add loopback implementation which disables autonegotiation prior to enabling loopback.

In esp_eth_phy_lan87xx.c:
Add autonego_ctrl implementation which prevents enabling autonegotiation when loopback is enabled.
Add loopback implementation which disables autonegotiation prior to enabling loopback.
Fix link indicating being down when loopback is enabled by force setting link up.
2023-08-03 13:18:44 +02:00

160 lines
6.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
*
* This file defines basic PHY registers in compliance to IEEE 802.3, 22.2.4 Management functions section.
*
*/
/**
* @brief BMCR(Basic Mode Control Register)
*
*/
typedef union {
struct {
uint32_t reserved : 7; /*!< Reserved */
uint32_t collision_test : 1; /*!< Collision test */
uint32_t duplex_mode : 1; /*!< Duplex mode:Full Duplex(1) and Half Duplex(0) */
uint32_t restart_auto_nego : 1; /*!< Restart auto-negotiation */
uint32_t isolate : 1; /*!< Isolate the PHY from MII except the SMI interface */
uint32_t power_down : 1; /*!< Power off PHY except SMI interface */
uint32_t en_auto_nego : 1; /*!< Enable auto negotiation */
uint32_t speed_select : 1; /*!< Select speed: 100Mbps(1) and 10Mbps(0) */
uint32_t en_loopback : 1; /*!< Enables transmit data to be routed to the receive path */
uint32_t reset : 1; /*!< Reset PHY registers. This bit is self-clearing. */
};
uint32_t val;
} bmcr_reg_t;
#define ETH_PHY_BMCR_REG_ADDR (0x00)
/**
* @brief BMSR(Basic Mode Status Register)
*
*/
typedef union {
struct {
uint32_t ext_capability : 1; /*!< Extended register capability */
uint32_t jabber_detect : 1; /*!< Jabber condition detected */
uint32_t link_status : 1; /*!< Link status */
uint32_t auto_nego_ability : 1; /*!< Auto negotiation ability */
uint32_t remote_fault : 1; /*!< Remote fault detected */
uint32_t auto_nego_complete : 1; /*!< Auto negotiation completed */
uint32_t mf_preamble_suppress : 1; /*!< Preamble suppression capability for management frame */
uint32_t reserved : 1; /*!< Reserved */
uint32_t ext_status : 1; /*!< Extended Status */
uint32_t base100_t2_hdx : 1; /*!< 100Base-T2 Half Duplex capability */
uint32_t base100_t2_fdx : 1; /*!< 100Base-T2 Full Duplex capability */
uint32_t base10_t_hdx : 1; /*!< 10Base-T Half Duplex capability */
uint32_t base10_t_fdx : 1; /*!< 10Base-T Full Duplex capability */
uint32_t base100_tx_hdx : 1; /*!< 100Base-Tx Half Duplex capability */
uint32_t base100_tx_fdx : 1; /*!< 100Base-Tx Full Duplex capability */
uint32_t based100_t4 : 1; /*!< 100Base-T4 capability */
};
uint32_t val;
} bmsr_reg_t;
#define ETH_PHY_BMSR_REG_ADDR (0x01)
/**
* @brief PHYIDR1(PHY Identifier Register 1)
*
*/
typedef union {
struct {
uint32_t oui_msb : 16; /*!< Organizationally Unique Identifier(OUI) most significant bits */
};
uint32_t val;
} phyidr1_reg_t;
#define ETH_PHY_IDR1_REG_ADDR (0x02)
/**
* @brief PHYIDR2(PHY Identifier Register 2)
*
*/
typedef union {
struct {
uint32_t model_revision : 4; /*!< Model revision number */
uint32_t vendor_model : 6; /*!< Vendor model number */
uint32_t oui_lsb : 6; /*!< Organizationally Unique Identifier(OUI) least significant bits */
};
uint32_t val;
} phyidr2_reg_t;
#define ETH_PHY_IDR2_REG_ADDR (0x03)
/**
* @brief ANAR(Auto-Negotiation Advertisement Register)
*
*/
typedef union {
struct {
uint32_t protocol_select : 5; /*!< Binary encoded selector supported by this PHY */
uint32_t base10_t : 1; /*!< 10Base-T support */
uint32_t base10_t_fd : 1; /*!< 10Base-T full duplex support */
uint32_t base100_tx : 1; /*!< 100Base-TX support */
uint32_t base100_tx_fd : 1; /*!< 100Base-TX full duplex support */
uint32_t base100_t4 : 1; /*!< 100Base-T4 support */
uint32_t symmetric_pause : 1; /*!< Symmetric pause support for full duplex links */
uint32_t asymmetric_pause : 1; /*!< Asymmetric pause support for full duplex links */
uint32_t reserved1 : 1; /*!< Reserved */
uint32_t remote_fault : 1; /*!< Advertise remote fault detection capability */
uint32_t acknowledge : 1; /*!< Link partner ability data reception acknowledged */
uint32_t next_page : 1; /*!< Next page indication, if set, next page transfer is desired */
};
uint32_t val;
} anar_reg_t;
#define ETH_PHY_ANAR_REG_ADDR (0x04)
/**
* @brief ANLPAR(Auto-Negotiation Link Partner Ability Register)
*
*/
typedef union {
struct {
uint32_t protocol_select : 5; /*!< Link Partners binary encoded node selector */
uint32_t base10_t : 1; /*!< 10Base-T support */
uint32_t base10_t_fd : 1; /*!< 10Base-T full duplex support */
uint32_t base100_tx : 1; /*!< 100Base-TX support */
uint32_t base100_tx_fd : 1; /*!< 100Base-TX full duplex support */
uint32_t base100_t4 : 1; /*!< 100Base-T4 support */
uint32_t symmetric_pause : 1; /*!< Symmetric pause supported by Link Partner */
uint32_t asymmetric_pause : 1; /*!< Asymmetric pause supported by Link Partner */
uint32_t reserved : 1; /*!< Reserved */
uint32_t remote_fault : 1; /*!< Link partner is indicating a remote fault */
uint32_t acknowledge : 1; /*!< Acknowledges from link partner */
uint32_t next_page : 1; /*!< Next page indication */
};
uint32_t val;
} anlpar_reg_t;
#define ETH_PHY_ANLPAR_REG_ADDR (0x05)
/**
* @brief ANER(Auto-Negotiate Expansion Register)
*
*/
typedef union {
struct {
uint32_t link_partner_auto_nego_able : 1; /*!< Link partner auto-negotiation ability */
uint32_t link_page_received : 1; /*!< Link code word page has received */
uint32_t next_page_able : 1; /*!< Next page ablility */
uint32_t link_partner_next_page_able : 1; /*!< Link partner next page ability */
uint32_t parallel_detection_fault : 1; /*!< Parallel detection fault */
uint32_t reserved : 11; /*!< Reserved */
};
uint32_t val;
} aner_reg_t;
#define ETH_PHY_ANER_REG_ADDR (0x06)
#ifdef __cplusplus
}
#endif