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

Commit 1fdb5291 authored by Ashay Jaiswal's avatar Ashay Jaiswal
Browse files

power: smb1390-psy: add support to configure minimum ILIM



Add support to configure minimum ILIM supported via device tree,
charging is disabled if request ILIM falls below ILIM configuration.

Change-Id: I6ec5b2827ec585ce884f91b78d6377fc3323294a
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
parent 7e801ca9
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -32,6 +32,12 @@ Charger specific properties:
  Definition: For details about IIO bindings see:
  Definition: For details about IIO bindings see:
	      Documentation/devicetree/bindings/iio/iio-bindings.txt
	      Documentation/devicetree/bindings/iio/iio-bindings.txt


- qcom,min-ilim-ua
  Usage:      optional
  Value type: <u32>
  Definition: Minimum ILIM supported, if requested ILIM goes below this value
	      disable SMB1390. If this values is not specified default minimum
	      ILIM is 1A.
================================================
================================================
Second Level Nodes - SMB1390 Charger Peripherals
Second Level Nodes - SMB1390 Charger Peripherals
================================================
================================================
+11 −4
Original line number Original line Diff line number Diff line
@@ -170,6 +170,7 @@ struct smb1390 {
	int			die_temp;
	int			die_temp;
	bool			suspended;
	bool			suspended;
	u32			debug_mask;
	u32			debug_mask;
	u32			min_ilim_ua;
};
};


struct smb_irq {
struct smb_irq {
@@ -502,8 +503,8 @@ static int smb1390_ilim_vote_cb(struct votable *votable, void *data,
		return rc;
		return rc;
	}
	}


	/* ILIM less than 1A is not accurate; disable charging */
	/* ILIM less than min_ilim_ua, disable charging */
	if (ilim_uA < 1000000) {
	if (ilim_uA < chip->min_ilim_ua) {
		smb1390_dbg(chip, PR_INFO, "ILIM %duA is too low to allow charging\n",
		smb1390_dbg(chip, PR_INFO, "ILIM %duA is too low to allow charging\n",
			ilim_uA);
			ilim_uA);
		vote(chip->disable_votable, ILIM_VOTER, true, 0);
		vote(chip->disable_votable, ILIM_VOTER, true, 0);
@@ -669,7 +670,7 @@ static void smb1390_taper_work(struct work_struct *work)
				fcc_uA);
				fcc_uA);
			vote(chip->fcc_votable, CP_VOTER, true, fcc_uA);
			vote(chip->fcc_votable, CP_VOTER, true, fcc_uA);


			if (fcc_uA < 2000000) {
			if (fcc_uA < (chip->min_ilim_ua * 2)) {
				vote(chip->disable_votable, TAPER_END_VOTER,
				vote(chip->disable_votable, TAPER_END_VOTER,
								true, 0);
								true, 0);
				goto out;
				goto out;
@@ -868,9 +869,15 @@ static int smb1390_parse_dt(struct smb1390 *chip)
			chip->iio.die_temp_chan = NULL;
			chip->iio.die_temp_chan = NULL;
			return rc;
			return rc;
		}
		}
	} else {
		return rc;
	}
	}


	return rc;
	chip->min_ilim_ua = 1000000; /* 1A */
	of_property_read_u32(chip->dev->of_node, "qcom,min-ilim-ua",
			&chip->min_ilim_ua);

	return 0;
}
}


static void smb1390_release_channels(struct smb1390 *chip)
static void smb1390_release_channels(struct smb1390 *chip)