Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Ethernet PHY Interface

Ethernet PHY Interface . More...

Data Structures

struct  phy_link_state
 Link state. More...
 
struct  phy_plca_cfg
 PLCA (Physical Layer Collision Avoidance) Reconciliation Sublayer configurations. More...
 

Macros

#define PHY_LINK_IS_FULL_DUPLEX(x)
 Check if phy link is full duplex.
 
#define PHY_LINK_IS_SPEED_1000M(x)
 Check if phy link speed is 1 Gbit/sec.
 
#define PHY_LINK_IS_SPEED_100M(x)
 Check if phy link speed is 100 Mbit/sec.
 
#define PHY_LINK_IS_SPEED_10M(x)
 Check if phy link speed is 10 Mbit/sec.
 

Typedefs

typedef void(* phy_callback_t) (const struct device *dev, struct phy_link_state *state, void *user_data)
 Define the callback function signature for phy_link_callback_set() function.
 

Enumerations

enum  phy_link_speed {
  LINK_HALF_10BASE = BIT(0) , LINK_FULL_10BASE = BIT(1) , LINK_HALF_100BASE = BIT(2) , LINK_FULL_100BASE = BIT(3) ,
  LINK_HALF_1000BASE = BIT(4) , LINK_FULL_1000BASE = BIT(5) , LINK_FULL_2500BASE = BIT(6) , LINK_FULL_5000BASE = BIT(7)
}
 Ethernet link speeds. More...
 

Functions

int genphy_get_plca_cfg (const struct device *dev, struct phy_plca_cfg *plca_cfg)
 Write PHY PLCA configuration.
 
int genphy_set_plca_cfg (const struct device *dev, struct phy_plca_cfg *plca_cfg)
 Read PHY PLCA configuration.
 
int genphy_get_plca_sts (const struct device *dev, bool *plca_status)
 Read PHY PLCA status.
 
static int phy_configure_link (const struct device *dev, enum phy_link_speed speeds)
 Configure PHY link.
 
static int phy_get_link_state (const struct device *dev, struct phy_link_state *state)
 Get PHY link state.
 
static int phy_link_callback_set (const struct device *dev, phy_callback_t callback, void *user_data)
 Set link state change callback.
 
static int phy_read (const struct device *dev, uint16_t reg_addr, uint32_t *value)
 Read PHY registers.
 
static int phy_write (const struct device *dev, uint16_t reg_addr, uint32_t value)
 Write PHY register.
 
static int phy_read_c45 (const struct device *dev, uint8_t devad, uint16_t regad, uint16_t *data)
 Read PHY C45 register.
 
static int phy_write_c45 (const struct device *dev, uint8_t devad, uint16_t regad, uint16_t data)
 Write PHY C45 register.
 
static int phy_set_plca_cfg (const struct device *dev, struct phy_plca_cfg *plca_cfg)
 Write PHY PLCA configuration.
 
static int phy_get_plca_cfg (const struct device *dev, struct phy_plca_cfg *plca_cfg)
 Read PHY PLCA configuration.
 
static int phy_get_plca_sts (const struct device *dev, bool *plca_status)
 Read PHY PLCA status.
 

Detailed Description

Ethernet PHY Interface .

Since
2.7
Version
0.8.0

Macro Definition Documentation

◆ PHY_LINK_IS_FULL_DUPLEX

#define PHY_LINK_IS_FULL_DUPLEX ( x)

#include <zephyr/net/phy.h>

Value:
@ LINK_FULL_2500BASE
2.5GBase Full-Duplex
Definition phy.h:48
@ LINK_FULL_10BASE
10Base Full-Duplex
Definition phy.h:38
@ LINK_FULL_1000BASE
1000Base Full-Duplex
Definition phy.h:46
@ LINK_FULL_5000BASE
5GBase Full-Duplex
Definition phy.h:50
@ LINK_FULL_100BASE
100Base Full-Duplex
Definition phy.h:42

Check if phy link is full duplex.

Parameters
xLink capabilities
Returns
True if link is full duplex, false if not.

◆ PHY_LINK_IS_SPEED_1000M

