Merge "regulator: cpr-regulator: specify a list_corner_voltage callback function"

This commit is contained in:
Linux Build Service Account 2015-07-05 02:35:43 -07:00 committed by Gerrit - the friendly Code Review server
commit 32e51e10ee
4 changed files with 69 additions and 0 deletions

View File

@ -2182,6 +2182,40 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector)
}
EXPORT_SYMBOL_GPL(regulator_list_voltage);
/**
* regulator_list_corner_voltage - return the maximum voltage in microvolts that
* can be physically configured for the regulator when operating at the
* specified voltage corner
* @regulator: regulator source
* @corner: voltage corner value
* Context: can sleep
*
* This function can be used for regulators which allow scaling between
* different voltage corners as opposed to be different absolute voltages. The
* absolute voltage for a given corner may vary part-to-part or for a given part
* at runtime based upon various factors.
*
* Returns a voltage corresponding to the specified voltage corner or a negative
* errno if the corner value can't be used on this system.
*/
int regulator_list_corner_voltage(struct regulator *regulator, int corner)
{
struct regulator_dev *rdev = regulator->rdev;
int ret;
if (corner < rdev->constraints->min_uV ||
corner > rdev->constraints->max_uV ||
!rdev->desc->ops->list_corner_voltage)
return -EINVAL;
mutex_lock(&rdev->mutex);
ret = rdev->desc->ops->list_corner_voltage(rdev, corner);
mutex_unlock(&rdev->mutex);
return ret;
}
EXPORT_SYMBOL(regulator_list_corner_voltage);
/**
* regulator_is_supported_voltage - check if a voltage range can be supported
*

View File

@ -1116,12 +1116,35 @@ static int cpr_regulator_get_voltage(struct regulator_dev *rdev)
return cpr_vreg->corner;
}
/**
* cpr_regulator_list_corner_voltage() - return the ceiling voltage mapped to
* the specified voltage corner
* @rdev: Regulator device pointer for the cpr-regulator
* @corner: Voltage corner
*
* This function is passed as a callback function into the regulator ops that
* are registered for each cpr-regulator device.
*
* Return: voltage value in microvolts or -EINVAL if the corner is out of range
*/
static int cpr_regulator_list_corner_voltage(struct regulator_dev *rdev,
int corner)
{
struct cpr_regulator *cpr_vreg = rdev_get_drvdata(rdev);
if (corner >= CPR_CORNER_MIN && corner <= cpr_vreg->num_corners)
return cpr_vreg->ceiling_volt[corner];
else
return -EINVAL;
}
static struct regulator_ops cpr_corner_ops = {
.enable = cpr_regulator_enable,
.disable = cpr_regulator_disable,
.is_enabled = cpr_regulator_is_enabled,
.set_voltage = cpr_regulator_set_voltage_op,
.get_voltage = cpr_regulator_get_voltage,
.list_corner_voltage = cpr_regulator_list_corner_voltage,
};
#ifdef CONFIG_PM

View File

@ -176,6 +176,7 @@ void regulator_bulk_free(int num_consumers,
int regulator_can_change_voltage(struct regulator *regulator);
int regulator_count_voltages(struct regulator *regulator);
int regulator_list_voltage(struct regulator *regulator, unsigned selector);
int regulator_list_corner_voltage(struct regulator *regulator, int corner);
int regulator_is_supported_voltage(struct regulator *regulator,
int min_uV, int max_uV);
int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
@ -376,6 +377,12 @@ static inline int regulator_count_voltages(struct regulator *regulator)
{
return 0;
}
static inline int regulator_list_corner_voltage(struct regulator *regulator,
int corner)
{
return -EINVAL;
}
#endif
static inline int regulator_set_voltage_tol(struct regulator *regulator,

View File

@ -60,6 +60,10 @@ enum regulator_status {
* if the selector indicates a voltage that is unusable on this system;
* or negative errno. Selectors range from zero to one less than
* regulator_desc.n_voltages. Voltages may be reported in any order.
* @list_corner_voltage: Return the maximum voltage in microvolts that
* that can be physically configured for the regulator when operating at
* the specified voltage corner or a negative errno if the corner value
* can't be used on this system.
*
* @set_current_limit: Configure a limit for a current-limited regulator.
* The driver should select the current closest to max_uA.
@ -100,6 +104,7 @@ struct regulator_ops {
/* enumerate supported voltages */
int (*list_voltage) (struct regulator_dev *, unsigned selector);
int (*list_corner_voltage)(struct regulator_dev *, int corner);
/* get/set regulator voltage */
int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV,