PebbleOS v4.47.0-1161-g94e3d98da
Loading...
Searching...
No Matches

PHY class. More...

Data Structures

struct  pbl_phy_listener
 PHY listener. More...
 
struct  pbl_phy_ops
 PHY driver operations, called with the device lock held. More...
 
struct  pbl_phy_state
 PHY runtime state. More...
 
struct  pbl_phy
 PHY. More...
 

Macros

#define PBL_PHY_STATE_DEFINE(sym)
 Define the runtime state of a PHY.
 
#define PBL_PHY_INIT(sym, _name, _parent, _ops)
 Initialize a struct pbl_phy.
 

Functions

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.
 
int pbl_phy_vbus_present (const struct pbl_phy *phy, bool *present)
 Check whether VBUS is present.
 
void pbl_phy_add_listener (const struct pbl_phy *phy, struct pbl_phy_listener *listener)
 Add a listener to a PHY.
 
void pbl_phy_report_vbus_changed (const struct pbl_phy *phy)
 Report VBUS coming or going to the listeners, from thread context.
 

Detailed Description

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.

ret = pbl_phy_power_on(phy);
...
ret = pbl_phy_power_off(phy);
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.

Data Structure Documentation

◆ pbl_phy_state

struct pbl_phy_state

PHY runtime state.

Data Fields
struct pbl_phy_listener * listeners Listeners.
struct pbl_mutex lock Device lock.

◆ pbl_phy

struct pbl_phy

PHY.

Data Fields
struct pbl_device dev Device.
const struct pbl_phy_ops * ops Driver operations.
struct pbl_phy_state * state Runtime state.

Macro Definition Documentation

◆ PBL_PHY_INIT

#define PBL_PHY_INIT (   sym,
  _name,
  _parent,
  _ops 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, pbl_phy_dev_init, _parent, &pbl_phy_class), \
.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
symSymbol of the instance, as passed to PBL_PHY_STATE_DEFINE().
_nameDevice name.
_parentParent device, or NULL.
_opsDriver operations.

◆ PBL_PHY_STATE_DEFINE

#define PBL_PHY_STATE_DEFINE (   sym)
Value:
static struct pbl_phy_state sym##_phy_state = {.lock = PBL_MUTEX_INITIALIZER}
#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
symSymbol of the instance.

Function Documentation

◆ pbl_phy_add_listener()

void pbl_phy_add_listener ( const struct pbl_phy *  phy,
struct pbl_phy_listener *  listener 
)

Add a listener to a PHY.

Parameters
phyPHY.
listenerListener, 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
phyPHY.
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
phyPHY.
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
phyPHY.

◆ pbl_phy_vbus_present()

int pbl_phy_vbus_present ( const struct pbl_phy *  phy,
bool *  present 
)

Check whether VBUS is present.

Parameters
phyPHY.
[out]presentTrue while VBUS is present.
Returns
0, -ENOTSUP if the PHY does not sense VBUS, or another negative errno.