From 4050ef091a18507617786648f901dd1eb477a8d5 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Fri, 24 May 2024 01:40:27 +0530 Subject: mb/google/trulo: Refactor gpio pad configuration This patch tries to simplify the baseboard/variant GPIO programming for Google/Trulo. The idea is to let each variant maintain its own complete GPIO PAD configuration table instead of having a back-and-forth call between baseboard and variants. With this patch coreboot performing GPIO programming is now much simpler where the common code block calls into respective variants and gets the gpio table prior to the pad configuration. BUG=b:334826281 ([TWL] Decouple GPIO from baseboard to variant) TEST=Able to build google/orisa. Change-Id: I4ab88ac094a45c608cd894feb5eeec24b867527a Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/82629 Tested-by: build bot (Jenkins) Reviewed-by: Eric Lai Reviewed-by: Dinesh Gehlot Reviewed-by: Kapil Porwal --- .../brya/variants/baseboard/trulo/Makefile.mk | 5 --- .../google/brya/variants/baseboard/trulo/gpio.c | 46 ------------------- .../google/brya/variants/orisa/Makefile.mk | 5 +++ src/mainboard/google/brya/variants/orisa/gpio.c | 51 ++++++++++++++++++++++ .../google/brya/variants/trulo/Makefile.mk | 5 +++ src/mainboard/google/brya/variants/trulo/gpio.c | 51 ++++++++++++++++++++++ 6 files changed, 112 insertions(+), 51 deletions(-) delete mode 100644 src/mainboard/google/brya/variants/baseboard/trulo/gpio.c create mode 100644 src/mainboard/google/brya/variants/orisa/Makefile.mk create mode 100644 src/mainboard/google/brya/variants/orisa/gpio.c create mode 100644 src/mainboard/google/brya/variants/trulo/Makefile.mk create mode 100644 src/mainboard/google/brya/variants/trulo/gpio.c (limited to 'src/mainboard/google/brya') diff --git a/src/mainboard/google/brya/variants/baseboard/trulo/Makefile.mk b/src/mainboard/google/brya/variants/baseboard/trulo/Makefile.mk index 54a5c5b5c9..be05cd4e5c 100644 --- a/src/mainboard/google/brya/variants/baseboard/trulo/Makefile.mk +++ b/src/mainboard/google/brya/variants/baseboard/trulo/Makefile.mk @@ -1,8 +1,3 @@ ## SPDX-License-Identifier: GPL-2.0-only -bootblock-y += gpio.c - romstage-y += memory.c -romstage-y += gpio.c - -ramstage-y += gpio.c diff --git a/src/mainboard/google/brya/variants/baseboard/trulo/gpio.c b/src/mainboard/google/brya/variants/baseboard/trulo/gpio.c deleted file mode 100644 index 410f194f65..0000000000 --- a/src/mainboard/google/brya/variants/baseboard/trulo/gpio.c +++ /dev/null @@ -1,46 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ - -#include -#include -#include -#include -#include - -/* Pad configuration in ramstage */ -static const struct pad_config gpio_table[] = { - /* TODO */ -}; - -/* Early pad configuration in bootblock */ -static const struct pad_config early_gpio_table[] = { - /* TODO */ -}; - -const struct pad_config *__weak variant_gpio_table(size_t *num) -{ - *num = ARRAY_SIZE(gpio_table); - return gpio_table; -} - -const struct pad_config *__weak variant_gpio_override_table(size_t *num) -{ - *num = 0; - return NULL; -} - -const struct pad_config *__weak variant_early_gpio_table(size_t *num) -{ - *num = ARRAY_SIZE(early_gpio_table); - return early_gpio_table; -} - -static const struct cros_gpio cros_gpios[] = { - /* TODO */ -}; -DECLARE_CROS_GPIOS(cros_gpios); - -const struct pad_config *__weak variant_romstage_gpio_table(size_t *num) -{ - *num = 0; - return NULL; -} diff --git a/src/mainboard/google/brya/variants/orisa/Makefile.mk b/src/mainboard/google/brya/variants/orisa/Makefile.mk new file mode 100644 index 0000000000..91f031e7a4 --- /dev/null +++ b/src/mainboard/google/brya/variants/orisa/Makefile.mk @@ -0,0 +1,5 @@ +## SPDX-License-Identifier: GPL-2.0-only + +bootblock-y += gpio.c +romstage-y += gpio.c +ramstage-y += gpio.c diff --git a/src/mainboard/google/brya/variants/orisa/gpio.c b/src/mainboard/google/brya/variants/orisa/gpio.c new file mode 100644 index 0000000000..beee6fcb29 --- /dev/null +++ b/src/mainboard/google/brya/variants/orisa/gpio.c @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include +#include + +/* Pad configuration in ramstage */ +static const struct pad_config gpio_table[] = { + /* TODO */ +}; + +/* Early pad configuration in bootblock */ +static const struct pad_config early_gpio_table[] = { + /* TODO */ +}; + +/* Fill romstage gpio configuration */ +static const struct pad_config romstage_gpio_table[] = { + /* TODO */ +}; + +const struct pad_config *variant_gpio_table(size_t *num) +{ + *num = ARRAY_SIZE(gpio_table); + return gpio_table; +} + +const struct pad_config *variant_gpio_override_table(size_t *num) +{ + *num = 0; + return NULL; +} + +const struct pad_config *variant_early_gpio_table(size_t *num) +{ + *num = ARRAY_SIZE(early_gpio_table); + return early_gpio_table; +} + +static const struct cros_gpio cros_gpios[] = { + /* TODO */ +}; +DECLARE_CROS_GPIOS(cros_gpios); + +const struct pad_config *variant_romstage_gpio_table(size_t *num) +{ + *num = ARRAY_SIZE(romstage_gpio_table); + return romstage_gpio_table; +} diff --git a/src/mainboard/google/brya/variants/trulo/Makefile.mk b/src/mainboard/google/brya/variants/trulo/Makefile.mk new file mode 100644 index 0000000000..91f031e7a4 --- /dev/null +++ b/src/mainboard/google/brya/variants/trulo/Makefile.mk @@ -0,0 +1,5 @@ +## SPDX-License-Identifier: GPL-2.0-only + +bootblock-y += gpio.c +romstage-y += gpio.c +ramstage-y += gpio.c diff --git a/src/mainboard/google/brya/variants/trulo/gpio.c b/src/mainboard/google/brya/variants/trulo/gpio.c new file mode 100644 index 0000000000..beee6fcb29 --- /dev/null +++ b/src/mainboard/google/brya/variants/trulo/gpio.c @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include +#include + +/* Pad configuration in ramstage */ +static const struct pad_config gpio_table[] = { + /* TODO */ +}; + +/* Early pad configuration in bootblock */ +static const struct pad_config early_gpio_table[] = { + /* TODO */ +}; + +/* Fill romstage gpio configuration */ +static const struct pad_config romstage_gpio_table[] = { + /* TODO */ +}; + +const struct pad_config *variant_gpio_table(size_t *num) +{ + *num = ARRAY_SIZE(gpio_table); + return gpio_table; +} + +const struct pad_config *variant_gpio_override_table(size_t *num) +{ + *num = 0; + return NULL; +} + +const struct pad_config *variant_early_gpio_table(size_t *num) +{ + *num = ARRAY_SIZE(early_gpio_table); + return early_gpio_table; +} + +static const struct cros_gpio cros_gpios[] = { + /* TODO */ +}; +DECLARE_CROS_GPIOS(cros_gpios); + +const struct pad_config *variant_romstage_gpio_table(size_t *num) +{ + *num = ARRAY_SIZE(romstage_gpio_table); + return romstage_gpio_table; +} -- cgit v1.2.3