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 <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/82629
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Eric Lai <ericllai@google.com>
Reviewed-by: Dinesh Gehlot <digehlot@google.com>
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
This commit is contained in:
Subrata Banik
2024-05-24 01:40:27 +05:30
parent 2889787522
commit 4050ef091a
5 changed files with 72 additions and 11 deletions

View File

@@ -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

View File

@@ -0,0 +1,5 @@
## SPDX-License-Identifier: GPL-2.0-only
bootblock-y += gpio.c
romstage-y += gpio.c
ramstage-y += gpio.c

View File

@@ -16,19 +16,24 @@ static const struct pad_config early_gpio_table[] = {
/* TODO */
};
const struct pad_config *__weak variant_gpio_table(size_t *num)
/* 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 *__weak variant_gpio_override_table(size_t *num)
const struct pad_config *variant_gpio_override_table(size_t *num)
{
*num = 0;
return NULL;
}
const struct pad_config *__weak variant_early_gpio_table(size_t *num)
const struct pad_config *variant_early_gpio_table(size_t *num)
{
*num = ARRAY_SIZE(early_gpio_table);
return early_gpio_table;
@@ -39,8 +44,8 @@ static const struct cros_gpio cros_gpios[] = {
};
DECLARE_CROS_GPIOS(cros_gpios);
const struct pad_config *__weak variant_romstage_gpio_table(size_t *num)
const struct pad_config *variant_romstage_gpio_table(size_t *num)
{
*num = 0;
return NULL;
*num = ARRAY_SIZE(romstage_gpio_table);
return romstage_gpio_table;
}

View File

@@ -0,0 +1,5 @@
## SPDX-License-Identifier: GPL-2.0-only
bootblock-y += gpio.c
romstage-y += gpio.c
ramstage-y += gpio.c

View File

@@ -0,0 +1,51 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include <baseboard/gpio.h>
#include <baseboard/variants.h>
#include <soc/gpio.h>
#include <types.h>
#include <vendorcode/google/chromeos/chromeos.h>
/* 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;
}