mb/google/brya/variants/felwinter: Enable Bluetooth offload support

Add fw_config support NMAX98360_ALC5682VS_I2S_2WAY and I2S2 vgpio
config and enabling cnvi_bt_audio_offload UPD bit.

BUG=none
TEST=emerge-brya coreboot

Signed-off-by: Mac Chiang <mac.chiang@intel.com>

Change-Id: I64a4e5479905911b2e9d1597b78131720abb689e
Reviewed-on: https://review.coreboot.org/c/coreboot/+/64691
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
diff --git a/src/mainboard/google/brya/variants/felwinter/Makefile.inc b/src/mainboard/google/brya/variants/felwinter/Makefile.inc
index 0256c73..d97f2af6 100644
--- a/src/mainboard/google/brya/variants/felwinter/Makefile.inc
+++ b/src/mainboard/google/brya/variants/felwinter/Makefile.inc
@@ -3,3 +3,6 @@
 
 ramstage-y += gpio.c
 ramstage-$(CONFIG_FW_CONFIG) += variant.c
+
+ramstage-$(CONFIG_FW_CONFIG) += fw_config.c
+ramstage-$(CONFIG_FW_CONFIG) += variant.c
diff --git a/src/mainboard/google/brya/variants/felwinter/fw_config.c b/src/mainboard/google/brya/variants/felwinter/fw_config.c
new file mode 100644
index 0000000..2a89c94
--- /dev/null
+++ b/src/mainboard/google/brya/variants/felwinter/fw_config.c
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <bootstate.h>
+#include <console/console.h>
+#include <fw_config.h>
+#include <gpio.h>
+
+static const struct pad_config bt_i2s_enable_pads[] = {
+	PAD_CFG_NF(GPP_VGPIO_30, NONE, DEEP, NF3),	/* BT_I2S_BCLK */
+	PAD_CFG_NF(GPP_VGPIO_31, NONE, DEEP, NF3),	/* BT_I2S_SYNC */
+	PAD_CFG_NF(GPP_VGPIO_32, NONE, DEEP, NF3),	/* BT_I2S_SDO */
+	PAD_CFG_NF(GPP_VGPIO_33, NONE, DEEP, NF3),	/* BT_I2S_SDI */
+	PAD_CFG_NF(GPP_VGPIO_34, NONE, DEEP, NF1),	/* SSP2_SCLK */
+	PAD_CFG_NF(GPP_VGPIO_35, NONE, DEEP, NF1),	/* SSP2_SFRM */
+	PAD_CFG_NF(GPP_VGPIO_36, NONE, DEEP, NF1),	/* SSP_TXD */
+	PAD_CFG_NF(GPP_VGPIO_37, NONE, DEEP, NF1),	/* SSP_RXD */
+};
+
+static const struct pad_config bt_i2s_disable_pads[] = {
+	PAD_NC(GPP_VGPIO_30, NONE),
+	PAD_NC(GPP_VGPIO_31, NONE),
+	PAD_NC(GPP_VGPIO_32, NONE),
+	PAD_NC(GPP_VGPIO_33, NONE),
+	PAD_NC(GPP_VGPIO_34, NONE),
+	PAD_NC(GPP_VGPIO_35, NONE),
+	PAD_NC(GPP_VGPIO_36, NONE),
+	PAD_NC(GPP_VGPIO_37, NONE),
+};
+
+static void fw_config_handle(void *unused)
+{
+	if (!fw_config_is_provisioned() ||
+	     fw_config_probe(FW_CONFIG(AUDIO_AMP, UNPROVISIONED))) {
+		printk(BIOS_INFO, "Disable BT offload audio related GPIO pins.\n");
+		gpio_configure_pads(bt_i2s_disable_pads, ARRAY_SIZE(bt_i2s_disable_pads));
+		return;
+	}
+
+	if (fw_config_probe(FW_CONFIG(AUDIO_AMP, MAX98360_ALC5682VS_I2S_2WAY))) {
+		printk(BIOS_INFO, "BT offload enabled over I2S with MAX98360+RT5682VS\n");
+		gpio_configure_pads(bt_i2s_enable_pads, ARRAY_SIZE(bt_i2s_enable_pads));
+	}
+
+}
+BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fw_config_handle, NULL);
diff --git a/src/mainboard/google/brya/variants/felwinter/variant.c b/src/mainboard/google/brya/variants/felwinter/variant.c
index b0bf99a..59a4d83 100644
--- a/src/mainboard/google/brya/variants/felwinter/variant.c
+++ b/src/mainboard/google/brya/variants/felwinter/variant.c
@@ -17,4 +17,6 @@
 		config->typec_aux_bias_pads[2].pad_auxn_dc = GPP_A20;
 		config->tcss_aux_ori = 0x10;
 	}
+	config->cnvi_bt_audio_offload = fw_config_probe(FW_CONFIG(AUDIO_AMP,
+						MAX98360_ALC5682VS_I2S_2WAY));
 }