diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2016-07-08 17:53:38 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-07-13 19:09:39 -0700 |
commit | b1462bf1f3e3d138a782e4b5afa25afc7403f634 (patch) | |
tree | 362e987ebdeaa09c3d6076d78f6fa8487bca931d /driver | |
parent | cd6328496f32b2f6a68e1b042b31cec6ad528d09 (diff) | |
download | chrome-ec-b1462bf1f3e3d138a782e4b5afa25afc7403f634.tar.gz |
charger: BD99955: Get the VBUS level from the charger
Added code to get the VBUS level by reading the charger registers.
BUG=chrome-os-partner:55117
BRANCH=none
TEST=Manually tested on Amenia, VBUS_VAL (5Ch) & VCC_VAL (5Eh)
registers are updated with the correct VBUS value on the
respective ports.
Change-Id: I3b019b2d87e4c347f12596df387a2a659092ae25
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/359416
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/charger/bd99955.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/driver/charger/bd99955.c b/driver/charger/bd99955.c index 7e76e54be6..21fe69f293 100644 --- a/driver/charger/bd99955.c +++ b/driver/charger/bd99955.c @@ -685,6 +685,22 @@ int charger_discharge_on_ac(int enable) BD99955_EXTENDED_COMMAND); } +int charger_get_vbus_level(void) +{ + int vbus_val; + int vcc_val; + int rv; + + rv = ch_raw_read16(BD99955_CMD_VBUS_VAL, &vbus_val, + BD99955_EXTENDED_COMMAND); + + rv += ch_raw_read16(BD99955_CMD_VCC_VAL, &vcc_val, + BD99955_EXTENDED_COMMAND); + + return rv ? 0 : MAX(vbus_val, vcc_val); +} + + /*** Non-standard interface functions ***/ int bd99955_is_vbus_provided(int port) |