diff options
author | Anton Staaf <robotboy@chromium.org> | 2016-01-13 11:32:05 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-01-20 14:25:32 -0800 |
commit | 4c290b058a3393e8842de1583b29310d99c93d9a (patch) | |
tree | 070a341c8af014347489a69d41cd16345429c08f /include | |
parent | d5ae5bc3702946c27ec5d9a84dfa3b32bb3664d2 (diff) | |
download | chrome-ec-4c290b058a3393e8842de1583b29310d99c93d9a.tar.gz |
GPIO: Simplify configuration
Previously there were only two uses of gpio_config_pins, one was
gpio_config_module, which passed in GPIO_CONFIG_ALL_PORTS (the only
place this is used), the other was the common I2C code when it needs to
return the SDA and SCL lines to their alternate function after unwedging
the bus.
These uses are so different that it doesn't make much sense to keep a
single API for them. This change adds a gpio_config_pin that is
simpler to use as it just takes a gpio_signal enum to select the GPIO
to configure and makes gpio_config_pins and GPIO_CONFIG_ALL_PORTS
internal to gpio.c
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=None
BUG=None
TEST=make buildall -j
Change-Id: I92bfb0b520b0aa2165655b2ff5076e428c88631f
Reviewed-on: https://chromium-review.googlesource.com/322437
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/gpio.h | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/include/gpio.h b/include/gpio.h index 02bdcc4f6f..060ef97c33 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -10,13 +10,6 @@ #include "common.h" -/* - * GPIO_CONFIG_ALL_PORTS signifies a "don't care" for the GPIO port. This is - * used in gpio_config_pins(). When the port parameter is set to this, the - * pin_mask parameter is ignored. - */ -#define GPIO_CONFIG_ALL_PORTS 0xFFFFFFFF - /* Flag definitions for gpio_info and gpio_alt_func */ /* The following are valid for both gpio_info and gpio_alt_func: */ #define GPIO_OPEN_DRAIN (1 << 0) /* Output type is open-drain */ @@ -130,23 +123,19 @@ void gpio_pre_init(void); * * @param id Module ID to initialize * @param enable Enable alternate functions if 1; high-Z pins if 0. + * @return EC_SUCCESS, or non-zero if module_id is not found. */ -void gpio_config_module(enum module_id id, int enable); +int gpio_config_module(enum module_id id, int enable); /** - * Enable/disable alternate function for pins - * - * Note, you can also configure an entire module by setting the port parameter - * equal to GPIO_CONFIG_ALL_PORTS. + * Enable/disable alternate function for single pin * * @param id module ID of pins - * @param port Port of pins - * @param pin_mask Bit mask of pins - * @param enable Enable alternate functions if 1; high-Z pins if 0 - * @return EC_SUCCESS, or non-zero if pins are not found. + * @param signal Signal to configure + * @param enable Enable alternate function if 1; GPIO if 0 + * @return EC_SUCCESS, or non-zero if pin is not found. * */ -int gpio_config_pins(enum module_id id, - uint32_t port, uint32_t pin_mask, int enable); +int gpio_config_pin(enum module_id id, enum gpio_signal signal, int enable); /** * Get the current value of a signal. |