diff options
author | arthur.lin <arthur.lin@lcfc.corp-partner.google.com> | 2021-03-10 20:07:27 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-17 00:46:59 +0000 |
commit | a84d0273bafd46c583b22fc730224040916ac502 (patch) | |
tree | 546fe372a79a61b4be666d638d335d246066f22b | |
parent | c8690c18c3f605523709990ec3a0dcb5549a2b3b (diff) | |
download | chrome-ec-a84d0273bafd46c583b22fc730224040916ac502.tar.gz |
boten: add 500ms debounce for pen detect pin
Add 500ms debounce for pen detect pin,
and new gpio PEN_DET_PCH.
BRANCH=dedede
BUG=b:175083024
TEST=make buildall -j
1. Plug out pen and check system can wake from S3.
Signed-off-by: arthur.lin <arthur.lin@lcfc.corp-partner.google.com>
Change-Id: Ib4b8b8a83cceef5ca77372170ffcad1c4771ab96
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2748207
Reviewed-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Will Lee <wwlee@google.com>
-rw-r--r-- | board/boten/board.c | 22 | ||||
-rw-r--r-- | board/boten/board.h | 1 | ||||
-rw-r--r-- | board/boten/gpio.inc | 2 |
3 files changed, 22 insertions, 3 deletions
diff --git a/board/boten/board.c b/board/boten/board.c index 76b4a25771..7c7ba53814 100644 --- a/board/boten/board.c +++ b/board/boten/board.c @@ -92,11 +92,29 @@ static void c0_ccsbu_ovp_interrupt(enum gpio_signal s) pd_handle_cc_overvoltage(0); } -static void pen_detect_interrupt(enum gpio_signal s) +/** + * Deferred function to handle pen detect change + */ +static void pendetect_deferred(void) { + static int debounced_pen_detect; int pen_detect = !gpio_get_level(GPIO_PEN_DET_ODL); - gpio_set_level(GPIO_EN_PP5000_PEN, pen_detect); + if (pen_detect == debounced_pen_detect) + return; + + debounced_pen_detect = pen_detect; + + gpio_set_level(GPIO_EN_PP5000_PEN, debounced_pen_detect); + gpio_set_level(GPIO_PEN_DET_PCH, !debounced_pen_detect); +} +DECLARE_DEFERRED(pendetect_deferred); + +void pen_detect_interrupt(enum gpio_signal s) +{ + /* Trigger deferred notification of pen detect change */ + hook_call_deferred(&pendetect_deferred_data, + 500 * MSEC); } void board_hibernate(void) diff --git a/board/boten/board.h b/board/boten/board.h index ecd5908c5a..dc3b2cdf99 100644 --- a/board/boten/board.h +++ b/board/boten/board.h @@ -136,6 +136,7 @@ enum battery_type { }; int board_is_sourcing_vbus(int port); +void pen_detect_interrupt(enum gpio_signal s); #endif /* !__ASSEMBLER__ */ diff --git a/board/boten/gpio.inc b/board/boten/gpio.inc index 072c5b08dc..493ef32acb 100644 --- a/board/boten/gpio.inc +++ b/board/boten/gpio.inc @@ -102,6 +102,7 @@ GPIO(CCD_MODE_ODL, PIN(H, 5), GPIO_INPUT) GPIO(EC_BATTERY_PRES_ODL, PIN(I, 4), GPIO_INPUT) GPIO_INT(PEN_DET_ODL, PIN(J, 1), GPIO_INT_BOTH | GPIO_PULL_UP, pen_detect_interrupt) GPIO(EN_PP5000_PEN, PIN(B, 5), GPIO_OUT_LOW) +GPIO(PEN_DET_PCH, PIN(F, 1), GPIO_OUT_LOW) GPIO(EN_KB_BL, PIN(J, 3), GPIO_OUT_LOW) /* Currently unused */ GPIO(ECH1_PACKET_MODE, PIN(H, 1), GPIO_OUT_LOW) @@ -109,7 +110,6 @@ GPIO(ECH1_PACKET_MODE, PIN(H, 1), GPIO_OUT_LOW) GPIO(GPIOC0_NC, PIN(C, 0), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOC3_NC, PIN(C, 3), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOC4_NC, PIN(C, 4), GPIO_INPUT | GPIO_PULL_DOWN) -GPIO(GPIOF1_NC, PIN(F, 1), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOF4_NC, PIN(F, 4), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOF5_NC, PIN(F, 5), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOG3_NC, PIN(G, 3), GPIO_INPUT | GPIO_PULL_DOWN) |