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

Commit 342d6951 authored by Baolin Wang's avatar Baolin Wang Committed by Todd Kjos
Browse files

FROMGIT: power: supply: sc27xx: Add POWER_SUPPLY_PROP_CHARGE_NOW attribute



Add the POWER_SUPPLY_PROP_CHARGE_NOW attribute to allow user to get
current battery capacity (uAh) to do measurement.

bug: 146864653
Signed-off-by: default avatarBaolin Wang <baolin.wang7@gmail.com>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
(cherry picked from commit 1c5dfc5e3f2df5892a849621d729daa87cfef436
https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next)
parent d5835903
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -614,6 +614,17 @@ static int sc27xx_fgu_get_property(struct power_supply *psy,
		val->intval = data->total_cap * 1000;
		break;

	case POWER_SUPPLY_PROP_CHARGE_NOW:
		ret = sc27xx_fgu_get_clbcnt(data, &value);
		if (ret)
			goto error;

		value = DIV_ROUND_CLOSEST(value * 10,
					  36 * SC27XX_FGU_SAMPLE_HZ);
		val->intval = sc27xx_fgu_adc_to_current(data, value);

		break;

	default:
		ret = -EINVAL;
		break;
@@ -682,6 +693,7 @@ static enum power_supply_property sc27xx_fgu_props[] = {
	POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
	POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
	POWER_SUPPLY_PROP_CALIBRATE,
	POWER_SUPPLY_PROP_CHARGE_NOW
};

static const struct power_supply_desc sc27xx_fgu_desc = {