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

Commit 7a621d99 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: report main charger's share in its current_max" into msm-4.9

parents 7c167400 eecf558c
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -677,7 +677,7 @@ static int smb2_usb_main_get_prop(struct power_supply *psy,
		rc = smblib_get_prop_fcc_delta(chg, val);
		rc = smblib_get_prop_fcc_delta(chg, val);
		break;
		break;
	case POWER_SUPPLY_PROP_CURRENT_MAX:
	case POWER_SUPPLY_PROP_CURRENT_MAX:
		val->intval = get_effective_result(chg->usb_icl_votable);
		rc = smblib_get_icl_current(chg, &val->intval);
		break;
		break;
	default:
	default:
		pr_debug("get prop %d is not supported in usb-main\n", psp);
		pr_debug("get prop %d is not supported in usb-main\n", psp);
+64 −0
Original line number Original line Diff line number Diff line
@@ -812,6 +812,28 @@ static int set_sdp_current(struct smb_charger *chg, int icl_ua)
	return rc;
	return rc;
}
}


static int get_sdp_current(struct smb_charger *chg, int *icl_ua)
{
	int rc;
	u8 icl_options;
	bool usb3 = false;

	rc = smblib_read(chg, USBIN_ICL_OPTIONS_REG, &icl_options);
	if (rc < 0) {
		smblib_err(chg, "Couldn't get ICL options rc=%d\n", rc);
		return rc;
	}

	usb3 = (icl_options & CFG_USB3P0_SEL_BIT);

	if (icl_options & USB51_MODE_BIT)
		*icl_ua = usb3 ? USBIN_900MA : USBIN_500MA;
	else
		*icl_ua = usb3 ? USBIN_150MA : USBIN_100MA;

	return rc;
}

int smblib_set_icl_current(struct smb_charger *chg, int icl_ua)
int smblib_set_icl_current(struct smb_charger *chg, int icl_ua)
{
{
	int rc = 0;
	int rc = 0;
@@ -889,6 +911,48 @@ int smblib_set_icl_current(struct smb_charger *chg, int icl_ua)
	return rc;
	return rc;
}
}


int smblib_get_icl_current(struct smb_charger *chg, int *icl_ua)
{
	int rc = 0;
	u8 load_cfg;
	bool override;
	union power_supply_propval pval;

	rc = smblib_get_prop_typec_mode(chg, &pval);
	if (rc < 0) {
		smblib_err(chg, "Couldn't get typeC mode rc = %d\n", rc);
		return rc;
	}

	if ((pval.intval == POWER_SUPPLY_TYPEC_SOURCE_DEFAULT
		|| chg->micro_usb_mode)
		&& (chg->usb_psy_desc.type == POWER_SUPPLY_TYPE_USB)) {
		rc = get_sdp_current(chg, icl_ua);
		if (rc < 0) {
			smblib_err(chg, "Couldn't get SDP ICL rc=%d\n", rc);
			return rc;
		}
	} else {
		rc = smblib_read(chg, USBIN_LOAD_CFG_REG, &load_cfg);
		if (rc < 0) {
			smblib_err(chg, "Couldn't get load cfg rc=%d\n", rc);
			return rc;
		}
		override = load_cfg & ICL_OVERRIDE_AFTER_APSD_BIT;
		if (!override)
			return INT_MAX;

		/* override is set */
		rc = smblib_get_charge_param(chg, &chg->param.usb_icl, icl_ua);
		if (rc < 0) {
			smblib_err(chg, "Couldn't get HC ICL rc=%d\n", rc);
			return rc;
		}
	}

	return 0;
}

/*********************
/*********************
 * VOTABLE CALLBACKS *
 * VOTABLE CALLBACKS *
 *********************/
 *********************/
+1 −0
Original line number Original line Diff line number Diff line
@@ -495,6 +495,7 @@ int smblib_icl_override(struct smb_charger *chg, bool override);
int smblib_dp_dm(struct smb_charger *chg, int val);
int smblib_dp_dm(struct smb_charger *chg, int val);
int smblib_rerun_aicl(struct smb_charger *chg);
int smblib_rerun_aicl(struct smb_charger *chg);
int smblib_set_icl_current(struct smb_charger *chg, int icl_ua);
int smblib_set_icl_current(struct smb_charger *chg, int icl_ua);
int smblib_get_icl_current(struct smb_charger *chg, int *icl_ua);
int smblib_get_charge_current(struct smb_charger *chg, int *total_current_ua);
int smblib_get_charge_current(struct smb_charger *chg, int *total_current_ua);


int smblib_init(struct smb_charger *chg);
int smblib_init(struct smb_charger *chg);