diff options
author | Steven Jian <steven.jian@intel.com> | 2015-04-01 01:25:42 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-05-27 03:58:16 +0000 |
commit | 937cc8a64e5971def21303e7a19a4ad9553e0ace (patch) | |
tree | 321543152e0c4d61e686ca7b92edd0d027bb168b /include | |
parent | e216906c9327655d71b8758b7f11c2f744e55018 (diff) | |
download | chrome-ec-937cc8a64e5971def21303e7a19a4ad9553e0ace.tar.gz |
mec1322: Simplify GPIO lists
Our existing GPIO macros use port# / gpio#, but the concept of different
GPIO ports does not exist on the mec1322. Therefore, add new GPIO macros
for chips which do not have distinct GPIO ports.
BUG=None
BRANCH=None
TEST=make buildall -j
Change-Id: Ibda97c6563ad447d16dab39ecadab43ccb25174b
Signed-off-by: Steven Jian <steven.jian@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/262841
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/gpio.wrap | 27 | ||||
-rw-r--r-- | include/gpio_list.h | 20 | ||||
-rw-r--r-- | include/gpio_signal.h | 4 |
3 files changed, 27 insertions, 24 deletions
diff --git a/include/gpio.wrap b/include/gpio.wrap index 1eb9f3643e..d9f9db2890 100644 --- a/include/gpio.wrap +++ b/include/gpio.wrap @@ -5,19 +5,26 @@ * found in the LICENSE file. */ +#ifndef GPIO_PIN +#error "Your architecture must define GPIO_PIN and it did not." +#endif + +#ifndef GPIO_PIN_MASK +#error "Your architecture must define GPIO_PIN_MASK and it did not." +#endif + /* * The GPIO macro is used to define a new GPIO pin name and function. * * The name is used to populate the gpio_signal enum by first * prepending GPIO_ to the name. It is also used to construct the - * string name that is presented in the shell interface. Similarly, - * the port parameter has GPIO_ prepended to it before it is used to - * initialize the port base address of a gpio_info struct. The pin - * number is used to create a bitmask. The flags parameter is passed - * on to the gpio_info directly. + * string name that is presented in the shell interface. The pin + * parameter should use PIN macro and will be expand to GPIO_PIN + * defined on each board. The flags parameter is passed on to the + * gpio_info directly. */ #ifndef GPIO -#define GPIO(name, port, pin, flags) +#define GPIO(name, pin, flags) #endif /* @@ -27,7 +34,7 @@ * array. */ #ifndef GPIO_INT -#define GPIO_INT(name, port, pin, flags, signal) +#define GPIO_INT(name, pin, flags, signal) #endif /* @@ -40,11 +47,11 @@ * alternate function mode. The function parameter is chip/variant specific * and will usually need to be looked up in the datasheet. The flags parameter * has the same meaning as in the GPIO macro above. This macro can assign - * multiple pins on the same port to a module, the second parameter is the - * bitmask of pins to be assigned. + * multiple pins on the same port to a module, pinmasks should use PIN_MASK + * and will be expanded as GPIO_PIN_MASK defined in each config_chip.h. */ #ifndef ALTERNATE -#define ALTERNATE(port, mask, function, module, flags) +#define ALTERNATE(pinmask, function, module, flags) #endif /* diff --git a/include/gpio_list.h b/include/gpio_list.h index c9bdd5668d..a94b6e7a9c 100644 --- a/include/gpio_list.h +++ b/include/gpio_list.h @@ -6,18 +6,14 @@ #include "gpio_signal.h" #ifdef CONFIG_COMMON_GPIO_SHORTNAMES -#define GPIO(name, port, pin, flags) \ - {#port#pin, GPIO_##port, (1 << pin), flags}, +#define GPIO(name, pin, flags) {GPIO_NAME_BY_##pin, GPIO_##pin, flags}, #else -#define GPIO(name, port, pin, flags) \ - {#name, GPIO_##port, (1 << pin), flags}, +#define GPIO(name, pin, flags) {#name, GPIO_##pin, flags}, #endif -#define UNIMPLEMENTED(name) \ - {#name, DUMMY_GPIO_BANK, 0, GPIO_DEFAULT}, +#define UNIMPLEMENTED(name) {#name, DUMMY_GPIO_BANK, 0, GPIO_DEFAULT}, +#define GPIO_INT(name, pin, flags, signal) GPIO(name, pin, flags) -#define GPIO_INT(name, port, pin, flags, signal) \ - GPIO(name, port, pin, flags) /* GPIO signal list. */ const struct gpio_info gpio_list[] = { #include "gpio.wrap" @@ -29,8 +25,8 @@ BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT); * Construct the gpio_alt_funcs array. This array is used by gpio_config_module * to enable and disable GPIO alternate functions on a module by module basis. */ -#define ALTERNATE(port, mask, function, module, flags) \ - {GPIO_##port, mask, function, module, flags}, +#define ALTERNATE(pinmask, function, module, flags) \ + {GPIO_##pinmask, function, module, flags}, const struct gpio_alt_func gpio_alt_funcs[] = { #include "gpio.wrap" @@ -39,7 +35,7 @@ const struct gpio_alt_func gpio_alt_funcs[] = { const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); /* GPIO Interrupt Handlers */ -#define GPIO_INT(name, port, pin, flags, signal) signal, +#define GPIO_INT(name, pin, flags, signal) signal, void (* const gpio_irq_handlers[])(enum gpio_signal signal) = { #include "gpio.wrap" }; @@ -49,6 +45,6 @@ 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. */ -#define GPIO_INT(name, port, pin, flags, signal) \ +#define GPIO_INT(name, pin, flags, signal) \ BUILD_ASSERT(GPIO_##name < ARRAY_SIZE(gpio_irq_handlers)); #include "gpio.wrap" diff --git a/include/gpio_signal.h b/include/gpio_signal.h index bcec1b522f..3270ba6a2d 100644 --- a/include/gpio_signal.h +++ b/include/gpio_signal.h @@ -6,9 +6,9 @@ #ifndef __CROS_EC_GPIO_SIGNAL_H #define __CROS_EC_GPIO_SIGNAL_H -#define GPIO(name, port, pin, flags) GPIO_##name, +#define GPIO(name, pin, flags) GPIO_##name, #define UNIMPLEMENTED(name) GPIO_##name, -#define GPIO_INT(name, port, pin, flags, signal) GPIO_##name, +#define GPIO_INT(name, pin, flags, signal) GPIO_##name, enum gpio_signal { #include "gpio.wrap" |