summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2016-09-01 17:57:05 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-09 17:15:25 -0700
commiteb10d4518b0e37c483fbc0ec4915df47dee10f45 (patch)
treebfc7afb6e9bacca7ca8268c88766fb3acefc87a6
parentd9048f0896763f4ea30e3fca9f7db0b955ab2fd3 (diff)
downloadchrome-ec-eb10d4518b0e37c483fbc0ec4915df47dee10f45.tar.gz
Add check to prevent duplicate PIN assignments
All PIN() assignments in board/$BOARD/gpio.inc must be unique, since otherwise you're just creating duplicate names and table entries for the same core interrupt and may not be initializing things the way you think. BUG=none BRANCH=none TEST=make buildall; test on Cr50 hardware Also verified that the image size is exactly the same before an after this CL. Change-Id: Ifb1805a010905f67fc5c0d246b6252af73715409 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/383773 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--board/host/gpio.inc24
-rw-r--r--include/gpio_list.h15
2 files changed, 27 insertions, 12 deletions
diff --git a/board/host/gpio.inc b/board/host/gpio.inc
index 5ffb9ae944..7695a6021d 100644
--- a/board/host/gpio.inc
+++ b/board/host/gpio.inc
@@ -9,18 +9,18 @@
* Note: Those with interrupt handlers must be declared first. */
GPIO_INT(LID_OPEN, PIN(0, 0), GPIO_INT_BOTH, lid_interrupt)
-GPIO_INT(POWER_BUTTON_L, PIN(0, 0), GPIO_INT_BOTH, power_button_interrupt)
-GPIO_INT(AC_PRESENT, PIN(0, 0), GPIO_INT_BOTH, extpower_interrupt)
-GPIO_INT(BUTTON_VOLUME_DOWN_L, PIN(0, 0), GPIO_INT_BOTH, button_interrupt)
-GPIO_INT(BUTTON_VOLUME_UP, PIN(0, 0), GPIO_INT_BOTH, button_interrupt)
-GPIO_INT(CHARGE_DONE, PIN(0, 0), GPIO_INT_BOTH, inductive_charging_interrupt)
+GPIO_INT(POWER_BUTTON_L, PIN(0, 1), GPIO_INT_BOTH, power_button_interrupt)
+GPIO_INT(AC_PRESENT, PIN(0, 2), GPIO_INT_BOTH, extpower_interrupt)
+GPIO_INT(BUTTON_VOLUME_DOWN_L, PIN(0, 3), GPIO_INT_BOTH, button_interrupt)
+GPIO_INT(BUTTON_VOLUME_UP, PIN(0, 4), GPIO_INT_BOTH, button_interrupt)
+GPIO_INT(CHARGE_DONE, PIN(0, 5), GPIO_INT_BOTH, inductive_charging_interrupt)
-GPIO(EC_INT_L, PIN(0, 0), 0)
-GPIO(WP, PIN(0, 0), 0)
-GPIO(ENTERING_RW, PIN(0, 0), 0)
-GPIO(PCH_BKLTEN, PIN(0, 0), 0)
-GPIO(ENABLE_BACKLIGHT, PIN(0, 0), 0)
+GPIO(EC_INT_L, PIN(0, 6), 0)
+GPIO(WP, PIN(0, 7), 0)
+GPIO(ENTERING_RW, PIN(0, 8), 0)
+GPIO(PCH_BKLTEN, PIN(0, 9), 0)
+GPIO(ENABLE_BACKLIGHT, PIN(0, 10), 0)
/* Inductive charging */
-GPIO(CHARGE_EN, PIN(0, 0), 0)
-GPIO(BASE_CHG_VDD_EN, PIN(0, 0), 0)
+GPIO(CHARGE_EN, PIN(0, 11), 0)
+GPIO(BASE_CHG_VDD_EN, PIN(0, 12), 0)
diff --git a/include/gpio_list.h b/include/gpio_list.h
index 5fa9839e13..802a943b0b 100644
--- a/include/gpio_list.h
+++ b/include/gpio_list.h
@@ -37,3 +37,18 @@ const int gpio_ih_count = ARRAY_SIZE(gpio_irq_handlers);
#define GPIO_INT(name, pin, flags, signal) \
BUILD_ASSERT(GPIO_##name < ARRAY_SIZE(gpio_irq_handlers));
#include "gpio.wrap"
+
+/*
+ * All PIN(...) assignments must be unique, since otherwise you're just
+ * creating duplicate names for the same thing, and may not always be
+ * initializing them the way you think.
+ */
+#define GPIO(name, pin, flags) pin
+#define GPIO_INT(name, pin, flags, signal) pin
+/*
+ * The compiler will complain if we use the same name twice. The linker ignores
+ * anything that gets by.
+ */
+#define PIN(a, b...) static const int _pin_ ## a ## _ ## b \
+ __attribute__((unused, section(".unused"))) = __LINE__;
+#include "gpio.wrap"