mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 01:30:30 -04:00
axp8xx: Add a regnode_init method
This method will set the desired voltaged based on values in the DTS. It will not enable the regulator, this is the job of either a consumer or regnode_set_constraint SYSINIT if the regulator is boot_on or always_on. MFC after: 2 weeks
This commit is contained in:
parent
194840a170
commit
5fcd039b3f
1 changed files with 28 additions and 0 deletions
|
|
@ -710,6 +710,8 @@ struct axp8xx_softc {
|
|||
|
||||
#define AXP_LOCK(sc) mtx_lock(&(sc)->mtx)
|
||||
#define AXP_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
|
||||
static int axp8xx_regnode_set_voltage(struct regnode *regnode, int min_uvolt,
|
||||
int max_uvolt, int *udelay);
|
||||
|
||||
static int
|
||||
axp8xx_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size)
|
||||
|
|
@ -753,6 +755,31 @@ axp8xx_write(device_t dev, uint8_t reg, uint8_t val)
|
|||
return (iicbus_transfer(dev, msg, 2));
|
||||
}
|
||||
|
||||
static int
|
||||
axp8xx_regnode_init(struct regnode *regnode)
|
||||
{
|
||||
struct axp8xx_reg_sc *sc;
|
||||
struct regnode_std_param *param;
|
||||
int rv, udelay;
|
||||
|
||||
sc = regnode_get_softc(regnode);
|
||||
param = regnode_get_stdparam(regnode);
|
||||
if (param->min_uvolt == 0)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Set the regulator at the correct voltage
|
||||
* Do not enable it, this is will be done either by a
|
||||
* consumer or by regnode_set_constraint if boot_on is true
|
||||
*/
|
||||
rv = axp8xx_regnode_set_voltage(regnode, param->min_uvolt,
|
||||
param->max_uvolt, &udelay);
|
||||
if (rv != 0)
|
||||
DELAY(udelay);
|
||||
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static int
|
||||
axp8xx_regnode_enable(struct regnode *regnode, bool enable, int *udelay)
|
||||
{
|
||||
|
|
@ -870,6 +897,7 @@ axp8xx_regnode_get_voltage(struct regnode *regnode, int *uvolt)
|
|||
|
||||
static regnode_method_t axp8xx_regnode_methods[] = {
|
||||
/* Regulator interface */
|
||||
REGNODEMETHOD(regnode_init, axp8xx_regnode_init),
|
||||
REGNODEMETHOD(regnode_enable, axp8xx_regnode_enable),
|
||||
REGNODEMETHOD(regnode_set_voltage, axp8xx_regnode_set_voltage),
|
||||
REGNODEMETHOD(regnode_get_voltage, axp8xx_regnode_get_voltage),
|
||||
|
|
|
|||
Loading…
Reference in a new issue