regulator: core: Handle fixed voltage in map_voltage_linear
RFC PATCH 1/3 regulator: core: Handle fixed voltage in map_voltage_linear
Fixed voltage is a kind of linear mapping where n_voltages is 1. This change allows [list|map]_voltage_linear to be used for fixed voltage.
For fixed voltage, n_voltages is 1 and the only valid selector is 0. Thus we actually don't care the uV_step setting.
---
This patch is v2 of
[PATCH RFC 1/2] regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage.
I change the subject line because for fixed voltage, we actually don't care the uV_step setting.
drivers/regulator/core.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/regulator/core.c +9 -0
@@ -2070,6 +2070,15 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev, {int ret, voltage; +/* For fixed voltage, check if voltage falls within specified range */ +if (rdev->desc->n_voltages ==1 ) { +if (min_uV <= rdev->desc->min_uV && + rdev->desc->min_uV <= max_uV) +return 0 ; +else +return -EINVAL ; + } +if (!rdev->desc->uV_step) {BUG_ON (!rdev->desc->uV_step);return -EINVAL ;
Signature · 1 line
1.7.9.5
RFC PATCH 2/3 regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops
--- drivers/regulator/isl6271a-regulator.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/regulator/isl6271a-regulator.c +5 -9
@@ -75,19 +75,13 @@ static struct regulator_ops isl_core_ops = {static int isl6271a_get_fixed_voltage (struct regulator_dev *dev) { -int id =rdev_get_id (dev); -return (id ==1 ) ?1100000 :1300000 ; -} - -static int isl6271a_list_fixed_voltage (struct regulator_dev *dev,unsigned selector) -{ -int id =rdev_get_id (dev); -return (id ==1 ) ?1100000 :1300000 ; +return dev->desc->min_uV; }static struct regulator_ops isl_fixed_ops = { .get_voltage = isl6271a_get_fixed_voltage, - .list_voltage = isl6271a_list_fixed_voltage, + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, };static const struct regulator_desc isl_rd[] = {
@@ -107,6 +101,7 @@ static const struct regulator_desc isl_rd[] = { .ops = &isl_fixed_ops, .type = REGULATOR_VOLTAGE, .owner = THIS_MODULE, + .min_uV = 1100000, }, { .name = "LDO2", .id = 2,
@@ -114,6 +109,7 @@ static const struct regulator_desc isl_rd[] = { .ops = &isl_fixed_ops, .type = REGULATOR_VOLTAGE, .owner = THIS_MODULE, + .min_uV = 1300000, }, };
Signature · 1 line
1.7.9.5
Re: [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops
Quoted 7 lines
static struct
regulator_opsisl_fixed_ops= { .get_voltage =isl6271a_get_fixed_voltage,
- .list_voltage =isl6271a_list_fixed_voltage,
+ .list_voltage =regulator_list_voltage_linear,
+ .map_voltage =regulator_map_voltage_linear, };
Oh. isl_fixed_ops does not implement set_voltage_sel callback, adding map_voltage here
seems misleading. I'll send a v2 soon.
Re: [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops
Quoted 3 lines · Axel Lin
Oh.
isl_fixed_opsdoes not implementset_voltage_selcallback, addingmap_voltagehere
seems misleading. I'll send a v2 soon.
Please send an incremental patch, this is already applied.
RFC PATCH 3/3 regulator: da903x: Don't read/write to DA9030_INVAL/DA9034_INVAL address
In reply to Axel LinFor fixed voltage, DA9030_LDO13 and DA9034_LDO5, the info->vol_reg is DA9030_INVAL/DA9034_INVAL.
It does not make sense to read/write to DA9030_INVAL/DA9034_INVAL address.
--- drivers/regulator/da903x.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/regulator/da903x.c +6 -0
@@ -107,6 +107,9 @@ static int da903x_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)struct device *da9034_dev =to_da903x_dev (rdev);uint8_t val, mask; +if (rdev->desc->n_voltages ==1 ) +return -EINVAL ; + val = selector << info->vol_shift; mask = ((1 << info->vol_nbits) -1 ) << info->vol_shift;
@@ -120,6 +123,9 @@ static int da903x_get_voltage_sel(struct regulator_dev *rdev)uint8_t val, mask;int ret; +if (rdev->desc->n_voltages ==1 ) +return 0 ; + ret =da903x_read (da9034_dev, info->vol_reg, &val);if (ret)return ret;
Signature · 1 line
1.7.9.5