diff options
-rw-r--r-- | common/charge_manager.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c index fa015086da..02bcbee5e3 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -440,6 +440,8 @@ static void charge_manager_get_best_charge_port(int *new_port, */ static void charge_manager_refresh(void) { + /* Always initialize charge port on first pass */ + static int active_charge_port_initialized; int new_supplier, new_port; int new_charge_current, new_charge_current_uncapped; int new_charge_voltage, i; @@ -458,9 +460,10 @@ static void charge_manager_refresh(void) * the port, for example, if the port has become a charge * source. */ - if ((new_port == charge_port && - new_supplier == charge_supplier) || - board_set_active_charge_port(new_port) == EC_SUCCESS) + if ((active_charge_port_initialized && + new_port == charge_port && + new_supplier == charge_supplier) || + board_set_active_charge_port(new_port) == EC_SUCCESS) break; /* 'Dont charge' request must be accepted */ @@ -474,6 +477,8 @@ static void charge_manager_refresh(void) available_charge[i][new_port].current = 0; } + active_charge_port_initialized = 1; + /* * Clear override if it wasn't selected as the 'best' port -- it means * that no charge is available on the port, or the port was rejected. |