PebbleOS v4.48.0-75-g7416f78a1
Loading...
Searching...
No Matches
nPM1300

Nordic nPM1300 PMIC core. More...

Data Structures

struct  pbl_mfd_npm1300
 nPM1300 core. More...
 

Macros

#define PBL_MFD_NPM1300_DEFINE(sym, _bus, _addr, _system_power_controller)
 Define the core.
 

Functions

static const struct pbl_mfd_npm1300 * pbl_mfd_npm1300_from_cell (const struct pbl_device *cell)
 Get the core a cell belongs to.
 
void pbl_mfd_npm1300_lock (const struct pbl_mfd_npm1300 *pmic)
 Lock the registers, around a read-modify-write sequence.
 
void pbl_mfd_npm1300_unlock (const struct pbl_mfd_npm1300 *pmic)
 Unlock the registers.
 
int pbl_mfd_npm1300_read (const struct pbl_mfd_npm1300 *pmic, uint16_t reg, uint8_t *val)
 Read a register.
 
int pbl_mfd_npm1300_write (const struct pbl_mfd_npm1300 *pmic, uint16_t reg, uint8_t val)
 Write a register.
 

Detailed Description

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.


Data Structure Documentation

◆ pbl_mfd_npm1300

struct pbl_mfd_npm1300

nPM1300 core.

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.

Macro Definition Documentation

◆ 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; \
const struct pbl_mfd_npm1300 sym = { \
.dev = \
PBL_DEVICE_INIT_CLASS(sym, "npm1300", pbl_mfd_npm1300_init, &(_bus)->dev, &pbl_mfd_class), \
.i2c = PBL_I2C_DEV(_bus, _addr), \
.state = &sym##_npm1300_state, \
.system_power_controller = (_system_power_controller), \
}; \
PBL_DEVICE_REGISTER(sym, &sym.dev); \
PBL_SYS_OFF_POWER_CUT_HANDLER_DEFINE(sym##_power_cut, PBL_SYS_OFF_PRIO_DEFAULT, \
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
symSymbol of the core.
_busI2C bus.
_addr7-bit I2C address.
_system_power_controllerWhether it cuts the power of the system.

Function Documentation

◆ pbl_mfd_npm1300_from_cell()

static const struct pbl_mfd_npm1300 * pbl_mfd_npm1300_from_cell ( const struct pbl_device *  cell)
inlinestatic

Get the core a cell belongs to.

Parameters
cellCell device, a child of the core.
Returns
Core.

References pbl_mfd_npm1300::dev, pbl_device::parent, and PBL_CONTAINER_OF.

◆ pbl_mfd_npm1300_lock()

void pbl_mfd_npm1300_lock ( const struct pbl_mfd_npm1300 *  pmic)

Lock the registers, around a read-modify-write sequence.

Single accesses lock on their own.

Parameters
pmicCore.

◆ 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
pmicCore.
regRegister address.
[out]valRegister value.
Returns
0 on success, or a negative errno.

◆ pbl_mfd_npm1300_unlock()

void pbl_mfd_npm1300_unlock ( const struct pbl_mfd_npm1300 *  pmic)

Unlock the registers.

Parameters
pmicCore.

◆ 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
pmicCore.
regRegister address.
valValue.
Returns
0 on success, or a negative errno.