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

Unverified Commit 80a36adc authored by zhangxianzhu's avatar zhangxianzhu Committed by Michael Bestas
Browse files

[ALM:11217991] [FP4] charge current is higher than 4A

 &&&%%%comment:[FP4] charge current is higher than 4A
 &&&%%%bug number:11217991
 &&&%%%product name:sm7225_r_fp4
 &&&%%%root cause:Specification
 &&&%%%Bug category:T2M
 &&&%%%Module_Impact:kernel
 &&&%%%Test_Suggestion:test charging
 &&&%%%Solution:charge current is lower than 4A
 &&&%%%Test_Report:test is ok
 &&&%%%VAL Can Test:NO
parent e1bde984
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -287,7 +287,12 @@ static int get_adapter_icl_based_ilim(struct pl_data *chip)
 */
static void cp_configure_ilim(struct pl_data *chip, const char *voter, int ilim)
{
	#if defined(CONFIG_TCT_PM7250_COMMON)
		int rc, fcc;
	#else
		int rc, fcc, target_icl;
	#endif

	union power_supply_propval pval = {0, };

	if (!is_usb_available(chip))
@@ -300,10 +305,11 @@ static void cp_configure_ilim(struct pl_data *chip, const char *voter, int ilim)
	if (cp_get_parallel_mode(chip, PARALLEL_OUTPUT_MODE)
					== POWER_SUPPLY_PL_OUTPUT_VPH)
		return;
#endif


	target_icl = get_adapter_icl_based_ilim(chip);
	ilim = (target_icl > 0) ? min(ilim, target_icl) : ilim;
#endif

	rc = power_supply_get_property(chip->cp_master_psy,
				POWER_SUPPLY_PROP_MIN_ICL, &pval);
@@ -2056,7 +2062,7 @@ static void handle_parallel_in_taper(struct pl_data *chip)
}
#endif

#if !defined(CONFIG_TCT_PM7250_COMMON)
#if 1//!defined(CONFIG_TCT_PM7250_COMMON)
static void handle_usb_change(struct pl_data *chip)
{
	int rc;
@@ -2155,7 +2161,7 @@ static void status_change_work(struct work_struct *work)
	is_parallel_available(chip);
#endif

#if !defined(CONFIG_TCT_PM7250_COMMON)
#if 1//!defined(CONFIG_TCT_PM7250_COMMON)
	handle_usb_change(chip);
#endif

+58 −8
Original line number Diff line number Diff line
@@ -1550,6 +1550,10 @@ static int smb5_usb_main_set_prop(struct power_supply *psy,
	enum power_supply_type real_chg_type = chg->real_charger_type;
	int rc = 0, offset_ua = 0;

#if defined(CONFIG_TCT_PM7250_COMMON)
	int proper_fcc;
#endif

	switch (psp) {
	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
		rc = smblib_set_charge_param(chg, &chg->param.fv, val->intval);
@@ -1560,8 +1564,23 @@ static int smb5_usb_main_set_prop(struct power_supply *psy,
		if (rc < 0)
			offset_ua = 0;

#if defined(CONFIG_TCT_PM7250_COMMON)
		if ((val->intval + offset_ua) > chg->batt_profile_fcc_ua) {
			proper_fcc = chg->batt_profile_fcc_ua;
		} else if ((rc == -ENXIO)
			&& (is_override_vote_enabled_locked(chg->fcc_main_votable))) {
			proper_fcc = get_effective_result_locked(chg->fcc_votable);
		} else {
			proper_fcc = val->intval + offset_ua;
		}
		pr_err("set final main_fcc = %d, %d + %d\n", proper_fcc,
				val->intval, offset_ua);
		rc = smblib_set_charge_param(chg, &chg->param.fcc,
						proper_fcc);
#else
		rc = smblib_set_charge_param(chg, &chg->param.fcc,
						val->intval + offset_ua);
#endif
		break;
	case POWER_SUPPLY_PROP_CURRENT_MAX:
		rc = smblib_set_icl_current(chg, val->intval);
@@ -1606,10 +1625,20 @@ static int smb5_usb_main_set_prop(struct power_supply *psy,
		break;
	case POWER_SUPPLY_PROP_FORCE_MAIN_FCC:
#if defined(CONFIG_TCT_PM7250_COMMON)
		return -EINVAL;
#endif
		if ((val->intval > 0) && (force_fcc >= 0)) {
			pr_err("FORCE_MAIN_FCC: %d -> %d\n", val->intval,
					force_fcc);
			vote_override(chg->fcc_main_votable, CC_MODE_VOTER,
						true, force_fcc);
		} else {
			pr_err("FORCE_MAIN_FCC: %d\n", val->intval);
			vote_override(chg->fcc_main_votable, CC_MODE_VOTER,
				(val->intval < 0) ? false : true, val->intval);
		}
#else
		vote_override(chg->fcc_main_votable, CC_MODE_VOTER,
				(val->intval < 0) ? false : true, val->intval);
#endif
		if (val->intval >= 0)
			chg->chg_param.forced_main_fcc = val->intval;
		/*
@@ -1624,10 +1653,20 @@ static int smb5_usb_main_set_prop(struct power_supply *psy,
		break;
	case POWER_SUPPLY_PROP_FORCE_MAIN_ICL:
#if defined(CONFIG_TCT_PM7250_COMMON)
		return -EINVAL;
#endif
		if ((val->intval > 0) && (force_icl >= 0)) {
			pr_err("FORCE_MAIN_ICL: %d -> %d\n", val->intval,
					force_icl);
			vote_override(chg->usb_icl_votable, CC_MODE_VOTER,
						true, force_icl);
		} else {
			pr_err("FORCE_MAIN_ICL: %d\n", val->intval);
			vote_override(chg->usb_icl_votable, CC_MODE_VOTER,
				(val->intval < 0) ? false : true, val->intval);
		}
#else
		vote_override(chg->usb_icl_votable, CC_MODE_VOTER,
				(val->intval < 0) ? false : true, val->intval);
#endif
		/* Main ICL updated re-calculate ILIM */
		if (real_chg_type == POWER_SUPPLY_TYPE_USB_HVDCP_3 ||
			real_chg_type == POWER_SUPPLY_TYPE_USB_HVDCP_3P5)
@@ -3988,12 +4027,14 @@ static int smb5_probe(struct platform_device *pdev)
		goto cleanup;
	}

#if !defined(CONFIG_TCT_PM7250_COMMON)
	rc = smb5_determine_initial_status(chip);
	if (rc < 0) {
		pr_err("Couldn't determine initial status rc=%d\n",
			rc);
		goto cleanup;
	}
#endif

	rc = smb5_request_interrupts(chip);
	if (rc < 0) {
@@ -4007,10 +4048,6 @@ static int smb5_probe(struct platform_device *pdev)
		goto free_irq;
	}

#if defined(CONFIG_TCT_PM7250_COMMON)
	recheck_unknown_typec(chg);
#endif

	smb5_create_debugfs(chip);

	rc = sysfs_create_groups(&chg->dev->kobj, smb5_groups);
@@ -4027,6 +4064,19 @@ static int smb5_probe(struct platform_device *pdev)

	device_init_wakeup(chg->dev, true);

#if defined(CONFIG_TCT_PM7250_COMMON)
	rc = smb5_determine_initial_status(chip);
	if (rc < 0) {
		pr_err("Couldn't determine initial status rc=%d\n",
			rc);
		goto free_irq;
	}
#endif

#if defined(CONFIG_TCT_PM7250_COMMON)
	recheck_unknown_typec(chg);
#endif

	pr_info("QPNP SMB5 probed successfully\n");

	return rc;
+60 −3
Original line number Diff line number Diff line
@@ -1045,9 +1045,17 @@ static int div2_cp_master_get_prop(struct power_supply *psy,
						chip->div2_cp_disable_votable);
		break;
	case POWER_SUPPLY_PROP_CP_SWITCHER_EN:
#if defined(CONFIG_TCT_PM7250_COMMON)
		rc = smb1398_get_enable_status(chip);
		if (!rc)
			val->intval = chip->switcher_en;
		else
			val->intval = 0;
#else
		rc = smb1398_get_enable_status(chip);
		if (!rc)
			val->intval = chip->switcher_en;
#endif
		break;
	case POWER_SUPPLY_PROP_CP_ISNS:
		rc = smb1398_div2_cp_get_master_isns(chip, &isns_ua);
@@ -1112,6 +1120,10 @@ static int div2_cp_master_get_prop(struct power_supply *psy,
		rc = -EINVAL;
		break;
	}
#if defined(CONFIG_TCT_PM7250_COMMON)
	if (rc < 0)
		rc = -ENODATA;
#endif

	return rc;
}
@@ -1406,16 +1418,29 @@ static int smb1398_div2_cp_ilim_vote_cb(struct votable *votable,

	min_ilim_ua = smb1398_div2_cp_get_min_icl(chip);

#if !defined(CONFIG_TCT_PM7250_COMMON)
	ilim_ua = (ilim_ua * DIV2_ILIM_CFG_PCT) / 100;

	max_ilim_ua = is_cps_available(chip) ?
		DIV2_MAX_ILIM_DUAL_CP_UA : DIV2_MAX_ILIM_UA;
	ilim_ua = min(ilim_ua, max_ilim_ua);
#endif
#if defined(CONFIG_TCT_PM7250_COMMON)
	if (ilim_ua <= min_ilim_ua) {
#else
	if (ilim_ua < min_ilim_ua) {
		dev_dbg(chip->dev, "ilim %duA is too low to config CP charging\n",
#endif
		dev_err(chip->dev, "ilim %duA is too low to config CP charging\n",
				ilim_ua);
		vote(chip->div2_cp_disable_votable, ILIM_VOTER, true, 0);
	} else {
#if defined(CONFIG_TCT_PM7250_COMMON)
		ilim_ua = (ilim_ua * DIV2_ILIM_CFG_PCT) / 100;

		max_ilim_ua = is_cps_available(chip) ?
			DIV2_MAX_ILIM_DUAL_CP_UA : DIV2_MAX_ILIM_UA;
		ilim_ua = min(ilim_ua, max_ilim_ua);

#endif
		if (is_cps_available(chip)) {
			split_ilim = true;
			slave_dis = ilim_ua < (2 * min_ilim_ua);
@@ -1705,9 +1730,13 @@ static void smb1398_status_change_work(struct work_struct *work)
	 * valid due to the battery discharging later, remove
	 * vote from CUTOFF_SOC_VOTER.
	 */
#if defined(CONFIG_TCT_PM7250_COMMON)
	vote(chip->div2_cp_disable_votable, CUTOFF_SOC_VOTER,
				is_cutoff_soc_reached(chip), 0);
#else
	if (!is_cutoff_soc_reached(chip))
		vote(chip->div2_cp_disable_votable, CUTOFF_SOC_VOTER, false, 0);

#endif
	rc = power_supply_get_property(chip->usb_psy,
			POWER_SUPPLY_PROP_PRESENT, &pval);
	if (rc < 0) {
@@ -1827,6 +1856,11 @@ static void smb1398_status_change_work(struct work_struct *work)
			queue_work(system_long_wq, &chip->taper_work);
		}
	}

#if defined(CONFIG_TCT_PM7250_COMMON)
	rerun_election(chip->div2_cp_ilim_votable);
#endif

out:
	pm_relax(chip->dev);
	chip->status_change_running = false;
@@ -1850,7 +1884,12 @@ static int smb1398_notifier_cb(struct notifier_block *nb,
		if (!chip->status_change_running) {
			chip->status_change_running = true;
			pm_stay_awake(chip->dev);

#if defined(CONFIG_TCT_PM7250_COMMON)
			queue_work(private_chg_wq, &chip->status_change_work);
#else
			schedule_work(&chip->status_change_work);
#endif
		}
		spin_unlock_irqrestore(&chip->status_change_lock, flags);
	}
@@ -2052,9 +2091,15 @@ static int smb1398_div2_cp_hw_init(struct smb1398_chip *chip)
		return rc;
	}

#if defined(CONFIG_TCT_PM7250_COMMON)
	/* Configure window (Vin/2 - Vout) UV level to 20mV */
	rc = smb1398_masked_write(chip, NOLOCK_SPARE_REG,
			DIV2_WIN_UV_SEL_BIT, DIV2_WIN_UV_SEL_BIT);
#else
	/* Configure window (Vin/2 - Vout) UV level to 10mV */
	rc = smb1398_masked_write(chip, NOLOCK_SPARE_REG,
			DIV2_WIN_UV_SEL_BIT, 0);
#endif
	if (rc < 0) {
		dev_err(chip->dev, "Couldn't set WIN_UV_10_MV rc=%d\n", rc);
		return rc;
@@ -2718,6 +2763,12 @@ static int smb1398_probe(struct platform_device *pdev)
	struct smb1398_chip *chip;
	int rc = 0;

#if defined(CONFIG_TCT_PM7250_COMMON)
	if (!power_supply_get_by_name("usb")) {
		pr_err("Could not get USB power_supply, deferring smb1398 probe\n");
		return -EPROBE_DEFER;
	}
#endif
	chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
	if (!chip)
		return -ENOMEM;
@@ -2797,6 +2848,12 @@ static int smb1398_resume(struct device *dev)

	chip->in_suspend = false;

#if defined(CONFIG_TCT_PM7250_COMMON)
	if(get_effective_result(chip->div2_cp_disable_votable)) {
		return 0;
	}
#endif

	if (chip->div2_cp_role == DIV2_CP_MASTER) {
		rerun_election(chip->div2_cp_ilim_votable);
		rerun_election(chip->div2_cp_disable_votable);
+59 −6
Original line number Diff line number Diff line
@@ -954,8 +954,13 @@ int smblib_get_qc3_main_icl_offset(struct smb_charger *chg, int *offset_ua)
		return rc;
	}

#if defined(CONFIG_TCT_PM7250_COMMON)
	if (!pval.intval)
		return -ENXIO;
#else
	if (!pval.intval)
		return -EINVAL;
#endif

	rc = power_supply_get_property(chg->cp_psy, POWER_SUPPLY_PROP_CP_ILIM,
					&pval);
@@ -3538,6 +3543,15 @@ int smblib_get_prop_usb_online(struct smb_charger *chg,
		return rc;
	}

#if defined(CONFIG_TCT_PM7250_COMMON)
	rc = smblib_read(chg, USBIN_BASE + INT_RT_STS_OFFSET, &stat);
	if (rc < 0) {
		smblib_err(chg, "Couldn't read USBIN_RT_STS rc=%d\n", rc);
		return rc;
	}
	val->intval = (bool)(stat & USBIN_PLUGIN_RT_STS_BIT);
	return 0;
#else
	rc = smblib_read(chg, POWER_PATH_STATUS_REG, &stat);
	if (rc < 0) {
		smblib_err(chg, "Couldn't read POWER_PATH_STATUS rc=%d\n",
@@ -3550,6 +3564,7 @@ int smblib_get_prop_usb_online(struct smb_charger *chg,
	val->intval = (stat & USE_USBIN_BIT) &&
		      (stat & VALID_INPUT_POWER_SOURCE_STS_BIT);
	return rc;
#endif
}

int smblib_get_usb_online(struct smb_charger *chg,
@@ -3600,9 +3615,6 @@ int smblib_get_prop_usb_voltage_max_design(struct smb_charger *chg,
			val->intval = MICRO_9V;
		else
			val->intval = MICRO_12V;
#if defined(CONFIG_TCT_PM7250_COMMON)
		val->intval = MICRO_9V;
#endif
		break;
	default:
		val->intval = MICRO_5V;
@@ -3632,9 +3644,6 @@ int smblib_get_prop_usb_voltage_max(struct smb_charger *chg,
			val->intval = MICRO_9V;
		else
			val->intval = MICRO_12V;
#if defined(CONFIG_TCT_PM7250_COMMON)
		val->intval = MICRO_9V;
#endif
		break;
	case POWER_SUPPLY_TYPE_USB_PD:
		val->intval = chg->voltage_max_uv;
@@ -4247,11 +4256,22 @@ int smblib_get_prop_input_current_max(struct smb_charger *chg,
	if (rc < 0)
		return rc;

#if defined(CONFIG_TCT_PM7250_COMMON)
	if (((chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP_3)
		|| (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP)
		|| (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_PD)
		|| (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP_3P5))
		&& (icl_ua < HW_ICL_MAX)) {
		val->intval = HW_ICL_MAX;
		return 0;
	}
#else
	if (is_override_vote_enabled_locked(chg->usb_icl_votable) &&
					icl_ua < USBIN_1000MA) {
		val->intval = USBIN_1000MA;
		return 0;
	}
#endif

	return smblib_get_charge_param(chg, &chg->param.icl_stat, &val->intval);
}
@@ -6323,12 +6343,36 @@ static void update_sw_icl_max(struct smb_charger *chg, int pst)
static void smblib_handle_apsd_done(struct smb_charger *chg, bool rising)
{
	const struct apsd_result *apsd_result;
#if defined(CONFIG_TCT_PM7250_COMMON)
	int rc;
	union power_supply_propval val = {0, };
#endif

	if (!rising)
		return;

	apsd_result = smblib_update_usb_type(chg);

#if defined(CONFIG_TCT_PM7250_COMMON)
	if ((chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP)
		|| (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP_3)
		|| (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_HVDCP_3P5)) {
		rc = smblib_get_prop_usb_voltage_now(chg, &val);
		if (rc < 0) {
			smblib_err(chg, "Couldn't read usbin_v, rc=%d\n", rc);
			return;
		}
		if (val.intval >= 11000000) {
			smblib_dbg(chg, PR_MISC, "USBOV: type=%d, v=%duV\n",
					chg->real_charger_type, val.intval);
			chg->qc3p5_detected = false;
			smblib_hvdcp_detect_enable(chg, false);
			smblib_rerun_apsd(chg);
			smblib_run_aicl(chg, RERUN_AICL_BIT);
			return;
		}
	}
#endif
	update_sw_icl_max(chg, apsd_result->pst);

	switch (apsd_result->bit) {
@@ -8181,8 +8225,17 @@ static void smblib_chg_termination_work(struct work_struct *work)
	vote(chg->awake_votable, CHG_TERMINATION_VOTER, true, 0);

	rc = smblib_is_input_present(chg, &input_present);

#if defined(CONFIG_TCT_PM7250_COMMON)
	if ((rc < 0) || !input_present) {
		vote(chg->usb_icl_votable, CHG_TERMINATION_VOTER, false, 0);
		vote(chg->dc_suspend_votable, CHG_TERMINATION_VOTER, false, 0);
		goto out;
	}
#else
	if ((rc < 0) || !input_present)
		goto out;
#endif

	rc = smblib_get_prop_from_bms(chg,
				POWER_SUPPLY_PROP_REAL_CAPACITY, &pval);
+1 −1
Original line number Diff line number Diff line
@@ -651,7 +651,7 @@ static void taper_fcc_step_chg(struct step_chg_info *chip, int index,
#define LIMIT_VBAT_MAX	(4400000)
#define LIMIT_VBAT_MIN	(4300000)
#define LIMIT_VBAT_CV	(4350000)
#define CV_DOWN_DELTA_UA	(100000)
#define CV_DOWN_DELTA_UA	(200000)
#define CV_UP_DELTA_UA		(50000)
#define MIN_FCC_UA		(500000)
#define MAX_FCC_UA		(2000000)