mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-05 22:41:44 +00:00
charge_manager: Allow rejected 'Dont charge' request on init
If our battery isn't able to provide enough power to the EC on boot, we should not cut off our input power, regardless of dual role determination or other charging policy. BUG=chrome-os-partner:54058 BRANCH=None TEST=Manual on gru. Drain battery completely, attach USB-C charger, verify that "Battery critical, don't disable charging" is seen on the console and the EC doesn't brown out. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I981f9dbf3d84390550bb696e561f5fa51ffc573a Reviewed-on: https://chromium-review.googlesource.com/351224 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
5cd47907a0
commit
e1eb211f31
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user