PebbleOS v4.47.0-1362-gd278268fe
Loading...
Searching...
No Matches
Regulator drivers

Interface for regulator drivers. More...

Data Structures

struct  pbl_regulator_ops
 Regulator driver operations. More...
 
struct  pbl_regulator
 A power rail. More...
 

Macros

#define PBL_REGULATOR_STATE_DEFINE(sym)
 Define the class state of regulator sym, for the PBL_*_REGULATOR_DEFINE() macro of a driver.
 
#define PBL_REGULATOR_INIT(sym, _name, _parent, _ops, _enable_time_us, _always_on)
 Initializer for the struct pbl_regulator of regulator sym.
 

Functions

int pbl_regulator_dev_init (const struct pbl_device *dev)
 Device init of every regulator: applies the driver's init, then switches the rail on if always-on, off otherwise.
 

Detailed Description

Interface for regulator drivers.

A driver embeds a struct pbl_regulator in its instance, sets it up with PBL_REGULATOR_STATE_DEFINE() and PBL_REGULATOR_INIT(), and implements the struct pbl_regulator_ops the class calls.


Data Structure Documentation

◆ pbl_regulator

struct pbl_regulator

A power rail.

Data Fields
bool always_on Switched on at init and never off.
struct pbl_device dev Device.
uint32_t enable_time_us Time from switching on until the rail is up, in microseconds.
const struct pbl_regulator_ops * ops Driver operations.
struct pbl_regulator_state * state Runtime state.

Macro Definition Documentation

◆ PBL_REGULATOR_INIT

#define PBL_REGULATOR_INIT (   sym,
  _name,
  _parent,
  _ops,
  _enable_time_us,
  _always_on 
)
Value:
{ \
.dev = \
PBL_DEVICE_INIT_CLASS(sym, _name, pbl_regulator_dev_init, _parent, &pbl_regulator_class), \
.ops = (_ops), \
.state = &sym##_regulator_state, \
.enable_time_us = (_enable_time_us), \
.always_on = (_always_on), \
}
int pbl_regulator_dev_init(const struct pbl_device *dev)
Device init of every regulator: applies the driver's init, then switches the rail on if always-on,...

Initializer for the struct pbl_regulator of regulator sym.

Parameters
symSymbol of the regulator instance, with its state defined by PBL_REGULATOR_STATE_DEFINE().
_nameName.
_parentParent device, or NULL.
_opsDriver operations.
_enable_time_usTime from switching on until the rail is up, in microseconds.
_always_onSwitched on at init and never off.

◆ PBL_REGULATOR_STATE_DEFINE

#define PBL_REGULATOR_STATE_DEFINE (   sym)
Value:
static struct pbl_regulator_state sym##_regulator_state
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:132

Define the class state of regulator sym, for the PBL_*_REGULATOR_DEFINE() macro of a driver.

Parameters
symSymbol of the regulator instance.

Function Documentation

◆ pbl_regulator_dev_init()

int pbl_regulator_dev_init ( const struct pbl_device *  dev)

Device init of every regulator: applies the driver's init, then switches the rail on if always-on, off otherwise.

Parameters
devRegulator device.
Returns
0 or a negative errno.