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

Commit 604cfc25 authored by Kavya Nunna's avatar Kavya Nunna
Browse files

power: qpnp-smblite: Add support for torch and charger concurrences



Reduce the ICL value by 300ma for charger and torch concurrences,
to avoid surge on USBIN due to the extra current drawn by torch.

Change-Id: I77936db266f4e5309fcd7827efdfea3c1cced62d
Signed-off-by: default avatarKavya Nunna <knunna@codeaurora.org>
parent 757f1d14
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -585,7 +585,7 @@ static int smblite_usb_main_set_prop(struct power_supply *psy,
{
	struct smblite *chip = power_supply_get_drvdata(psy);
	struct smb_charger *chg = &chip->chg;
	int rc = 0;
	int rc = 0, icl_ua;
	union power_supply_propval pval = {0, };

	switch (psp) {
@@ -612,7 +612,23 @@ static int smblite_usb_main_set_prop(struct power_supply *psy,
				/* vote 100ma when usb is not present*/
				vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER,
							true, USBIN_100UA);
			} else if (chg->flash_active) {
				icl_ua = get_effective_result_locked(
						chg->usb_icl_votable);
				if (icl_ua >= USBIN_400UA) {
					vote(chg->usb_icl_votable,
						FLASH_ACTIVE_VOTER,
						true, icl_ua - USBIN_300UA);
				}
			} else {
				vote(chg->usb_icl_votable, FLASH_ACTIVE_VOTER,
							false, 0);
			}
			pr_debug("flash_active=%d usb_present=%d icl=%d\n",
				chg->flash_active, pval.intval,
				get_effective_result_locked(
				chg->usb_icl_votable));

		}
		break;
	default:
+21 −2
Original line number Diff line number Diff line
@@ -433,6 +433,7 @@ static void smblite_lib_uusb_removal(struct smb_charger *chg)
	vote(chg->pl_enable_votable_indirect, USBIN_V_VOTER, false, 0);
	vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true,
			is_flashlite_active(chg) ? USBIN_500UA : USBIN_100UA);
	vote(chg->usb_icl_votable, FLASH_ACTIVE_VOTER, false, 0);

	/* Remove SW thermal regulation votes */
	vote(chg->usb_icl_votable, SW_THERM_REGULATION_VOTER, false, 0);
@@ -1606,8 +1607,15 @@ int smblite_lib_set_prop_current_max(struct smb_charger *chg,
	}

	/* Update TypeC Rp based current */
	if (chg->connector_type == POWER_SUPPLY_CONNECTOR_TYPEC)
	if (chg->connector_type == POWER_SUPPLY_CONNECTOR_TYPEC) {
		update_sw_icl_max(chg, chg->real_charger_type);
	} else if (is_flashlite_active(chg) && (val->intval >=  USBIN_400UA)) {
		/* For Uusb based SDP port */
		vote(chg->usb_icl_votable, FLASH_ACTIVE_VOTER, true,
				val->intval - USBIN_300UA);
		smblite_lib_dbg(chg, PR_MISC, "flash_active = 1, ICL set to  %d\n",
						val->intval - USBIN_300UA);
	}

	return 0;
}
@@ -2278,7 +2286,7 @@ static void update_sw_icl_max(struct smb_charger *chg,
				enum power_supply_type type)
{
	int typec_mode;
	int rp_ua;
	int rp_ua, icl_ua;

	if (chg->typec_mode == POWER_SUPPLY_TYPEC_SINK_AUDIO_ADAPTER) {
		vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, 500000);
@@ -2330,6 +2338,16 @@ static void update_sw_icl_max(struct smb_charger *chg,
					USBIN_100UA);
		break;
	}

	if (is_flashlite_active(chg)) {
		icl_ua =  get_effective_result(chg->usb_icl_votable);
		if (icl_ua >=  USBIN_400UA) {
			vote(chg->usb_icl_votable, FLASH_ACTIVE_VOTER, true,
				icl_ua - USBIN_300UA);
			smblite_lib_dbg(chg, PR_MISC, "flash_active = 1 ICL is set to %d\n",
						icl_ua - USBIN_300UA);
		}
	}
}

static void typec_sink_insertion(struct smb_charger *chg)
@@ -2543,6 +2561,7 @@ static void typec_src_removal(struct smb_charger *chg)
	/* reset input current limit voters */
	vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true,
			is_flashlite_active(chg) ? USBIN_500UA : USBIN_100UA);
	vote(chg->usb_icl_votable, FLASH_ACTIVE_VOTER, false, 0);
	vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0);

	/* reset parallel voters */
+3 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ enum print_reason {
#define DETACH_DETECT_VOTER		"DETACH_DETECT_VOTER"
#define ICL_CHANGE_VOTER		"ICL_CHANGE_VOTER"
#define TYPEC_SWAP_VOTER		"TYPEC_SWAP_VOTER"
#define FLASH_ACTIVE_VOTER		"FLASH_ACTIVE_VOTER"

#define BOOST_BACK_STORM_COUNT	3
#define WEAK_CHG_STORM_COUNT	8
@@ -60,6 +61,8 @@ enum print_reason {
#define USBIN_25UA	25000
#define USBIN_100UA     100000
#define USBIN_150UA     150000
#define USBIN_300UA     300000
#define USBIN_400UA     400000
#define USBIN_500UA     500000
#define USBIN_900UA     900000
#define CDP_CURRENT_UA			1500000