charge_manager: Support multiple independent charge ceilings

We will soon have a need to independently set a charge ceiling from both
the PD state machine and from incoming host commands. Store these
ceilings separately, and have the minimum take effect.

BUG=chrome-os-partner:43285
TEST=Pass unit tests. Also, host command current limit takes effect with
subsequent commit.
BRANCH=None

Change-Id: I0ecfe888a7df0d5da5a68999c164c7c841da348b
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/293818
Reviewed-by: Alec Berg <alecaberg@chromium.org>
This commit is contained in:
Shawn Nematbakhsh
2015-08-14 15:28:20 -07:00
committed by ChromeOS Commit Bot
parent aa14b36f18
commit 4d382ad640
5 changed files with 100 additions and 23 deletions

View File

@@ -51,8 +51,21 @@ enum dualrole_capabilities {
/* Called by charging tasks to indicate partner dualrole capability change */
void charge_manager_update_dualrole(int port, enum dualrole_capabilities cap);
/* Update charge ceiling for a given port */
void charge_manager_set_ceil(int port, int ceil);
/*
* Charge ceiling can be set independently by different tasks / functions,
* for different purposes.
*/
enum ceil_requestor {
/* Set by PD task, during negotiation */
CEIL_REQUESTOR_PD,
/* Set by host commands */
CEIL_REQUESTOR_HOST,
/* Number of ceiling groups */
CEIL_REQUESTOR_COUNT,
};
/* Update charge ceiling for a given port / requestor */
void charge_manager_set_ceil(int port, enum ceil_requestor requestor, int ceil);
/* Select an 'override port', which is always the preferred charge port */
int charge_manager_set_override(int port);