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

Commit 589dd42d authored by Harry Yang's avatar Harry Yang
Browse files

qpnp-smb2: Support faking battery full status in WiPower



Support faking battery full status in WiPower charging mode. This is
helpful in testing/debugging WiPower charging cycle.

Change-Id: I4aacbad3b8f0553e55822b80928c9ab244af10ee
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent 089d1cb5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1031,6 +1031,9 @@ static int smb2_batt_set_prop(struct power_supply *psy,
	struct smb_charger *chg = power_supply_get_drvdata(psy);

	switch (prop) {
	case POWER_SUPPLY_PROP_STATUS:
		rc = smblib_set_prop_batt_status(chg, val);
		break;
	case POWER_SUPPLY_PROP_INPUT_SUSPEND:
		rc = smblib_set_prop_input_suspend(chg, val);
		break;
@@ -1108,6 +1111,7 @@ static int smb2_batt_prop_is_writeable(struct power_supply *psy,
		enum power_supply_property psp)
{
	switch (psp) {
	case POWER_SUPPLY_PROP_STATUS:
	case POWER_SUPPLY_PROP_INPUT_SUSPEND:
	case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL:
	case POWER_SUPPLY_PROP_CAPACITY:
+21 −0
Original line number Diff line number Diff line
@@ -1634,6 +1634,12 @@ int smblib_get_prop_batt_status(struct smb_charger *chg,
	if (val->intval != POWER_SUPPLY_STATUS_CHARGING)
		return 0;

	if (!usb_online && dc_online
		&& chg->fake_batt_status == POWER_SUPPLY_STATUS_FULL) {
		val->intval = POWER_SUPPLY_STATUS_FULL;
		return 0;
	}

	rc = smblib_read(chg, BATTERY_CHARGER_STATUS_7_REG, &stat);
	if (rc < 0) {
		smblib_err(chg, "Couldn't read BATTERY_CHARGER_STATUS_2 rc=%d\n",
@@ -1876,6 +1882,20 @@ int smblib_set_prop_batt_capacity(struct smb_charger *chg,
	return 0;
}

int smblib_set_prop_batt_status(struct smb_charger *chg,
				  const union power_supply_propval *val)
{
	/* Faking battery full */
	if (val->intval == POWER_SUPPLY_STATUS_FULL)
		chg->fake_batt_status = val->intval;
	else
		chg->fake_batt_status = -EINVAL;

	power_supply_changed(chg->batt_psy);

	return 0;
}

int smblib_set_prop_system_temp_level(struct smb_charger *chg,
				const union power_supply_propval *val)
{
@@ -4711,6 +4731,7 @@ int smblib_init(struct smb_charger *chg)
	INIT_DELAYED_WORK(&chg->bb_removal_work, smblib_bb_removal_work);
	chg->fake_capacity = -EINVAL;
	chg->fake_input_current_limited = -EINVAL;
	chg->fake_batt_status = -EINVAL;

	switch (chg->mode) {
	case PARALLEL_MASTER:
+3 −0
Original line number Diff line number Diff line
@@ -307,6 +307,7 @@ struct smb_charger {
	int			*thermal_mitigation;
	int			dcp_icl_ua;
	int			fake_capacity;
	int			fake_batt_status;
	bool			step_chg_enabled;
	bool			is_hdc;
	bool			chg_done;
@@ -426,6 +427,8 @@ int smblib_set_prop_input_suspend(struct smb_charger *chg,
				const union power_supply_propval *val);
int smblib_set_prop_batt_capacity(struct smb_charger *chg,
				const union power_supply_propval *val);
int smblib_set_prop_batt_status(struct smb_charger *chg,
				const union power_supply_propval *val);
int smblib_set_prop_system_temp_level(struct smb_charger *chg,
				const union power_supply_propval *val);
int smblib_set_prop_input_current_limited(struct smb_charger *chg,