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

Commit e8fc10a6 authored by Osvaldo Banuelos's avatar Osvaldo Banuelos
Browse files

regulator: cpr3-regulator: cap max_uV in LDO regulator set_voltage() calls



Currently, the maximum voltage specified in regulator_set_voltage() calls
for CPUSS regulators correspond to the last known aggregated ceiling
voltage. However, this voltage may be higher than what the LDO can actually
supply. In those cases, cap the voltage to the maximum physically supported
LDO voltage. This effectively prevents the regulator framework from
performing unnecessary set_voltage() calls for LDO regulators whose max_uV
voltages are limited by machine-specific constraints.

Change-Id: Iacc9abf22234b9fda8ec8e2f10fa270cab165e6a
Signed-off-by: default avatarOsvaldo Banuelos <osvaldob@codeaurora.org>
parent 4c47f344
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -749,7 +749,8 @@ static int cpr3_regulator_set_bhs_mode(struct cpr3_regulator *vreg,
		bhs_volt = vreg->ldo_max_volt;
	}

	rc = regulator_set_voltage(ldo_reg, bhs_volt, vdd_ceiling_volt);
	rc = regulator_set_voltage(ldo_reg, bhs_volt, min(vdd_ceiling_volt,
							  vreg->ldo_max_volt));
	if (rc) {
		cpr3_err(vreg, "regulator_set_voltage(ldo) == %d failed, rc=%d\n",
			 bhs_volt, rc);
@@ -787,7 +788,7 @@ static int cpr3_regulator_config_vreg_ldo(struct cpr3_regulator *vreg,
			     int vdd_volt)
{
	struct regulator *ldo_reg = vreg->ldo_regulator;
	int rc, ldo_volt, bhs_volt;
	int rc, ldo_volt, bhs_volt, max_volt;

	rc = cpr3_regulator_config_ldo_retention(vreg, vdd_floor_volt);
	if (rc)
@@ -800,6 +801,8 @@ static int cpr3_regulator_config_vreg_ldo(struct cpr3_regulator *vreg,
	ldo_volt = vreg->corner[vreg->current_corner].open_loop_volt
		- vreg->ldo_adjust_volt;

	max_volt = min(vdd_ceiling_volt, vreg->ldo_max_volt);

	if (vdd_floor_volt >= ldo_volt + vreg->ldo_headroom_volt) {
		if (vreg->ldo_regulator_bypass == BHS_MODE) {
			if (ldo_volt > vreg->ldo_max_volt) {
@@ -818,8 +821,8 @@ static int cpr3_regulator_config_vreg_ldo(struct cpr3_regulator *vreg,
					   bhs_volt, vreg->ldo_max_volt);
				bhs_volt = vreg->ldo_max_volt;
			}
			rc = regulator_set_voltage(ldo_reg, bhs_volt,
						vdd_ceiling_volt);

			rc = regulator_set_voltage(ldo_reg, bhs_volt, max_volt);
			if (rc) {
				cpr3_err(vreg, "regulator_set_voltage(ldo) == %d failed, rc=%d\n",
					 bhs_volt, rc);
@@ -836,7 +839,7 @@ static int cpr3_regulator_config_vreg_ldo(struct cpr3_regulator *vreg,
		}

		/* Configure final LDO output voltage */
		rc = regulator_set_voltage(ldo_reg, ldo_volt, vdd_ceiling_volt);
		rc = regulator_set_voltage(ldo_reg, ldo_volt, max_volt);
		if (rc) {
			cpr3_err(vreg, "regulator_set_voltage(ldo) == %d failed, rc=%d\n",
				 ldo_volt, rc);