diff options
author | Eric Yilun Lin <yllin@chromium.org> | 2020-12-30 17:42:13 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-31 07:00:42 +0000 |
commit | 07f44d01967a536eafe58a06858d39fd2344faaa (patch) | |
tree | 63e22455809c7d67dc8f72b74abe19863ea66511 /common/keyboard_mkbp.c | |
parent | c1ef1854e6b3de173837217502bfe1f5f4459f22 (diff) | |
download | chrome-ec-07f44d01967a536eafe58a06858d39fd2344faaa.tar.gz |
keyboard_mkbp: report switches result until init'd
When sysjump, the switch results will be re-evluated, and
if the AP is up, this might report the intermediate switch states
and misalign the switches states between EC and AP.
This CL delay reporting the switches until all the switches are inited.
BUG=b:173962511
TEST=AP boot to OS, sysjump, and system stays at S0
BRANCH=none
Change-Id: Ifce7654ae8f6eb651cf1f7402c8e9e34f1b713f6
Signed-off-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2607206
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'common/keyboard_mkbp.c')
-rw-r--r-- | common/keyboard_mkbp.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/common/keyboard_mkbp.c b/common/keyboard_mkbp.c index 4de8952254..9729331544 100644 --- a/common/keyboard_mkbp.c +++ b/common/keyboard_mkbp.c @@ -70,6 +70,7 @@ static struct mutex fifo_remove_mutex; /* Button and switch state. */ static uint32_t mkbp_button_state; static uint32_t mkbp_switch_state; +static bool mkbp_init_done; #ifndef HAS_TASK_KEYSCAN /* Keys simulated-pressed */ static uint8_t __bss_slow simulated_key[KEYBOARD_COLS_MAX]; @@ -270,8 +271,14 @@ void mkbp_update_switches(uint32_t sw, int state) mkbp_switch_state &= ~BIT(sw); mkbp_switch_state |= (!!state << sw); - mkbp_fifo_add(EC_MKBP_EVENT_SWITCH, - (const uint8_t *)&mkbp_switch_state); + /* + * Only inform AP mkbp changes when all switches initialized, in case + * of the middle states causing the weird behaviour in the AP side, + * especially when sysjumped while AP up. + */ + if (mkbp_init_done) + mkbp_fifo_add(EC_MKBP_EVENT_SWITCH, + (const uint8_t *)&mkbp_switch_state); } #ifdef CONFIG_LID_SWITCH @@ -305,6 +312,15 @@ DECLARE_HOOK(HOOK_BASE_ATTACHED_CHANGE, mkbp_base_attached_change, DECLARE_HOOK(HOOK_INIT, mkbp_base_attached_change, HOOK_PRIO_INIT_LID+1); #endif +static void mkbp_report_switch_on_init(void) +{ + /* All switches initialized, report switch state to AP */ + mkbp_init_done = true; + mkbp_fifo_add(EC_MKBP_EVENT_SWITCH, + (const uint8_t *)&mkbp_switch_state); +} +DECLARE_HOOK(HOOK_INIT, mkbp_report_switch_on_init, HOOK_PRIO_LAST); + void keyboard_update_button(enum keyboard_button_type button, int is_pressed) { switch (button) { |