Ethernet PHY Driver
Overview

The library provides the Ethernet PHY-related interface APIs for the Ethernet connection manager library to enable the completion of Ethernet-based applications on supported platforms.The current version of ethernet-phy-driver library has Ethernet PHY-related interface APIs implemented for PHY chip DP83867IR.

Features and Functionality

The library contains the necessary ethernet PHY interface APIs implemented for PHY chip DP83867IR.

Other features:

  • Supports the Ethernet PHY driver for the PHY chip DP83867IR.

Supported Platforms

This library and its features are supported on the following Infineon platforms:

Quick Start

The ethernet PHY driver library disables all the debug log messages by default. To enable log messages, the application must perform the following:

  1. Add the ENABLE_ETH_PHY_DRIVER_LOGS macro to the DEFINES in the code example's Makefile. The Makefile entry would look like as follows:
    DEFINES+=ENABLE_ETH_PHY_DRIVER_LOGS
  2. Call the cy_log_init() function provided by the cy-log module. cy-log is part of the connectivity-utilities library. See *connectivity-utilities library API documentation.

API Overview

1. Ethernet-phy-driver library Initialization.

cy_eth_phy_driver_init() - To ensure synchronization, the ethernet-phy-driver library initializes mutex, semaphore, or any relevant global variable.
Application is expected to call this API once before registering ethernet phy callbacks.
cy_rslt_t cy_eth_phy_driver_init(void);

2. Ethernet PHY Initialization.

cy_eth_phy_init() - Initializes the ethernet port pins and initializes the ethernet PHY object.
The current implementation initializes the required ethernet ports of the given PHY hardware and creates a PHY object. Subsequently, this same PHY object will be utilized to perform other ethernet PHY operations.
cy_rslt_t cy_eth_phy_init(uint8_t eth_idx, ETH_Type *reg_base);

3. Ethernet PHY Configure.

cy_eth_phy_configure() - Configures ethernet PHY.
Configures ethernet PHY with given duplex mode and PHY speed.
cy_rslt_t cy_eth_phy_configure(uint8_t eth_idx, uint32_t duplex, uint32_t speed);

4. Ethernet PHY Reset.

cy_eth_phy_reset() - Resets the ethernet PHY.
Performs a full reset of ethernet PHY, including all ethernet PHY registers.
cy_rslt_t cy_eth_phy_reset(uint8_t eth_idx, ETH_Type *reg_base);

5. Ethernet PHY Discover.

cy_eth_phy_discover() - Discovers connected ethernet PHY.
Discovers connected ethernet PHY at address zero.
cy_rslt_t cy_eth_phy_discover(uint8_t eth_idx);

6. Enable extended Ethernet PHY Registers.

cy_eth_phy_enable_ext_reg() - Configures ethernet PHY extended Registers.
For the selected ethernet PHY chip, this API configures and enables extended registers according to the type of PHY interface and the PHY speed.
cy_rslt_t cy_eth_phy_enable_ext_reg(ETH_Type *reg_base, uint32_t phy_speed);

7. Get Ethernet PHY Link Speed.

cy_eth_phy_get_linkspeed() - Get configured ethernet PHY link speed.
Gets the configured PHY duplex mode and PHY speed of selected ethernet interface.
cy_rslt_t cy_eth_phy_get_linkspeed(uint8_t eth_idx, uint32_t *duplex, uint32_t *speed);

8. Get Ethernet PHY Link Status.

cy_eth_phy_get_linkstatus() - Get ethernet PHY link status.
Gets the ethernet PHY link status of selected ethernet interface.
cy_rslt_t cy_eth_phy_get_linkstatus(uint8_t eth_idx, uint32_t *link_status);

9. Get Ethernet PHY Auto Negotiation Status.

cy_eth_phy_get_auto_neg_status() - Get current Auto-Negotiation status (completed or In-progress)..
Gets the current Auto-Negotiation status (completed or In-progress) of selected ethernet interface.
cy_rslt_t cy_eth_phy_get_auto_neg_status(uint8_t eth_idx, uint32_t *neg_status);

10. Get Ethernet PHY Link Partner Capabilities.

cy_eth_phy_get_link_partner_cap() - Gets Link partner capabilities (speed and duplex).
Gets the Link partner capabilities (speed and duplex) of selected ethernet interface.
cy_rslt_t cy_eth_phy_get_link_partner_cap(uint8_t eth_idx, uint32_t *duplex, uint32_t *speed);

11. Ethernet-phy-driver library de-Initialization.

cy_eth_phy_lib_deinit() - The ethernet-phy-driver library deinitializes mutex, semaphore, and resets any relevant global variable.
The current implementation deinitializes the required ethernet ports of the given PHY hardware and resets a PHY object.
cy_rslt_t cy_eth_phy_lib_deinit(void);

Code Snippets

Snippet 1: Ethernet-phy-driver library Init

This code snippet demonstrates the initialization ethernet-phy-driver library. The ethernet-phy-driver library initializes mutex, semaphore, or any relevant global variable which are required for handling ethernet PHY operations.

void snippet_ethernet_phy_driver_lib_init( void )
{
/* Status variables for various operations */
cy_rslt_t result = CY_RSLT_SUCCESS;
/* Initialize the ethernet-phy-driver Library. */
if( result != CY_RSLT_SUCCESS )
{
/* Failure path */
}
}
cy_rslt_t cy_eth_phy_driver_init(void)
Does general allocation and initialization of resources needed for the library.

Snippet 2: Registering Ethernet-phy-driver APIs with ethernet-connection-manager

The following code snippet demonstrates an example for initializing the cy_ecm_phy_callbacks_t structure which is required to start the ethernet-connection-manager.

cy_ecm_phy_callbacks_t phy_callbacks =
{
.phy_init = cy_eth_phy_init,
.phy_configure = cy_eth_phy_configure,
.phy_enable_ext_reg = cy_eth_phy_enable_ext_reg,
.phy_discover = cy_eth_phy_discover,
.phy_get_auto_neg_status = cy_eth_phy_get_auto_neg_status,
.phy_get_link_partner_cap = cy_eth_phy_get_link_partner_cap,
.phy_get_linkspeed = cy_eth_phy_get_linkspeed,
.phy_get_linkstatus = cy_eth_phy_get_linkstatus,
.phy_reset = cy_eth_phy_reset
};
void snippet_register_ethernet_phy_driver_api( void )
{
/* Status variables for various operations */
cy_rslt_t result = CY_RSLT_SUCCESS;
/* Initialize the ECM Library and network stack */
result = cy_ecm_init();
if( result != CY_RSLT_SUCCESS )
{
/* Failure path */
}
/* Initialize the ethernet-phy-driver Library. */
if( result != CY_RSLT_SUCCESS )
{
/* Failure path */
}
/* Initialize the Ethernet driver with the provided configurations */
result = cy_ecm_ethif_init( CY_ECM_INTERFACE_ETH0, &phy_callbacks, &ecm_handle );
if( result != CY_RSLT_SUCCESS )
{
/* Failure path */
}
}
cy_rslt_t cy_eth_phy_get_linkstatus(uint8_t eth_idx, uint32_t *link_status)
Ethernet PHY driver get link status.
cy_rslt_t cy_eth_phy_configure(uint8_t eth_idx, uint32_t duplex, uint32_t speed)
Ethernet PHY driver Configure.
cy_rslt_t cy_eth_phy_init(uint8_t eth_idx, ETH_Type *reg_base)
Ethernet PHY driver Initialization.
cy_rslt_t cy_eth_phy_reset(uint8_t eth_idx, ETH_Type *reg_base)
Ethernet PHY driver reset.
cy_rslt_t cy_eth_phy_discover(uint8_t eth_idx)
Ethernet PHY driver discover.
cy_rslt_t cy_eth_phy_get_linkspeed(uint8_t eth_idx, uint32_t *duplex, uint32_t *speed)
Ethernet PHY driver get link speed.
cy_rslt_t cy_eth_phy_enable_ext_reg(ETH_Type *reg_base, uint32_t phy_speed)
Enable extended Ethernet PHY driver Registers.
cy_rslt_t cy_eth_phy_get_link_partner_cap(uint8_t eth_idx, uint32_t *duplex, uint32_t *speed)
Get Ethernet PHY Link Partner Capabilities.
cy_rslt_t cy_eth_phy_get_auto_neg_status(uint8_t eth_idx, uint32_t *neg_status)
Get Ethernet PHY Auto Negotiation Status.

Snippet 3: Ethernet-phy-driver library Deinit

This code snippet demonstrates the initialization ethernet-phy-driver library.

void snippet_ethernet_phy_driver_library_deinit( void )
{
/* Status variables for various operations */
cy_rslt_t result = CY_RSLT_SUCCESS;
/* Initialize the ECM Library and network stack */
result = cy_ecm_init();
if( result != CY_RSLT_SUCCESS )
{
/* Failure path */
}
/* Initialize the ethernet-phy-driver Library. */
if( result != CY_RSLT_SUCCESS )
{
/* Failure path */
}
/* Application logic */
/* Deinitialize the ECM Library and network stack */
result = cy_ecm_deinit();
if( result != CY_RSLT_SUCCESS )
{
/* Failure path */
}
/* Deinitialize the ethernet-phy-driver Library. */
if( result != CY_RSLT_SUCCESS )
{
/* Failure path */
}
}
cy_rslt_t cy_eth_phy_driver_deinit(void)
Releases the resources allocated in the cy_eth_phy_driver_init function.