Kane Chen has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/59558 )
Change subject: mb/google/zork/var/shuboz: Add fw_config probe for ALC5682-VD & VS ......................................................................
mb/google/zork/var/shuboz: Add fw_config probe for ALC5682-VD & VS
ALC5682-VD/ALC5682I-VS load different kernel driver by different hid name. Update hid name and machine_dev depending on the AUDIO_CODEC_SOURCE field of fw_config. Define FW_CONFIG bits 36 - 37 (SSFC bits 4 - 5) for codec selection.
ALC5682-VD: _HID = "10EC5682" ALC5682I-VS: _HID = "RTL5682"
BUG=b:198689479 BRANCH=zork TEST=ALC5682-VD/ALC5682I-VS audio codec can work
Signed-off-by: Kane Chen kane_chen@pegatron.corp-partner.google.com Change-Id: I0c78aa166010ffa4d0cacc8a11d418d5a6906749 --- M src/mainboard/google/zork/variants/baseboard/helpers.c M src/mainboard/google/zork/variants/shuboz/overridetree.cb M src/mainboard/google/zork/variants/shuboz/variant.c 3 files changed, 65 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/58/59558/1
diff --git a/src/mainboard/google/zork/variants/baseboard/helpers.c b/src/mainboard/google/zork/variants/baseboard/helpers.c index d6c5e48..7057a48 100644 --- a/src/mainboard/google/zork/variants/baseboard/helpers.c +++ b/src/mainboard/google/zork/variants/baseboard/helpers.c @@ -55,6 +55,9 @@ /* Audio AMP type */ FW_CONFIG_MASK_AUDIO_AMP = 0x1, FW_CONFIG_SHIFT_AUDIO_AMP = 35, + /* Audio codec type */ + FW_CONFIG_MASK_AUDIO_CODEC_SOURCE = 0x3, + FW_CONFIG_SHIFT_AUDIO_CODEC_SOURCE = 36, };
static int get_fw_config(uint64_t *val) diff --git a/src/mainboard/google/zork/variants/shuboz/overridetree.cb b/src/mainboard/google/zork/variants/shuboz/overridetree.cb index c3cc9e6..0b31a77 100644 --- a/src/mainboard/google/zork/variants/shuboz/overridetree.cb +++ b/src/mainboard/google/zork/variants/shuboz/overridetree.cb @@ -1,4 +1,10 @@ # SPDX-License-Identifier: GPL-2.0-or-later +fw_config + field AUDIO_CODEC_SOURCE 36 37 + option AUDIO_CODEC_ALC5682 0 + option AUDIO_CODEC_ALC5682I_VS 1 + end +end
chip soc/amd/picasso
diff --git a/src/mainboard/google/zork/variants/shuboz/variant.c b/src/mainboard/google/zork/variants/shuboz/variant.c index 9907c72..c5e6581 100644 --- a/src/mainboard/google/zork/variants/shuboz/variant.c +++ b/src/mainboard/google/zork/variants/shuboz/variant.c @@ -3,6 +3,12 @@ #include <baseboard/variants.h> #include <soc/pci_devs.h> #include "chip.h" +#include <fw_config.h> +#include <drivers/i2c/generic/chip.h> +#include <drivers/amd/i2s_machine_dev/chip.h> +#include <device/device.h> +#include <device/path.h> +#include <console/console.h>
uint32_t usb_oc_map_override[USB_PORT_COUNT] = { USB_OC_PIN_0, @@ -42,6 +48,55 @@ *ddi_num = ARRAY_SIZE(hdmi_ddi_descriptors); }
+extern struct chip_operations drivers_i2c_generic_ops; +extern struct chip_operations drivers_amd_i2s_machine_dev_ops; + +static void audio_codec_update(void) +{ + const struct device_path codec_path[] = { + {.type = DEVICE_PATH_PCI, .pci.devfn = LPC_DEVFN}, + {.type = DEVICE_PATH_PNP, .pnp.port = 0xc09, .pnp.device = 0}, + {.type = DEVICE_PATH_GENERIC, .generic.id = 0}, + {.type = DEVICE_PATH_I2C, .i2c.device = 0x1a, .i2c.mode_10bit = I2C_MODE_7_BIT } + }; + const struct device_path machine_dev_path[] = { + {.type = DEVICE_PATH_PCI, .pci.devfn = PCIE_GPP_A_DEVFN}, + {.type = DEVICE_PATH_PCI, .pci.devfn = AUDIO_DEVFN}, + {.type = DEVICE_PATH_GENERIC, .generic.id = 0, .generic.subid = 0} + }; + const struct device *codec = + find_dev_nested_path(pci_root_bus(), codec_path, ARRAY_SIZE(codec_path)); + struct drivers_i2c_generic_config *config; + + if (!codec || (codec->chip_ops != &drivers_i2c_generic_ops) || !codec->chip_info) + return; + + config = codec->chip_info; + + if (fw_config_probe(FW_CONFIG(AUDIO_CODEC_SOURCE, AUDIO_CODEC_ALC5682))) + config->hid = "10EC5682"; + else if (fw_config_probe(FW_CONFIG(AUDIO_CODEC_SOURCE, AUDIO_CODEC_ALC5682I_VS))) + config->hid = "RTL5682"; + printk(BIOS_INFO, "Configure audio codec, config->hid %s\n", config->hid); + + const struct device *machine_dev = + find_dev_nested_path(pci_root_bus(), machine_dev_path, ARRAY_SIZE(machine_dev_path)); + struct drivers_amd_i2s_machine_dev_config *machine_dev_config; + + if (!machine_dev || (machine_dev->chip_ops != &drivers_amd_i2s_machine_dev_ops) || !machine_dev->chip_info) { + machine_dev_config = machine_dev->chip_info; + return; + } + machine_dev_config = machine_dev->chip_info; + + if (fw_config_probe(FW_CONFIG(AUDIO_CODEC_SOURCE, AUDIO_CODEC_ALC5682))) + machine_dev_config->hid = "AMDI5682"; + else if (fw_config_probe(FW_CONFIG(AUDIO_CODEC_SOURCE, AUDIO_CODEC_ALC5682I_VS))) + machine_dev_config->hid = "10029835"; + printk(BIOS_INFO, "Configure i2s device, machine_dev_config->hid %s\n", machine_dev_config->hid); + +} + void variant_devtree_update(void) { struct soc_amd_picasso_config *soc_cfg; @@ -56,4 +111,5 @@ for (i = 0; i < USB_PORT_COUNT; i++) soc_cfg->usb_port_overcurrent_pin[i] = usb_oc_map_override[i]; } + audio_codec_update(); }