Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85a82e88 authored by David Collins's avatar David Collins Committed by Gerrit - the friendly Code Review server
Browse files

regulator: core: add regulator_list_corner_voltage function



Introduce a regulator_list_corner_voltage function for consumers
that need to know the maximum absolute voltage that may be
physically configured when a regulator is operating at a given
voltage corner.

Change-Id: Ide7a0b502796774fcad01f5cb5679f0938c72f96
Signed-off-by: default avatarDavid Collins <collinsd@codeaurora.org>
parent b88dc6d8
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -2652,6 +2652,40 @@ int regulator_list_hardware_vsel(struct regulator *regulator,
}
EXPORT_SYMBOL_GPL(regulator_list_hardware_vsel);

/**
 * 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_get_linear_step - return the voltage step size between VSEL values
 * @regulator: regulator source
+6 −0
Original line number Diff line number Diff line
@@ -225,6 +225,7 @@ void regulator_bulk_free(int num_consumers,

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);
unsigned int regulator_get_linear_step(struct regulator *regulator);
@@ -552,6 +553,11 @@ static inline int regulator_list_voltage(struct regulator *regulator, unsigned s
	return -EINVAL;
}

static inline int regulator_list_corner_voltage(struct regulator *regulator,
	int corner)
{
	return -EINVAL;
}
#endif

static inline int regulator_set_voltage_triplet(struct regulator *regulator,
+5 −0
Original line number Diff line number Diff line
@@ -87,6 +87,10 @@ struct regulator_linear_range {
 *	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.
@@ -142,6 +146,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,