Power rail class.
More...
Power rail class.
A power rail is a struct pbl_regulator device. Consumers enable and disable it with a use count; a rail marked always-on is switched on at init and stays on, and any other rail starts off.
int pbl_regulator_enable(const struct pbl_regulator *reg)
Take a reference on a rail, switching it on for the first user.
int pbl_regulator_disable(const struct pbl_regulator *reg)
Drop a reference on a rail, switching it off after the last user.
◆ pbl_regulator
| Data Fields |
|
bool |
always_on |
Switched on at init and never off. |
|
struct pbl_device |
dev |
Device. |
|
const struct pbl_regulator_ops * |
ops |
Driver operations. |
|
struct pbl_regulator_state * |
state |
Runtime state. |
◆ PBL_REGULATOR_INIT
| #define PBL_REGULATOR_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_parent, |
|
|
|
_ops, |
|
|
|
_always_on |
|
) |
| |
Value: { \
.ops = (_ops), \
.state = &sym##_regulator_state, \
.always_on = (_always_on), \
}
#define PBL_DEVICE_INIT(sym, _name, _init, _parent, _deps)
Initializer for the struct pbl_device of device instance sym.
Definition device.h:142
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
-
| sym | Symbol of the regulator instance, with its state defined by PBL_REGULATOR_STATE_DEFINE(). |
| _name | Name. |
| _parent | Parent device, or NULL. |
| _ops | Driver operations. |
| _always_on | Switched 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:109
Define the class state of regulator sym, for the PBL_*_REGULATOR_DEFINE() macro of a driver.
- Parameters
-
| sym | Symbol of the regulator instance. |
◆ 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
-
- Returns
- 0 or a negative errno.
◆ pbl_regulator_disable()
Drop a reference on a rail, switching it off after the last user.
Must balance a successful pbl_regulator_enable().
- Parameters
-
- Returns
- 0 or a negative errno.
◆ pbl_regulator_enable()
Take a reference on a rail, switching it on for the first user.
- Parameters
-
- Returns
- 0 or a negative errno.
◆ pbl_regulator_is_enabled()
| bool pbl_regulator_is_enabled |
( |
const struct pbl_regulator * |
reg | ) |
|
Check whether a rail is on.
- Parameters
-
- Returns
- True if the rail is always-on or has users.