diff options
author | Aseda Aboagye <aaboagye@google.com> | 2020-12-14 15:20:25 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-15 04:24:45 +0000 |
commit | b1c2f9ba00ff0e08be28fc943a6251b0ffc25519 (patch) | |
tree | 25a2f1787cfbc46542a98126bd96ada9d3503b6b /driver/charger/sm5803.c | |
parent | e0db691a8d3cd40ca95ccc8eadf93093af733905 (diff) | |
download | chrome-ec-b1c2f9ba00ff0e08be28fc943a6251b0ffc25519.tar.gz |
sm5803a: Enable IBAT_CHG ADC for all chargers
In order for the charger IC to measure and report battery charge
current, the ADC needs to enabled. Only the primary charger has a
sense resistor for measuring the battery charge current.
This commits simply enables the IBAT_CHG ADC for all charger ICs upon
init. The primary charger needs it for measuring the battery charge
current where the auxiliary chargers need it for calculating system
resistance.
BUG=b:175280922
BRANCH=dedede
TEST=Build and flash drawlat. Plug in charger in C0, issue `charger`
command, verify that battery charge current is shown.
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Change-Id: Id7ec930eb69d09a5d3388c7260d6d4f9515e8546
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2590503
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Auto-Submit: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver/charger/sm5803.c')
-rw-r--r-- | driver/charger/sm5803.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c index dec74093c6..49bfe382e0 100644 --- a/driver/charger/sm5803.c +++ b/driver/charger/sm5803.c @@ -569,8 +569,18 @@ static void sm5803_init(int chgnum) reg &= ~SM5803_CLOCK_SEL_LOW; rv |= main_write8(chgnum, SM5803_REG_CLOCK_SEL, reg); - /* Turn on GPADCs to default */ - rv |= meas_write8(chgnum, SM5803_REG_GPADC_CONFIG1, 0xF3); + /* + * Turn on GPADCs to default. Enable the IBAT_CHG ADC in order to + * measure battery current and calculate system resistance. + */ + reg = SM5803_GPADCC1_TINT_EN | + SM5803_GPADCC1_VSYS_EN | + SM5803_GPADCC1_VCHGPWR_EN | + SM5803_GPADCC1_VBUS_EN | + SM5803_GPADCC1_IBAT_CHG_EN | + SM5803_GPADCC1_IBAT_DIS_EN | + SM5803_GPADCC1_VBATSNSP_EN; + rv |= meas_write8(chgnum, SM5803_REG_GPADC_CONFIG1, reg); /* Enable Psys DAC */ rv |= meas_read8(chgnum, SM5803_REG_PSYS1, ®); @@ -593,16 +603,6 @@ static void sm5803_init(int chgnum) rv = chg_write8(chgnum, SM5803_REG_DPM_VL_SET_MSB, (reg >> 3)); rv |= chg_write8(chgnum, SM5803_REG_DPM_VL_SET_LSB, (reg & 0x7)); - if (chgnum != CHARGER_PRIMARY) { - /* - * Enable the IBAT_CHG adc in order to calculate - * system resistance. - */ - rv |= meas_read8(chgnum, SM5803_REG_GPADC_CONFIG1, ®); - reg |= SM5803_GPADCC1_IBAT_CHG_EN; - rv |= meas_write8(chgnum, SM5803_REG_GPADC_CONFIG1, reg); - } - /* Set default input current */ reg = SM5803_CURRENT_TO_REG(CONFIG_CHARGER_INPUT_CURRENT) & SM5803_CHG_ILIM_RAW; |