summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@google.com>2017-02-22 19:40:38 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-02-24 13:32:53 -0800
commitfb8e36631af8395d45d3bef79822c03dd6298ca3 (patch)
treea69281a2d6c334f9d80c2bbafa09852deb4dde89
parent83cf8d0a7a3e952da34740b9a1e255eaa64395af (diff)
downloadchrome-ec-fb8e36631af8395d45d3bef79822c03dd6298ca3.tar.gz
npcx: gpio: Only call ISR for enabled interrupts
The GPIOs on npcx are handled in banks of 8, and when processing an interrupt for a particular bank the ISR is executed for each GPIO in the bank that has a pending bit set. If an interrupt in a bank is not enabled (but has fired before so the pending bit is set) but another one in the same bank is enabled and asserts, then the ISR both of the GPIOs will be executed because they both have pending bits set. This results in the ISR for a disabled interrupt getting executed when it should not and leads to unexpected behavior. Masking the GPIOs that are not enabled means only the ISR for the explicitly enabled GPIOs in that bank will be executed. Example: With the Eve board we have PCH_SLP_SUS_L on GPIO(6,2) which is enabled at init time and is in the same WKINTG_1 bank as TRACKPAD_INT_L on GPIO(7,1) which is not enabled, but I am working on a patch to enable it. When going into suspend PCH_SLP_SUS_L asserts, and that is causing the ISR for both PCH_SLP_SUS_L and TRACKPAD_INT_L to be executed. If I try to use TRACKPAD_INT_L as a wake source from DeepS3 this means the system immediately wakes after going to sleep. BUG=chrome-os-partner:62224 BRANCH=none TEST=With an additional patch to enable trackpad wake from S3 on Eve, observe that the system can enter S3 and stay there instead of immediately waking up due to the TRACKPAD_INT_L ISR firing when it is not enabled. Change-Id: Idc66e22c93756faf6c4319980cfb8dfe63e0dfaa Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/446524 Reviewed-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--chip/npcx/gpio.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/chip/npcx/gpio.c b/chip/npcx/gpio.c
index 1a05074c44..fc5fad8b36 100644
--- a/chip/npcx/gpio.c
+++ b/chip/npcx/gpio.c
@@ -769,6 +769,9 @@ static void gpio_interrupt(int int_no)
/* Get pending mask */
wui_mask = NPCX_WKPND(i, j);
+ /* Get enabled mask */
+ wui_mask &= NPCX_WKEN(i, j);
+
/* If pending bits is not zero */
if (!wui_mask)
continue;