13#ifndef ZEPHYR_INCLUDE_DRIVERS_PHY_H_
14#define ZEPHYR_INCLUDE_DRIVERS_PHY_H_
58#define PHY_LINK_IS_FULL_DUPLEX(x) (x & (BIT(1) | BIT(3) | BIT(5) | BIT(6) | BIT(7)))
67#define PHY_LINK_IS_SPEED_1000M(x) (x & (BIT(4) | BIT(5)))
76#define PHY_LINK_IS_SPEED_100M(x) (x & (BIT(2) | BIT(3)))
105__subsystem
struct ethphy_driver_api {
107 int (*get_link)(
const struct device *dev,
111 int (*cfg_link)(
const struct device *dev,
145 const struct ethphy_driver_api *api =
146 (
const struct ethphy_driver_api *)dev->
api;
148 return api->cfg_link(dev, speeds);
167 const struct ethphy_driver_api *api =
168 (
const struct ethphy_driver_api *)dev->
api;
170 return api->get_link(dev,
state);
191 const struct ethphy_driver_api *api =
192 (
const struct ethphy_driver_api *)dev->
api;
194 return api->link_cb_set(dev, callback, user_data);
212 const struct ethphy_driver_api *api =
213 (
const struct ethphy_driver_api *)dev->
api;
215 return api->read(dev, reg_addr, value);
233 const struct ethphy_driver_api *api =
234 (
const struct ethphy_driver_api *)dev->
api;
236 return api->write(dev, reg_addr, value);
static int phy_link_callback_set(const struct device *dev, phy_callback_t callback, void *user_data)
Set link state change callback.
Definition phy.h:187
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.
Definition phy.h:95
static int phy_read(const struct device *dev, uint16_t reg_addr, uint32_t *value)
Read PHY registers.
Definition phy.h:209
static int phy_get_link_state(const struct device *dev, struct phy_link_state *state)
Get PHY link state.
Definition phy.h:164
static int phy_write(const struct device *dev, uint16_t reg_addr, uint32_t value)
Write PHY register.
Definition phy.h:230
phy_link_speed
Ethernet link speeds.
Definition phy.h:32
static int phy_configure_link(const struct device *dev, enum phy_link_speed speeds)
Configure PHY link.
Definition phy.h:142
@ LINK_HALF_100BASE_T
100Base-T Half-Duplex
Definition phy.h:38
@ LINK_FULL_2500BASE_T
2.5GBase-T Full-Duplex
Definition phy.h:46
@ LINK_HALF_10BASE_T
10Base-T Half-Duplex
Definition phy.h:34
@ LINK_FULL_5000BASE_T
5GBase-T Full-Duplex
Definition phy.h:48
@ LINK_FULL_1000BASE_T
1000Base-T Full-Duplex
Definition phy.h:44
@ LINK_FULL_10BASE_T
10Base-T Full-Duplex
Definition phy.h:36
@ LINK_FULL_100BASE_T
100Base-T Full-Duplex
Definition phy.h:40
@ LINK_HALF_1000BASE_T
1000Base-T Half-Duplex
Definition phy.h:42
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
state
Definition parser_state.h:29
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418
Link state.
Definition phy.h:79
bool is_up
When true the link is active and connected.
Definition phy.h:83
enum phy_link_speed speed
Link speed.
Definition phy.h:81