regulator: core: Add helpers for multiple linear ranges
Many regulators have several linear ranges of selector with different
step sizes, for example offering better resolution at lower voltages.
Provide regulator_{map,list}_voltage_linear_range() allowing these
regulators to use generic code. To do so a table of regulator_linear_range
structs needs to be pointed to from the descriptor.
This was inspired by similar code included in a driver submission from
Chao Xie and Yi Zhang at Marvell.
Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
ad81f0545e
commit
94d33c02c7
2 changed files with 112 additions and 0 deletions
|
|
@ -39,6 +39,24 @@ enum regulator_status {
|
|||
REGULATOR_STATUS_UNDEFINED,
|
||||
};
|
||||
|
||||
/**
|
||||
* Specify a range of voltages for regulator_map_linar_range() and
|
||||
* regulator_list_linear_range().
|
||||
*
|
||||
* @min_uV: Lowest voltage in range
|
||||
* @max_uV: Highest voltage in range
|
||||
* @min_sel: Lowest selector for range
|
||||
* @max_sel: Highest selector for range
|
||||
* @uV_step: Step size
|
||||
*/
|
||||
struct regulator_linear_range {
|
||||
unsigned int min_uV;
|
||||
unsigned int max_uV;
|
||||
unsigned int min_sel;
|
||||
unsigned int max_sel;
|
||||
unsigned int uV_step;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct regulator_ops - regulator operations.
|
||||
*
|
||||
|
|
@ -223,6 +241,9 @@ struct regulator_desc {
|
|||
unsigned int linear_min_sel;
|
||||
unsigned int ramp_delay;
|
||||
|
||||
const struct regulator_linear_range *linear_ranges;
|
||||
int n_linear_ranges;
|
||||
|
||||
const unsigned int *volt_table;
|
||||
|
||||
unsigned int vsel_reg;
|
||||
|
|
@ -326,10 +347,14 @@ int regulator_mode_to_status(unsigned int);
|
|||
|
||||
int regulator_list_voltage_linear(struct regulator_dev *rdev,
|
||||
unsigned int selector);
|
||||
int regulator_list_voltage_linear_range(struct regulator_dev *rdev,
|
||||
unsigned int selector);
|
||||
int regulator_list_voltage_table(struct regulator_dev *rdev,
|
||||
unsigned int selector);
|
||||
int regulator_map_voltage_linear(struct regulator_dev *rdev,
|
||||
int min_uV, int max_uV);
|
||||
int regulator_map_voltage_linear_range(struct regulator_dev *rdev,
|
||||
int min_uV, int max_uV);
|
||||
int regulator_map_voltage_iterate(struct regulator_dev *rdev,
|
||||
int min_uV, int max_uV);
|
||||
int regulator_map_voltage_ascend(struct regulator_dev *rdev,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue