regulator: helpers: Export helper voltage listing
Some drivers need to translate voltage values to selectors prior regulator registration. Currently a regulator_desc based list_voltages helper is only exported for regulators using the linear_ranges. Export similar helper also for regulators using simple linear mapping. Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Link: https://lore.kernel.org/r/1200ef7a50c84327ada019b85f6527b4fc9b5ce1.1617020713.git.matti.vaittinen@fi.rohmeurope.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
0d02ec6b31
commit
e3baacf542
|
@ -508,6 +508,33 @@ int regulator_map_voltage_pickable_linear_range(struct regulator_dev *rdev,
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(regulator_map_voltage_pickable_linear_range);
|
||||
|
||||
/**
|
||||
* regulator_desc_list_voltage_linear - List voltages with simple calculation
|
||||
*
|
||||
* @desc: Regulator desc for regulator which volatges are to be listed
|
||||
* @selector: Selector to convert into a voltage
|
||||
*
|
||||
* Regulators with a simple linear mapping between voltages and
|
||||
* selectors can set min_uV and uV_step in the regulator descriptor
|
||||
* and then use this function prior regulator registration to list
|
||||
* the voltages. This is useful when voltages need to be listed during
|
||||
* device-tree parsing.
|
||||
*/
|
||||
int regulator_desc_list_voltage_linear(const struct regulator_desc *desc,
|
||||
unsigned int selector)
|
||||
{
|
||||
if (selector >= desc->n_voltages)
|
||||
return -EINVAL;
|
||||
|
||||
if (selector < desc->linear_min_sel)
|
||||
return 0;
|
||||
|
||||
selector -= desc->linear_min_sel;
|
||||
|
||||
return desc->min_uV + (desc->uV_step * selector);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(regulator_desc_list_voltage_linear);
|
||||
|
||||
/**
|
||||
* regulator_list_voltage_linear - List voltages with simple calculation
|
||||
*
|
||||
|
@ -521,14 +548,7 @@ EXPORT_SYMBOL_GPL(regulator_map_voltage_pickable_linear_range);
|
|||
int regulator_list_voltage_linear(struct regulator_dev *rdev,
|
||||
unsigned int selector)
|
||||
{
|
||||
if (selector >= rdev->desc->n_voltages)
|
||||
return -EINVAL;
|
||||
if (selector < rdev->desc->linear_min_sel)
|
||||
return 0;
|
||||
|
||||
selector -= rdev->desc->linear_min_sel;
|
||||
|
||||
return rdev->desc->min_uV + (rdev->desc->uV_step * selector);
|
||||
return regulator_desc_list_voltage_linear(rdev->desc, selector);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(regulator_list_voltage_linear);
|
||||
|
||||
|
|
|
@ -543,4 +543,6 @@ void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);
|
|||
int regulator_desc_list_voltage_linear_range(const struct regulator_desc *desc,
|
||||
unsigned int selector);
|
||||
|
||||
int regulator_desc_list_voltage_linear(const struct regulator_desc *desc,
|
||||
unsigned int selector);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue