summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/hammer/board.c14
-rw-r--r--board/hammer/board.h2
-rw-r--r--board/hammer/gpio.inc6
-rw-r--r--common/lid_switch.c4
4 files changed, 23 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
diff --git a/common/lid_switch.c b/common/lid_switch.c
index eef4ccb045..2851a53f77 100644
--- a/common/lid_switch.c
+++ b/common/lid_switch.c
@@ -53,7 +53,9 @@ static void lid_switch_open(void)
CPRINTS("lid open");
debounced_lid_open = 1;
hook_notify(HOOK_LID_CHANGE);
+#ifdef CONFIG_HOSTCMD_EVENTS
host_set_single_event(EC_HOST_EVENT_LID_OPEN);
+#endif
}
/**
@@ -69,7 +71,9 @@ static void lid_switch_close(void)
CPRINTS("lid close");
debounced_lid_open = 0;
hook_notify(HOOK_LID_CHANGE);
+#ifdef CONFIG_HOSTCMD_EVENTS
host_set_single_event(EC_HOST_EVENT_LID_CLOSED);
+#endif
}
test_mockable int lid_is_open(void)