The Ethernet PHY driver supports auto-negotiation and manual modes. The PHY driver uses an MDIO abstraction to perform register reads and writes. The MDIO abstraction can be implemented using Enet LLD's Enet Management Data I/O (MDIO) API or any other MDIO driver.
Sub Modules | |
Generic PHY | |
TI DP83822 PHY | |
TI DP83867 PHY | |
TI DP83869 PHY | |
TI DP83TG720 PHY | |
VSC8514 PHY | |
Data Structures | |
struct | EnetPhy_Version |
PHY version (ID). More... | |
struct | EnetPhy_LinkCfg |
Link speed and duplexity configuration. More... | |
struct | EnetPhy_FsmTimeoutCfg |
PHY State-Machine time-out values. More... | |
struct | EnetPhy_Cfg |
PHY configuration parameters. More... | |
struct | EnetPhy_Mdio |
MDIO driver. More... | |
struct | EnetPhy_State |
PHY driver FSM state. More... | |
struct | EnetPhy_Obj |
PHY driver object. More... | |
Functions | |
void | EnetPhy_initCfg (EnetPhy_Cfg *phyCfg) |
Initialize PHY config params. More... | |
void | EnetPhy_setExtendedCfg (EnetPhy_Cfg *phyCfg, const void *extendedCfg, uint32_t extendedCfgSize) |
Set PHY extended parameters. More... | |
EnetPhy_Handle | EnetPhy_open (const EnetPhy_Cfg *phyCfg, EnetPhy_Mii mii, const EnetPhy_LinkCfg *linkCfg, uint32_t macPortCaps, EnetPhy_MdioHandle hMdio, void *mdioArgs) |
Open the PHY driver. More... | |
void | EnetPhy_close (EnetPhy_Handle hPhy) |
Close the PHY driver. More... | |
EnetPhy_LinkStatus | EnetPhy_tick (EnetPhy_Handle hPhy) |
Run PHY state machine. More... | |
int32_t | EnetPhy_getId (EnetPhy_Handle hPhy, EnetPhy_Version *version) |
Get PHY id. More... | |
bool | EnetPhy_isAlive (EnetPhy_Handle hPhy) |
Get PHY alive status. More... | |
bool | EnetPhy_isLinked (EnetPhy_Handle hPhy) |
Get link status. More... | |
int32_t | EnetPhy_getLinkCfg (EnetPhy_Handle hPhy, EnetPhy_LinkCfg *linkCfg) |
Get link configuration. More... | |
int32_t | EnetPhy_readReg (EnetPhy_Handle hPhy, uint32_t reg, uint16_t *val) |
Read PHY register. More... | |
int32_t | EnetPhy_writeReg (EnetPhy_Handle hPhy, uint32_t reg, uint16_t val) |
Write PHY register. More... | |
int32_t | EnetPhy_rmwReg (EnetPhy_Handle hPhy, uint32_t reg, uint16_t mask, uint16_t val) |
Read-modify-write PHY register. More... | |
int32_t | EnetPhy_readExtReg (EnetPhy_Handle hPhy, uint32_t reg, uint16_t *val) |
Read PHY extended register. More... | |
int32_t | EnetPhy_writeExtReg (EnetPhy_Handle hPhy, uint32_t reg, uint16_t val) |
Write PHY extended register. More... | |
int32_t | EnetPhy_rmwExtReg (EnetPhy_Handle hPhy, uint32_t reg, uint16_t mask, uint16_t val) |
Read-modify-write PHY extended register. More... | |
int32_t | EnetPhy_readC45Reg (EnetPhy_Handle hPhy, uint8_t mmd, uint32_t reg, uint16_t *val) |
Read PHY register using Clause-45 frame. More... | |
int32_t | EnetPhy_writeC45Reg (EnetPhy_Handle hPhy, uint8_t mmd, uint32_t reg, uint16_t val) |
Write PHY register using Clause-45 frame. More... | |
int32_t | EnetPhy_rmwC45Reg (EnetPhy_Handle hPhy, uint8_t mmd, uint32_t reg, uint16_t mask, uint16_t val) |
Read-modify-write PHY register using Clause-45 frame. More... | |
void | EnetPhy_printRegs (EnetPhy_Handle hPhy) |
Print all PHY registers. More... | |
Typedefs | |
typedef EnetPhy_Mdio * | EnetPhy_MdioHandle |
MDIO driver handle. More... | |
typedef struct EnetPhy_Drv_s * | EnetPhyDrv_Handle |
PHY specific driver handle. More... | |
typedef struct EnetPhy_Obj_s * | EnetPhy_Handle |
PHY driver object handle. More... | |
Macros | |
#define | ENETPHY_IS_ADDR_VALID(addr) ((addr) <= 31U) |
Check if PHY address is valid (0 - 31). More... | |
#define | ENETPHY_BIT(n) (1U << (n)) |
Macro to set bit at given bit position. More... | |
#define | ENETPHY_IS_BIT_SET(val, n) (((val) & ENETPHY_BIT(n)) != 0U) |
Macro to check if bit at given bit position is set. More... | |
#define | ENETPHY_ARRAYSIZE(x) (sizeof(x) / sizeof(x[0])) |
Macro to get the size of an array. More... | |
#define | ENETPHY_EXTENDED_CFG_SIZE_MAX (128U) |
Max extended configuration size, arbitrarily chosen. More... | |
#define | ENETPHY_FSM_TICK_PERIOD_MS (100U) |
Enet PHY State Machine tick period. More... | |
#define | ENETPHY_INVALID_PHYADDR (~0U) |
Invalid PHY address indicator. More... | |
#define | ENETPHY_TIMEOUT_WAIT_FOREVER (0xFFFFFFFFU) |
State timeout value to set to disable timeout. More... | |
#define | ENETPHY_TIMEOUT_NO_WAIT (0U) |
State timeout value to set to expire immediately. More... | |
Ethernet PHY driver error codes | |
Error codes returned by the Ethernet PHY driver APIs. | |
#define | ENETPHY_SOK (CSL_PASS) |
Success. More... | |
#define | ENETPHY_EFAIL (CSL_EFAIL) |
Generic failure error condition (typically caused by hardware). More... | |
#define | ENETPHY_EBADARGS (CSL_EBADARGS) |
Bad arguments (i.e. NULL pointer). More... | |
#define | ENETPHY_EINVALIDPARAMS (CSL_EINVALID_PARAMS) |
Invalid parameters (i.e. value out-of-range). More... | |
#define | ENETPHY_ETIMEOUT (CSL_ETIMEOUT) |
Time out while waiting for a given condition to happen. More... | |
#define | ENETPHY_EALLOC (CSL_EALLOC) |
Allocation failure. More... | |
#define | ENETPHY_EPERM (CSL_EALLOC - 4) |
Operation not permitted. More... | |
#define | ENETPHY_ENOTSUPPORTED (CSL_EALLOC - 5) |
Operation not supported. More... | |
Ethernet PHY link capability masks | |
Error codes returned by the Ethernet PHY driver APIs. | |
#define | ENETPHY_LINK_CAP_HD10 ENETPHY_BIT(1) |
10-Mbps, half-duplex capability mask. More... | |
#define | ENETPHY_LINK_CAP_FD10 ENETPHY_BIT(2) |
10-Mbps, full-duplex capability mask. More... | |
#define | ENETPHY_LINK_CAP_HD100 ENETPHY_BIT(3) |
100-Mbps, half-duplex capability mask. More... | |
#define | ENETPHY_LINK_CAP_FD100 ENETPHY_BIT(4) |
100-Mbps, full-duplex capability mask. More... | |
#define | ENETPHY_LINK_CAP_HD1000 ENETPHY_BIT(5) |
1-Gbps, half-duplex capability mask. More... | |
#define | ENETPHY_LINK_CAP_FD1000 ENETPHY_BIT(6) |
1-Gbps, full-duplex capability mask. More... | |
#define | ENETPHY_LINK_CAP_10 |
10-Mbps, full and half-duplex capability mask. More... | |
#define | ENETPHY_LINK_CAP_100 |
100-Mbps, full and half-duplex capability mask. More... | |
#define | ENETPHY_LINK_CAP_1000 |
1-Gbps, full and half-duplex capability mask. More... | |
#define | ENETPHY_LINK_CAP_ALL |
Auto-negotiation mask with all duplexity and speed values set. More... | |
#define ENETPHY_BIT | ( | n | ) | (1U << (n)) |
Macro to set bit at given bit position.
#define ENETPHY_IS_BIT_SET | ( | val, | |
n | |||
) | (((val) & ENETPHY_BIT(n)) != 0U) |
Macro to check if bit at given bit position is set.
#define ENETPHY_ARRAYSIZE | ( | x | ) | (sizeof(x) / sizeof(x[0])) |
Macro to get the size of an array.
#define ENETPHY_SOK (CSL_PASS) |
Success.
#define ENETPHY_EFAIL (CSL_EFAIL) |
Generic failure error condition (typically caused by hardware).
#define ENETPHY_EBADARGS (CSL_EBADARGS) |
Bad arguments (i.e. NULL pointer).
#define ENETPHY_EINVALIDPARAMS (CSL_EINVALID_PARAMS) |
Invalid parameters (i.e. value out-of-range).
#define ENETPHY_ETIMEOUT (CSL_ETIMEOUT) |
Time out while waiting for a given condition to happen.
#define ENETPHY_EALLOC (CSL_EALLOC) |
Allocation failure.
#define ENETPHY_EPERM (CSL_EALLOC - 4) |
Operation not permitted.
#define ENETPHY_ENOTSUPPORTED (CSL_EALLOC - 5) |
Operation not supported.
#define ENETPHY_LINK_CAP_HD10 ENETPHY_BIT(1) |
10-Mbps, half-duplex capability mask.
#define ENETPHY_LINK_CAP_FD10 ENETPHY_BIT(2) |
10-Mbps, full-duplex capability mask.
#define ENETPHY_LINK_CAP_HD100 ENETPHY_BIT(3) |
100-Mbps, half-duplex capability mask.
#define ENETPHY_LINK_CAP_FD100 ENETPHY_BIT(4) |
100-Mbps, full-duplex capability mask.
#define ENETPHY_LINK_CAP_HD1000 ENETPHY_BIT(5) |
1-Gbps, half-duplex capability mask.
#define ENETPHY_LINK_CAP_FD1000 ENETPHY_BIT(6) |
1-Gbps, full-duplex capability mask.
#define ENETPHY_LINK_CAP_10 |
10-Mbps, full and half-duplex capability mask.
#define ENETPHY_LINK_CAP_100 |
100-Mbps, full and half-duplex capability mask.
#define ENETPHY_LINK_CAP_1000 |
1-Gbps, full and half-duplex capability mask.
#define ENETPHY_LINK_CAP_ALL |
Auto-negotiation mask with all duplexity and speed values set.
#define ENETPHY_EXTENDED_CFG_SIZE_MAX (128U) |
Max extended configuration size, arbitrarily chosen.
#define ENETPHY_FSM_TICK_PERIOD_MS (100U) |
Enet PHY State Machine tick period.
#define ENETPHY_INVALID_PHYADDR (~0U) |
Invalid PHY address indicator.
#define ENETPHY_TIMEOUT_WAIT_FOREVER (0xFFFFFFFFU) |
State timeout value to set to disable timeout.
#define ENETPHY_TIMEOUT_NO_WAIT (0U) |
State timeout value to set to expire immediately.
typedef EnetPhy_Mdio* EnetPhy_MdioHandle |
MDIO driver handle.
typedef struct EnetPhy_Drv_s* EnetPhyDrv_Handle |
PHY specific driver handle.
typedef struct EnetPhy_Obj_s* EnetPhy_Handle |
PHY driver object handle.
PHY driver opaque handle used to call any PHY related APIs.
enum EnetPhy_Magic |
enum EnetPhy_Mii |
enum EnetPhy_Speed |
enum EnetPhy_Duplexity |
enum EnetPhy_LinkStatus |
enum EnetPhy_FsmState |
PHY driver state-machine states.
void EnetPhy_initCfg | ( | EnetPhy_Cfg * | phyCfg | ) |
Initialize PHY config params.
Initializes PHY driver configuration parameters.
phyCfg | PHY configuration params |
void EnetPhy_setExtendedCfg | ( | EnetPhy_Cfg * | phyCfg, |
const void * | extendedCfg, | ||
uint32_t | extendedCfgSize | ||
) |
Set PHY extended parameters.
Sets the PHY-specific extended parameters to the PHY config structure.
phyCfg | Pointer to the PHY config |
extendedCfg | Pointer to the PHY extended config |
extendedCfgSize | Size of the PHY extended config |
EnetPhy_Handle EnetPhy_open | ( | const EnetPhy_Cfg * | phyCfg, |
EnetPhy_Mii | mii, | ||
const EnetPhy_LinkCfg * | linkCfg, | ||
uint32_t | macPortCaps, | ||
EnetPhy_MdioHandle | hMdio, | ||
void * | mdioArgs | ||
) |
Open the PHY driver.
Open the Ethernet PHY driver for the given MAC port number. The PHY driver takes PHY specific configuration parameters, the MAC port type connection and the desired link configuration (auto or manual).
phyCfg | PHY configuration params |
mii | PHY MII interface type |
linkCfg | Link configuration (speed and duplexity) |
macPortCaps | MAC port speed/duplex capabilities. It's a bit mask of EnetPhy_LinkCaps |
hMdio | MDIO driver to be used for PHY register read/write |
mdioArgs | Private data passed to the MDIO driver functions |
void EnetPhy_close | ( | EnetPhy_Handle | hPhy | ) |
Close the PHY driver.
Closes the Ethernet PHY driver.
hPhy | PHY device handle |
EnetPhy_LinkStatus EnetPhy_tick | ( | EnetPhy_Handle | hPhy | ) |
Run PHY state machine.
Runs the PHY FSM.
hPhy | PHY device handle |
int32_t EnetPhy_getId | ( | EnetPhy_Handle | hPhy, |
EnetPhy_Version * | version | ||
) |
Get PHY id.
Gets the device ID of a PHY, read from IDR1 and IDR2 registers.
hPhy | PHY device handle |
version | Pointer to PHY version. |
bool EnetPhy_isAlive | ( | EnetPhy_Handle | hPhy | ) |
Get PHY alive status.
Gets the PHY alive status. Whether PHY is responding to read accesses.
hPhy | PHY device handle |
bool EnetPhy_isLinked | ( | EnetPhy_Handle | hPhy | ) |
Get link status.
Gets the link status: linked or not, based on driver's state machine. The PHY driver state machine can take a little longer to detect link up because it runs on tick period intervals and need to traverse few states to reach link up FSM state.
hPhy | PHY device handle |
int32_t EnetPhy_getLinkCfg | ( | EnetPhy_Handle | hPhy, |
EnetPhy_LinkCfg * | linkCfg | ||
) |
Get link configuration.
Gets the link configuration, that is, the configuration that the PHY has negotiated with the link partner or the manual link configuration it was set to.
hPhy | PHY device handle |
linkCfg | Link configuration |
int32_t EnetPhy_readReg | ( | EnetPhy_Handle | hPhy, |
uint32_t | reg, | ||
uint16_t * | val | ||
) |
Read PHY register.
Reads a PHY register. It's not meant for extended registers.
hPhy | PHY device handle |
reg | Register number |
val | Pointer to the read value |
int32_t EnetPhy_writeReg | ( | EnetPhy_Handle | hPhy, |
uint32_t | reg, | ||
uint16_t | val | ||
) |
Write PHY register.
Writes a PHY register. It's not meant for extended registers.
hPhy | PHY device handle |
reg | Register number |
val | Value to be written |
int32_t EnetPhy_rmwReg | ( | EnetPhy_Handle | hPhy, |
uint32_t | reg, | ||
uint16_t | mask, | ||
uint16_t | val | ||
) |
Read-modify-write PHY register.
Read-modify-write a PHY register. It's not meant for extended registers.
hPhy | PHY device handle |
reg | Register number |
mask | Bitmask to be applied on read value and value to be written |
val | Value to be written |
int32_t EnetPhy_readExtReg | ( | EnetPhy_Handle | hPhy, |
uint32_t | reg, | ||
uint16_t * | val | ||
) |
Read PHY extended register.
Reads a PHY extended register.
hPhy | PHY device handle |
reg | Register number |
val | Pointer to the read value |
int32_t EnetPhy_writeExtReg | ( | EnetPhy_Handle | hPhy, |
uint32_t | reg, | ||
uint16_t | val | ||
) |
Write PHY extended register.
Writes a PHY extended register.
hPhy | PHY device handle |
reg | Register number |
val | Value to be written |
int32_t EnetPhy_rmwExtReg | ( | EnetPhy_Handle | hPhy, |
uint32_t | reg, | ||
uint16_t | mask, | ||
uint16_t | val | ||
) |
Read-modify-write PHY extended register.
Read-modify-write a PHY extended register.
hPhy | PHY device handle |
reg | Register number |
mask | Bitmask to be applied on read value and value to be written |
val | Value to be written |
int32_t EnetPhy_readC45Reg | ( | EnetPhy_Handle | hPhy, |
uint8_t | mmd, | ||
uint32_t | reg, | ||
uint16_t * | val | ||
) |
Read PHY register using Clause-45 frame.
Reads a PHY register using Clause-45 frame.
hPhy | PHY device handle |
mmd | MMD |
reg | Register number |
val | Pointer to the read value |
int32_t EnetPhy_writeC45Reg | ( | EnetPhy_Handle | hPhy, |
uint8_t | mmd, | ||
uint32_t | reg, | ||
uint16_t | val | ||
) |
Write PHY register using Clause-45 frame.
Writes a PHY register using Clause-45 frame.
hPhy | PHY device handle |
mmd | MMD |
reg | Register number |
val | Value to be written |
int32_t EnetPhy_rmwC45Reg | ( | EnetPhy_Handle | hPhy, |
uint8_t | mmd, | ||
uint32_t | reg, | ||
uint16_t | mask, | ||
uint16_t | val | ||
) |
Read-modify-write PHY register using Clause-45 frame.
Read-modify-write a PHY register using Clause-45 frame.
hPhy | PHY device handle |
mmd | MMD |
reg | Register number |
mask | Bitmask to be applied on read value and value to be written |
val | Value to be written |
void EnetPhy_printRegs | ( | EnetPhy_Handle | hPhy | ) |
Print all PHY registers.
Prints all registers of a PHY.
hPhy | PHY device handle |