PHY class.
More...
PHY class.
A PHY is the transceiver of a controller, as the USB PHY of a USB controller. The controller takes it from its devicetree phys property, powers it on before using the bus and off after.
A USB PHY that senses VBUS reports it: pbl_phy_vbus_present() tells whether it is there, and the listeners added with pbl_phy_add_listener() hear it come and go, from thread context.
...
int pbl_phy_power_on(const struct pbl_phy *phy)
Power a PHY on.
int pbl_phy_power_off(const struct pbl_phy *phy)
Power a PHY off.
◆ pbl_phy_state
◆ pbl_phy
◆ PBL_PHY_INIT
| #define PBL_PHY_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_parent, |
|
|
|
_ops |
|
) |
| |
Value: { \
.ops = (_ops), \
.state = &sym##_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_phy.
- Parameters
-
| sym | Symbol of the instance, as passed to PBL_PHY_STATE_DEFINE(). |
| _name | Device name. |
| _parent | Parent device, or NULL. |
| _ops | Driver operations. |
◆ PBL_PHY_STATE_DEFINE
| #define PBL_PHY_STATE_DEFINE |
( |
|
sym | ) |
|
Value:
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132
struct pbl_mutex lock
Device lock.
Definition phy.h:56
PHY runtime state.
Definition phy.h:54
#define PBL_MUTEX_INITIALIZER
Static initializer for an unlocked mutex.
Definition mutex.h:50
Define the runtime state of a PHY.
- Parameters
-
| sym | Symbol of the instance. |
◆ pbl_phy_add_listener()
Add a listener to a PHY.
- Parameters
-
| phy | PHY. |
| listener | Listener, not added yet, which stays in use. |
◆ pbl_phy_power_off()
| int pbl_phy_power_off |
( |
const struct pbl_phy * |
phy | ) |
|
Power a PHY off.
- Parameters
-
- Returns
- 0 or a negative errno.
◆ pbl_phy_power_on()
| int pbl_phy_power_on |
( |
const struct pbl_phy * |
phy | ) |
|
Power a PHY on.
- Parameters
-
- Returns
- 0 or a negative errno.
◆ pbl_phy_report_vbus_changed()
| void pbl_phy_report_vbus_changed |
( |
const struct pbl_phy * |
phy | ) |
|
Report VBUS coming or going to the listeners, from thread context.
For drivers.
- Parameters
-
◆ pbl_phy_vbus_present()
| int pbl_phy_vbus_present |
( |
const struct pbl_phy * |
phy, |
|
|
bool * |
present |
|
) |
| |
Check whether VBUS is present.
- Parameters
-
| phy | PHY. |
| [out] | present | True while VBUS is present. |
- Returns
- 0,
-ENOTSUP if the PHY does not sense VBUS, or another negative errno.