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

Commit 02a69c56 authored by Osvaldo Banuelos's avatar Osvaldo Banuelos
Browse files

regulator: kryo-regulator: cap LDO voltage request during M3 enter notifier



LDO hardware may have a physical limitation in terms of the maximum
voltage it can provide. Ensure that the requested LDO voltage programmed
during the LDO to BHS switch in the M3 LPM prepare notifier path
does not exceed this limit. If it does, request for the LDO to output
its maximum voltage to allow the BHS switch to complete reliably.

Change-Id: I3304acb6361a726aa9e365b49ebe23d4f949f978
Signed-off-by: default avatarOsvaldo Banuelos <osvaldob@codeaurora.org>
parent 75d530af
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -851,7 +851,7 @@ static int kryo_regulator_retention_init(struct kryo_regulator *kvreg,

static int kryo_regulator_lpm_prepare(struct kryo_regulator *kvreg)
{
	int vdd_volt_uv, vdd_vlvl = 0;
	int vdd_volt_uv, bhs_volt, vdd_vlvl = 0;
	unsigned long flags;

	spin_lock_irqsave(&kvreg->slock, flags);
@@ -875,9 +875,19 @@ static int kryo_regulator_lpm_prepare(struct kryo_regulator *kvreg)
		kvreg_debug(kvreg, "switching to BHS mode, vdd_apcc=%d uV, current LDO Vref=%d, LPM enter count=%lx\n",
			    vdd_volt_uv, kvreg->volt, kvreg->lpm_enter_count);

		/* Program vdd supply minus LDO headroom as voltage */
		kryo_set_ldo_volt(kvreg, vdd_volt_uv
				  - kvreg->headroom_volt);
		/*
		 * Program vdd supply minus LDO headroom as voltage.
		 * Cap this value to the maximum physically supported
		 * LDO voltage, if necessary.
		 */
		bhs_volt = vdd_volt_uv - kvreg->headroom_volt;
		if (bhs_volt > kvreg->vref_func_max_volt) {
			kvreg_debug(kvreg, "limited to LDO output of %d uV when switching to BHS mode\n",
				    kvreg->vref_func_max_volt);
			bhs_volt = kvreg->vref_func_max_volt;
		}

		kryo_set_ldo_volt(kvreg, bhs_volt);

		/* Switch Power Gate Mode */
		kryo_configure_mode(kvreg, BHS_MODE);