summaryrefslogtreecommitdiff
path: root/board/hammer
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2018-01-31 16:05:06 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-02-08 06:57:51 -0800
commitececca49aad9dc928d2dd4d30763477db30cb64e (patch)
tree70b0aa916c970bc8249e6ddb1917b8f1323e64c0 /board/hammer
parent96470c4dfb35e380f87c86f9d809687613cdc01e (diff)
downloadchrome-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')
-rw-r--r--board/hammer/board.c14
-rw-r--r--board/hammer/board.h2
-rw-r--r--board/hammer/gpio.inc6
3 files changed, 19 insertions, 3 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.
diff --git a/board/hammer/board.h b/board/hammer/board.h
index 9d824e0c32..f9f5e1bce7 100644
--- a/board/hammer/board.h
+++ b/board/hammer/board.h
@@ -213,6 +213,8 @@
#ifdef BOARD_WHISKERS
#define CONFIG_LED_DRIVER_LM3630A
+#define CONFIG_LID_SWITCH
+#define CONFIG_USB_INHIBIT_CONNECT
#endif
/* Enable Elan touchpad driver */
diff --git a/board/hammer/gpio.inc b/board/hammer/gpio.inc
index f11cb2e2bd..3f720e58b7 100644
--- a/board/hammer/gpio.inc
+++ b/board/hammer/gpio.inc
@@ -10,6 +10,9 @@
#ifdef SECTION_IS_RW
GPIO_INT(TOUCHPAD_INT, PIN(B, 8), GPIO_INT_FALLING, touchpad_interrupt)
+#ifdef BOARD_WHISKERS
+GPIO_INT(LID_OPEN, PIN(B, 11), GPIO_PULL_UP | GPIO_INT_BOTH, lid_interrupt)
+#endif /* BOARD_WHISKERS */
#endif /* SECTION_IS_RW */
/* Keyboard inputs */
@@ -75,9 +78,6 @@ GPIO(EN_OTG, PIN(B, 5), GPIO_INPUT)
#elif defined(BOARD_WHISKERS)
GPIO(DETECT_PATH_DISABLE_L, PIN(A, 8), GPIO_ODR_HIGH)
GPIO(SPI1_NSS, PIN(A, 15), GPIO_OUT_HIGH)
-
-/* TODO(b:68934906): Enable interrupt on this pin */
-GPIO(LID_OPEN, PIN(B, 11), GPIO_INPUT | GPIO_PULL_UP)
#else
GPIO(BASE_DET, PIN(A, 15), GPIO_INPUT)
#endif