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

Commit 3d4cd6cd authored by hecaiqiang's avatar hecaiqiang
Browse files

Synchronize codes for Oneplus 7 Pro Oxygen OS 9.5.11.GM21AA

Optimize the connector protect logic

Change-Id: Ie1b046ca9aee2bd4becbc992787c33fbb19c6e16
parent 475370f9
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -271,6 +271,15 @@ module_param_call(lpd_enable, lpd_enable_set, param_get_int,
			&__lpd_enable, 0644);
MODULE_PARM_DESC(lpd_enable, "Enable lpd trigger control by user");

static int __usb_connector_temp;
module_param_named(
	usb_connector_temp, __usb_connector_temp, int, 0644
);

static int __disable_connector_protect;
module_param_named(
	disable_connector_protect, __disable_connector_protect, int, 0644
);

#define PMI632_MAX_ICL_UA	3000000
#define PM6150_MAX_FCC_UA	3000000
@@ -3391,6 +3400,8 @@ static int smb5_probe(struct platform_device *pdev)
	chg->weak_chg_icl_ua = &__weak_chg_icl_ua;
	chg->lpd_enable = &__lpd_enable;
	chg->lpd_result = &__lpd_result;
	chg->usb_connector_temp = &__usb_connector_temp;
	chg->disable_connector_protect = &__disable_connector_protect;
	chg->mode = PARALLEL_MASTER;
	chg->irq_info = smb5_irqs;
	chg->die_health = -EINVAL;
+17 −4
Original line number Diff line number Diff line
@@ -4801,6 +4801,8 @@ irqreturn_t usb_plugin_irq_handler(int irq, void *data)
	struct smb_irq_data *irq_data = data;
	struct smb_charger *chg = irq_data->parent_data;

	if (chg->count_run)
		chg->count_run = 0;
	if (chg->pd_hard_reset)
		smblib_usb_plugin_hard_reset_locked(chg);
	else
@@ -5873,6 +5875,7 @@ static void op_get_aicl_work(struct work_struct *work)
#define NORMAL_CHECK_INTERVAL 300 /*ms*/
#define FAST_CHECK_INTERVAL 100 /*ms*/
#define HIGH_TEMP_SHORT_CHECK_TIMEOUT 1500 /*ms*/
#define LOOP_ENTER_TEMP 40

static void op_connect_temp_check_work(struct work_struct *work)
{
@@ -5880,7 +5883,7 @@ static void op_connect_temp_check_work(struct work_struct *work)
	struct smb_charger *chg = container_of(dwork,
				struct smb_charger, connecter_check_work);
	int batt_temp = 0, interval_temp = 0;
	int i;
	int i = 0, loop_enter_temp = 0;

	if (!chg->vbus_present)
		return;
@@ -5889,6 +5892,11 @@ static void op_connect_temp_check_work(struct work_struct *work)
	batt_temp = get_prop_batt_temp(chg)/10;
	interval_temp = chg->connecter_temp - batt_temp;

	if (*chg->usb_connector_temp)
		loop_enter_temp = *chg->usb_connector_temp;
	else
		loop_enter_temp = LOOP_ENTER_TEMP;

	if (!chg->count_run) {/*count run state keep count_total not change*/
		if (chg->connecter_temp >= 45) {
			chg->count_total =
@@ -5947,8 +5955,8 @@ static void op_connect_temp_check_work(struct work_struct *work)
					chg->connecter_temp);
			op_disconnect_vbus(chg, true);
			return;
		} else if (chg->connecter_temp >= 35) {
		/* >= 35 enter*/
		} else if (chg->connecter_temp >= loop_enter_temp) {
		/* >= 40 enter*/
			if (chg->count_run <= chg->count_total) {
			/*time out count*/
				if (chg->count_run == 0)
@@ -5975,7 +5983,7 @@ static void op_connect_temp_check_work(struct work_struct *work)
					smblib_dbg(chg, PR_FAST_DEBUG, "count reset!\n");
				}
			}
		} else {/*<10*/
		} else {/*<40*/
			if (chg->count_run)/* high temp cold down count reset.*/
				chg->count_run = 0;
			smblib_dbg(chg, PR_FAST_DEBUG,
@@ -6224,6 +6232,7 @@ static void op_handle_usb_removal(struct smb_charger *chg)
	chg->re_trigr_dash_done = 0;
	chg->recovery_boost_count = 0;
	chg->ck_unplug_count = 0;
	chg->count_run = 0;
	vote(chg->fcc_votable,
		DEFAULT_VOTER, true, SDP_CURRENT_UA);
	op_battery_temp_region_set(chg, BATT_TEMP_INVALID);
@@ -8104,6 +8113,10 @@ static int get_usb_temp(struct smb_charger *chg)

void op_disconnect_vbus(struct smb_charger *chg, bool enable)
{
	if (*chg->disable_connector_protect) {
		pr_info("disable usb connector protect, return!\n");
		return;
	}
#ifdef	CONFIG_OP_DEBUG_CHG
/* *#806# aging test not need Vbus disconnect feature*/
	return;
+2 −0
Original line number Diff line number Diff line
@@ -351,6 +351,8 @@ struct smb_charger {
	int			*pd_disabled;
	int			*lpd_enable;
	int			*lpd_result;
	int			*usb_connector_temp;
	int			*disable_connector_protect;
	enum smb_mode		mode;
	struct smb_chg_freq	chg_freq;
	int			smb_version;