From d490afbe04a41f380ab79dfe92f28dda74ab52a7 Mon Sep 17 00:00:00 2001 From: Mathew King Date: Thu, 11 Mar 2021 08:25:52 -0700 Subject: [PATCH] mb/google/guybrush: Configure early GPIOs in earliest stage Configure early GPIOs in verstage if it is run in PSP otherwise configure them in bootblock. BUG=b:181961514, b:180721208 TEST=builds Signed-off-by: Mathew King Change-Id: Ib9410089592776ffe198901f2de914fd04bdbade Reviewed-on: https://review.coreboot.org/c/coreboot/+/51348 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- src/mainboard/google/guybrush/bootblock.c | 6 ++++-- .../guybrush/variants/baseboard/Makefile.inc | 2 ++ .../google/guybrush/variants/baseboard/gpio.c | 12 ++++++------ .../baseboard/include/baseboard/variants.h | 4 ++-- src/mainboard/google/guybrush/verstage.c | 14 ++++++++++++++ 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/mainboard/google/guybrush/bootblock.c b/src/mainboard/google/guybrush/bootblock.c index 5eacd0b9d0..4b11bd0545 100644 --- a/src/mainboard/google/guybrush/bootblock.c +++ b/src/mainboard/google/guybrush/bootblock.c @@ -11,8 +11,10 @@ void bootblock_mainboard_early_init(void) size_t num_gpios; const struct soc_amd_gpio *gpios; - gpios = variant_bootblock_gpio_table(&num_gpios); - program_gpios(gpios, num_gpios); + if (!CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) { + gpios = variant_early_gpio_table(&num_gpios); + program_gpios(gpios, num_gpios); + } if (CONFIG(GPIO_SIGN_OF_LIFE)) { for (int x = 0; x < 20; x++) { diff --git a/src/mainboard/google/guybrush/variants/baseboard/Makefile.inc b/src/mainboard/google/guybrush/variants/baseboard/Makefile.inc index 7c092e44c2..3b86b93aba 100644 --- a/src/mainboard/google/guybrush/variants/baseboard/Makefile.inc +++ b/src/mainboard/google/guybrush/variants/baseboard/Makefile.inc @@ -2,4 +2,6 @@ bootblock-y += gpio.c ramstage-y += gpio.c +verstage-y += gpio.c + smm-y += gpio.c diff --git a/src/mainboard/google/guybrush/variants/baseboard/gpio.c b/src/mainboard/google/guybrush/variants/baseboard/gpio.c index 68c7d290ef..3e9d88a468 100644 --- a/src/mainboard/google/guybrush/variants/baseboard/gpio.c +++ b/src/mainboard/google/guybrush/variants/baseboard/gpio.c @@ -163,9 +163,9 @@ static const struct soc_amd_gpio base_gpio_table[] = { PAD_NF(GPIO_148, I2C1_SDA, PULL_NONE), }; -/* Early GPIO configuration in bootblock */ -static const struct soc_amd_gpio bootblock_gpio_table[] = { - /* TODO: Fill bootblock gpio configuration */ +/* Early GPIO configuration */ +static const struct soc_amd_gpio early_gpio_table[] = { + /* TODO: Fill early gpio configuration */ }; /* GPIO configuration for sleep */ @@ -184,10 +184,10 @@ const struct soc_amd_gpio *__weak variant_override_gpio_table(size_t *size) return NULL; } -const struct soc_amd_gpio *__weak variant_bootblock_gpio_table(size_t *size) +const struct soc_amd_gpio *__weak variant_early_gpio_table(size_t *size) { - *size = ARRAY_SIZE(bootblock_gpio_table); - return bootblock_gpio_table; + *size = ARRAY_SIZE(early_gpio_table); + return early_gpio_table; } const __weak struct soc_amd_gpio *variant_sleep_gpio_table(size_t *size) diff --git a/src/mainboard/google/guybrush/variants/baseboard/include/baseboard/variants.h b/src/mainboard/google/guybrush/variants/baseboard/include/baseboard/variants.h index 91a2f147d2..dccaed0e2c 100644 --- a/src/mainboard/google/guybrush/variants/baseboard/include/baseboard/variants.h +++ b/src/mainboard/google/guybrush/variants/baseboard/include/baseboard/variants.h @@ -18,8 +18,8 @@ const struct soc_amd_gpio *variant_base_gpio_table(size_t *size); */ const struct soc_amd_gpio *variant_override_gpio_table(size_t *size); -/* This function provides GPIO init in bootblock. */ -const struct soc_amd_gpio *variant_bootblock_gpio_table(size_t *size); +/* This function provides early GPIO init in bootblock or psp. */ +const struct soc_amd_gpio *variant_early_gpio_table(size_t *size); /* This function provides GPIO settings before entering sleep. */ const struct soc_amd_gpio *variant_sleep_gpio_table(size_t *size); diff --git a/src/mainboard/google/guybrush/verstage.c b/src/mainboard/google/guybrush/verstage.c index ab079cad91..e7543c0779 100644 --- a/src/mainboard/google/guybrush/verstage.c +++ b/src/mainboard/google/guybrush/verstage.c @@ -1,9 +1,23 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ +#include +#include #include +static void setup_gpio(void) +{ + const struct soc_amd_gpio *gpios; + size_t num_gpios; + + if (CONFIG(VBOOT_STARTS_BEFORE_BOOTBLOCK)) { + gpios = variant_early_gpio_table(&num_gpios); + program_gpios(gpios, num_gpios); + } +} + void verstage_mainboard_early_init(void) { + setup_gpio(); } void verstage_mainboard_init(void)