summaryrefslogtreecommitdiff
path: root/chip/mec1322
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@google.com>2017-02-24 18:38:54 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-03-01 16:36:24 -0800
commit6e157818c18e090d43200b6f6dcfbd1082b60df6 (patch)
treef23ef45672eecde5ec8c166aad4908d07ae74510 /chip/mec1322
parent850a227aea334bbb82119cf7811d4a53b72de23e (diff)
downloadchrome-ec-6e157818c18e090d43200b6f6dcfbd1082b60df6.tar.gz
gpio: Add function to clear pending interrupt
Currently if an interrupt is pending before it is enabled the interrupt will fire immediately. In most cases this is fine, but if we want to use the interrupt to trigger something like waking the AP it should be sure that it won't immediately fire once enabled. For example: on the Eve board we have the trackpad interrupt run to the AP and the EC in order to support wake from Deep S3 (magic AP state that only the EC can wake it from). This interrupt is used in S0 by the AP while ignored by the EC, and then enabled on the transition to S3 in order to be able to wake. Since it has been active the interrupt may be pending in the EC (depending on the chip), which can result in the interrupt firing immediately and waking the AP. BUG=chrome-os-partner:62224 BRANCH=none TEST=This has been functionally tested on npcx only as that is what I have a use case and system for, the others compile and look right but have not been directly tested. Change-Id: I9e0877d99e7f09f4c30bf9861fbad81c12c059ad Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/446962 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'chip/mec1322')
-rw-r--r--chip/mec1322/gpio.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/chip/mec1322/gpio.c b/chip/mec1322/gpio.c
index 0d59dc5849..4df46dd6d8 100644
--- a/chip/mec1322/gpio.c
+++ b/chip/mec1322/gpio.c
@@ -173,6 +173,24 @@ int gpio_disable_interrupt(enum gpio_signal signal)
return EC_SUCCESS;
}
+int gpio_clear_pending_interrupt(enum gpio_signal signal)
+{
+ int i, port, girq_id, bit_id;
+
+ if (gpio_list[signal].mask == 0)
+ return EC_SUCCESS;
+
+ i = GPIO_MASK_TO_NUM(gpio_list[signal].mask);
+ port = gpio_list[signal].port;
+ girq_id = int_map[port].girq_id;
+ bit_id = (port - int_map[port].port_offset) * 8 + i;
+
+ /* Clear interrupt source sticky status bit even if not enabled */
+ MEC1322_INT_SOURCE(girq_id) |= 1 << bit_id;
+
+ return EC_SUCCESS;
+}
+
void gpio_pre_init(void)
{
int i;