summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatryk Duda <pdk@semihalf.com>2021-07-15 19:18:53 +0000
committerCommit Bot <commit-bot@chromium.org>2021-07-16 09:28:41 +0000
commita4e494dabda23e842a6861506af43c265a0bf7b5 (patch)
tree62890a4279bf9eb1d7ce3c1f50f4b1d78aa296ec
parentf84a6447bbfc1e82095f1c135078a1d8b6e80913 (diff)
downloadchrome-ec-a4e494dabda23e842a6861506af43c265a0bf7b5.tar.gz
common/gpio: Set GPIO flags after setting alternate function
On STM32, gpio_set_alternate_function() called with GPIO_ALT_FUNC_NONE argument causes the pin to be set to input. In gpio_reset() function, we are setting flags first and then we are changing pin function to GPIO. As a result, using gpio_reset() on STM32 boards causes pin to be configured as input, regardles of gpio.inc file. To fix this, we should always change pin functionality to GPIO before setting GPIO flags and/or state. This approach seems to be natural also. BUG=b:170432597 BRANCH=none TEST=Flash EC on some STM32 based board (eg. dartmonkey). Use gpio_reset() function on some GPIO pin which is configured as GPIO_OUT_LOW/GPIO_OUT_HIGH in gpio.inc file (eg. FP_RST_ODL on dartmonkey). Use `gpioset` and `gpioget` command to change state of the GPIO pin, and verify it works. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I0a6c2ee8d1c1cf33b14bd54bb432c63b820427be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3033241 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--common/gpio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/common/gpio.c b/common/gpio.c
index 42a9d2a2e6..9fa8512e27 100644
--- a/common/gpio.c
+++ b/common/gpio.c
@@ -127,8 +127,8 @@ void gpio_reset(enum gpio_signal signal)
{
const struct gpio_info *g = gpio_list + signal;
- gpio_set_flags_by_mask(g->port, g->mask, g->flags);
gpio_set_alternate_function(g->port, g->mask, GPIO_ALT_FUNC_NONE);
+ gpio_set_flags_by_mask(g->port, g->mask, g->flags);
}
const char *gpio_get_name(enum gpio_signal signal)