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

Commit c665d840 authored by Fenglin Wu's avatar Fenglin Wu
Browse files

qcom-charger: Add ship mode support



Add POWER_SUPPLY_PROP_SET_SHIP_MODE property to set ship mode. In
ship-mode, the bat-fet is opened and battery is completely disconnected
from the system.

CRs-Fixed: 1092969
Change-Id: Idc50342df8600f482a16f9a2f3a97773c3487eb8
Signed-off-by: default avatarFenglin Wu <fenglinw@codeaurora.org>
parent 2a167923
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -666,6 +666,7 @@ static enum power_supply_property smb2_batt_props[] = {
	POWER_SUPPLY_PROP_CHARGE_DONE,
	POWER_SUPPLY_PROP_PARALLEL_DISABLE,
	POWER_SUPPLY_PROP_PARALLEL_PERCENT,
	POWER_SUPPLY_PROP_SET_SHIP_MODE,
};

static int smb2_batt_get_prop(struct power_supply *psy,
@@ -741,6 +742,10 @@ static int smb2_batt_get_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_PARALLEL_PERCENT:
		val->intval = chg->pl.slave_pct;
		break;
	case POWER_SUPPLY_PROP_SET_SHIP_MODE:
		/* Not in ship mode as long as device is active */
		val->intval = 0;
		break;
	default:
		pr_err("batt power supply prop %d not supported\n", psp);
		return -EINVAL;
@@ -786,6 +791,12 @@ static int smb2_batt_set_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
		vote(chg->fcc_max_votable, DEFAULT_VOTER, true, val->intval);
		break;
	case POWER_SUPPLY_PROP_SET_SHIP_MODE:
		/* Not in ship mode as long as the device is active */
		if (!val->intval)
			break;
		rc = smblib_set_prop_ship_mode(chg, val);
		break;
	default:
		rc = -EINVAL;
	}
+19 −0
Original line number Diff line number Diff line
@@ -39,6 +39,9 @@

static bool is_secure(struct smb_charger *chg, int addr)
{

	if (addr == SHIP_MODE_REG)
		return true;
	/* assume everything above 0xA0 is secure */
	return (bool)((addr & 0xFF) >= 0xA0);
}
@@ -2084,6 +2087,22 @@ int smblib_set_prop_pd_active(struct smb_charger *chg,
	return rc;
}

int smblib_set_prop_ship_mode(struct smb_charger *chg,
				const union power_supply_propval *val)
{
	int rc;

	smblib_dbg(chg, PR_MISC, "Set ship mode: %d!!\n", !!val->intval);

	rc = smblib_masked_write(chg, SHIP_MODE_REG, SHIP_MODE_EN_BIT,
			!!val->intval ? SHIP_MODE_EN_BIT : 0);
	if (rc < 0)
		dev_err(chg->dev, "Couldn't %s ship mode, rc=%d\n",
				!!val->intval ? "enable" : "disable", rc);

	return rc;
}

int smblib_reg_block_update(struct smb_charger *chg,
				struct reg_info *entry)
{
+2 −1
Original line number Diff line number Diff line
@@ -352,9 +352,10 @@ int smblib_set_prop_pd_active(struct smb_charger *chg,
				const union power_supply_propval *val);
int smblib_set_prop_pd_in_hard_reset(struct smb_charger *chg,
				const union power_supply_propval *val);

int smblib_get_prop_slave_current_now(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_set_prop_ship_mode(struct smb_charger *chg,
				const union power_supply_propval *val);

int smblib_validate_initial_typec_legacy_status(struct smb_charger *chg);