summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2016-07-08 17:53:38 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-13 19:09:39 -0700
commitb1462bf1f3e3d138a782e4b5afa25afc7403f634 (patch)
tree362e987ebdeaa09c3d6076d78f6fa8487bca931d /driver
parentcd6328496f32b2f6a68e1b042b31cec6ad528d09 (diff)
downloadchrome-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.c16
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)