diff options
author | Aseda Aboagye <aaboagye@google.com> | 2016-10-04 10:32:39 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-10-04 21:19:39 -0700 |
commit | 701223cf0950dccb0e10f3e7b4eb419224d1f21a (patch) | |
tree | e0fe4c8138ead8ef569f1447f1f655fe47204d8b /common/i2c.c | |
parent | 03857a3b350717d4b1c12d3aa61b51ea5e4cffcf (diff) | |
download | chrome-ec-701223cf0950dccb0e10f3e7b4eb419224d1f21a.tar.gz |
i2c_passthru: Return NAK when battery not present.
virtual_battery_read() returns a cached value for some of the supported
smart battery parameters. If a value isn't supported, it calls out to
the actual battery. In the case of a battery that's not present, but a
supported battery parameter is queried, we would still return
_something_. This seems to confuse powerd and causes slow boot.
This commit changes the i2c passthru command to return a NAK when the
virtual battery is enabled but the battery is not present.
BUG=chrome-os-partner:55954
BRANCH=gru
TEST=Build and flash kevin. Unplug battery. Verify boot is nice and
quick.
Change-Id: Ib3ab768504c29904f01b91e6194a9689bfdb1e1e
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/392926
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
(cherry picked from commit b5eb2d93820c9e1a162cb1b390b3563bf9effcd5)
Reviewed-on: https://chromium-review.googlesource.com/393187
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/i2c.c')
-rw-r--r-- | common/i2c.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/common/i2c.c b/common/i2c.c index 996ffe3f09..fc6e657a18 100644 --- a/common/i2c.c +++ b/common/i2c.c @@ -599,6 +599,18 @@ static int i2c_command_passthru(struct host_cmd_handler_args *args) #if defined(VIRTUAL_BATTERY_ADDR) && defined(I2C_PORT_VIRTUAL_BATTERY) if (params->port == I2C_PORT_VIRTUAL_BATTERY && VIRTUAL_BATTERY_ADDR == addr) { +#if defined(CONFIG_BATTERY_PRESENT_GPIO) || \ + defined(CONFIG_BATTERY_PRESENT_CUSTOM) + /* + * If the battery isn't present, return a NAK (which we + * would have gotten anyways had we attempted to talk to + * the battery.) + */ + if (battery_is_present() != BP_YES) { + resp->i2c_status = EC_I2C_STATUS_NAK; + break; + } +#endif /* defined(CONFIG_BATTERY_PRESENT_{GPIO/CUSTOM}) */ /* get batt param from write msg */ if (*out) batt_param = *out; |