From 03807acfa968da58d3596a5b23e2aeabbb984fa8 Mon Sep 17 00:00:00 2001 From: Terry Cheong Date: Thu, 7 Dec 2023 19:39:41 +0800 Subject: mb/google/rex/var/screebo: set audio GPIO pins based on fw_config Enable BT offload when I2S option is selected for screebo. BUG=b:275538390 TEST=Verified audio playback using BT speaker/headset in I2S mode on google/screebo. Fixes: https://review.coreboot.org/c/coreboot/+/77755 Change-Id: I7ebe8e28d35428ce2fb8129dc145fec9ac60f9da Signed-off-by: Terry Cheong Reviewed-on: https://review.coreboot.org/c/coreboot/+/79378 Reviewed-by: Subrata Banik Tested-by: build bot (Jenkins) --- .../google/rex/variants/screebo/Makefile.inc | 1 + .../google/rex/variants/screebo/fw_config.c | 87 ++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 src/mainboard/google/rex/variants/screebo/fw_config.c diff --git a/src/mainboard/google/rex/variants/screebo/Makefile.inc b/src/mainboard/google/rex/variants/screebo/Makefile.inc index 8bea0ff390..7bc4fba5a0 100644 --- a/src/mainboard/google/rex/variants/screebo/Makefile.inc +++ b/src/mainboard/google/rex/variants/screebo/Makefile.inc @@ -6,3 +6,4 @@ romstage-y += gpio.c romstage-y += memory.c ramstage-y += gpio.c ramstage-y += variant.c +ramstage-$(CONFIG_FW_CONFIG) += fw_config.c diff --git a/src/mainboard/google/rex/variants/screebo/fw_config.c b/src/mainboard/google/rex/variants/screebo/fw_config.c new file mode 100644 index 0000000000..18b1089dbf --- /dev/null +++ b/src/mainboard/google/rex/variants/screebo/fw_config.c @@ -0,0 +1,87 @@ +/* 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 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), +}; + + +static const struct pad_config bt_i2s_enable_pads[] = { + /* GPP_V30 : [] ==> BT_I2S_BCLK */ + PAD_CFG_NF(GPP_VGPIO30, NONE, DEEP, NF2), + /* GPP_V31 : [] ==> BT_I2S_SYNC */ + PAD_CFG_NF(GPP_VGPIO31, NONE, DEEP, NF2), + /* GPP_V32 : [] ==> BT_I2S_SDO */ + PAD_CFG_NF(GPP_VGPIO32, NONE, DEEP, NF2), + /* GPP_V33 : [] ==> BT_I2S_SDI */ + PAD_CFG_NF(GPP_VGPIO33, NONE, DEEP, NF2), + /* GPP_V34 : [] ==> SSP2_SCLK */ + PAD_CFG_NF(GPP_VGPIO34, NONE, DEEP, NF1), + /* GPP_V35 : [] ==> SSP2_SFRM */ + PAD_CFG_NF(GPP_VGPIO35, NONE, DEEP, NF1), + /* GPP_V36 : [] ==> SSP_TXD */ + PAD_CFG_NF(GPP_VGPIO36, NONE, DEEP, NF1), + /* GPP_V37 : [] ==> SSP_RXD */ + PAD_CFG_NF(GPP_VGPIO37, NONE, DEEP, NF1), +}; + +static const struct pad_config bt_i2s_disable_pads[] = { + /* GPP_V30 : [] ==> BT_I2S_BCLK */ + PAD_NC(GPP_VGPIO30, NONE), + /* GPP_V31 : [] ==> BT_I2S_SYNC */ + PAD_NC(GPP_VGPIO31, NONE), + /* GPP_V32 : [] ==> BT_I2S_SDO */ + PAD_NC(GPP_VGPIO32, NONE), + /* GPP_V33 : [] ==> BT_I2S_SDI */ + PAD_NC(GPP_VGPIO33, NONE), + /* GPP_V34 : [] ==> SSP2_SCLK */ + PAD_NC(GPP_VGPIO34, NONE), + /* GPP_V35 : [] ==> SSP2_SFRM */ + PAD_NC(GPP_VGPIO35, NONE), + /* GPP_V36 : [] ==> SSP_TXD */ + PAD_NC(GPP_VGPIO36, NONE), + /* GPP_V37 : [] ==> SSP_RXD */ + PAD_NC(GPP_VGPIO37, 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, bt_i2s_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, bt_i2s_disable_pads); + } else if (fw_config_probe(FW_CONFIG(AUDIO, ALC1019_ALC5682I_I2S))) { + printk(BIOS_INFO, "Configure GPIOs for BT offload mode.\n"); + GPIO_PADBASED_OVERRIDE(padbased_table, bt_i2s_enable_pads); + } +} -- cgit v1.2.3