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

This commit is contained in:
qctecmdr 2020-07-09 23:56:48 -07:00 committed by Gerrit - the friendly Code Review server
commit 6b31883f23
3 changed files with 41 additions and 3 deletions

View file

@ -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:

View file

@ -440,6 +440,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);
@ -1613,8 +1614,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;
}
@ -2285,7 +2293,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);
@ -2337,6 +2345,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)
@ -2550,6 +2568,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 */

View file

@ -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