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

Commit 988cc1bc authored by Sahil Chandna's avatar Sahil Chandna Committed by Gerrit - the friendly Code Review server
Browse files

power: qpnp-smb5: Disable CP(s) as part of thermal mitigation



Add support to disable the charge pump(s) when the system
health is overheat. Configure ICL of main charger to 500mA
in this condition.

Change-Id: Ied81bd08cbf950fe9cb2ee267eeb75adbbfe6530
Signed-off-by: default avatarSahil Chandna <chandna@codeaurora.org>
parent ff360fb9
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1167,6 +1167,7 @@ static enum power_supply_property smb5_usb_main_props[] = {
	POWER_SUPPLY_PROP_FORCE_MAIN_ICL,
	POWER_SUPPLY_PROP_COMP_CLAMP_LEVEL,
	POWER_SUPPLY_PROP_HEALTH,
	POWER_SUPPLY_PROP_HOT_TEMP,
};

static int smb5_usb_main_get_prop(struct power_supply *psy,
@@ -1230,6 +1231,10 @@ static int smb5_usb_main_get_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_HEALTH:
		val->intval = smblib_get_prop_smb_health(chg);
		break;
	/* Use this property to report overheat status */
	case POWER_SUPPLY_PROP_HOT_TEMP:
		val->intval = chg->thermal_overheat;
		break;
	default:
		pr_debug("get prop %d is not supported in usb-main\n", psp);
		rc = -EINVAL;
@@ -1325,6 +1330,9 @@ static int smb5_usb_main_set_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_COMP_CLAMP_LEVEL:
		rc = smb5_set_prop_comp_clamp_level(chg, val);
		break;
	case POWER_SUPPLY_PROP_HOT_TEMP:
		rc = smblib_set_prop_thermal_overheat(chg, val->intval);
		break;
	default:
		pr_err("set prop %d is not supported\n", psp);
		rc = -EINVAL;
@@ -1345,6 +1353,7 @@ static int smb5_usb_main_prop_is_writeable(struct power_supply *psy,
	case POWER_SUPPLY_PROP_FORCE_MAIN_FCC:
	case POWER_SUPPLY_PROP_FORCE_MAIN_ICL:
	case POWER_SUPPLY_PROP_COMP_CLAMP_LEVEL:
	case POWER_SUPPLY_PROP_HOT_TEMP:
		rc = 1;
		break;
	default:
+30 −0
Original line number Diff line number Diff line
@@ -4674,6 +4674,33 @@ int smblib_get_charge_current(struct smb_charger *chg,
	return 0;
}

#define IADP_OVERHEAT_UA	500000
int smblib_set_prop_thermal_overheat(struct smb_charger *chg,
						int therm_overheat)
{
	int icl_ua = 0;

	if (chg->thermal_overheat == !!therm_overheat)
		return 0;

	/* Configure ICL to 500mA in case system health is Overheat */
	if (therm_overheat)
		icl_ua = IADP_OVERHEAT_UA;

	if (!chg->cp_disable_votable)
		chg->cp_disable_votable = find_votable("CP_DISABLE");

	if (chg->cp_disable_votable) {
		vote(chg->cp_disable_votable, OVERHEAT_LIMIT_VOTER,
							therm_overheat, 0);
		vote(chg->usb_icl_votable, OVERHEAT_LIMIT_VOTER,
							therm_overheat, icl_ua);
	}

	chg->thermal_overheat = !!therm_overheat;
	return 0;
}

/**********************
 * INTERRUPT HANDLERS *
 **********************/
@@ -5683,8 +5710,11 @@ static void typec_src_removal(struct smb_charger *chg)
	/* Reset CC mode votes */
	vote(chg->fcc_main_votable, MAIN_FCC_VOTER, false, 0);
	chg->adapter_cc_mode = 0;
	chg->thermal_overheat = 0;
	vote_override(chg->fcc_votable, CC_MODE_VOTER, false, 0);
	vote_override(chg->usb_icl_votable, CC_MODE_VOTER, false, 0);
	vote(chg->cp_disable_votable, OVERHEAT_LIMIT_VOTER, false, 0);
	vote(chg->usb_icl_votable, OVERHEAT_LIMIT_VOTER, false, 0);

	/* write back the default FLOAT charger configuration */
	rc = smblib_masked_write(chg, USBIN_OPTIONS_2_CFG_REG,
+4 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ enum print_reason {
#define CC_MODE_VOTER			"CC_MODE_VOTER"
#define MAIN_FCC_VOTER			"MAIN_FCC_VOTER"
#define DCIN_AICL_VOTER			"DCIN_AICL_VOTER"
#define OVERHEAT_LIMIT_VOTER		"OVERHEAT_LIMIT_VOTER"

#define BOOST_BACK_STORM_COUNT	3
#define WEAK_CHG_STORM_COUNT	8
@@ -419,6 +420,7 @@ struct smb_charger {

	/* CC Mode */
	int	adapter_cc_mode;
	int	thermal_overheat;

	/* regulators */
	struct smb_regulator	*vbus_vreg;
@@ -740,6 +742,8 @@ int smblib_get_prop_charger_temp(struct smb_charger *chg,
int smblib_get_prop_die_health(struct smb_charger *chg);
int smblib_get_prop_smb_health(struct smb_charger *chg);
int smblib_get_prop_connector_health(struct smb_charger *chg);
int smblib_set_prop_thermal_overheat(struct smb_charger *chg,
			       int therm_overheat);
int smblib_get_skin_temp_status(struct smb_charger *chg);
int smblib_get_prop_vph_voltage_now(struct smb_charger *chg,
				union power_supply_propval *val);