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

Commit 88c26c1b authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

power: qg-soc: Allow SOC to increase only if we are charging



The current logic checks only for input presence to allow increase
in SOC. This check does not work well during hard JEITA conditions,
where input is present but device is not charging. Fix this
by making sure that we are indeed charging to allow SOC to scale up.

Change-Id: I649cbc136f404e44c78c6443d5586cbdeb0fd768
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 4041d09a
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
/* Copyright (c) 2018 The Linux Foundation. All rights reserved.
/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -118,6 +118,8 @@ static void get_next_update_time(struct qpnp_qg *chip)

static bool is_scaling_required(struct qpnp_qg *chip)
{
	bool usb_present = is_usb_present(chip);

	if (!chip->profile_loaded)
		return false;

@@ -133,11 +135,16 @@ static bool is_scaling_required(struct qpnp_qg *chip)
		/* SOC has not changed */
		return false;


	if (chip->catch_up_soc > chip->msoc && !is_usb_present(chip))
	if (chip->catch_up_soc > chip->msoc && !usb_present)
		/* USB is not present and SOC has increased */
		return false;

	if (chip->catch_up_soc > chip->msoc && usb_present &&
			(chip->charge_status != POWER_SUPPLY_STATUS_CHARGING &&
			chip->charge_status != POWER_SUPPLY_STATUS_FULL))
		/* USB is present, but not charging */
		return false;

	return true;
}