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/discovery | |
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/discovery')
-rw-r--r-- | board/discovery/board.c | 14 | ||||
-rw-r--r-- | board/discovery/board.h | 14 | ||||
-rw-r--r-- | board/discovery/gpio.inc | 17 |
3 files changed, 19 insertions, 26 deletions
diff --git a/board/discovery/board.c b/board/discovery/board.c index f900acf015..5548577943 100644 --- a/board/discovery/board.c +++ b/board/discovery/board.c @@ -15,19 +15,7 @@ void button_event(enum gpio_signal signal) { } -/* GPIO signal list. Must match order from enum gpio_signal. */ -const struct gpio_info gpio_list[] = { - /* Inputs with interrupt handlers are first for efficiency */ - {"USER_BUTTON", GPIO_A, (1<<0), GPIO_INT_BOTH, button_event}, - /* Outputs */ - {"LED_BLUE", GPIO_B, (1<<6), GPIO_OUT_LOW, NULL}, - {"LED_GREEN", GPIO_B, (1<<7), GPIO_OUT_LOW, NULL}, - - /* Unimplemented signals which we need to emulate for now */ - GPIO_SIGNAL_NOT_IMPLEMENTED("ENTERING_RW"), - GPIO_SIGNAL_NOT_IMPLEMENTED("WP_L"), -}; -BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); +#include "gpio_list.h" /* Initialize board. */ static void board_init(void) diff --git a/board/discovery/board.h b/board/discovery/board.h index 0ef0ff18a7..a4716ebe6e 100644 --- a/board/discovery/board.h +++ b/board/discovery/board.h @@ -24,19 +24,7 @@ #define TIM_CLOCK_MSB 3 #define TIM_CLOCK_LSB 4 -/* GPIO signal list */ -enum gpio_signal { - /* Inputs with interrupt handlers are first for efficiency */ - GPIO_USER_BUTTON = 0, - /* Outputs */ - GPIO_LED_BLUE, - GPIO_LED_GREEN, - /* Unimplemented signals we emulate */ - GPIO_ENTERING_RW, - GPIO_WP_L, - /* Number of GPIOs; not an actual GPIO */ - GPIO_COUNT -}; +#include "gpio_signal.h" #endif /* !__ASSEMBLER__ */ diff --git a/board/discovery/gpio.inc b/board/discovery/gpio.inc new file mode 100644 index 0000000000..4f09cc3ab3 --- /dev/null +++ b/board/discovery/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. + */ + +/* Inputs with interrupt handlers are first for efficiency */ +GPIO(USER_BUTTON, A, 0, GPIO_INT_BOTH, button_event) + +/* Outputs */ +GPIO(LED_BLUE, B, 6, GPIO_OUT_LOW, NULL) +GPIO(LED_GREEN, B, 7, GPIO_OUT_LOW, NULL) + +/* Unimplemented signals which we need to emulate for now */ +UNIMPLEMENTED(ENTERING_RW) +UNIMPLEMENTED(WP_L) |