diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-01-31 16:05:06 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-02-08 06:57:51 -0800 |
commit | ececca49aad9dc928d2dd4d30763477db30cb64e (patch) | |
tree | 70b0aa916c970bc8249e6ddb1917b8f1323e64c0 /board/hammer/board.c | |
parent | 96470c4dfb35e380f87c86f9d809687613cdc01e (diff) | |
download | chrome-ec-ececca49aad9dc928d2dd4d30763477db30cb64e.tar.gz |
whiskers: Disable keyboard/USB interface when magnet sensor active
BRANCH=none
BUG=b:72722179
TEST=lidopen/lidclose, see that USB interface is getting enabled/disabled
TEST=Close/open sensor with a magnet, see that USB interface is getting
enabled/disabled
TEST=Boot with sensor open, USB interface is on
Change-Id: Ic738fa2f2adea03cd29914bb5fc96a1fa6834122
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/894783
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board/hammer/board.c')
-rw-r--r-- | board/hammer/board.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/board/hammer/board.c b/board/hammer/board.c index f1dadcd8f5..a7ccbf5e87 100644 --- a/board/hammer/board.c +++ b/board/hammer/board.c @@ -14,6 +14,7 @@ #include "i2c.h" #include "keyboard_raw.h" #include "keyboard_scan.h" +#include "lid_switch.h" #include "printf.h" #include "pwm.h" #include "pwm_chip.h" @@ -29,6 +30,7 @@ #include "usart-stm32f0.h" #include "usart_tx_dma.h" #include "usart_rx_dma.h" +#include "usb_api.h" #include "usb_descriptor.h" #include "usb_i2c.h" #include "util.h" @@ -240,6 +242,18 @@ void board_touchpad_reset(void) #endif } +#if defined(SECTION_IS_RW) && defined(BOARD_WHISKERS) +static void lid_change(void) +{ + if (lid_is_open()) + usb_connect(); + else + usb_disconnect(); +} +DECLARE_HOOK(HOOK_LID_CHANGE, lid_change, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_INIT, lid_change, HOOK_PRIO_DEFAULT + 1); +#endif + /* * Get entropy based on Clock Recovery System, which is enabled on hammer to * synchronize USB SOF with internal oscillator. |