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

Commit 2c09be70 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-fg: Enable FULL_SOC based on charging status



Currently, FULL_SOC interrupt is enabled as a wakeup interrupt
always. In some circumstances, it fires randomly after the
charger is removed but the SOC remains high. This wakes up the
device. Hence, keep it enabled only when the device is charging
and keep it disabled during discharging.

CRs-Fixed: 1075428
Change-Id: I575ba72030c3c453aac1118bceebe64a0445d138
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent b7ac7086
Loading
Loading
Loading
Loading
+24 −5
Original line number Diff line number Diff line
@@ -529,6 +529,7 @@ struct fg_chip {
	bool			charge_done;
	bool			resume_soc_lowered;
	bool			vbat_low_irq_enabled;
	bool			full_soc_irq_enabled;
	bool			charge_full;
	bool			hold_soc_while_full;
	bool			input_present;
@@ -1332,8 +1333,11 @@ static void fg_enable_irqs(struct fg_chip *chip, bool enable)
	if (enable) {
		enable_irq(chip->soc_irq[DELTA_SOC].irq);
		enable_irq_wake(chip->soc_irq[DELTA_SOC].irq);
		if (!chip->full_soc_irq_enabled) {
			enable_irq(chip->soc_irq[FULL_SOC].irq);
			enable_irq_wake(chip->soc_irq[FULL_SOC].irq);
			chip->full_soc_irq_enabled = true;
		}
		enable_irq(chip->batt_irq[BATT_MISSING].irq);
		if (!chip->vbat_low_irq_enabled) {
			enable_irq(chip->batt_irq[VBATT_LOW].irq);
@@ -1348,8 +1352,11 @@ static void fg_enable_irqs(struct fg_chip *chip, bool enable)
	} else {
		disable_irq_wake(chip->soc_irq[DELTA_SOC].irq);
		disable_irq_nosync(chip->soc_irq[DELTA_SOC].irq);
		if (chip->full_soc_irq_enabled) {
			disable_irq_wake(chip->soc_irq[FULL_SOC].irq);
			disable_irq_nosync(chip->soc_irq[FULL_SOC].irq);
			chip->full_soc_irq_enabled = false;
		}
		disable_irq(chip->batt_irq[BATT_MISSING].irq);
		if (chip->vbat_low_irq_enabled) {
			disable_irq_wake(chip->batt_irq[VBATT_LOW].irq);
@@ -3950,6 +3957,13 @@ static void status_change_work(struct work_struct *work)
			enable_irq_wake(chip->batt_irq[VBATT_LOW].irq);
			chip->vbat_low_irq_enabled = true;
		}

		if (!chip->full_soc_irq_enabled) {
			enable_irq(chip->soc_irq[FULL_SOC].irq);
			enable_irq_wake(chip->soc_irq[FULL_SOC].irq);
			chip->full_soc_irq_enabled = true;
		}

		if (!!(chip->wa_flag & PULSE_REQUEST_WA) && capacity == 100)
			fg_configure_soc(chip);
	} else if (chip->status == POWER_SUPPLY_STATUS_DISCHARGING) {
@@ -3959,6 +3973,12 @@ static void status_change_work(struct work_struct *work)
			disable_irq_nosync(chip->batt_irq[VBATT_LOW].irq);
			chip->vbat_low_irq_enabled = false;
		}

		if (chip->full_soc_irq_enabled) {
			disable_irq_wake(chip->soc_irq[FULL_SOC].irq);
			disable_irq_nosync(chip->soc_irq[FULL_SOC].irq);
			chip->full_soc_irq_enabled = false;
		}
	}
	fg_cap_learning_check(chip);
	schedule_work(&chip->update_esr_work);
@@ -7194,7 +7214,6 @@ static int fg_init_irqs(struct fg_chip *chip)
			}

			enable_irq_wake(chip->soc_irq[DELTA_SOC].irq);
			enable_irq_wake(chip->soc_irq[FULL_SOC].irq);
			if (!chip->use_vbat_low_empty_soc)
				enable_irq_wake(chip->soc_irq[EMPTY_SOC].irq);
			break;