drivers: regulator: drop mode specific APIs
- Mode specific APIs repeat the same functionality offered by non-mode specific APIs - The same functionality can be achieved by the non-mode APIs, since they apply to the active mode which can be set using regulator_set_mode() first. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
0a84377f1c
commit
b909d0e560
3 changed files with 0 additions and 261 deletions
|
@ -322,76 +322,6 @@ static int regulator_pca9420_get_current_limit(const struct device *dev)
|
|||
return MIN(config->max_ua, cconfig->vin_ilim_ua);
|
||||
}
|
||||
|
||||
/*
|
||||
* Part of the extended regulator consumer API.
|
||||
* sets the target voltage for a given regulator mode. This mode does
|
||||
* not need to be the active mode. This API can be used to configure
|
||||
* voltages for a mode, then the regulator can be switched to that mode
|
||||
* with the regulator_pca9420_set_mode api
|
||||
*/
|
||||
static int regulator_pca9420_set_mode_voltage(const struct device *dev,
|
||||
uint32_t mode, int32_t min_uv,
|
||||
int32_t max_uv)
|
||||
{
|
||||
return regulator_set_voltage_mode(dev, min_uv, max_uv, mode);
|
||||
}
|
||||
|
||||
/*
|
||||
* Part of the extended regulator consumer API.
|
||||
* Disables the regulator in a given mode. Does not implement the
|
||||
* onoff service, as this is incompatible with multiple mode operation
|
||||
*/
|
||||
static int regulator_pca9420_mode_disable(const struct device *dev,
|
||||
uint32_t mode)
|
||||
{
|
||||
const struct regulator_pca9420_config *config = dev->config;
|
||||
const struct regulator_pca9420_common_config *cconfig = config->parent->config;
|
||||
uint8_t dis_val;
|
||||
|
||||
dis_val = config->enable_inverted ? config->desc->enable_val : 0;
|
||||
return i2c_reg_update_byte_dt(
|
||||
&cconfig->i2c,
|
||||
config->desc->enable_reg + PCA9420_MODECFG_OFFSET(mode),
|
||||
config->desc->enable_mask, dis_val);
|
||||
}
|
||||
|
||||
/*
|
||||
* Part of the extended regulator consumer API.
|
||||
* Enables the regulator in a given mode. Does not implement the
|
||||
* onoff service, as this is incompatible with multiple mode operation
|
||||
*/
|
||||
static int regulator_pca9420_mode_enable(const struct device *dev,
|
||||
uint32_t mode)
|
||||
{
|
||||
const struct regulator_pca9420_config *config = dev->config;
|
||||
const struct regulator_pca9420_common_config *cconfig = config->parent->config;
|
||||
uint8_t en_val;
|
||||
|
||||
en_val = config->enable_inverted ? 0 : config->desc->enable_val;
|
||||
return i2c_reg_update_byte_dt(
|
||||
&cconfig->i2c,
|
||||
config->desc->enable_reg + PCA9420_MODECFG_OFFSET(mode),
|
||||
config->desc->enable_mask, en_val);
|
||||
}
|
||||
|
||||
/*
|
||||
* Part of the extended regulator consumer API.
|
||||
* gets the target voltage for a given regulator mode. This mode does
|
||||
* not need to be the active mode. This API can be used to read voltages
|
||||
* from a regulator mode other than the default.
|
||||
*/
|
||||
static int32_t regulator_pca9420_get_mode_voltage(const struct device *dev,
|
||||
uint32_t mode)
|
||||
{
|
||||
int32_t voltage;
|
||||
|
||||
if (regulator_pca9420_get_voltage_mode(dev, mode, &voltage) < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return voltage;
|
||||
}
|
||||
|
||||
static int regulator_pca9420_set_mode(const struct device *dev, uint32_t mode)
|
||||
{
|
||||
const struct regulator_pca9420_config *config = dev->config;
|
||||
|
@ -512,10 +442,6 @@ static const struct regulator_driver_api api = {
|
|||
.get_voltage = regulator_pca9420_get_voltage,
|
||||
.get_current_limit = regulator_pca9420_get_current_limit,
|
||||
.set_mode = regulator_pca9420_set_mode,
|
||||
.set_mode_voltage = regulator_pca9420_set_mode_voltage,
|
||||
.get_mode_voltage = regulator_pca9420_get_mode_voltage,
|
||||
.mode_disable = regulator_pca9420_mode_disable,
|
||||
.mode_enable = regulator_pca9420_mode_enable,
|
||||
};
|
||||
|
||||
#define REGULATOR_PCA9420_DEFINE(node_id, id, name, _parent) \
|
||||
|
|
|
@ -128,79 +128,6 @@ static int cmd_set_mode(const struct shell *sh, size_t argc, char **argv)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int cmd_set_mode_vol(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
int mode, lvol, uvol, ret;
|
||||
const struct device *reg_dev;
|
||||
|
||||
reg_dev = device_get_binding(argv[1]);
|
||||
if (reg_dev == NULL) {
|
||||
shell_error(sh, "regulator device %s not available", argv[1]);
|
||||
return -ENODEV;
|
||||
}
|
||||
mode = strtol(argv[2], NULL, 10);
|
||||
lvol = strtol(argv[3], NULL, 10) * 1000;
|
||||
uvol = strtol(argv[4], NULL, 10) * 1000;
|
||||
ret = regulator_set_mode_voltage(reg_dev, mode, lvol, uvol);
|
||||
if (ret < 0) {
|
||||
shell_error(sh, "failed to set mode voltage, error %d", ret);
|
||||
return ret;
|
||||
}
|
||||
ret = regulator_get_mode_voltage(reg_dev, mode);
|
||||
if (ret < 0) {
|
||||
shell_error(sh, "failed to get mode voltage, error %d", ret);
|
||||
return ret;
|
||||
}
|
||||
shell_print(sh, "set voltage for mode %d to %d uV", mode, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cmd_reg_mode_en(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
const struct device *reg_dev;
|
||||
int ret, mode;
|
||||
|
||||
reg_dev = device_get_binding(argv[1]);
|
||||
if (reg_dev == NULL) {
|
||||
shell_error(sh, "regulator device %s not available", argv[1]);
|
||||
return -ENODEV;
|
||||
}
|
||||
mode = strtol(argv[2], NULL, 10);
|
||||
|
||||
ret = regulator_mode_enable(reg_dev, mode);
|
||||
if (ret < 0) {
|
||||
shell_error(sh, "failed to enable regulator for "
|
||||
"mode %d, error %d", mode, ret);
|
||||
return ret;
|
||||
}
|
||||
shell_print(sh, "enabled regulator for mode %d", mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int cmd_reg_mode_dis(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
const struct device *reg_dev;
|
||||
int ret, mode;
|
||||
|
||||
reg_dev = device_get_binding(argv[1]);
|
||||
if (reg_dev == NULL) {
|
||||
shell_error(sh, "regulator device %s not available", argv[1]);
|
||||
return -ENODEV;
|
||||
}
|
||||
mode = strtol(argv[2], NULL, 10);
|
||||
|
||||
ret = regulator_mode_disable(reg_dev, mode);
|
||||
if (ret < 0) {
|
||||
shell_error(sh, "failed to disable regulator for "
|
||||
"mode %d, error %d", mode, ret);
|
||||
return ret;
|
||||
}
|
||||
shell_print(sh, "disabled regulator for mode %d", mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
SHELL_STATIC_SUBCMD_SET_CREATE(regulator_set,
|
||||
SHELL_CMD_ARG(enable, NULL,
|
||||
"Enable regulator\n"
|
||||
|
@ -217,16 +144,6 @@ SHELL_STATIC_SUBCMD_SET_CREATE(regulator_set,
|
|||
SHELL_CMD_ARG(set_mode, NULL, "Set mode of regulator\n"
|
||||
"Usage: set_mode <device> <mode index>",
|
||||
cmd_set_mode, 3, 0),
|
||||
SHELL_CMD_ARG(set_mode_vol, NULL, "Set voltage for mode of regulator\n"
|
||||
"Usage: set_mode_vol <device> <mode index> "
|
||||
"<low limit (uV)> <high limit (uV)>",
|
||||
cmd_set_mode_vol, 5, 0),
|
||||
SHELL_CMD_ARG(mode_enable, NULL,
|
||||
"Enable regulator in given mode\n"
|
||||
"Usage: enable <device> <mode index>", cmd_reg_mode_en, 3, 0),
|
||||
SHELL_CMD_ARG(mode_disable, NULL,
|
||||
"Disable regulator in given mode\n"
|
||||
"Usage: disable <device> <mode index>", cmd_reg_mode_dis, 3, 0),
|
||||
SHELL_SUBCMD_SET_END
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue