The ETHPHY driver provides APIs to control the Ethernet PHY devices present on the board. It accesses the PHY registers using the MDIO module.
Features Supported
- Note
- Only the commands needed for Industial Protocol examples are supported
- Commands for following things:
- Get the PHY link status
- Set/get speed and half-duplex/full-duplex configuration
- Configure PHY LEDs
- Select MII mode
- Soft-restart PHY
- Enable Auto MDI-X
- Disable 1G Advertisement
- Get auto-negotiation status
- Get auto-negotiation capability of link partner
- Configure features like fast link down detection, extended full duplex ability, odd nibble detection and enhanced IPG detection
- Set Tx/Rx FIFO Half Full Threshold for RGMII mode
SysConfig Features
- Note
- It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.
- Option to select the type of Ethernet PHY
- Option to select the MDIO instance to which PHY is connected
- Option to set the PHY address
- Based on above parameters, the SysConfig generated code does following:
- Open the ETHPHY instance using ETHPHY_open API as a part of Board_driversOpen. Handle can used by including
"ti_board_open_close.h"
file.
- Close the ETHPHY instance as a part of Board_driversClose
- Create macros like
CONFIG_ETHPHY0
using the name passed in SysConfig. This is used as an index to the array of handles.
Example Usage
Include the below file to access the APIs
#include <board/ethphy/ethphy_dp83869.h>
Selecting MII mode and soft-resetting the PHY
(void) status;
(void) status;
Configuring PHY LED sources
ETHPHY_DP83869_LedSourceConfig ledConfig;
ledConfig.ledNum = ETHPHY_DP83869_LED0;
ledConfig.mode = ETHPHY_DP83869_LED_MODE_LINK_OK;
(void) status;
ledConfig.ledNum = ETHPHY_DP83869_LED1;
ledConfig.mode = ETHPHY_DP83869_LED_MODE_1000BT_LINK_UP;
(void) status;
ledConfig.ledNum = ETHPHY_DP83869_LED2;
ledConfig.mode = ETHPHY_DP83869_LED_MODE_LINK_OK_AND_BLINK_ON_RX_TX;
(void) status;
ledConfig.ledNum = ETHPHY_DP83869_LED_GPIO;
ledConfig.mode = ETHPHY_DP83869_LED_MODE_10_OR_100BT_LINK_UP;
(void) status;
Adding Support for Custom PHY
In the SysConfig for ETHPHY, there are following options apart from the Ethernet PHYs supported in the SDK :
- CUSTOM : Generate SysConfig code with a custom PHY name.
extern ETHPHY_Fxns gEthPhyFxns_MyEthPhyDevice;
will be added in the ti_board_open_close.c
file generated by SysConfig. Hence ETHPHY_Fxns should be defined for the custom PHY. Essentially one needs to write code similar to a supported PHY device (For an example, see ${SDK_INSTALL_PATH}/source/board/ethphy/ethphy_dp83869.c
). APIs for Ethernet PHY can be used directly in this case.
- NONE : SysConfig does not generate any code for ETHPHY. Modules like EtherCAT and Ethernet (ICSS) add instances of ETHPHY in SysConfig. This option can be used if the PHY implementation is custom, and you do not want any code to be generated from SysConfig. APIs for Ethernet PHY can not be used directly in this case.
API
APIs for Ethernet PHY