summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hendricks <dhendrix@chromium.org>2013-03-08 12:04:43 -0800
committerChromeBot <chrome-bot@google.com>2013-03-08 13:27:22 -0800
commitd4ca1d9c00c93b31dcf786095c3ac3828960990c (patch)
treebffed3f93f657aab889a299a8c997b16dddfd202
parent4ac742b4d511359687a00de1ab6c3ca785f06b0b (diff)
downloadchrome-ec-d4ca1d9c00c93b31dcf786095c3ac3828960990c.tar.gz
stm32: Dynamically generate keyboard IRQ mask
This replaces the hard-coded IRQ mask which has so far worked on Chrome platforms with a variable that gets set in the initialization part of keyboard_scan_task(). A simple loop is used to OR the GPIO mask for each keyboard input provided by the board's gpio_list array. This will make it easier to adapt the code to future targets with different pin mappings. BUG=none BRANCH=none TEST=Tested on Snow Signed-off-by: David Hendricks <dhendrix@chromium.org> Change-Id: I848ab3c7e8d276dbb807a97c6b26c5b3c05af166 Reviewed-on: https://gerrit.chromium.org/gerrit/44952 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--chip/stm32/keyboard_scan.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/chip/stm32/keyboard_scan.c b/chip/stm32/keyboard_scan.c
index 5f74938312..db4263fd91 100644
--- a/chip/stm32/keyboard_scan.c
+++ b/chip/stm32/keyboard_scan.c
@@ -36,10 +36,10 @@ enum COL_INDEX {
#define KB_INPUTS 8
-#define SCAN_TIME_COUNT 32
+/* Mask of external interrupts on input lines */
+static unsigned int irq_mask;
-/* 15:14, 12:8, 2 */
-#define IRQ_MASK 0xdf04
+#define SCAN_TIME_COUNT 32
static struct mutex scanning_enabled;
@@ -228,15 +228,15 @@ void setup_interrupts(void)
pr_before = STM32_EXTI_PR;
select_column(COL_ASSERT_ALL);
pr_after = STM32_EXTI_PR;
- STM32_EXTI_PR |= ((pr_after & ~pr_before) & IRQ_MASK);
+ STM32_EXTI_PR |= ((pr_after & ~pr_before) & irq_mask);
- STM32_EXTI_IMR |= IRQ_MASK; /* 1: unmask interrupt */
+ STM32_EXTI_IMR |= irq_mask; /* 1: unmask interrupt */
}
void enter_polling_mode(void)
{
- STM32_EXTI_IMR &= ~IRQ_MASK; /* 0: mask interrupts */
+ STM32_EXTI_IMR &= ~irq_mask; /* 0: mask interrupts */
select_column(COL_TRI_STATE_ALL);
}
@@ -579,6 +579,14 @@ static void scan_keyboard(void)
}
}
+static void set_irq_mask(void)
+{
+ int i;
+
+ for (i = GPIO_KB_IN00; i < GPIO_KB_IN00 + KB_INPUTS; i++)
+ irq_mask |= gpio_list[i].mask;
+}
+
void keyboard_scan_task(void)
{
/* Enable interrupts for keyboard matrix inputs */
@@ -591,6 +599,9 @@ void keyboard_scan_task(void)
gpio_enable_interrupt(GPIO_KB_IN06);
gpio_enable_interrupt(GPIO_KB_IN07);
+ /* Determine EXTI_PR mask to use for the board */
+ set_irq_mask();
+
print_state(debounced_state, "init state");
while (1) {