summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2021-11-11 18:14:07 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-18 04:54:52 +0000
commitb46752dc210a5521a1782fd79e765596380c5a67 (patch)
tree1c571cb8072d43f90b7c1b155427d4796c7e9675
parent1c448adb961a62560b20ee3ce430fd4723371cbe (diff)
downloadchrome-ec-b46752dc210a5521a1782fd79e765596380c5a67.tar.gz
Revert "gpio: extend flags size to accommodate GPIO_ flags"
This reverts commit 7d36fb8991e7a249ae56db508078480c27914f2e. BUG=b:200823466 TEST=make buildall -j Change-Id: Ifbef35feaf42fca1faa3fc78ceff5cb9bced19f8 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3285750 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
-rw-r--r--chip/g/config_chip.h2
-rw-r--r--chip/host/config_chip.h2
-rw-r--r--common/gpio.c46
3 files changed, 28 insertions, 22 deletions
diff --git a/chip/g/config_chip.h b/chip/g/config_chip.h
index 97e88dac6b..29d1fb0638 100644
--- a/chip/g/config_chip.h
+++ b/chip/g/config_chip.h
@@ -57,7 +57,7 @@
/* Magic for gpio.inc */
#define GPIO_PIN(port, index) (port), (1 << (index))
-#define GPIO_PIN_MASK(p, m) .port = (p), .mask = (m)
+#define GPIO_PIN_MASK(port, mask) (port), (mask)
#define DUMMY_GPIO_BANK 0
#define PCLK_FREQ (24 * 1000 * 1000)
diff --git a/chip/host/config_chip.h b/chip/host/config_chip.h
index 8fea752bae..aa48520b3a 100644
--- a/chip/host/config_chip.h
+++ b/chip/host/config_chip.h
@@ -51,7 +51,7 @@ extern char __host_flash[CONFIG_FLASH_SIZE];
#undef CONFIG_COMMON_TIMER
#define GPIO_PIN(port, index) GPIO_##port, BIT(index)
-#define GPIO_PIN_MASK(p, m) .port = GPIO_##p, .mask = (m)
+#define GPIO_PIN_MASK(port, mask) GPIO_##port, (mask)
#define I2C_PORT_COUNT 1
diff --git a/common/gpio.c b/common/gpio.c
index cb3723f865..79d436815d 100644
--- a/common/gpio.c
+++ b/common/gpio.c
@@ -13,32 +13,31 @@
/* GPIO alternate function structure */
struct gpio_alt_func {
- /* Module ID (as uint8_t, since enum would be 32-bit) */
- uint8_t module_id;
-
- /* Alternate function number */
- uint8_t func;
-
/* Port base address */
uint32_t port;
/* Bitmask on that port (multiple bits allowed) */
uint32_t mask;
+ /* Alternate function number */
+ uint8_t func;
+
+ /* Module ID (as uint8_t, since enum would be 32-bit) */
+ uint8_t module_id;
+
/* Flags (GPIO_*; see above). */
- uint32_t flags;
+ uint16_t flags;
};
/*
* 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(pinmask, function, module, flagz) \
- {GPIO_##pinmask, .func = (function), .module_id = (module), \
- .flags = (flagz)},
+#define ALTERNATE(pinmask, function, module, flags) \
+ {GPIO_##pinmask, function, module, flags},
static const struct gpio_alt_func gpio_alt_funcs[] = {
-#include "gpio.wrap"
+ #include "gpio.wrap"
};
/*
@@ -48,7 +47,9 @@ static const struct gpio_alt_func gpio_alt_funcs[] = {
*/
#define GPIO_CONFIG_ALL_PORTS 0xFFFFFFFF
-static int gpio_config_pins(enum module_id id, uint32_t port, uint32_t pin_mask,
+static int gpio_config_pins(enum module_id id,
+ uint32_t port,
+ uint32_t pin_mask,
int enable)
{
const struct gpio_alt_func *af;
@@ -56,9 +57,10 @@ static int gpio_config_pins(enum module_id id, uint32_t port, uint32_t pin_mask,
/* Find pins and set to alternate functions */
for (af = gpio_alt_funcs;
- af < gpio_alt_funcs + ARRAY_SIZE(gpio_alt_funcs); af++) {
+ af < gpio_alt_funcs + ARRAY_SIZE(gpio_alt_funcs);
+ af++) {
if (af->module_id != id)
- continue; /* Pins for some other module */
+ continue; /* Pins for some other module */
/* Check to see if the requested port matches. */
if ((port != GPIO_CONFIG_ALL_PORTS) && (port != af->port))
@@ -71,11 +73,13 @@ static int gpio_config_pins(enum module_id id, uint32_t port, uint32_t pin_mask,
if ((af->mask & pin_mask) == pin_mask) {
if (!(af->flags & GPIO_DEFAULT))
gpio_set_flags_by_mask(
- af->port, (af->mask & pin_mask),
+ af->port,
+ (af->mask & pin_mask),
enable ? af->flags : GPIO_INPUT);
- gpio_set_alternate_function(af->port,
- (af->mask & pin_mask),
- enable ? af->func : -1);
+ gpio_set_alternate_function(
+ af->port,
+ (af->mask & pin_mask),
+ enable ? af->func : -1);
rv = EC_SUCCESS;
/* We're done here if we were just setting one port. */
if (port != GPIO_CONFIG_ALL_PORTS)
@@ -97,8 +101,10 @@ int gpio_config_module(enum module_id id, int enable)
int gpio_config_pin(enum module_id id, enum gpio_signal signal, int enable)
{
- return gpio_config_pins(id, gpio_list[signal].port,
- gpio_list[signal].mask, enable);
+ return gpio_config_pins(id,
+ gpio_list[signal].port,
+ gpio_list[signal].mask,
+ enable);
}
void gpio_set_flags(enum gpio_signal signal, int flags)