Ethernet PHY class.
More...
Ethernet PHY class.
The transceiver between an Ethernet MAC and the wire. The MAC takes it from its devicetree phy-handle, starts it with the link modes to advertise when its interface goes up and stops it, powered down, when it goes down.
While started, the class polls the link every second and reports it coming up or going down to the listeners, from thread context, with the speed and duplex it negotiated: the MAC configures itself to match. Listeners do not start or stop the PHY.
...
int pbl_net_phy_start(const struct pbl_net_phy *phy, uint32_t adv)
Power a PHY up and start negotiating a link.
int pbl_net_phy_stop(const struct pbl_net_phy *phy)
Stop a PHY and power it down.
#define PBL_NET_PHY_ADV_ALL
Advertise every mode the PHY has.
Definition phy.h:45
void pbl_net_phy_add_listener(const struct pbl_net_phy *phy, struct pbl_net_phy_listener *listener)
Add a listener to a PHY.
◆ pbl_net_phy_link
| Data Fields |
|
bool |
full_duplex |
Full duplex, else half. |
|
enum pbl_net_phy_speed |
speed |
Speed. |
|
bool |
up |
The link is up; the other fields only mean something then. |
◆ pbl_net_phy
| Data Fields |
|
struct pbl_device |
dev |
Device. |
|
const struct pbl_net_phy_ops * |
ops |
Driver operations. |
|
struct pbl_net_phy_state * |
state |
Runtime state. |
◆ PBL_NET_PHY_ADV_100_FULL
| #define PBL_NET_PHY_ADV_100_FULL PBL_BIT(3) |
Advertise 100BASE-TX full duplex.
◆ PBL_NET_PHY_ADV_100_HALF
| #define PBL_NET_PHY_ADV_100_HALF PBL_BIT(2) |
Advertise 100BASE-TX half duplex.
◆ PBL_NET_PHY_ADV_10_FULL
| #define PBL_NET_PHY_ADV_10_FULL PBL_BIT(1) |
Advertise 10BASE-T full duplex.
◆ PBL_NET_PHY_ADV_10_HALF
| #define PBL_NET_PHY_ADV_10_HALF PBL_BIT(0) |
Advertise 10BASE-T half duplex.
◆ PBL_NET_PHY_ADV_ALL
| #define PBL_NET_PHY_ADV_ALL |
Value:
#define PBL_NET_PHY_ADV_100_FULL
Advertise 100BASE-TX full duplex.
Definition phy.h:43
#define PBL_NET_PHY_ADV_10_FULL
Advertise 10BASE-T full duplex.
Definition phy.h:39
#define PBL_NET_PHY_ADV_100_HALF
Advertise 100BASE-TX half duplex.
Definition phy.h:41
#define PBL_NET_PHY_ADV_10_HALF
Advertise 10BASE-T half duplex.
Definition phy.h:37
Advertise every mode the PHY has.
◆ PBL_NET_PHY_INIT
| #define PBL_NET_PHY_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_parent, |
|
|
|
_ops |
|
) |
| |
Value: { \
.ops = (_ops), \
.state = &sym##_net_phy_state, \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:153
Initialize a struct pbl_net_phy.
- Parameters
-
| sym | Symbol of the instance, as passed to PBL_NET_PHY_STATE_DEFINE(). |
| _name | Device name. |
| _parent | Parent device, the MDIO bus, or NULL. |
| _ops | Driver operations. |
◆ PBL_NET_PHY_STATE_DEFINE
| #define PBL_NET_PHY_STATE_DEFINE |
( |
|
sym | ) |
|
Value:
static struct pbl_net_phy_state sym##_net_phy_state
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132
Define the runtime state of an Ethernet PHY.
- Parameters
-
| sym | Symbol of the instance. |
◆ pbl_net_phy_speed
Link speeds.
| Enumerator |
|---|
| PBL_NET_PHY_SPEED_10 | 10 Mb/s.
|
| PBL_NET_PHY_SPEED_100 | 100 Mb/s.
|
◆ pbl_net_phy_add_listener()
Add a listener to a PHY.
- Parameters
-
| phy | Ethernet PHY. |
| listener | Listener, not added yet, which stays in use. |
◆ pbl_net_phy_get_link()
Get the link state last reported to the listeners.
- Parameters
-
| phy | Ethernet PHY. |
| [out] | link | Link state, down while the PHY is stopped. |
◆ pbl_net_phy_start()
| int pbl_net_phy_start |
( |
const struct pbl_net_phy * |
phy, |
|
|
uint32_t |
adv |
|
) |
| |
Power a PHY up and start negotiating a link.
- Parameters
-
| phy | Ethernet PHY. |
| adv | Modes to advertise, PBL_NET_PHY_ADV_* flags; those the PHY lacks are left out. |
- Returns
- 0,
-EALREADY if started, -EINVAL if adv has no mode, or another negative errno.
◆ pbl_net_phy_stop()
Stop a PHY and power it down.
A link that was up is reported down.
- Parameters
-
- Returns
- 0,
-EALREADY if stopped, or another negative errno.