samus_pd: Adjust input current limit downward to prevent OC

Based on measurements, Samus can pull more current than desired, even
taking into account the existing INPUT_CURRENT_LIMIT_OFFSET_MA
adjustment. Decrease the programmed current limit by an additional
factor, determined by taking the worst-case power measurements across 15
different Samus devices, to ensure that Samus never pulls more current
than desired.

BUG=chrome-os-partner:55297
BRANCH=samus
TEST=Verify with debug prints that curr_lim_ma becomes 256 when
negotiated current limit is 500mA and curr_lim_ma becomes 2556 when
negotiated limit is 3000mA.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I6912d987c5a519f55a831698873a69c4cac817b8
Reviewed-on: https://chromium-review.googlesource.com/684696
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
Shawn Nematbakhsh
2017-09-25 10:47:57 -07:00
committed by chrome-bot
parent ff148ae240
commit 3fe117d346

View File

@@ -30,9 +30,6 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
/* Amount to offset the input current limit when sending to EC */
#define INPUT_CURRENT_LIMIT_OFFSET_MA 192
/*
* When battery is high, system may not be pulling full current. Also, when
* high AND input voltage is below boost bypass, then limit input current
@@ -484,8 +481,8 @@ static int board_update_charge_limit(int charge_ma)
pwm_set_duty(PWM_CH_ILIM, pwm_duty);
#endif
pd_status.curr_lim_ma = MAX(0, charge_ma -
INPUT_CURRENT_LIMIT_OFFSET_MA);
pd_status.curr_lim_ma = charge_ma >= 500 ?
(charge_ma - 500) * 92 / 100 + 256 : 0;
CPRINTS("New ilim %d", charge_ma);
return 1;