summaryrefslogtreecommitdiff
path: root/driver/charger/sm5803.c
diff options
context:
space:
mode:
authorDevin Lu <Devin.Lu@quantatw.com>2021-04-14 15:25:42 +0800
committerCommit Bot <commit-bot@chromium.org>2021-04-14 17:49:49 +0000
commit3b24719d7ad5616b4611abdd735dd8a84e7a6b5d (patch)
treed6a6b1a181c5872a320e2ab56ac17fb7102c193e /driver/charger/sm5803.c
parent8bd8010f6d54330fe4b42f8eb532dcb635cbca57 (diff)
downloadchrome-ec-3b24719d7ad5616b4611abdd735dd8a84e7a6b5d.tar.gz
sm5803: Add hysteresis control for TINT
To prevent sm5803 is triggering INT2 continually when temperature near to 330 K. This patch adds hysteresis control for TINT. BUG=b:185209738 BRANCH=firmware-dedede-13606.B-master TEST=i2c analyzer to see INT2 is not trigger continually. Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: Ib83fbc3c84a872bc393084a0c651e14b35efbdcf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2825077 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'driver/charger/sm5803.c')
-rw-r--r--driver/charger/sm5803.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c
index 7c635ddb93..81108e7506 100644
--- a/driver/charger/sm5803.c
+++ b/driver/charger/sm5803.c
@@ -636,11 +636,16 @@ static void sm5803_init(int chgnum)
SM5803_INT4_CHG_DONE |
SM5803_INT4_OTG_FAIL);
- /* Set TINT interrupts for 360 K and 330 K */
+ /* Set TINT interrupts for higher threshold 360 K */
rv |= meas_write8(chgnum, SM5803_REG_TINT_HIGH_TH,
SM5803_TINT_HIGH_LEVEL);
+ /*
+ * Set TINT interrupts for lower threshold to 0 when not
+ * throttled to prevent trigger interrupts continually
+ */
rv |= meas_write8(chgnum, SM5803_REG_TINT_LOW_TH,
- SM5803_TINT_LOW_LEVEL);
+ SM5803_TINT_MIN_LEVEL);
+
/* Configure TINT interrupts to fire after thresholds are set */
rv |= main_write8(chgnum, SM5803_REG_INT2_EN, SM5803_INT2_TINT);
@@ -1032,20 +1037,31 @@ void sm5803_handle_interrupt(int chgnum)
}
if (int_reg & SM5803_INT2_TINT) {
- /*
- * Ignore any interrupts from the low threshold when not
- * throttled in order to prevent console spam when the
- * temperature is holding near the threshold.
- */
rv = meas_read8(chgnum, SM5803_REG_TINT_MEAS_MSB, &meas_reg);
if ((meas_reg <= SM5803_TINT_LOW_LEVEL) && throttled) {
throttled = false;
throttle_ap(THROTTLE_OFF, THROTTLE_HARD,
THROTTLE_SRC_THERMAL);
+ /*
+ * Set back higher threshold to 360 K and set lower
+ * threshold to 0.
+ */
+ rv |= meas_write8(chgnum, SM5803_REG_TINT_LOW_TH,
+ SM5803_TINT_MIN_LEVEL);
+ rv |= meas_write8(chgnum, SM5803_REG_TINT_HIGH_TH,
+ SM5803_TINT_HIGH_LEVEL);
} else if (meas_reg >= SM5803_TINT_HIGH_LEVEL) {
throttled = true;
throttle_ap(THROTTLE_ON, THROTTLE_HARD,
THROTTLE_SRC_THERMAL);
+ /*
+ * Set back lower threshold to 330 K and set higher
+ * threshold to maximum.
+ */
+ rv |= meas_write8(chgnum, SM5803_REG_TINT_HIGH_TH,
+ SM5803_TINT_MAX_LEVEL);
+ rv |= meas_write8(chgnum, SM5803_REG_TINT_LOW_TH,
+ SM5803_TINT_LOW_LEVEL);
}
/*
* If the interrupt came in and we're not currently throttling