From 6bb5b9a058f1acb6266039931f9b209c107b7987 Mon Sep 17 00:00:00 2001 From: Eric Lai Date: Tue, 9 Mar 2021 13:05:47 +0800 Subject: [PATCH] mb/google/mancomb: Add stubs to configure GPIOs BUG=b:182211161 TEST=builds Signed-off-by: Eric Lai Change-Id: I7de5e4a4d2273d0ea5a84210ea0ce28d312eaa95 Reviewed-on: https://review.coreboot.org/c/coreboot/+/51365 Tested-by: build bot (Jenkins) Reviewed-by: Mathew King --- src/mainboard/google/mancomb/bootblock.c | 5 ++- src/mainboard/google/mancomb/mainboard.c | 13 +++++++- .../mancomb/variants/baseboard/Makefile.inc | 3 ++ .../google/mancomb/variants/baseboard/gpio.c | 32 +++++++++++++++++++ .../baseboard/include/baseboard/variants.h | 18 +++++++++++ 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 src/mainboard/google/mancomb/variants/baseboard/Makefile.inc create mode 100644 src/mainboard/google/mancomb/variants/baseboard/gpio.c diff --git a/src/mainboard/google/mancomb/bootblock.c b/src/mainboard/google/mancomb/bootblock.c index dd4c1516b1..b57ab3c5bb 100644 --- a/src/mainboard/google/mancomb/bootblock.c +++ b/src/mainboard/google/mancomb/bootblock.c @@ -5,5 +5,8 @@ void bootblock_mainboard_early_init(void) { - /* TODO: Perform mainboard initialization */ + size_t num_gpios; + const struct soc_amd_gpio *gpios; + gpios = variant_bootblock_gpio_table(&num_gpios); + program_gpios(gpios, num_gpios); } diff --git a/src/mainboard/google/mancomb/mainboard.c b/src/mainboard/google/mancomb/mainboard.c index 3dc2c41d69..4129cff11d 100644 --- a/src/mainboard/google/mancomb/mainboard.c +++ b/src/mainboard/google/mancomb/mainboard.c @@ -1,10 +1,21 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ +#include #include +static void mainboard_configure_gpios(void) +{ + size_t base_num_gpios, override_num_gpios; + const struct soc_amd_gpio *base_gpios, *override_gpios; + base_gpios = variant_base_gpio_table(&base_num_gpios); + override_gpios = variant_override_gpio_table(&override_num_gpios); + gpio_configure_pads_with_override(base_gpios, base_num_gpios, override_gpios, + override_num_gpios); +} + static void mainboard_init(void *chip_info) { - /* TODO: Perform mainboard initialization */ + mainboard_configure_gpios(); } static void mainboard_enable(struct device *dev) diff --git a/src/mainboard/google/mancomb/variants/baseboard/Makefile.inc b/src/mainboard/google/mancomb/variants/baseboard/Makefile.inc new file mode 100644 index 0000000000..9fb63f5f43 --- /dev/null +++ b/src/mainboard/google/mancomb/variants/baseboard/Makefile.inc @@ -0,0 +1,3 @@ +bootblock-y += gpio.c + +ramstage-y += gpio.c diff --git a/src/mainboard/google/mancomb/variants/baseboard/gpio.c b/src/mainboard/google/mancomb/variants/baseboard/gpio.c new file mode 100644 index 0000000000..de210e1f88 --- /dev/null +++ b/src/mainboard/google/mancomb/variants/baseboard/gpio.c @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include + +/* GPIO configuration in ramstage*/ +static const struct soc_amd_gpio base_gpio_table[] = { + /* TODO: Fill gpio configuration */ +}; + +/* Early GPIO configuration in bootblock */ +static const struct soc_amd_gpio bootblock_gpio_table[] = { + /* TODO: Fill bootblock gpio configuration */ +}; + +const struct soc_amd_gpio *__weak variant_base_gpio_table(size_t *size) +{ + *size = ARRAY_SIZE(base_gpio_table); + return base_gpio_table; +} +const struct soc_amd_gpio *__weak variant_override_gpio_table(size_t *size) +{ + *size = 0; + return NULL; +} + +const struct soc_amd_gpio *__weak variant_bootblock_gpio_table(size_t *size) +{ + *size = ARRAY_SIZE(bootblock_gpio_table); + return bootblock_gpio_table; +} diff --git a/src/mainboard/google/mancomb/variants/baseboard/include/baseboard/variants.h b/src/mainboard/google/mancomb/variants/baseboard/include/baseboard/variants.h index 927af2f913..2946463f4b 100644 --- a/src/mainboard/google/mancomb/variants/baseboard/include/baseboard/variants.h +++ b/src/mainboard/google/mancomb/variants/baseboard/include/baseboard/variants.h @@ -3,4 +3,22 @@ #ifndef __BASEBOARD_VARIANTS_H__ #define __BASEBOARD_VARIANTS_H__ +#include + +/* + * This function provides base GPIO configuration table. It is typically provided by + * baseboard using a weak implementation. If GPIO configuration for a variant differs + * significantly from the baseboard, then the variant can also provide a strong implementation + * of this function. + */ +const struct soc_amd_gpio *variant_base_gpio_table(size_t *size); +/* + * This function allows variant to override any GPIOs that are different than the base GPIO + * configuration provided by variant_base_gpio_table(). + */ +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); + #endif /* __BASEBOARD_VARIANTS_H__ */