summaryrefslogtreecommitdiff
path: root/include/gpio_list.h
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2015-04-08 16:42:55 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-04-10 22:08:25 +0000
commite9883124ff1600db5788e44c332a403499fb5da6 (patch)
tree5e5b64b72e89037845cc549e1c4262bf9d224a04 /include/gpio_list.h
parent0b043fed030129ea99272f1ba729307fafaa93e2 (diff)
downloadchrome-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 'include/gpio_list.h')
-rw-r--r--include/gpio_list.h29
1 files changed, 24 insertions, 5 deletions
diff --git a/include/gpio_list.h b/include/gpio_list.h
index c7e2962747..c9bdd5668d 100644
--- a/include/gpio_list.h
+++ b/include/gpio_list.h
@@ -3,17 +3,21 @@
* found in the LICENSE file.
*/
+#include "gpio_signal.h"
+
#ifdef CONFIG_COMMON_GPIO_SHORTNAMES
-#define GPIO(name, port, pin, flags, signal) \
- {#port#pin, GPIO_##port, (1 << pin), flags, signal},
+#define GPIO(name, port, pin, flags) \
+ {#port#pin, GPIO_##port, (1 << pin), flags},
#else
-#define GPIO(name, port, pin, flags, signal) \
- {#name, GPIO_##port, (1 << pin), flags, signal},
+#define GPIO(name, port, pin, flags) \
+ {#name, GPIO_##port, (1 << pin), flags},
#endif
#define UNIMPLEMENTED(name) \
- {#name, DUMMY_GPIO_BANK, 0, GPIO_DEFAULT, NULL},
+ {#name, DUMMY_GPIO_BANK, 0, GPIO_DEFAULT},
+#define GPIO_INT(name, port, pin, flags, signal) \
+ GPIO(name, port, pin, flags)
/* GPIO signal list. */
const struct gpio_info gpio_list[] = {
#include "gpio.wrap"
@@ -33,3 +37,18 @@ const struct gpio_alt_func gpio_alt_funcs[] = {
};
const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs);
+
+/* GPIO Interrupt Handlers */
+#define GPIO_INT(name, port, pin, flags, signal) signal,
+void (* const gpio_irq_handlers[])(enum gpio_signal signal) = {
+ #include "gpio.wrap"
+};
+const int gpio_ih_count = ARRAY_SIZE(gpio_irq_handlers);
+
+/*
+ * ALL GPIOs with interrupt handlers must be declared at the top of the gpio.inc
+ * file.
+ */
+#define GPIO_INT(name, port, pin, flags, signal) \
+ BUILD_ASSERT(GPIO_##name < ARRAY_SIZE(gpio_irq_handlers));
+#include "gpio.wrap"