summaryrefslogtreecommitdiff
path: root/include/gpio_list.h
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2020-02-14 13:35:37 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-25 02:48:13 +0000
commita51fa30d71c486bd256a4922a1feb6f9f36b7a7d (patch)
tree6af5605baa367a5c817f10f50f91e2bd8b09d823 /include/gpio_list.h
parent4e6b1019d5e507710c4b4662656959bb9c767e8f (diff)
downloadchrome-ec-a51fa30d71c486bd256a4922a1feb6f9f36b7a7d.tar.gz
gpio: Free gpio.inc from oppressive order
This CL enables gpio.wrap to correct the order of all declaration in gpio.inc. Previously, gpio.inc had to be written such that GPIO_INTs were at the top of the file, GPIOs following GPIO_INTs, and then IOEX_INTs before IOEXs declaration. This ordering was required because the signal name enums were used to index into the interrupt handler table. See crrev.com/c/263973 (gpio: Refactor IRQ handler pointer out of gpio_list). This constraint not only limited the creativity and art of an individual crafting a gpio.inc, but also made recursively including gpio.inc's (for baseboard or other) messy and ugly. BRANCH=none BUG=none TEST=make buildall Change-Id: Ie4531b95b65728b646087f00e9434f4cfdc49287 Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2056498 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'include/gpio_list.h')
-rw-r--r--include/gpio_list.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/gpio_list.h b/include/gpio_list.h
index 22025b25d8..08d1883cf4 100644
--- a/include/gpio_list.h
+++ b/include/gpio_list.h
@@ -9,12 +9,14 @@
#ifdef CONFIG_COMMON_GPIO_SHORTNAMES
#define GPIO(name, pin, flags) {GPIO_NAME_BY_##pin, GPIO_##pin, flags},
+#define GPIO_INT(name, pin, flags, signal) \
+ {GPIO_NAME_BY_##pin, GPIO_##pin, flags},
#else
#define GPIO(name, pin, flags) {#name, GPIO_##pin, flags},
+#define GPIO_INT(name, pin, flags, signal) {#name, GPIO_##pin, flags},
#endif
#define UNIMPLEMENTED(name) {#name, DUMMY_GPIO_BANK, 0, GPIO_DEFAULT},
-#define GPIO_INT(name, pin, flags, signal) GPIO(name, pin, flags)
/* GPIO signal list. */
const struct gpio_info gpio_list[] = {
@@ -39,8 +41,11 @@ void (* const gpio_irq_handlers[])(enum gpio_signal signal) = {
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.
+ * ALL GPIO_INTs must appear before GPIOs (from gpio.wrap).
+ * This is because the enum gpio_signal names are used to index into
+ * the gpio_irq_handlers array.
+ *
+ * This constraint is handled within gpio.wrap.
*/
#define GPIO_INT(name, pin, flags, signal) \
BUILD_ASSERT(GPIO_##name < ARRAY_SIZE(gpio_irq_handlers));
@@ -92,7 +97,7 @@ const int gpio_ih_count = ARRAY_SIZE(gpio_irq_handlers);
* - flags: the same as the flags of GPIO.
* - handler: the IOEX IO's interrupt handler.
*/
-#define IOEX_INT(name, expin, flags, handler) IOEX(name, expin, flags)
+#define IOEX_INT(name, expin, flags, handler) {#name, IOEX_##expin, flags},
/* IO expander signal list. */
const struct ioex_info ioex_list[] = {