diff options
author | Anton Staaf <robotboy@chromium.org> | 2014-06-24 07:52:49 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-06-26 02:43:01 +0000 |
commit | 9ccfd4553e708a5df4be3aa18b97c75da3f6c1b9 (patch) | |
tree | bd10678c7ee25901de97260967b8bee4a849baa5 /board/host | |
parent | 88c0ffd692b4e6d5fadc75bb15255e0684d6a1c9 (diff) | |
download | chrome-ec-9ccfd4553e708a5df4be3aa18b97c75da3f6c1b9.tar.gz |
gpio: Replace duplication in gpio declarations with X-macro file
Previously each board.h and board.c contained an enum and an array
for gpio definitons that had to be manually kept in sync, with no
compiler assistance other than that their lengths matched.
This change adds a single gpio.inc file that declares all gpio's
that a board uses and is used as an X-macro include file to
generate both the gpio_signal enum and the gpio_list array.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=none
TEST=make buildall -j
Change-Id: If9c9feca968619a59ff9f20701359bcb9374e4da
Reviewed-on: https://chromium-review.googlesource.com/205354
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'board/host')
-rw-r--r-- | board/host/board.c | 22 | ||||
-rw-r--r-- | board/host/board.h | 15 | ||||
-rw-r--r-- | board/host/gpio.inc | 17 |
3 files changed, 25 insertions, 29 deletions
diff --git a/board/host/board.c b/board/host/board.c index 1d9ab77c23..407018a573 100644 --- a/board/host/board.c +++ b/board/host/board.c @@ -14,22 +14,14 @@ #include "timer.h" #include "util.h" -#define MOCK_GPIO(x) {#x, 0, 0, 0, 0} -#define MOCK_GPIO_INT(x, i, r) {#x, 0, 0, i, r} +/* + * GPIO_0 is the name generated by the gpio.inc GPIO macros for all of the host + * GPIO ports. This maps back to 0, which is then ignored by the host GPIO mock + * code. + */ +#define GPIO_0 0 -const struct gpio_info gpio_list[] = { - MOCK_GPIO(EC_INT), - MOCK_GPIO_INT(LID_OPEN, GPIO_INT_BOTH, lid_interrupt), - MOCK_GPIO_INT(POWER_BUTTON_L, GPIO_INT_BOTH, power_button_interrupt), - MOCK_GPIO(WP), - MOCK_GPIO(ENTERING_RW), - MOCK_GPIO_INT(AC_PRESENT, GPIO_INT_BOTH, extpower_interrupt), - MOCK_GPIO(PCH_BKLTEN), - MOCK_GPIO(ENABLE_BACKLIGHT), - MOCK_GPIO_INT(BUTTON_VOLUME_DOWN_L, GPIO_INT_BOTH, button_interrupt), - MOCK_GPIO_INT(BUTTON_VOLUME_UP, GPIO_INT_BOTH, button_interrupt), -}; -BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +#include "gpio_list.h" /* Pins with alternate functions; not on simulated host platform */ const struct gpio_alt_func gpio_alt_funcs[] = { diff --git a/board/host/board.h b/board/host/board.h index 5ab078292f..b8ce98513a 100644 --- a/board/host/board.h +++ b/board/host/board.h @@ -21,20 +21,7 @@ #define CONFIG_WP_ACTIVE_HIGH -enum gpio_signal { - GPIO_EC_INT, - GPIO_LID_OPEN, - GPIO_POWER_BUTTON_L, - GPIO_WP, - GPIO_ENTERING_RW, - GPIO_AC_PRESENT, - GPIO_PCH_BKLTEN, - GPIO_ENABLE_BACKLIGHT, - GPIO_BUTTON_VOLUME_DOWN_L, - GPIO_BUTTON_VOLUME_UP, - - GPIO_COUNT -}; +#include "gpio_signal.h" enum temp_sensor_id { TEMP_SENSOR_CPU = 0, diff --git a/board/host/gpio.inc b/board/host/gpio.inc new file mode 100644 index 0000000000..578e97c066 --- /dev/null +++ b/board/host/gpio.inc @@ -0,0 +1,17 @@ +/* -*- mode:c -*- + * + * Copyright (c) 2014 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +GPIO(EC_INT, 0, 0, 0, NULL) +GPIO(LID_OPEN, 0, 0, GPIO_INT_BOTH, lid_interrupt) +GPIO(POWER_BUTTON_L, 0, 0, GPIO_INT_BOTH, power_button_interrupt) +GPIO(WP, 0, 0, 0, NULL) +GPIO(ENTERING_RW, 0, 0, 0, NULL) +GPIO(AC_PRESENT, 0, 0, GPIO_INT_BOTH, extpower_interrupt) +GPIO(PCH_BKLTEN, 0, 0, 0, NULL) +GPIO(ENABLE_BACKLIGHT, 0, 0, 0, NULL) +GPIO(BUTTON_VOLUME_DOWN_L, 0, 0, GPIO_INT_BOTH, button_interrupt) +GPIO(BUTTON_VOLUME_UP, 0, 0, GPIO_INT_BOTH, button_interrupt) |