diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/charge_manager.c | 19 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 13 |
2 files changed, 29 insertions, 3 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c index a4d9d8dea4..cd59c93007 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -817,6 +817,25 @@ void charge_manager_set_ceil(int port, enum ceil_requestor requestor, int ceil) } } +void charge_manager_force_ceil(int port, int ceil) +{ + ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_COUNT); + + /* + * Force our input current to ceil if we're exceeding it, without + * waiting for our deferred task to run. + */ + if (port == charge_port && ceil < charge_current) + board_set_charge_limit(port, CHARGE_SUPPLIER_PD, + ceil, charge_current_uncapped); + + /* + * Now inform charge_manager so it stays in sync with the state of + * the world. + */ + charge_manager_set_ceil(port, CEIL_REQUESTOR_PD, ceil); +} + /** * Select an 'override port', a port which is always the preferred charge port. * Returns EC_SUCCESS on success, ec_error_list status on failure. diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 4370835fe1..3ea1dbf723 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -659,9 +659,16 @@ static int pd_send_request_msg(int port, int always_send_request) */ return -1; - /* Don't re-request the same voltage */ - if (!always_send_request && pd[port].prev_request_mv == supply_voltage) - return EC_SUCCESS; + if (!always_send_request) { + /* Don't re-request the same voltage */ + if (pd[port].prev_request_mv == supply_voltage) + return EC_SUCCESS; +#ifdef CONFIG_CHARGE_MANAGER + /* Limit current to PD_MIN_MA during transition */ + else + charge_manager_force_ceil(port, PD_MIN_MA); +#endif + } CPRINTF("Req C%d [%d] %dmV %dmA", port, RDO_POS(rdo), supply_voltage, curr_limit); |