#define PHY_LINK_IS_SPEED_1000M ( x)

#include <zephyr/net/phy.h>

Value:
@ LINK_HALF_1000BASE
1000Base Half-Duplex
Definition phy.h:44

Check if phy link speed is 1 Gbit/sec.

Parameters
xLink capabilities
Returns
True if link is 1 Gbit/sec, false if not.

◆ PHY_LINK_IS_SPEED_100M

#define PHY_LINK_IS_SPEED_100M ( x)

#include <zephyr/net/phy.h>

Value:
@ LINK_HALF_100BASE
100Base Half-Duplex
Definition phy.h:40

Check if phy link speed is 100 Mbit/sec.

Parameters
xLink capabilities
Returns
True if link is 100 Mbit/sec, false if not.

◆ PHY_LINK_IS_SPEED_10M

#define PHY_LINK_IS_SPEED_10M ( x)

#include <zephyr/net/phy.h>

Value:
@ LINK_HALF_10BASE
10Base Half-Duplex
Definition phy.h:36

Check if phy link speed is 10 Mbit/sec.

Parameters
xLink capabilities
Returns
True if link is 10 Mbit/sec, false if not.

Typedef Documentation

◆ phy_callback_t

typedef void(* phy_callback_t) (const struct device *dev, struct phy_link_state *state, void *user_data)

#include <zephyr/net/phy.h>

Define the callback function signature for phy_link_callback_set() function.

Parameters
devPHY device structure
statePointer to link_state structure.
user_dataPointer to data specified by user

Enumeration Type Documentation

◆ phy_link_speed

#include <zephyr/net/phy.h>

Ethernet link speeds.

Enumerator
LINK_HALF_10BASE 

10Base Half-Duplex

LINK_FULL_10BASE 

10Base Full-Duplex

LINK_HALF_100BASE 

100Base Half-Duplex

LINK_FULL_100BASE 

100Base Full-Duplex

LINK_HALF_1000BASE 

1000Base Half-Duplex

LINK_FULL_1000BASE 

1000Base Full-Duplex

LINK_FULL_2500BASE 

2.5GBase Full-Duplex

LINK_FULL_5000BASE 

5GBase Full-Duplex

Function Documentation

◆ genphy_get_plca_cfg()

int genphy_get_plca_cfg ( const struct device * dev,
struct phy_plca_cfg * plca_cfg )

#include <zephyr/net/phy.h>

Write PHY PLCA configuration.

This routine provides a generic interface to configure PHY PLCA settings.

Parameters
[in]devPHY device structure
[in]plca_cfgPointer to plca configuration structure
Return values
0If successful.
-EIOIf communication with PHY failed.

◆ genphy_get_plca_sts()

int genphy_get_plca_sts ( const struct device * dev,
bool * plca_status )

#include <zephyr/net/phy.h>

Read PHY PLCA status.

This routine provides a generic interface to get PHY PLCA status.

Parameters
[in]devPHY device structure
plca_statusPointer to plca status
Return values
0If successful.
-EIOIf communication with PHY failed.

◆ genphy_set_plca_cfg()

int genphy_set_plca_cfg ( const struct device * dev,
struct phy_plca_cfg * plca_cfg )

#include <zephyr/net/phy.h>

Read PHY PLCA configuration.

This routine provides a generic interface to get PHY PLCA settings.

Parameters
[in]devPHY device structure
plca_cfgPointer to plca configuration structure
Return values
0If successful.
-EIOIf communication with PHY failed.

◆ phy_configure_link()

static int phy_configure_link ( const struct device * dev,
enum phy_link_speed speeds )
inlinestatic

#include <zephyr/net/phy.h>

Configure PHY link.

This route configures the advertised link speeds.

Parameters
[in]devPHY device structure
speedsOR'd link speeds to be advertised by the PHY
Return values
0If successful.
-EIOIf communication with PHY failed.
-ENOTSUPIf not supported.

◆ phy_get_link_state()

static int phy_get_link_state ( const struct device * dev,
struct phy_link_state * state )
inlinestatic

