mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 18:41:11 +00:00
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>
This commit is contained in:
committed by
chrome-bot
parent
96470c4dfb
commit
ececca49aa
@@ -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.
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user