mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 10:45:22 +00:00
spring: Hard-limit current draw from Toad
The Toad cable is browning out from time to time. Let's limit its current in aggressive mode. Also fix a bug in hard current limit calculation. BUG=None TEST=Plug-in Toad cable and see PWM duty cycle starts higher. BRANCH=Spring Change-Id: I06d64418989aa32a99545986fe841914f054acde Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/59161 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
@@ -278,8 +278,14 @@ static int apple_charger_current(void)
|
||||
|
||||
static int hard_current_limit(int limit)
|
||||
{
|
||||
/*
|
||||
* In aggressive mode, the PWM duty cycle goes lower than the nominal
|
||||
* cycle for PWM_CTRL_OC_MARGIN. Therefore, increase duty cycle by
|
||||
* PWM_CTRL_OC_MARGIN avoids going over the hard limit.
|
||||
* (Note that lower PWM cycle translates to higher current)
|
||||
*/
|
||||
if (current_limit_mode == LIMIT_AGGRESSIVE)
|
||||
return limit - PWM_CTRL_OC_MARGIN;
|
||||
return MIN(limit + PWM_CTRL_OC_MARGIN, 100);
|
||||
else
|
||||
return limit;
|
||||
}
|
||||
@@ -524,6 +530,8 @@ static void usb_update_ilim(int dev_type)
|
||||
current_limit = hard_current_limit(I_LIMIT_1500MA);
|
||||
else if (dev_type & TSU6721_TYPE_JIG_UART_ON)
|
||||
current_limit = hard_current_limit(I_LIMIT_2000MA);
|
||||
else if (dev_type & TOAD_DEVICE_TYPE)
|
||||
current_limit = hard_current_limit(I_LIMIT_500MA);
|
||||
|
||||
pwm_nominal_duty_cycle(current_limit);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user