From 15dd9b89962a184cba4974c571960fe468f2a103 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Tue, 5 Jan 2021 00:17:56 +0100 Subject: [PATCH] soc/amd/common/block/gpio_banks: fix sequence in gpio_output When configuring a GPIO pin as output the value should be written before it gets configures as an output to avoid a possible glitch on the output when the GPIO pin was an input before and the output value was different from the one that got written afterwards. Change-Id: I2bb5e629ef0ed2daadc903ecc1852200fe3a5cb9 Signed-off-by: Felix Held Reviewed-on: https://review.coreboot.org/c/coreboot/+/49119 Tested-by: build bot (Jenkins) Reviewed-by: Raul Rangel --- src/soc/amd/common/block/gpio_banks/gpio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/soc/amd/common/block/gpio_banks/gpio.c b/src/soc/amd/common/block/gpio_banks/gpio.c index 03804d56f1..bdc243fa2c 100644 --- a/src/soc/amd/common/block/gpio_banks/gpio.c +++ b/src/soc/amd/common/block/gpio_banks/gpio.c @@ -162,8 +162,9 @@ void gpio_input(gpio_t gpio_num) void gpio_output(gpio_t gpio_num, int value) { - gpio_or32(gpio_num, GPIO_OUTPUT_ENABLE); + /* set GPIO output value before setting the direction to output to avoid glitches */ gpio_set(gpio_num, value); + gpio_or32(gpio_num, GPIO_OUTPUT_ENABLE); } const char *gpio_acpi_path(gpio_t gpio)