diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-03-09 09:23:35 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-03-09 00:16:39 -0800 |
commit | 2f7da4a6aec737c589d55a28d15595b5794a33fb (patch) | |
tree | 483e62f900f2e2b0730603d507caecdd55dd1f52 /board/poppy | |
parent | 99cc9435a01f4083a4676aa25fbfb959d02e4688 (diff) | |
download | chrome-ec-2f7da4a6aec737c589d55a28d15595b5794a33fb.tar.gz |
base_detect_lux: Only allow enabling power if base is connected
Since we only enable power to the base in the charger task (we
can't enable power before OTG/power allocation is setup properly),
there is a potential race when we quickly plug/unplug the base.
Fix this by only allowing the enable power when the detection
code knows that the base is actually connected.
BRANCH=none
BUG=b:74403503
TEST=Plug/unplug wand several times with charger attached,
PPVAR_VAR_BASE is always 0 whenever the base is disconnected.
Change-Id: I96da9ed39ddbbbe7aea54ad96c62fde6115538c0
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/956204
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Diffstat (limited to 'board/poppy')
-rw-r--r-- | board/poppy/base_detect_lux.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/board/poppy/base_detect_lux.c b/board/poppy/base_detect_lux.c index a8ae6d18d3..48c4aa8929 100644 --- a/board/poppy/base_detect_lux.c +++ b/board/poppy/base_detect_lux.c @@ -86,10 +86,14 @@ int board_is_base_connected(void) /** * Board-specific routine to enable power distribution between lid and base * (current can flow both ways). + * + * We only allow the base power to be enabled if the detection code knows that + * the base is connected. */ void board_enable_base_power(int enable) { - gpio_set_level(GPIO_PPVAR_VAR_BASE, enable); + gpio_set_level(GPIO_PPVAR_VAR_BASE, + enable && current_base_status == BASE_CONNECTED); } /* @@ -109,6 +113,8 @@ static void base_detect_change(enum base_status status) if (current_base_status == status) return; + current_base_status = status; + /* Enable pull-down if connected. */ gpio_set_level(GPIO_EC_COMM_PD, !connected); /* Disable power to/from base as quickly as possible. */ @@ -122,7 +128,6 @@ static void base_detect_change(enum base_status status) task_wake(TASK_ID_CHARGER); tablet_set_mode(!connected); - current_base_status = status; } static void print_base_detect_value(const char *str, int v) |