From b49d5872e9eacae9cee17c9bf011835bc5e3eb45 Mon Sep 17 00:00:00 2001 From: Vijay Hiremath Date: Thu, 31 May 2018 23:13:58 -0700 Subject: [PATCH] bq25703: Report actual input current limit IIN_DPM register reflects the actual input current limit programmed in the register, either from host or from ICO. After ICO, the current limit used by DPM regulation may differ from the IIN_HOST register settings. BUG=b:80279932 BRANCH=none TEST=Manually tested on BIP Used BC1.2 DCP charger 'charger' command yield 900mA while charge ramp set to 2.4A. Change-Id: I6389205bd70d7729e9dd810fef3dfbf83a7d8c65 Signed-off-by: Vijay Hiremath Reviewed-on: https://chromium-review.googlesource.com/1080343 Commit-Ready: Vijay P Hiremath Tested-by: Vijay P Hiremath Reviewed-by: Aseda Aboagye Reviewed-by: Jett Rink --- driver/charger/bq25703.c | 8 +++++++- include/charger.h | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/driver/charger/bq25703.c b/driver/charger/bq25703.c index 0054168a59..55e90ee7e3 100644 --- a/driver/charger/bq25703.c +++ b/driver/charger/bq25703.c @@ -228,7 +228,13 @@ int charger_get_input_current(int *input_current) { int rv, reg; - rv = raw_read8(BQ25703_REG_IIN_HOST, ®); + /* + * IIN_DPM register reflects the actual input current limit programmed + * in the register, either from host or from ICO. After ICO, the + * current limit used by DPM regulation may differ from the IIN_HOST + * register settings. + */ + rv = raw_read8(BQ25703_REG_IIN_DPM, ®); if (!rv) *input_current = REG_TO_INPUT_CURRENT(reg); diff --git a/include/charger.h b/include/charger.h index fcdbc3034e..964c3bf759 100644 --- a/include/charger.h +++ b/include/charger.h @@ -138,8 +138,17 @@ int board_discharge_on_ac(int enable); int charger_get_system_power(void); /* Other parameters that may be charger-specific, but are common so far. */ + +/* Set desired input current value */ int charger_set_input_current(int input_current); + +/* + * Get actual input current value. + * Actual input current may be less than the desired input current set + * due to current ratings of the wall adapter. + */ int charger_get_input_current(int *input_current); + int charger_manufacturer_id(int *id); int charger_device_id(int *id); int charger_get_option(int *option);