regulator: core: Allow drivers to set voltage mapping table in regulator_desc
Some regulator hardware use table based mapping can set volt_table in regulator_desc and use regulator_list_voltage_table() for their list_voltage callback. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
f8f5701bda
commit
cffc9592fd
2 changed files with 30 additions and 0 deletions
|
@ -1882,6 +1882,31 @@ int regulator_list_voltage_linear(struct regulator_dev *rdev,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(regulator_list_voltage_linear);
|
EXPORT_SYMBOL_GPL(regulator_list_voltage_linear);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* regulator_list_voltage_table - List voltages with table based mapping
|
||||||
|
*
|
||||||
|
* @rdev: Regulator device
|
||||||
|
* @selector: Selector to convert into a voltage
|
||||||
|
*
|
||||||
|
* Regulators with table based mapping between voltages and
|
||||||
|
* selectors can set volt_table in the regulator descriptor
|
||||||
|
* and then use this function as their list_voltage() operation.
|
||||||
|
*/
|
||||||
|
int regulator_list_voltage_table(struct regulator_dev *rdev,
|
||||||
|
unsigned int selector)
|
||||||
|
{
|
||||||
|
if (!rdev->desc->volt_table) {
|
||||||
|
BUG_ON(!rdev->desc->volt_table);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selector >= rdev->desc->n_voltages)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return rdev->desc->volt_table[selector];
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(regulator_list_voltage_table);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* regulator_list_voltage - enumerate supported voltages
|
* regulator_list_voltage - enumerate supported voltages
|
||||||
* @regulator: regulator source
|
* @regulator: regulator source
|
||||||
|
|
|
@ -170,6 +170,7 @@ enum regulator_type {
|
||||||
*
|
*
|
||||||
* @min_uV: Voltage given by the lowest selector (if linear mapping)
|
* @min_uV: Voltage given by the lowest selector (if linear mapping)
|
||||||
* @uV_step: Voltage increase with each selector (if linear mapping)
|
* @uV_step: Voltage increase with each selector (if linear mapping)
|
||||||
|
* @volt_table: Voltage mapping table (if table based mapping)
|
||||||
*
|
*
|
||||||
* @vsel_reg: Register for selector when using regulator_regmap_X_voltage_
|
* @vsel_reg: Register for selector when using regulator_regmap_X_voltage_
|
||||||
* @vsel_mask: Mask for register bitfield used for selector
|
* @vsel_mask: Mask for register bitfield used for selector
|
||||||
|
@ -189,6 +190,8 @@ struct regulator_desc {
|
||||||
unsigned int min_uV;
|
unsigned int min_uV;
|
||||||
unsigned int uV_step;
|
unsigned int uV_step;
|
||||||
|
|
||||||
|
const unsigned int *volt_table;
|
||||||
|
|
||||||
unsigned int vsel_reg;
|
unsigned int vsel_reg;
|
||||||
unsigned int vsel_mask;
|
unsigned int vsel_mask;
|
||||||
unsigned int enable_reg;
|
unsigned int enable_reg;
|
||||||
|
@ -271,6 +274,8 @@ int regulator_mode_to_status(unsigned int);
|
||||||
|
|
||||||
int regulator_list_voltage_linear(struct regulator_dev *rdev,
|
int regulator_list_voltage_linear(struct regulator_dev *rdev,
|
||||||
unsigned int selector);
|
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 regulator_map_voltage_linear(struct regulator_dev *rdev,
|
||||||
int min_uV, int max_uV);
|
int min_uV, int max_uV);
|
||||||
int regulator_map_voltage_iterate(struct regulator_dev *rdev,
|
int regulator_map_voltage_iterate(struct regulator_dev *rdev,
|
||||||
|
|
Loading…
Add table
Reference in a new issue