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

Commit 5309f44c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: qpnp-smbcharger: allow lowering of charger current"

parents 78a2cddd 0cd6c7d9
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -173,6 +173,11 @@ Optional Properties:
					charger if one exists. Do not define
					this property if no parallel chargers
					exist.
- qcom,parallel-allowed-lowering-ma	Acceptable current drop from the initial limit
					to keep parallel charger activated. If the
					charger current reduces beyond this threshold
					parallel charger is disabled. Must be specified
					if parallel charger is used.

Example:
	qcom,qpnp-smbcharger {
+1 −0
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@
			qcom,thermal-mitigation = <1500 700 600 0>;
			qcom,parallel-usb-min-current-ma = <1400>;
			qcom,parallel-9v-usb-min-current-ma = <900>;
			qcom,parallel-allowed-lowering-ma = <500>;
			regulator-name = "pmi8994_otg_vreg";

			qcom,chgr@1000 {
+23 −4
Original line number Diff line number Diff line
@@ -47,9 +47,11 @@ struct parallel_usb_cfg {
	struct power_supply		*psy;
	int				min_current_thr_ma;
	int				min_9v_current_thr_ma;
	int				allowed_lowering_ma;
	int				current_max_ma;
	bool				avail;
	struct mutex			lock;
	int				initial_aicl_ma;
};

struct smbchg_chip {
@@ -1159,7 +1161,7 @@ static bool smbchg_is_parallel_usb_ok(struct smbchg_chip *chip)
		return false;
	}
	if (chip->usb_tl_current_ma < min_current_thr_ma) {
		pr_smb(PR_STATUS, "Too little current to enable: %d < %d\n",
		pr_smb(PR_STATUS, "Weak USB chg skip enable: %d < %d\n",
			chip->usb_tl_current_ma, min_current_thr_ma);
		return false;
	}
@@ -1245,6 +1247,7 @@ static void smbchg_parallel_usb_disable(struct smbchg_chip *chip)
		return;
	pr_smb(PR_STATUS, "disabling parallel charger\n");
	taper_irq_en(chip, false);
	chip->parallel.initial_aicl_ma = 0;
	chip->parallel.current_max_ma = 0;
	power_supply_set_current_limit(parallel_psy,
				SUSPEND_CURRENT_MA * 1000);
@@ -1355,6 +1358,15 @@ static void smbchg_parallel_usb_enable(struct smbchg_chip *chip)
	if (current_limit_ma <= 0)
		goto disable_parallel;

	if (chip->parallel.initial_aicl_ma == 0) {
		if (current_limit_ma < min_current_thr_ma) {
			pr_smb(PR_STATUS, "Initial AICL very low: %d < %d\n",
				current_limit_ma, min_current_thr_ma);
			goto disable_parallel;
		}
		chip->parallel.initial_aicl_ma = current_limit_ma;
	}

	/*
	 * Use the previous set current from the parallel charger.
	 * Treat 2mA as 0 because that is the suspend current setting
@@ -1369,9 +1381,14 @@ static void smbchg_parallel_usb_enable(struct smbchg_chip *chip)
	 */
	total_current_ma = current_limit_ma + parallel_cl_ma;

	if (total_current_ma < min_current_thr_ma) {
		pr_smb(PR_STATUS, "Too little current to enable: %d < %d\n",
				total_current_ma, min_current_thr_ma);
	if (total_current_ma < chip->parallel.initial_aicl_ma
			- chip->parallel.allowed_lowering_ma) {
		pr_smb(PR_STATUS,
			"Too little total current : %d (%d + %d) < %d - %d\n",
			total_current_ma,
			current_limit_ma, parallel_cl_ma,
			chip->parallel.initial_aicl_ma,
			chip->parallel.allowed_lowering_ma);
		goto disable_parallel;
	}

@@ -2932,6 +2949,8 @@ static int smb_parse_dt(struct smbchg_chip *chip)
			"parallel-usb-min-current-ma", rc, 1);
	OF_PROP_READ(chip, chip->parallel.min_9v_current_thr_ma,
			"parallel-usb-9v-min-current-ma", rc, 1);
	OF_PROP_READ(chip, chip->parallel.allowed_lowering_ma,
			"parallel-allowed-lowering-ma", rc, 1);
	if (chip->parallel.min_current_thr_ma != -EINVAL)
		chip->parallel.avail = true;
	pr_smb(PR_STATUS, "parallel usb thr: %d, 9v thr: %d\n",