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 <shawnn@chromium.org>
Change-Id: Ice2a9963983dca2ee9c0c543bf55c27753c42933
Reviewed-on: https://chromium-review.googlesource.com/584820
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Shawn Nematbakhsh
2017-07-25 09:05:34 -07:00
committed by chrome-bot
parent fb374add5b
commit e302a0d87f

View File

@@ -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 */
}