Skip to content

Commit

Permalink
drivers: regulator: max20335: allow current limit operations only for…
Browse files Browse the repository at this point in the history
… BUCKs

LDOs don't have such possibility so add the extra checks.

Signed-off-by: Bartosz Bilas <[email protected]>
  • Loading branch information
bbilas authored and carlescufi committed Jan 8, 2024
1 parent 6f84f34 commit 7213e8e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions drivers/regulator/regulator_max20335.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ static unsigned int regulator_max20335_count_current_limits(const struct device
{
const struct regulator_max20335_config *config = dev->config;

if (config->source != MAX20335_PMIC_SOURCE_BUCK1 &&
config->source != MAX20335_PMIC_SOURCE_BUCK2) {
return -ENOTSUP;
}

return linear_range_values_count(config->desc->ua_range);
}

Expand All @@ -232,6 +237,11 @@ static int regulator_max20335_list_current_limit(const struct device *dev, unsig
{
const struct regulator_max20335_config *config = dev->config;

if (config->source != MAX20335_PMIC_SOURCE_BUCK1 &&
config->source != MAX20335_PMIC_SOURCE_BUCK2) {
return -ENOTSUP;
}

return linear_range_get_value(config->desc->ua_range, idx, current_ua);
}

Expand All @@ -244,6 +254,11 @@ static int regulator_max20335_set_current_limit(const struct device *dev,
uint16_t idx;
int ret;

if (config->source != MAX20335_PMIC_SOURCE_BUCK1 &&
config->source != MAX20335_PMIC_SOURCE_BUCK2) {
return -ENOTSUP;
}

ret = i2c_reg_read_byte_dt(&config->bus, MAX20335_BUCK12_CSET, &val);
if (ret < 0) {
return ret;
Expand Down

0 comments on commit 7213e8e

Please sign in to comment.