summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/kevin/board.c14
-rw-r--r--common/charge_manager.c10
2 files changed, 22 insertions, 2 deletions
diff --git a/board/kevin/board.c b/board/kevin/board.c
index 2e4060d13d..544dbbf864 100644
--- a/board/kevin/board.c
+++ b/board/kevin/board.c
@@ -183,6 +183,19 @@ uint16_t tcpc_get_alert_status(void)
int board_set_active_charge_port(int charge_port)
{
enum bd99955_charge_port bd99955_port;
+ static int initialized;
+
+ /*
+ * Reject charge port disable if our battery is critical and we
+ * have yet to initialize a charge port - continue to charge using
+ * charger ROM / POR settings.
+ */
+ if (!initialized &&
+ charge_port == CHARGE_PORT_NONE &&
+ charge_get_percent() < 2) {
+ CPRINTS("Battery critical, don't disable charging");
+ return -1;
+ }
CPRINTS("New chg p%d", charge_port);
@@ -198,6 +211,7 @@ int board_set_active_charge_port(int charge_port)
break;
}
+ initialized = 1;
return bd99955_select_input_port(bd99955_port);
}
diff --git a/common/charge_manager.c b/common/charge_manager.c
index 58f87819bd..69bda55a65 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -466,8 +466,14 @@ static void charge_manager_refresh(void)
board_set_active_charge_port(new_port) == EC_SUCCESS)
break;
- /* 'Dont charge' request must be accepted */
- ASSERT(new_port != CHARGE_PORT_NONE);
+ /*
+ * Allow 'Dont charge' request to be rejected only if it
+ * is our initial selection.
+ */
+ if (new_port == CHARGE_PORT_NONE) {
+ ASSERT(!active_charge_port_initialized);
+ return;
+ }
/*
* Zero the available charge on the rejected port so that