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

Commit 240a6fca authored by Harry Yang's avatar Harry Yang
Browse files

qcom: smb138x: Reduce die temperature samples for initial readings



Die temperature samples 10 times to take average to reduce error,
which extends time in reading and causes delay during boot up, where
the data is not really insterested.

To improve it, only take one sample for the first few user temp
readings.

Change-Id: Ifc10de8a624f1d50d303673ff553d4801337481b
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent c78ba94d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -310,6 +310,7 @@ struct smb_charger {
	u32			wa_flags;
	enum cc2_sink_type	cc2_sink_detach_flag;
	int			boost_current_ua;
	int			temp_speed_reading_count;

	/* extcon for VBUS / ID notification to USB for uUSB */
	struct extcon_dev	*extcon;
+11 −2
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#define STACKED_DIODE_EN_BIT		BIT(2)

#define TDIE_AVG_COUNT	10
#define MAX_SPEED_READING_TIMES		5

enum {
	OOB_COMP_WA_BIT = BIT(0),
@@ -126,8 +127,16 @@ static int smb138x_get_prop_charger_temp(struct smb138x *chip,
	union power_supply_propval pval;
	int rc = 0, avg = 0, i;
	struct smb_charger *chg = &chip->chg;
	int die_avg_count;

	for (i = 0; i < TDIE_AVG_COUNT; i++) {
	if (chg->temp_speed_reading_count < MAX_SPEED_READING_TIMES) {
		chg->temp_speed_reading_count++;
		die_avg_count = 1;
	} else {
		die_avg_count = TDIE_AVG_COUNT;
	}

	for (i = 0; i < die_avg_count; i++) {
		pval.intval = 0;
		rc = smblib_get_prop_charger_temp(chg, &pval);
		if (rc < 0) {
@@ -137,7 +146,7 @@ static int smb138x_get_prop_charger_temp(struct smb138x *chip,
		}
		avg += pval.intval;
	}
	val->intval = avg / TDIE_AVG_COUNT;
	val->intval = avg / die_avg_count;
	return rc;
}