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 <kapilporwal@google.com>
Change-Id: I0ed452a0d08e6779add318d9bbd1e97b50b6aea9
Reviewed-on: https://review.coreboot.org/c/coreboot/+/73121
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
This commit is contained in:
Kapil Porwal
2023-02-19 22:07:55 +05:30
committed by Felix Held
parent 8c1075a592
commit 8618bc6c9f
2 changed files with 59 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,58 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <baseboard/variants.h>
#include <bootstate.h>
#include <console/console.h>
#include <fw_config.h>
#include <gpio.h>
#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);
}
}