From e302a0d87fb47f9ec93ccfa771f13f55abd73758 Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Tue, 25 Jul 2017 09:05:34 -0700 Subject: [PATCH] npcx: gpio: Optimize gpio_interrupt_type_sel() for code space reduction gpio_interrupt_type_sel() is guaranteed to be called with at least one GPIO_INT_ANY bit set, but our new toolchain doesn't seem to realize it. BUG=chromium:747553 BRANCH=None TEST=`make BOARD=gru -j` with next_gcc, also verify kevin boots to OS. Signed-off-by: Shawn Nematbakhsh Change-Id: Ice2a9963983dca2ee9c0c543bf55c27753c42933 Reviewed-on: https://chromium-review.googlesource.com/584820 Commit-Ready: Shawn N Tested-by: Shawn N Reviewed-by: Randall Spangler --- chip/npcx/gpio.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/chip/npcx/gpio.c b/chip/npcx/gpio.c index 47bc6bc59a..efc4458ecb 100644 --- a/chip/npcx/gpio.c +++ b/chip/npcx/gpio.c @@ -123,6 +123,8 @@ static void gpio_interrupt_type_sel(enum gpio_signal signal, uint32_t flags) group = gpio_wui_table[signal].group; pmask = 1 << gpio_wui_table[signal].bit; + ASSERT(flags & GPIO_INT_ANY); + /* Handle interrupt for level trigger */ if ((flags & GPIO_INT_F_HIGH) || (flags & GPIO_INT_F_LOW)) { /* Set detection mode to level */ @@ -133,17 +135,9 @@ static void gpio_interrupt_type_sel(enum gpio_signal signal, uint32_t flags) /* Handle interrupting on level low */ else if (flags & GPIO_INT_F_LOW) NPCX_WKEDG(table, group) |= pmask; - - /* Enable wake-up input sources */ - NPCX_WKINEN(table, group) |= pmask; - /* - * Clear pending bit since it might be set - * if WKINEN bit is changed. - */ - NPCX_WKPCL(table, group) |= pmask; } /* Handle interrupt for edge trigger */ - else if ((flags & GPIO_INT_F_RISING) || (flags & GPIO_INT_F_FALLING)) { + else { /* Set detection mode to edge */ NPCX_WKMOD(table, group) &= ~pmask; /* Handle interrupting on both edges */ @@ -164,17 +158,15 @@ static void gpio_interrupt_type_sel(enum gpio_signal signal, uint32_t flags) NPCX_WKAEDG(table, group) &= ~pmask; NPCX_WKEDG(table, group) |= pmask; } + } - /* Enable wake-up input sources */ - NPCX_WKINEN(table, group) |= pmask; - /* - * Clear pending bit since it might be set - * if WKINEN bit is changed. - */ - NPCX_WKPCL(table, group) |= pmask; - } else - /* Disable wake-up input sources */ - NPCX_WKEN(table, group) &= ~pmask; + /* Enable wake-up input sources */ + NPCX_WKINEN(table, group) |= pmask; + /* + * Clear pending bit since it might be set + * if WKINEN bit is changed. + */ + NPCX_WKPCL(table, group) |= pmask; /* No support analog mode */ }