From 87248e7dce9fcd1d7c3e1dd58fc29fac5f74a481 Mon Sep 17 00:00:00 2001 From: Craig Hesling Date: Thu, 12 Mar 2020 11:05:11 -0700 Subject: stm32: Fix manual interrupt clearing function This fixes a bug in gpio_clear_pending_interrupt, where all pending interrupts are unintentionally cleared. This is not in the code path for normal gpio interrupt handlers, since the normal interrupt clearing occurs in gpio_interrupt (right below this function). BRANCH=none BUG=chromium:1059520 TEST=none Signed-off-by: Craig Hesling Change-Id: I4d6fe7947f4d76cf3b57dfbf3bb926e41851c80c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2101208 Reviewed-by: Randall Spangler Reviewed-by: Jett Rink (cherry picked from commit c2c2c083fef813e3e3c70f8c13a1418717ba682d) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2107290 --- chip/stm32/gpio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chip/stm32/gpio.c b/chip/stm32/gpio.c index a8415cce1b..21c7a7ce2e 100644 --- a/chip/stm32/gpio.c +++ b/chip/stm32/gpio.c @@ -127,7 +127,8 @@ int gpio_clear_pending_interrupt(enum gpio_signal signal) if (!g->mask || signal >= GPIO_IH_COUNT) return EC_ERROR_INVAL; - STM32_EXTI_PR |= g->mask; + /* Write 1 to clear interrupt */ + STM32_EXTI_PR = g->mask; return EC_SUCCESS; } @@ -142,6 +143,7 @@ void __keep gpio_interrupt(void) uint32_t pending = STM32_EXTI_PR & 0xFFFF; uint8_t signal; + /* Write 1 to clear interrupt */ STM32_EXTI_PR = pending; while (pending) { -- cgit v1.2.1