rk805: Add regnode_status method

This allow consumers to check if the regulator is enable or not.

Reviewed by:	mmel
Differential Revision:	https://reviews.freebsd.org/D23005
This commit is contained in:
Emmanuel Vadot 2020-01-08 11:30:03 +00:00
parent d194b63134
commit 546652fbe3

View File

@ -412,6 +412,22 @@ rk805_regnode_voltage_to_reg(struct rk805_reg_sc *sc, int min_uvolt,
return (0);
}
static int
rk805_regnode_status(struct regnode *regnode, int *status)
{
struct rk805_reg_sc *sc;
uint8_t val;
sc = regnode_get_softc(regnode);
*status = 0;
rk805_read(sc->base_dev, sc->def->enable_reg, &val, 1);
if (val & sc->def->enable_mask)
*status = REGULATOR_STATUS_ENABLED;
return (0);
}
static int
rk805_regnode_set_voltage(struct regnode *regnode, int min_uvolt,
int max_uvolt, int *udelay)
@ -477,6 +493,7 @@ static regnode_method_t rk805_regnode_methods[] = {
/* Regulator interface */
REGNODEMETHOD(regnode_init, rk805_regnode_init),
REGNODEMETHOD(regnode_enable, rk805_regnode_enable),
REGNODEMETHOD(regnode_status, rk805_regnode_status),
REGNODEMETHOD(regnode_set_voltage, rk805_regnode_set_voltage),
REGNODEMETHOD(regnode_get_voltage, rk805_regnode_get_voltage),
REGNODEMETHOD(regnode_check_voltage, regnode_method_check_voltage),