diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-03-09 14:13:49 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-03-09 07:17:50 -0800 |
commit | 49f76d0c863146cce707e724fa79de629b912a65 (patch) | |
tree | 99bd91b8ea6f66d870712cd4c7beb3b3b02b5bab | |
parent | 7d02681c034ef9dd5cc61256b4d91f473a63a510 (diff) | |
download | chrome-ec-49f76d0c863146cce707e724fa79de629b912a65.tar.gz |
isl923x: Round up requested OTG current
Without this patch, requesting 100mA or output current would be
rounded down to zero.
This would also cause other issues when doing base/lid and lid/base
power transfers on lux/wand, as the input current has a much finer
grain control, which could lead the input charger to brown out
the output charger.
BRANCH=none
BUG=b:67920792
TEST=Flash lux/wand, lux can provide as little as 100mA of current
successfully.
Change-Id: Ibf170a6ee3c2dfbdbbc03948c3b0e6ab878eee47
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/956660
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | driver/charger/isl923x.c | 3 | ||||
-rw-r--r-- | include/charger.h | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c index b4fdb04ec5..da2e84255a 100644 --- a/driver/charger/isl923x.c +++ b/driver/charger/isl923x.c @@ -139,7 +139,8 @@ int charger_set_otg_current_voltage(int output_current, int output_voltage) int rv; uint16_t volt_reg = (output_voltage / ISL9238_OTG_VOLTAGE_STEP) << ISL9238_OTG_VOLTAGE_SHIFT; - uint16_t current_reg = (output_current / ISL923X_OTG_CURRENT_STEP) + uint16_t current_reg = + DIV_ROUND_UP(output_current, ISL923X_OTG_CURRENT_STEP) << ISL923X_OTG_CURRENT_SHIFT; if (output_current < 0 || output_current > ISL923X_OTG_CURRENT_MAX || diff --git a/include/charger.h b/include/charger.h index 2ae41e36d3..fcdbc3034e 100644 --- a/include/charger.h +++ b/include/charger.h @@ -79,8 +79,10 @@ int charger_enable_otg_power(int enabled); * to reset the value before enabling OTG power to ensure one does not provide * excessive voltage to a device. * - * @param output_current Requested current limit in mA. - * @param output_voltage Requested voltage in mV. + * @param output_current Requested current limit in mA, driver should + * round the value up. + * @param output_voltage Requested voltage in mV, driver should round the + * the value down. * * @return EC_SUCCESS on success, an error otherwise. */ |