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

Commit 0feec513 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-qnovo5: Update ok_to_qnovo based on JEITA



Currently, ok_to_qnovo is not updated when the battery enters
JEITA (warm or cool) conditions because of which Qnovo pulse
charging can still happen. Read battery health and update it for
improving Qnovo charging performance.

While at it, add a pr_fmt() so that the log is visible.

Change-Id: I7de241f89f9baff3d83ba23c43732b41a04e0a2b
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent feb00d1a
Loading
Loading
Loading
Loading
+35 −2
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@
 * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt)	"Qnovo: %s: " fmt, __func__

#include <linux/device.h>
#include <linux/module.h>
#include <linux/platform_device.h>
@@ -73,6 +75,7 @@
#define USER_VOTER		"user_voter"
#define SHUTDOWN_VOTER		"user_voter"
#define OK_TO_QNOVO_VOTER	"ok_to_qnovo_voter"
#define HW_OK_TO_QNOVO_VOTER	"HW_OK_TO_QNOVO_VOTER"

#define QNOVO_VOTER		"qnovo_voter"
#define QNOVO_OVERALL_VOTER	"QNOVO_OVERALL_VOTER"
@@ -1126,8 +1129,8 @@ static void status_change_work(struct work_struct *work)
	struct qnovo *chip = container_of(work,
			struct qnovo, status_change_work);
	union power_supply_propval pval;
	bool usb_present = false;
	int rc;
	bool usb_present = false, hw_ok_to_qnovo = false;
	int rc, battery_health, charge_status;

	if (is_usb_available(chip)) {
		rc = power_supply_get_property(chip->usb_psy,
@@ -1159,6 +1162,36 @@ static void status_change_work(struct work_struct *work)
		schedule_delayed_work(&chip->usb_debounce_work,
				msecs_to_jiffies(DEBOUNCE_MS));
	}

	if (!is_batt_available(chip))
		return;

	rc = power_supply_get_property(chip->batt_psy, POWER_SUPPLY_PROP_HEALTH,
					&pval);
	if (rc < 0) {
		pr_err("Error in getting battery health, rc=%d\n", rc);
		return;
	}
	battery_health = pval.intval;

	rc = power_supply_get_property(chip->batt_psy, POWER_SUPPLY_PROP_STATUS,
					&pval);
	if (rc < 0) {
		pr_err("Error in getting charging status, rc=%d\n", rc);
		return;
	}
	charge_status = pval.intval;

	pr_debug("USB present: %d health:%d charge_status: %d\n",
		chip->usb_present, battery_health, charge_status);

	if (chip->usb_present) {
		hw_ok_to_qnovo =
			(battery_health == POWER_SUPPLY_HEALTH_GOOD) &&
			(charge_status == POWER_SUPPLY_STATUS_CHARGING);
		vote(chip->not_ok_to_qnovo_votable, HW_OK_TO_QNOVO_VOTER,
					!hw_ok_to_qnovo, 0);
	}
}

static int qnovo_notifier_call(struct notifier_block *nb,