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

Commit 03662e99 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-smbcharger: add support to read battery id and full charge



Add support to read battery resistance and full charge capacity
from fuel gauge and expose it through battery power supply. This
is needed as the userspace reads battery power supply to get
these parameters.

CRs-Fixed: 1035402
Change-Id: I7facc795cd2b734a38a5ffdacd2a2eab63074744
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 62fc063d
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -1105,6 +1105,33 @@ static int get_prop_batt_current_now(struct smbchg_chip *chip)
	return ua;
}

#define DEFAULT_BATT_RESISTANCE_ID	0
static int get_prop_batt_resistance_id(struct smbchg_chip *chip)
{
	int rbatt, rc;

	rc = get_property_from_fg(chip, POWER_SUPPLY_PROP_RESISTANCE_ID,
			&rbatt);
	if (rc) {
		pr_smb(PR_STATUS, "Couldn't get resistance id rc = %d\n", rc);
		rbatt = DEFAULT_BATT_RESISTANCE_ID;
	}
	return rbatt;
}

#define DEFAULT_BATT_FULL_CHG_CAPACITY	0
static int get_prop_batt_full_charge(struct smbchg_chip *chip)
{
	int bfc, rc;

	rc = get_property_from_fg(chip, POWER_SUPPLY_PROP_CHARGE_FULL, &bfc);
	if (rc) {
		pr_smb(PR_STATUS, "Couldn't get charge_full rc = %d\n", rc);
		bfc = DEFAULT_BATT_FULL_CHG_CAPACITY;
	}
	return bfc;
}

#define DEFAULT_BATT_VOLTAGE_NOW	0
static int get_prop_batt_voltage_now(struct smbchg_chip *chip)
{
@@ -5751,6 +5778,8 @@ static enum power_supply_property smbchg_battery_properties[] = {
	POWER_SUPPLY_PROP_CURRENT_NOW,
	POWER_SUPPLY_PROP_TEMP,
	POWER_SUPPLY_PROP_VOLTAGE_NOW,
	POWER_SUPPLY_PROP_RESISTANCE_ID,
	POWER_SUPPLY_PROP_CHARGE_FULL,
	POWER_SUPPLY_PROP_SAFETY_TIMER_ENABLE,
	POWER_SUPPLY_PROP_INPUT_CURRENT_MAX,
	POWER_SUPPLY_PROP_INPUT_CURRENT_SETTLED,
@@ -5939,6 +5968,12 @@ static int smbchg_battery_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
		val->intval = get_prop_batt_voltage_now(chip);
		break;
	case POWER_SUPPLY_PROP_RESISTANCE_ID:
		val->intval = get_prop_batt_resistance_id(chip);
		break;
	case POWER_SUPPLY_PROP_CHARGE_FULL:
		val->intval = get_prop_batt_full_charge(chip);
		break;
	case POWER_SUPPLY_PROP_TEMP:
		val->intval = get_prop_batt_temp(chip);
		break;