#include <zephyr/net/phy.h>

Get PHY link state.

Returns the current state of the PHY link. This can be used by to determine when a link is up and the negotiated link speed.

Parameters
[in]devPHY device structure
statePointer to receive PHY state
Return values
0If successful.
-EIOIf communication with PHY failed.

◆ phy_get_plca_cfg()

static int phy_get_plca_cfg ( const struct device * dev,
struct phy_plca_cfg * plca_cfg )
inlinestatic

#include <zephyr/net/phy.h>

Read PHY PLCA configuration.

This routine provides a generic interface to get PHY PLCA settings.

Parameters
[in]devPHY device structure
plca_cfgPointer to plca configuration structure
Return values
0If successful.
-EIOIf communication with PHY failed.

◆ phy_get_plca_sts()

static int phy_get_plca_sts ( const struct device * dev,
bool * plca_status )
inlinestatic

#include <zephyr/net/phy.h>

Read PHY PLCA status.

This routine provides a generic interface to get PHY PLCA status.

Parameters
[in]devPHY device structure
plca_statusPointer to plca status
Return values
0If successful.
-EIOIf communication with PHY failed.

◆ phy_link_callback_set()

static int phy_link_callback_set ( const struct device * dev,
phy_callback_t callback,
void * user_data )
inlinestatic

#include <zephyr/net/phy.h>

Set link state change callback.

Sets a callback that is invoked when link state changes. This is the preferred method for ethernet drivers to be notified of the PHY link state change. The callback will be invoked once after setting it, even if link state has not changed. There can only one callback function set and active at a time. This function is mainly used by ethernet drivers to register a callback to be notified of link state changes and should therefore not be used by applications.

Parameters
[in]devPHY device structure
callbackCallback handler
user_dataPointer to data specified by user.
Return values
0If successful.
-ENOTSUPIf not supported.

◆ phy_read()

static int phy_read ( const struct device * dev,
uint16_t reg_addr,
uint32_t * value )
inlinestatic

#include <zephyr/net/phy.h>

Read PHY registers.

This routine provides a generic interface to read from a PHY register.

Parameters
[in]devPHY device structure
[in]reg_addrRegister address
valuePointer to receive read value
Return values
0If successful.
-EIOIf communication with PHY failed.

◆ phy_read_c45()

static int phy_read_c45 ( const struct device * dev,
uint8_t devad,
uint16_t regad,
uint16_t * data )
inlinestatic

#include <zephyr/net/phy.h>

Read PHY C45 register.

This routine provides a generic interface to read to a PHY C45 register.

Parameters
[in]devPHY device structure
[in]devadDevice address
[in]regadRegister address
dataPointer to receive read data
Return values
0If successful.
-EIOIf communication with PHY failed.

◆ phy_set_plca_cfg()

static int phy_set_plca_cfg ( const struct device * dev,
struct phy_plca_cfg * plca_cfg )
inlinestatic

#include <zephyr/net/phy.h>

Write PHY PLCA configuration.

This routine provides a generic interface to configure PHY PLCA settings.

Parameters
[in]devPHY device structure
[in]plca_cfgPointer to plca configuration structure
Return values
0If successful.
-EIOIf communication with PHY failed.

◆ phy_write()

static int phy_write ( const struct device * dev,
uint16_t reg_addr,
uint32_t value )
inlinestatic

#include <zephyr/net/phy.h>

Write PHY register.

This routine provides a generic interface to write to a PHY register.

Parameters
[in]devPHY device structure
[in]reg_addrRegister address
[in]valueValue to write
Return values
0If successful.
-EIOIf communication with PHY failed.

◆ phy_write_c45()

static int phy_write_c45 ( const struct device * dev,
uint8_t devad,
uint16_t regad,
uint16_t data )
inlinestatic

#include <zephyr/net/phy.h>

Write PHY C45 register.

This routine provides a generic interface to write to a PHY C45 register.

Parameters
[in]devPHY device structure
[in]devadDevice address
[in]regadRegister address
[in]dataData to write
Return values
0If successful.
-EIOIf communication with PHY failed.