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>
This commit is contained in:
Aseda Aboagye 2020-12-14 15:20:25 -08:00 committed by Commit Bot
parent e0db691a8d
commit b1c2f9ba00
1 changed files with 12 additions and 12 deletions

View File

@ -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, &reg);
@ -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);
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;