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

Commit edd6b4da authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "qpnp-smb2: make qnovo vote for current and voltage"

parents 83d523c6 38d7ef50
Loading
Loading
Loading
Loading
+1 −28
Original line number Original line Diff line number Diff line
@@ -410,19 +410,6 @@ static int pl_fcc_vote_callback(struct votable *votable, void *data,
	if (!chip->main_psy)
	if (!chip->main_psy)
		return 0;
		return 0;


	if (chip->batt_psy) {
		rc = power_supply_get_property(chip->batt_psy,
			POWER_SUPPLY_PROP_CURRENT_QNOVO,
			&pval);
		if (rc < 0) {
			pr_err("Couldn't get qnovo fcc, rc=%d\n", rc);
			return rc;
		}

		if (pval.intval != -EINVAL)
			total_fcc_ua = pval.intval;
	}

	if (chip->pl_mode == POWER_SUPPLY_PL_NONE
	if (chip->pl_mode == POWER_SUPPLY_PL_NONE
	    || get_effective_result_locked(chip->pl_disable_votable)) {
	    || get_effective_result_locked(chip->pl_disable_votable)) {
		pval.intval = total_fcc_ua;
		pval.intval = total_fcc_ua;
@@ -473,7 +460,6 @@ static int pl_fv_vote_callback(struct votable *votable, void *data,
	struct pl_data *chip = data;
	struct pl_data *chip = data;
	union power_supply_propval pval = {0, };
	union power_supply_propval pval = {0, };
	int rc = 0;
	int rc = 0;
	int effective_fv_uv = fv_uv;


	if (fv_uv < 0)
	if (fv_uv < 0)
		return 0;
		return 0;
@@ -481,20 +467,7 @@ static int pl_fv_vote_callback(struct votable *votable, void *data,
	if (!chip->main_psy)
	if (!chip->main_psy)
		return 0;
		return 0;


	if (chip->batt_psy) {
	pval.intval = fv_uv;
		rc = power_supply_get_property(chip->batt_psy,
			POWER_SUPPLY_PROP_VOLTAGE_QNOVO,
			&pval);
		if (rc < 0) {
			pr_err("Couldn't get qnovo fv, rc=%d\n", rc);
			return rc;
		}

		if (pval.intval != -EINVAL)
			effective_fv_uv = pval.intval;
	}

	pval.intval = effective_fv_uv;


	rc = power_supply_set_property(chip->main_psy,
	rc = power_supply_set_property(chip->main_psy,
			POWER_SUPPLY_PROP_VOLTAGE_MAX, &pval);
			POWER_SUPPLY_PROP_VOLTAGE_MAX, &pval);
+36 −20
Original line number Original line Diff line number Diff line
@@ -238,11 +238,9 @@ static struct smb_params pm660_params = {


#define STEP_CHARGING_MAX_STEPS	5
#define STEP_CHARGING_MAX_STEPS	5
struct smb_dt_props {
struct smb_dt_props {
	int	fcc_ua;
	int	usb_icl_ua;
	int	usb_icl_ua;
	int	dc_icl_ua;
	int	dc_icl_ua;
	int	boost_threshold_ua;
	int	boost_threshold_ua;
	int	fv_uv;
	int	wipower_max_uw;
	int	wipower_max_uw;
	int	min_freq_khz;
	int	min_freq_khz;
	int	max_freq_khz;
	int	max_freq_khz;
@@ -310,14 +308,14 @@ static int smb2_parse_dt(struct smb2 *chip)
						"qcom,external-vconn");
						"qcom,external-vconn");


	rc = of_property_read_u32(node,
	rc = of_property_read_u32(node,
				"qcom,fcc-max-ua", &chip->dt.fcc_ua);
				"qcom,fcc-max-ua", &chg->batt_profile_fcc_ua);
	if (rc < 0)
	if (rc < 0)
		chip->dt.fcc_ua = -EINVAL;
		chg->batt_profile_fcc_ua = -EINVAL;


	rc = of_property_read_u32(node,
	rc = of_property_read_u32(node,
				"qcom,fv-max-uv", &chip->dt.fv_uv);
				"qcom,fv-max-uv", &chg->batt_profile_fv_uv);
	if (rc < 0)
	if (rc < 0)
		chip->dt.fv_uv = -EINVAL;
		chg->batt_profile_fv_uv = -EINVAL;


	rc = of_property_read_u32(node,
	rc = of_property_read_u32(node,
				"qcom,usb-icl-ua", &chip->dt.usb_icl_ua);
				"qcom,usb-icl-ua", &chip->dt.usb_icl_ua);
@@ -942,13 +940,15 @@ static int smb2_batt_get_prop(struct power_supply *psy,
		rc = smblib_get_prop_charge_qnovo_enable(chg, val);
		rc = smblib_get_prop_charge_qnovo_enable(chg, val);
		break;
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_QNOVO:
	case POWER_SUPPLY_PROP_VOLTAGE_QNOVO:
		val->intval = chg->qnovo_fv_uv;
		val->intval = get_client_vote_locked(chg->fv_votable,
				QNOVO_VOTER);
		break;
		break;
	case POWER_SUPPLY_PROP_CURRENT_NOW:
	case POWER_SUPPLY_PROP_CURRENT_NOW:
		rc = smblib_get_prop_batt_current_now(chg, val);
		rc = smblib_get_prop_batt_current_now(chg, val);
		break;
		break;
	case POWER_SUPPLY_PROP_CURRENT_QNOVO:
	case POWER_SUPPLY_PROP_CURRENT_QNOVO:
		val->intval = chg->qnovo_fcc_ua;
		val->intval = get_client_vote_locked(chg->fcc_votable,
				QNOVO_VOTER);
		break;
		break;
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
		val->intval = get_client_vote(chg->fcc_votable,
		val->intval = get_client_vote(chg->fcc_votable,
@@ -1014,23 +1014,37 @@ static int smb2_batt_set_prop(struct power_supply *psy,
		vote(chg->pl_disable_votable, USER_VOTER, (bool)val->intval, 0);
		vote(chg->pl_disable_votable, USER_VOTER, (bool)val->intval, 0);
		break;
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
		vote(chg->fv_votable, DEFAULT_VOTER, true, val->intval);
		chg->batt_profile_fv_uv = val->intval;
		vote(chg->fv_votable, BATT_PROFILE_VOTER, true, val->intval);
		break;
		break;
	case POWER_SUPPLY_PROP_CHARGE_QNOVO_ENABLE:
	case POWER_SUPPLY_PROP_CHARGE_QNOVO_ENABLE:
		rc = smblib_set_prop_charge_qnovo_enable(chg, val);
		rc = smblib_set_prop_charge_qnovo_enable(chg, val);
		break;
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_QNOVO:
	case POWER_SUPPLY_PROP_VOLTAGE_QNOVO:
		chg->qnovo_fv_uv = val->intval;
		if (val->intval == -EINVAL) {
		rc = rerun_election(chg->fv_votable);
			vote(chg->fv_votable, BATT_PROFILE_VOTER,
					true, chg->batt_profile_fv_uv);
			vote(chg->fv_votable, QNOVO_VOTER, false, 0);
		} else {
			vote(chg->fv_votable, QNOVO_VOTER, true, val->intval);
			vote(chg->fv_votable, BATT_PROFILE_VOTER, false, 0);
		}
		break;
		break;
	case POWER_SUPPLY_PROP_CURRENT_QNOVO:
	case POWER_SUPPLY_PROP_CURRENT_QNOVO:
		chg->qnovo_fcc_ua = val->intval;
		vote(chg->pl_disable_votable, PL_QNOVO_VOTER,
		vote(chg->pl_disable_votable, PL_QNOVO_VOTER,
			val->intval != -EINVAL && val->intval < 2000000, 0);
			val->intval != -EINVAL && val->intval < 2000000, 0);
		rc = rerun_election(chg->fcc_votable);
		if (val->intval == -EINVAL) {
			vote(chg->fcc_votable, BATT_PROFILE_VOTER,
					true, chg->batt_profile_fcc_ua);
			vote(chg->fcc_votable, QNOVO_VOTER, false, 0);
		} else {
			vote(chg->fcc_votable, QNOVO_VOTER, true, val->intval);
			vote(chg->fcc_votable, BATT_PROFILE_VOTER, false, 0);
		}
		break;
		break;
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
		vote(chg->fcc_votable, DEFAULT_VOTER, true, val->intval);
		chg->batt_profile_fcc_ua = val->intval;
		vote(chg->fcc_votable, BATT_PROFILE_VOTER, true, val->intval);
		break;
		break;
	case POWER_SUPPLY_PROP_SET_SHIP_MODE:
	case POWER_SUPPLY_PROP_SET_SHIP_MODE:
		/* Not in ship mode as long as the device is active */
		/* Not in ship mode as long as the device is active */
@@ -1447,11 +1461,13 @@ static int smb2_init_hw(struct smb2 *chip)
	if (chip->dt.no_battery)
	if (chip->dt.no_battery)
		chg->fake_capacity = 50;
		chg->fake_capacity = 50;


	if (chip->dt.fcc_ua < 0)
	if (chg->batt_profile_fcc_ua < 0)
		smblib_get_charge_param(chg, &chg->param.fcc, &chip->dt.fcc_ua);
		smblib_get_charge_param(chg, &chg->param.fcc,
				&chg->batt_profile_fcc_ua);


	if (chip->dt.fv_uv < 0)
	if (chg->batt_profile_fv_uv < 0)
		smblib_get_charge_param(chg, &chg->param.fv, &chip->dt.fv_uv);
		smblib_get_charge_param(chg, &chg->param.fv,
				&chg->batt_profile_fv_uv);


	smblib_get_charge_param(chg, &chg->param.usb_icl,
	smblib_get_charge_param(chg, &chg->param.usb_icl,
				&chg->default_icl_ua);
				&chg->default_icl_ua);
@@ -1512,9 +1528,9 @@ static int smb2_init_hw(struct smb2 *chip)
	vote(chg->dc_suspend_votable,
	vote(chg->dc_suspend_votable,
		DEFAULT_VOTER, chip->dt.no_battery, 0);
		DEFAULT_VOTER, chip->dt.no_battery, 0);
	vote(chg->fcc_votable,
	vote(chg->fcc_votable,
		DEFAULT_VOTER, true, chip->dt.fcc_ua);
		BATT_PROFILE_VOTER, true, chg->batt_profile_fcc_ua);
	vote(chg->fv_votable,
	vote(chg->fv_votable,
		DEFAULT_VOTER, true, chip->dt.fv_uv);
		BATT_PROFILE_VOTER, true, chg->batt_profile_fv_uv);
	vote(chg->dc_icl_votable,
	vote(chg->dc_icl_votable,
		DEFAULT_VOTER, true, chip->dt.dc_icl_ua);
		DEFAULT_VOTER, true, chip->dt.dc_icl_ua);
	vote(chg->hvdcp_disable_votable_indirect, PD_INACTIVE_VOTER,
	vote(chg->hvdcp_disable_votable_indirect, PD_INACTIVE_VOTER,
+0 −3
Original line number Original line Diff line number Diff line
@@ -4474,9 +4474,6 @@ int smblib_init(struct smb_charger *chg)


	switch (chg->mode) {
	switch (chg->mode) {
	case PARALLEL_MASTER:
	case PARALLEL_MASTER:
		chg->qnovo_fcc_ua = -EINVAL;
		chg->qnovo_fv_uv = -EINVAL;

		rc = qcom_batt_init();
		rc = qcom_batt_init();
		if (rc < 0) {
		if (rc < 0) {
			smblib_err(chg, "Couldn't init qcom_batt_init rc=%d\n",
			smblib_err(chg, "Couldn't init qcom_batt_init rc=%d\n",
+6 −2
Original line number Original line Diff line number Diff line
@@ -62,6 +62,8 @@ enum print_reason {
#define AICL_RERUN_VOTER		"AICL_RERUN_VOTER"
#define AICL_RERUN_VOTER		"AICL_RERUN_VOTER"
#define LEGACY_UNKNOWN_VOTER		"LEGACY_UNKNOWN_VOTER"
#define LEGACY_UNKNOWN_VOTER		"LEGACY_UNKNOWN_VOTER"
#define CC2_WA_VOTER			"CC2_WA_VOTER"
#define CC2_WA_VOTER			"CC2_WA_VOTER"
#define QNOVO_VOTER			"QNOVO_VOTER"
#define BATT_PROFILE_VOTER		"BATT_PROFILE_VOTER"


#define VCONN_MAX_ATTEMPTS	3
#define VCONN_MAX_ATTEMPTS	3
#define OTG_MAX_ATTEMPTS	3
#define OTG_MAX_ATTEMPTS	3
@@ -325,9 +327,11 @@ struct smb_charger {
	/* extcon for VBUS / ID notification to USB for uUSB */
	/* extcon for VBUS / ID notification to USB for uUSB */
	struct extcon_dev	*extcon;
	struct extcon_dev	*extcon;


	/* battery profile */
	int			batt_profile_fcc_ua;
	int			batt_profile_fv_uv;

	/* qnovo */
	/* qnovo */
	int			qnovo_fcc_ua;
	int			qnovo_fv_uv;
	int			usb_icl_delta_ua;
	int			usb_icl_delta_ua;
	int			pulse_cnt;
	int			pulse_cnt;
};
};