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

Commit 897fcd87 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy Committed by Abhijeet Dharmapurikar
Browse files

qpnp-fg-gen3: notify charger with float voltage and FCC



Whenever the battery profile is loaded, notify charger SW with
float voltage and FCC obtained from the battery profile.

Change-Id: I0419b34fde9d74460b849ee8a7ef7e2cdf5592d2
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 8a09bace
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -1644,6 +1644,37 @@ out:
	return rc;
}

static void fg_notify_charger(struct fg_chip *chip)
{
	union power_supply_propval prop = {0, };
	int rc;

	if (!is_charger_available(chip)) {
		pr_warn("Charger not available yet?\n");
		return;
	}

	prop.intval = chip->bp.float_volt_uv;
	rc = power_supply_set_property(chip->batt_psy,
			POWER_SUPPLY_PROP_VOLTAGE_MAX, &prop);
	if (rc < 0) {
		pr_err("Error in setting voltage_max property on batt_psy, rc=%d\n",
			rc);
		return;
	}

	prop.intval = chip->bp.fastchg_curr_ma;
	rc = power_supply_set_property(chip->batt_psy,
			POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, &prop);
	if (rc < 0) {
		pr_err("Error in setting constant_charge_current_max property on batt_psy, rc=%d\n",
			rc);
		return;
	}

	fg_dbg(chip, FG_STATUS, "Notified charger on float voltage and FCC\n");
}

static void profile_load_work(struct work_struct *work)
{
	struct fg_chip *chip = container_of(work,
@@ -1709,6 +1740,7 @@ done:
				rc);
	}

	fg_notify_charger(chip);
	chip->profile_loaded = true;
	fg_dbg(chip, FG_STATUS, "profile loaded successfully");
out:
@@ -1798,6 +1830,7 @@ static int fg_psy_get_property(struct power_supply *psy,
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
		pval->intval = chip->bp.float_volt_uv;
		break;
	case POWER_SUPPLY_PROP_CYCLE_COUNT:
		pval->intval = fg_get_cycle_count(chip);
		break;