drivers: regulator: apply initial mode
Apply initial mode (regulator-initial-mode) as part of the regulator_common_init_enable call. Update tests to cover this change. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
88c082a46e
commit
fbba106a23
3 changed files with 13 additions and 4 deletions
|
@ -15,14 +15,19 @@ void regulator_common_data_init(const struct device *dev)
|
||||||
|
|
||||||
int regulator_common_init_enable(const struct device *dev)
|
int regulator_common_init_enable(const struct device *dev)
|
||||||
{
|
{
|
||||||
|
const struct regulator_driver_api *api = dev->api;
|
||||||
const struct regulator_common_config *config = dev->config;
|
const struct regulator_common_config *config = dev->config;
|
||||||
struct regulator_common_data *data = dev->data;
|
struct regulator_common_data *data = dev->data;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (config->initial_mode != REGULATOR_INITIAL_MODE_UNKNOWN) {
|
||||||
|
ret = regulator_set_mode(dev, config->initial_mode);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((config->flags & REGULATOR_INIT_ENABLED) != 0U) {
|
if ((config->flags & REGULATOR_INIT_ENABLED) != 0U) {
|
||||||
const struct regulator_driver_api *api = dev->api;
|
|
||||||
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = api->enable(dev);
|
ret = api->enable(dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
regulator-min-microamp = <100>;
|
regulator-min-microamp = <100>;
|
||||||
regulator-max-microamp = <200>;
|
regulator-max-microamp = <200>;
|
||||||
regulator-allowed-modes = <1 10>;
|
regulator-allowed-modes = <1 10>;
|
||||||
|
regulator-initial-mode = <1>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -626,6 +626,9 @@ void *setup(void)
|
||||||
zassert_true(regulator_is_enabled(reg1));
|
zassert_true(regulator_is_enabled(reg1));
|
||||||
zassert_true(regulator_is_enabled(reg2));
|
zassert_true(regulator_is_enabled(reg2));
|
||||||
|
|
||||||
|
/* REG3 mode set at init time (initial-mode) */
|
||||||
|
zassert_equal(regulator_fake_set_mode_fake.call_count, 1U);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue