diff options
author | Aseda Aboagye <aaboagye@google.com> | 2015-04-08 16:42:55 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-04-10 22:08:25 +0000 |
commit | e9883124ff1600db5788e44c332a403499fb5da6 (patch) | |
tree | 5e5b64b72e89037845cc549e1c4262bf9d224a04 /chip/lm4/gpio.c | |
parent | 0b043fed030129ea99272f1ba729307fafaa93e2 (diff) | |
download | chrome-ec-e9883124ff1600db5788e44c332a403499fb5da6.tar.gz |
gpio: Refactor IRQ handler pointer out of gpio_list
In the gpio_info struct, we had a irq_handler pointer defined even
though a majority of the GPIOs did not have irq handlers associated. By
removing the irq_handler pointer out of the struct, we can save some
space with some targets saving more than others. (For example, ~260
bytes for samus_pd).
This change also brings about a new define:
GPIO_INT(name, port, pin, flags, signal)
And the existing GPIO macro has had the signal parameter removed since
they were just NULL.
GPIO(name, port, pin, flags)
In each of the gpio.inc files, all the GPIOs with irq handlers must be
defined at the top of the file. This is because their enum values from
gpio_signal are used as the index to the gpio_irq_handlers table.
BUG=chromium:471331
BRANCH=none
TEST=Flashed ec to samus and samus_pd, verified lightbar tap, lid, power
button, keyboard, charging, all still working.
TEST=Moved a GPIO_INT declaration after a GPIO declaration and watched the build
fail.
TEST=make -j BOARD=peppy tests
TEST=make -j BOARD=auron tests
TEST=make -j BOARD=link tests
Change-Id: Id6e261b0a3cd63223ca92f2e96a80c95e85cdefb
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/263973
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'chip/lm4/gpio.c')
-rw-r--r-- | chip/lm4/gpio.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/chip/lm4/gpio.c b/chip/lm4/gpio.c index e5236e31d2..97e886294b 100644 --- a/chip/lm4/gpio.c +++ b/chip/lm4/gpio.c @@ -150,9 +150,8 @@ void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags) int gpio_enable_interrupt(enum gpio_signal signal) { const struct gpio_info *g = gpio_list + signal; - /* Fail if no interrupt handler */ - if (!g->irq_handler) + if (signal >= GPIO_IH_COUNT) return EC_ERROR_UNKNOWN; LM4_GPIO_IM(g->port) |= g->mask; @@ -164,7 +163,7 @@ int gpio_disable_interrupt(enum gpio_signal signal) const struct gpio_info *g = gpio_list + signal; /* Fail if no interrupt handler */ - if (!g->irq_handler) + if (signal >= GPIO_IH_COUNT) return EC_ERROR_UNKNOWN; LM4_GPIO_IM(g->port) &= ~g->mask; @@ -305,9 +304,9 @@ static void gpio_interrupt(int port, uint32_t mis) int i = 0; const struct gpio_info *g = gpio_list; - for (i = 0; i < GPIO_COUNT && mis; i++, g++) { - if (port == g->port && (mis & g->mask) && g->irq_handler) { - g->irq_handler(i); + for (i = 0; i < GPIO_IH_COUNT && mis; i++, g++) { + if (port == g->port && (mis & g->mask)) { + gpio_irq_handlers[i](i); mis &= ~g->mask; } } |