diff options
author | Mike Lee <mike5@huaqin.corp-partner.google.com> | 2021-05-12 11:25:50 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-13 07:58:20 +0000 |
commit | c975b4c6eeff51b3ed9958d59058e2b9cbfc3cb3 (patch) | |
tree | 165d8ac20b87c1d2af784ca36bcfc865cf434a6d | |
parent | 479c52fe81e43ff26b381a1d216e86c3483ba2c4 (diff) | |
download | chrome-ec-c975b4c6eeff51b3ed9958d59058e2b9cbfc3cb3.tar.gz |
raa489000: enable adc function
Enable adc function so that We can quickly get the bus voltage.
and move clear ADC bit after charger_get_vbus_voltage to reduce
power consumption
BUG=b:178981107,b:178728138
BRANCH=dedede
TEST=storo can keep asgate not drop with ac only
TEST=sasukette can keep asgate not drop with AC only
Signed-off-by: Mike Lee <mike5@huaqin.corp-partner.google.com>
Change-Id: I39db6f80a5439dbd890c788981796165abb49415
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2890492
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | driver/tcpm/raa489000.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/driver/tcpm/raa489000.c b/driver/tcpm/raa489000.c index 94c363ad81..42039fc864 100644 --- a/driver/tcpm/raa489000.c +++ b/driver/tcpm/raa489000.c @@ -85,17 +85,20 @@ int raa489000_init(int port) /* * TODO(b:147316511) Since this register can be accessed by multiple * tasks, we should add a mutex when modifying this register. + * + * See(b:178981107,b:178728138) When the battery does not exist, + * we must enable ADC function so that charger_get_vbus_voltage + * can get the correct voltage. */ - if (IS_ENABLED(CONFIG_OCPC) && port == 0) { - i2c_port = tcpc_config[port].i2c_info.port; - rv = i2c_read16(i2c_port, ISL923X_ADDR_FLAGS, - ISL9238_REG_CONTROL3, ®val); - regval |= RAA489000_ENABLE_ADC; - rv |= i2c_write16(i2c_port, ISL923X_ADDR_FLAGS, - ISL9238_REG_CONTROL3, regval); - if (rv) - CPRINTS("c%d: failed to enable ADCs", port); - } + i2c_port = tcpc_config[port].i2c_info.port; + rv = i2c_read16(i2c_port, ISL923X_ADDR_FLAGS, + ISL9238_REG_CONTROL3, ®val); + regval |= RAA489000_ENABLE_ADC; + rv |= i2c_write16(i2c_port, ISL923X_ADDR_FLAGS, + ISL9238_REG_CONTROL3, regval); + if (rv) + CPRINTS("c%d: failed to enable ADCs", port); + /* Enable Vbus detection */ rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_ENABLE_VBUS_DETECT); @@ -111,6 +114,24 @@ int raa489000_init(int port) * works as this part is a combined charger IC and TCPC. */ charger_get_vbus_voltage(port, &vbus_mv); + + /* + * Disable the ADC + * + * See(b:178356507) 9mW is reduced on S0iX power consumption + * by clearing 'Enable ADC' bit. + */ + if (IS_ENABLED(CONFIG_OCPC) && (port != 0)) { + i2c_port = tcpc_config[port].i2c_info.port; + rv = i2c_read16(i2c_port, ISL923X_ADDR_FLAGS, + ISL9238_REG_CONTROL3, ®val); + regval &= ~RAA489000_ENABLE_ADC; + rv |= i2c_write16(i2c_port, ISL923X_ADDR_FLAGS, + ISL9238_REG_CONTROL3, regval); + if (rv) + CPRINTS("c%d: failed to disable ADCs", port); + } + if (vbus_mv && charge_manager_get_active_charge_port() == CHARGE_PORT_NONE && !pd_is_battery_capable()) { |