diff options
author | Peter Marheine <pmarheine@chromium.org> | 2020-01-23 11:44:17 +1100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-23 13:21:25 +0000 |
commit | a6f7d01bded9658655ef31fefa41e789c48e9079 (patch) | |
tree | 65724c52d6bb96cc78c5283c78c7a7a04d4fcf7e | |
parent | 99f5aac5dd9608b6abab382eeb4ec83df62cf116 (diff) | |
download | chrome-ec-a6f7d01bded9658655ef31fefa41e789c48e9079.tar.gz |
puff: correctly re-init charge ports after sysjump
When the AP does SW sync with the EC, it can make the EC reset (sysjump)
while the AP is on. This would cause us to incorrectly forget what
charge port was active because we didn't allow any changes while the
AP was on, even if the EC didn't have a current state.
Change port selection policy to allow changes while the AP is on,
provided no port is currently selected and the request agrees with the
state of the hardware.
BUG=b:148036160
TEST=chgsup now remains unchanged after sysjump with the AP on, port
changes remain forbidden.
BRANCH=None
Change-Id: Ibf1d4de2298a9a5e631af457d8618cb0accd5e08
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2014561
Reviewed-by: Andrew McRae <amcrae@chromium.org>
-rw-r--r-- | board/puff/board.c | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/board/puff/board.c b/board/puff/board.c index 479e90f7fa..cf38b5d43d 100644 --- a/board/puff/board.c +++ b/board/puff/board.c @@ -166,17 +166,16 @@ static void adp_connect_deferred(void) return; if (connected) { pi.voltage = 19000; - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - /* - * TODO(b:143975429) set current according to SKU. - * Different SKUs will ship with different power bricks - * that have varying power, though setting this to the - * maximum current available on any SKU may be okay - * (assume the included brick is sufficient to run the - * system at max power and over-reporting available - * power will have no effect). - */ - pi.current = 4740; + /* + * TODO(b:143975429) set current according to SKU. + * Different SKUs will ship with different power bricks + * that have varying power, though setting this to the + * maximum current available on any SKU may be okay + * (assume the included brick is sufficient to run the + * system at max power and over-reporting available + * power will have no effect). + */ + pi.current = 4740; } charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED, DEDICATED_CHARGE_PORT, &pi); @@ -482,9 +481,24 @@ int board_set_active_charge_port(int port) if (board_vbus_source_enabled(port)) return EC_ERROR_INVAL; - /* Change is only permitted while the system is off */ - if (!chipset_in_state(CHIPSET_STATE_ANY_OFF)) - return EC_ERROR_INVAL; + if (!chipset_in_state(CHIPSET_STATE_ANY_OFF)) { + int bj_active, bj_requested; + + if (charge_manager_get_active_charge_port() != CHARGE_PORT_NONE) + /* Change is only permitted while the system is off */ + return EC_ERROR_INVAL; + + /* + * Current setting is no charge port but the AP is on, so the + * charge manager is out of sync (probably because we're + * reinitializing after sysjump). Reject requests that aren't + * in sync with our outputs. + */ + bj_active = !gpio_get_level(GPIO_EN_PPVAR_BJ_ADP_L); + bj_requested = port == CHARGE_PORT_BARRELJACK; + if (bj_active != bj_requested) + return EC_ERROR_INVAL; + } CPRINTS("New charger p%d", port); |