From 8618bc6c9f2f48ad612bcd13409ffaf9014b5b63 Mon Sep 17 00:00:00 2001 From: Kapil Porwal Date: Sun, 19 Feb 2023 22:07:55 +0530 Subject: mb/google/rex: Set audio GPIOs based on fw_config Define some actions based on probe results for audio: - Disable the SoundWire GPIOs when I2S option is selected. - Disable the I2S GPIOs when SoundWire option is selected. - Disable all the GPIOs when no audio is enabled. BUG=b:269497731 TEST=Test that GPIOs are configured based on the current value of the fw_config field in cbi. Signed-off-by: Kapil Porwal Change-Id: I0ed452a0d08e6779add318d9bbd1e97b50b6aea9 Reviewed-on: https://review.coreboot.org/c/coreboot/+/73121 Tested-by: build bot (Jenkins) Reviewed-by: Eric Lai --- .../google/rex/variants/rex0/Makefile.inc | 1 + src/mainboard/google/rex/variants/rex0/fw_config.c | 58 ++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/mainboard/google/rex/variants/rex0/fw_config.c diff --git a/src/mainboard/google/rex/variants/rex0/Makefile.inc b/src/mainboard/google/rex/variants/rex0/Makefile.inc index 86a10df2a0..cdbf407ca5 100644 --- a/src/mainboard/google/rex/variants/rex0/Makefile.inc +++ b/src/mainboard/google/rex/variants/rex0/Makefile.inc @@ -2,3 +2,4 @@ bootblock-y += gpio.c romstage-y += gpio.c ramstage-y += gpio.c ramstage-y += variant.c +ramstage-$(CONFIG_FW_CONFIG) += fw_config.c diff --git a/src/mainboard/google/rex/variants/rex0/fw_config.c b/src/mainboard/google/rex/variants/rex0/fw_config.c new file mode 100644 index 0000000000..7d7c901270 --- /dev/null +++ b/src/mainboard/google/rex/variants/rex0/fw_config.c @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include +#include + +#define GPIO_PADBASED_OVERRIDE(b, a) gpio_padbased_override(b, a, ARRAY_SIZE(a)) + +static const struct pad_config dmic_disable_pads[] = { + PAD_NC(GPP_S02, NONE), + PAD_NC(GPP_S03, NONE), + PAD_NC(GPP_S06, NONE), + PAD_NC(GPP_S07, NONE), +}; + +static const struct pad_config sndw_disable_pads[] = { + PAD_NC(GPP_S00, NONE), + PAD_NC(GPP_S01, NONE), + PAD_NC(GPP_S04, NONE), + PAD_NC(GPP_S05, NONE), +}; + +static const struct pad_config i2s_disable_pads[] = { + PAD_NC(GPP_D09, NONE), + PAD_NC(GPP_D10, NONE), + PAD_NC(GPP_D11, NONE), + PAD_NC(GPP_D12, DN_20K), + PAD_NC(GPP_D13, NONE), + PAD_NC(GPP_D14, NONE), + PAD_NC(GPP_D15, NONE), + PAD_NC(GPP_D16, NONE), + PAD_NC(GPP_D17, NONE), +}; + +void fw_config_gpio_padbased_override(struct pad_config *padbased_table) +{ + if (!fw_config_is_provisioned()) { + GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); + GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads); + GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); + return; + } + + if (fw_config_probe(FW_CONFIG(AUDIO, AUDIO_UNKNOWN))) { + printk(BIOS_INFO, "Configure GPIOs for no audio.\n"); + GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); + GPIO_PADBASED_OVERRIDE(padbased_table, dmic_disable_pads); + GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); + } else if (fw_config_probe(FW_CONFIG(AUDIO, MAX98363_CS42L42_SNDW))) { + printk(BIOS_INFO, "Configure GPIOs for SoundWire audio.\n"); + GPIO_PADBASED_OVERRIDE(padbased_table, i2s_disable_pads); + } else if (fw_config_probe(FW_CONFIG(AUDIO, MAX98360_ALC5682I_I2S))) { + printk(BIOS_INFO, "Configure GPIOs for I2S audio.\n"); + GPIO_PADBASED_OVERRIDE(padbased_table, sndw_disable_pads); + } +} -- cgit v1.2.3