From 0f93e28bc7d3bfe61ba792d31d6a9ed7be43728e Mon Sep 17 00:00:00 2001 From: Diana Z Date: Fri, 24 Jul 2020 11:43:26 -0600 Subject: SM5803: Disable Ibus PROCHOT comparator in init The Ibus PROCHOT comparison should be unnecessary. Additionally, the bit will only set when a charger is plugged in so the current code has inconsistent behavior based on whether a charger is present during EC init. BRANCH=None BUG=b:161214528 TEST=on waddledee, boot both with and without a charger plugged in and note that PROCHOT doesn't set in either case Signed-off-by: Diana Z Change-Id: I63bb22736dac7dbf1c9e7f627319538cbe9bbd81 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2317886 Reviewed-by: Aseda Aboagye Commit-Queue: Aseda Aboagye --- driver/charger/sm5803.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c index 8b9ebb7fcd..6e33e23efb 100644 --- a/driver/charger/sm5803.c +++ b/driver/charger/sm5803.c @@ -99,10 +99,9 @@ static inline enum ec_error_list test_write8(int chgnum, int offset, int value) offset, value); } -static inline enum ec_error_list test_update8(int chgnum, - const int offset, +static inline enum ec_error_list test_update8(int chgnum, const int offset, const uint8_t mask, - const enum mask_update_action action) + const enum mask_update_action action) { return i2c_update8(chg_chips[chgnum].i2c_port, SM5803_ADDR_TEST_FLAGS, offset, mask, action); @@ -385,10 +384,15 @@ static void sm5803_init(int chgnum) rv |= main_write8(chgnum, 0x1F, 0x0); } + /* Disable Ibus PROCHOT comparator */ + rv = chg_read8(chgnum, SM5803_REG_PHOT1, ®); + reg &= ~SM5803_PHOT1_IBUS_PHOT_COMP_EN; + rv |= chg_write8(chgnum, SM5803_REG_PHOT1, reg); + /* Set default input current */ reg = SM5803_CURRENT_TO_REG(CONFIG_CHARGER_INPUT_CURRENT) & SM5803_CHG_ILIM_RAW; - rv = chg_write8(chgnum, SM5803_REG_CHG_ILIM, reg); + rv |= chg_write8(chgnum, SM5803_REG_CHG_ILIM, reg); /* Set Vbus interrupt levels for 3.5V and 4.0V */ rv |= meas_write8(chgnum, SM5803_REG_VBUS_LOW_TH, -- cgit v1.2.1