Nordic nPM1300 PMIC core.
More...
Nordic nPM1300 PMIC core.
The core is a struct pbl_mfd_npm1300 device on its I2C bus. It owns the register access, under a lock so its cells cannot interleave read-modify-write sequences, and brings its cells up from its init. Each cell is a child device in its own subsystem: the charger (Charger), the GPIO port (nPM1300 GPIO) and one regulator per rail (nPM1300 regulators).
As the system power controller, the core cuts the power of the system for pbl_power_cut() by entering ship mode, which a button press or VBUS ends. The cut is refused while VBUS is present.
◆ pbl_mfd_npm1300
| Data Fields |
|
struct pbl_device |
dev |
Device, child of the I2C bus. |
|
struct pbl_i2c_dev |
i2c |
I2C device. |
|
struct pbl_mfd_npm1300_state * |
state |
Runtime state. |
|
bool |
system_power_controller |
Whether it cuts the power of the system. |
◆ PBL_MFD_NPM1300_DEFINE
| #define PBL_MFD_NPM1300_DEFINE |
( |
|
sym, |
|
|
|
_bus, |
|
|
|
_addr, |
|
|
|
_system_power_controller |
|
) |
| |
Value:
static struct pbl_mfd_npm1300_state sym##_npm1300_state; \
PBL_DEVICE_INIT_CLASS(sym,
"npm1300", pbl_mfd_npm1300_init, &(_bus)->
dev, &
pbl_mfd_class), \
.
state = &sym##_npm1300_state, \
}; \
PBL_DEVICE_REGISTER(sym, &sym.
dev); \
pbl_mfd_npm1300_power_cut_check, pbl_mfd_npm1300_power_cut, \
(void *)&sym)
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:131
#define PBL_I2C_DEV(_bus, _addr)
Initializer for a struct pbl_i2c_dev.
Definition i2c.h:159
bool system_power_controller
Whether it cuts the power of the system.
Definition npm1300.h:46
struct pbl_device dev
Device, child of the I2C bus.
Definition npm1300.h:40
nPM1300 core.
Definition npm1300.h:38
const struct pbl_device_class pbl_mfd_class
Class of the devices.
#define PBL_SYS_OFF_PRIO_DEFAULT
Default handler priority.
Definition reboot.h:58
struct pbl_device_state * state
Runtime state.
Definition device.h:101
Define the core.
- Parameters
-
| sym | Symbol of the core. |
| _bus | I2C bus. |
| _addr | 7-bit I2C address. |
| _system_power_controller | Whether it cuts the power of the system. |
◆ pbl_mfd_npm1300_from_cell()
◆ pbl_mfd_npm1300_lock()
Lock the registers, around a read-modify-write sequence.
Single accesses lock on their own.
- Parameters
-
◆ pbl_mfd_npm1300_read()
| int pbl_mfd_npm1300_read |
( |
const struct pbl_mfd_npm1300 * |
pmic, |
|
|
uint16_t |
reg, |
|
|
uint8_t * |
val |
|
) |
| |
Read a register.
- Parameters
-
| pmic | Core. |
| reg | Register address. |
| [out] | val | Register value. |
- Returns
- 0 on success, or a negative errno.
◆ pbl_mfd_npm1300_unlock()
Unlock the registers.
- Parameters
-
◆ pbl_mfd_npm1300_write()
| int pbl_mfd_npm1300_write |
( |
const struct pbl_mfd_npm1300 * |
pmic, |
|
|
uint16_t |
reg, |
|
|
uint8_t |
val |
|
) |
| |
Write a register.
- Parameters
-
| pmic | Core. |
| reg | Register address. |
| val | Value. |
- Returns
- 0 on success, or a negative errno.