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/twinkie | |
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/twinkie')
-rw-r--r-- | board/twinkie/board.c | 40 | ||||
-rw-r--r-- | board/twinkie/board.h | 41 | ||||
-rw-r--r-- | board/twinkie/gpio.inc | 41 |
3 files changed, 43 insertions, 79 deletions
diff --git a/board/twinkie/board.c b/board/twinkie/board.c index 5a5ad855f3..5e8e2773e0 100644 --- a/board/twinkie/board.c +++ b/board/twinkie/board.c @@ -26,45 +26,7 @@ void vbus_event(enum gpio_signal signal) ccprintf("INA!\n"); } -/* GPIO signal list. Must match order from enum gpio_signal. */ -const struct gpio_info gpio_list[] = { - {"CC2_ALERT_L", GPIO_A, (1<<7), GPIO_INT_FALLING, cc2_event}, - {"VBUS_ALERT_L", GPIO_B, (1<<2), GPIO_INT_FALLING, vbus_event}, - - {"CC1_EN", GPIO_A, (1<<0), GPIO_OUT_HIGH, NULL}, - {"CC1_PD", GPIO_A, (1<<1), GPIO_ANALOG, NULL}, - {"CC2_EN", GPIO_A, (1<<2), GPIO_OUT_HIGH, NULL}, - {"CC2_PD", GPIO_A, (1<<3), GPIO_ANALOG, NULL}, - {"DAC", GPIO_A, (1<<4), GPIO_ANALOG, NULL}, - {"CC2_TX_DATA", GPIO_A, (1<<6), GPIO_OUT_LOW, NULL}, - - {"CC1_RA", GPIO_A, (1<<8), GPIO_ODR_HIGH, NULL}, - {"USB_DM", GPIO_A, (1<<11), GPIO_ANALOG, NULL}, - {"USB_DP", GPIO_A, (1<<12), GPIO_ANALOG, NULL}, - {"CC1_RPUSB", GPIO_A, (1<<13), GPIO_ODR_HIGH, NULL}, - {"CC1_RP1A5", GPIO_A, (1<<14), GPIO_ODR_HIGH, NULL}, - {"CC1_RP3A0", GPIO_A, (1<<15), GPIO_ODR_HIGH, NULL}, - {"CC2_RPUSB", GPIO_B, (1<<0), GPIO_ODR_HIGH, NULL}, - - {"CC1_TX_EN", GPIO_B, (1<<1), GPIO_OUT_LOW, NULL}, - {"CC2_TX_EN", GPIO_B, (1<<3), GPIO_OUT_LOW, NULL}, - {"CC1_TX_DATA", GPIO_B, (1<<4), GPIO_OUT_LOW, NULL}, - {"CC1_RD", GPIO_B, (1<<5), GPIO_ODR_HIGH, NULL}, - {"I2C_SCL", GPIO_B, (1<<6), GPIO_INPUT, NULL}, - {"I2C_SDA", GPIO_B, (1<<7), GPIO_INPUT, NULL}, - {"CC2_RD", GPIO_B, (1<<8), GPIO_ODR_HIGH, NULL}, - {"LED_G_L", GPIO_B, (1<<11), GPIO_ODR_HIGH, NULL}, - {"LED_R_L", GPIO_B, (1<<13), GPIO_ODR_HIGH, NULL}, - {"LED_B_L", GPIO_B, (1<<14), GPIO_ODR_HIGH, NULL}, - {"CC2_RA", GPIO_B, (1<<15), GPIO_ODR_HIGH, NULL}, - {"CC2_RP1A5", GPIO_C, (1<<14), GPIO_ODR_HIGH, NULL}, - {"CC2_RP3A0", GPIO_C, (1<<15), GPIO_ODR_HIGH, 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. */ void board_config_pre_init(void) diff --git a/board/twinkie/board.h b/board/twinkie/board.h index 5124180df2..69de431b45 100644 --- a/board/twinkie/board.h +++ b/board/twinkie/board.h @@ -40,46 +40,7 @@ #define TIM_CLOCK32 2 #define TIM_ADC 3 -/* GPIO signal list */ -enum gpio_signal { - GPIO_CC2_ALERT_L, - GPIO_VBUS_ALERT_L, - - GPIO_CC1_EN, - GPIO_CC1_PD, - GPIO_CC2_EN, - GPIO_CC2_PD, - GPIO_DAC, - GPIO_CC2_TX_DATA, - - GPIO_CC1_RA, - GPIO_USB_DM, - GPIO_USB_DP, - GPIO_CC1_RPUSB, - GPIO_CC1_RP1A5, - GPIO_CC1_RP3A0, - GPIO_CC2_RPUSB, - - GPIO_CC1_TX_EN, - GPIO_CC2_TX_EN, - GPIO_CC1_TX_DATA, - GPIO_CC1_RD, - GPIO_I2C_SCL, - GPIO_I2C_SDA, - GPIO_CC2_RD, - GPIO_LED_G_L, - GPIO_LED_R_L, - GPIO_LED_B_L, - GPIO_CC2_RA, - GPIO_CC2_RP1A5, - GPIO_CC2_RP3A0, - - /* Unimplemented signals we emulate */ - GPIO_ENTERING_RW, - GPIO_WP_L, - /* Number of GPIOs; not an actual GPIO */ - GPIO_COUNT -}; +#include "gpio_signal.h" /* ADC signal */ enum adc_channel { diff --git a/board/twinkie/gpio.inc b/board/twinkie/gpio.inc new file mode 100644 index 0000000000..405d6f3b6b --- /dev/null +++ b/board/twinkie/gpio.inc @@ -0,0 +1,41 @@ +/* -*- 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(CC2_ALERT_L, A, 7, GPIO_INT_FALLING, cc2_event) +GPIO(VBUS_ALERT_L, B, 2, GPIO_INT_FALLING, vbus_event) + +GPIO(CC1_EN, A, 0, GPIO_OUT_HIGH, NULL) +GPIO(CC1_PD, A, 1, GPIO_ANALOG, NULL) +GPIO(CC2_EN, A, 2, GPIO_OUT_HIGH, NULL) +GPIO(CC2_PD, A, 3, GPIO_ANALOG, NULL) +GPIO(DAC, A, 4, GPIO_ANALOG, NULL) +GPIO(CC2_TX_DATA, A, 6, GPIO_OUT_LOW, NULL) + +GPIO(CC1_RA, A, 8, GPIO_ODR_HIGH, NULL) +GPIO(USB_DM, A, 11, GPIO_ANALOG, NULL) +GPIO(USB_DP, A, 12, GPIO_ANALOG, NULL) +GPIO(CC1_RPUSB, A, 13, GPIO_ODR_HIGH, NULL) +GPIO(CC1_RP1A5, A, 14, GPIO_ODR_HIGH, NULL) +GPIO(CC1_RP3A0, A, 15, GPIO_ODR_HIGH, NULL) +GPIO(CC2_RPUSB, B, 0, GPIO_ODR_HIGH, NULL) + +GPIO(CC1_TX_EN, B, 1, GPIO_OUT_LOW, NULL) +GPIO(CC2_TX_EN, B, 3, GPIO_OUT_LOW, NULL) +GPIO(CC1_TX_DATA, B, 4, GPIO_OUT_LOW, NULL) +GPIO(CC1_RD, B, 5, GPIO_ODR_HIGH, NULL) +GPIO(I2C_SCL, B, 6, GPIO_INPUT, NULL) +GPIO(I2C_SDA, B, 7, GPIO_INPUT, NULL) +GPIO(CC2_RD, B, 8, GPIO_ODR_HIGH, NULL) +GPIO(LED_G_L, B, 11, GPIO_ODR_HIGH, NULL) +GPIO(LED_R_L, B, 13, GPIO_ODR_HIGH, NULL) +GPIO(LED_B_L, B, 14, GPIO_ODR_HIGH, NULL) +GPIO(CC2_RA, B, 15, GPIO_ODR_HIGH, NULL) +GPIO(CC2_RP1A5, C, 14, GPIO_ODR_HIGH, NULL) +GPIO(CC2_RP3A0, C, 15, GPIO_ODR_HIGH, NULL) + +/* Unimplemented signals which we need to emulate for now */ +UNIMPLEMENTED(ENTERING_RW) +UNIMPLEMENTED(WP_L) |