diff --git a/common/extpower_usb.c b/common/extpower_usb.c index 97034b1eec..5be7d2efc9 100644 --- a/common/extpower_usb.c +++ b/common/extpower_usb.c @@ -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 {