diff options
author | Randall Spangler <rspangler@chromium.org> | 2013-11-21 15:41:39 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-11-23 05:11:31 +0000 |
commit | 7f3ed512dbb250f946fa62dd2ee5781b170fee48 (patch) | |
tree | cd73c1d5b0ffd3e0bb1a3f3e153e560e02f1bff3 /chip | |
parent | 11aed2342e280376903059588ea378818ddd0179 (diff) | |
download | chrome-ec-7f3ed512dbb250f946fa62dd2ee5781b170fee48.tar.gz |
gpio: Make GPIO_INT_BOTH explicitly RISING|FALLING
For historical reasons on LM4, we defined GPIO_INT_F_BOTH separately
from GPIO_INT_F_RISING and GPIO_INT_F_FALLING. This means that the
code has weird checks like BOTH || (RISING && FALLING), which have
propagated in error-prone ways across the other chips.
Instead, explcitly define BOTH to be RISING|FALLING.
Ideally, we would have called it GPIO_INT_EDGE to match
GPIO_INT_LEVEL, but changing that now would be a big find-replace.
Which might still be a good idea, but that is best done in its own CL.
BUG=chrome-os-partner:24204
BRANCH=none
TEST=build and boot pit, spring, and link; that covers STM32F, STM32L, and LM4.
Change-Id: I23ba05a3f41bb14b09af61dc52a178f710f5c1bb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/177643
Reviewed-by: Jeremy Thorpe <jeremyt@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r-- | chip/host/gpio.c | 6 | ||||
-rw-r--r-- | chip/lm4/gpio.c | 4 | ||||
-rw-r--r-- | chip/stm32/gpio-stm32f.c | 4 | ||||
-rw-r--r-- | chip/stm32/gpio-stm32l.c | 4 |
4 files changed, 9 insertions, 9 deletions
diff --git a/chip/host/gpio.c b/chip/host/gpio.c index 2fcb32b2a8..eda2c456bf 100644 --- a/chip/host/gpio.c +++ b/chip/host/gpio.c @@ -27,11 +27,9 @@ test_mockable int gpio_get_level(enum gpio_signal signal) static int gpio_interrupt_check(uint32_t flags, int old, int new) { - if ((flags & (GPIO_INT_F_RISING|GPIO_INT_F_BOTH)) && - old == 0 && new == 1) + if ((flags & GPIO_INT_F_RISING) && old == 0 && new == 1) return 1; - if ((flags & (GPIO_INT_F_FALLING|GPIO_INT_F_BOTH)) && - old == 1 && new == 0) + if ((flags & GPIO_INT_F_FALLING) && old == 1 && new == 0) return 1; if ((flags & GPIO_INT_F_LOW) && new == 0) return 1; diff --git a/chip/lm4/gpio.c b/chip/lm4/gpio.c index 7bed71bbc6..58d7665f20 100644 --- a/chip/lm4/gpio.c +++ b/chip/lm4/gpio.c @@ -128,7 +128,9 @@ void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags) else LM4_GPIO_IEV(port) &= ~mask; - if (flags & GPIO_INT_F_BOTH) + /* Handle interrupting on both edges */ + if ((flags & GPIO_INT_F_RISING) && + (flags & GPIO_INT_F_FALLING)) LM4_GPIO_IBE(port) |= mask; else LM4_GPIO_IBE(port) &= ~mask; diff --git a/chip/stm32/gpio-stm32f.c b/chip/stm32/gpio-stm32f.c index eba75d48e0..8ab72cc635 100644 --- a/chip/stm32/gpio-stm32f.c +++ b/chip/stm32/gpio-stm32f.c @@ -108,9 +108,9 @@ void gpio_set_flags_by_mask(uint32_t port, uint32_t pmask, uint32_t flags) /* Set up interrupts if necessary */ ASSERT(!(flags & (GPIO_INT_F_LOW | GPIO_INT_F_HIGH))); - if (flags & (GPIO_INT_F_RISING | GPIO_INT_F_BOTH)) + if (flags & GPIO_INT_F_RISING) STM32_EXTI_RTSR |= pmask; - if (flags & (GPIO_INT_F_FALLING | GPIO_INT_F_BOTH)) + if (flags & GPIO_INT_F_FALLING) STM32_EXTI_FTSR |= pmask; /* Interrupt is enabled by gpio_enable_interrupt() */ } diff --git a/chip/stm32/gpio-stm32l.c b/chip/stm32/gpio-stm32l.c index 727c4c1d99..c141a2fd58 100644 --- a/chip/stm32/gpio-stm32l.c +++ b/chip/stm32/gpio-stm32l.c @@ -74,9 +74,9 @@ void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags) /* Set up interrupts if necessary */ ASSERT(!(flags & (GPIO_INT_F_LOW | GPIO_INT_F_HIGH))); - if (flags & (GPIO_INT_F_RISING | GPIO_INT_F_BOTH)) + if (flags & GPIO_INT_F_RISING) STM32_EXTI_RTSR |= mask; - if (flags & (GPIO_INT_F_FALLING | GPIO_INT_F_BOTH)) + if (flags & GPIO_INT_F_FALLING) STM32_EXTI_FTSR |= mask; /* Interrupt is enabled by gpio_enable_interrupt() */ } |