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

Commit ef9bf4d1 authored by Xiaozhe Shi's avatar Xiaozhe Shi
Browse files

power: qpnp-charger: make the battery capacity writeable



There are some applications that may want to fake a battery state of
charge (SoC). To standarize this on different devices, make the battery
power supply capacity property writeable.

Change-Id: I75fd301febb994032de8b07c1d58bb38ffdc2c55
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent b5b762bb
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -340,6 +340,7 @@ struct qpnp_chg_chip {
	unsigned int			cold_batt_p;
	int				warm_bat_decidegc;
	int				cool_bat_decidegc;
	int				fake_battery_soc;
	unsigned int			safe_current;
	unsigned int			revision;
	unsigned int			type;
@@ -1692,6 +1693,7 @@ qpnp_batt_property_is_writeable(struct power_supply *psy,
	case POWER_SUPPLY_PROP_VOLTAGE_MIN:
	case POWER_SUPPLY_PROP_COOL_TEMP:
	case POWER_SUPPLY_PROP_WARM_TEMP:
	case POWER_SUPPLY_PROP_CAPACITY:
		return 1;
	default:
		break;
@@ -2047,6 +2049,9 @@ get_prop_capacity(struct qpnp_chg_chip *chip)
	union power_supply_propval ret = {0,};
	int battery_status, bms_status, soc, charger_in;

	if (chip->fake_battery_soc >= 0)
		return chip->fake_battery_soc;

	if (chip->use_default_batt_values || !get_prop_batt_present(chip))
		return DEFAULT_CAPACITY;

@@ -3537,6 +3542,10 @@ qpnp_batt_power_set_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_WARM_TEMP:
		rc = qpnp_chg_configure_jeita(chip, psp, val->intval);
		break;
	case POWER_SUPPLY_PROP_CAPACITY:
		chip->fake_battery_soc = val->intval;
		power_supply_changed(&chip->batt_psy);
		break;
	case POWER_SUPPLY_PROP_CHARGING_ENABLED:
		chip->charging_disabled = !(val->intval);
		if (chip->charging_disabled) {
@@ -4374,6 +4383,7 @@ qpnp_charger_probe(struct spmi_device *spmi)
	}

	chip->prev_usb_max_ma = -EINVAL;
	chip->fake_battery_soc = -EINVAL;
	chip->dev = &(spmi->dev);
	chip->spmi = spmi;