From a6de947a6baada8a0633d86e0bf3abda3e80405c Mon Sep 17 00:00:00 2001 From: Reka Norman Date: Wed, 6 Apr 2022 20:34:07 +1000 Subject: mb/google/brya/var/nereid: Configure descriptor for either Type-C or HDMI Some bytes in the descriptor need to be set differently for Type-C and HDMI. To allow using a single firmware variant for both cases, update the descriptor at runtime based on fw_config. This is a temporary workaround while we find a better solution. The byte values were determined by changing the following CSE strap and comparing the generated descriptors: Type-C: TypeCPort2Config = "No Thunderbolt" HDMI: TypeCPort2Config = "DP Fixed Connection" The default value before updating the descriptor is Type-C, but this was chosen arbitrarily. BUG=b:226848617 TEST=Type-C and HDMI both work on nereid with fw_config set correctly. Change-Id: I2cc230e3bd35816c81989ae7e01df5d2c152062e Signed-off-by: Reka Norman Reviewed-on: https://review.coreboot.org/c/coreboot/+/63366 Tested-by: build bot (Jenkins) Reviewed-by: Eric Lai Reviewed-by: Sam McNally --- src/mainboard/google/brya/Kconfig.name | 1 + src/mainboard/google/brya/bootblock.c | 7 +++++ .../baseboard/include/baseboard/variants.h | 2 ++ .../google/brya/variants/nereid/Makefile.inc | 1 + .../google/brya/variants/nereid/variant.c | 30 ++++++++++++++++++++++ 5 files changed, 41 insertions(+) diff --git a/src/mainboard/google/brya/Kconfig.name b/src/mainboard/google/brya/Kconfig.name index 3126d28495..4be201403b 100644 --- a/src/mainboard/google/brya/Kconfig.name +++ b/src/mainboard/google/brya/Kconfig.name @@ -90,6 +90,7 @@ config BOARD_GOOGLE_NIVVIKS config BOARD_GOOGLE_NEREID bool "-> Nereid" + select ALDERLAKE_CONFIGURE_DESCRIPTOR select BOARD_GOOGLE_BASEBOARD_NISSA config BOARD_GOOGLE_PRIMUS diff --git a/src/mainboard/google/brya/bootblock.c b/src/mainboard/google/brya/bootblock.c index 1815615f5e..c24e9590e2 100644 --- a/src/mainboard/google/brya/bootblock.c +++ b/src/mainboard/google/brya/bootblock.c @@ -10,3 +10,10 @@ void bootblock_mainboard_early_init(void) pads = variant_early_gpio_table(&num); gpio_configure_pads(pads, num); } + +void bootblock_mainboard_init(void) +{ + variant_update_descriptor(); +} + +void __weak variant_update_descriptor(void) {} diff --git a/src/mainboard/google/brya/variants/baseboard/include/baseboard/variants.h b/src/mainboard/google/brya/variants/baseboard/include/baseboard/variants.h index 8c79a8a871..baf05979ca 100644 --- a/src/mainboard/google/brya/variants/baseboard/include/baseboard/variants.h +++ b/src/mainboard/google/brya/variants/baseboard/include/baseboard/variants.h @@ -34,6 +34,8 @@ void variant_generate_s0ix_hook(enum s0ix_entry); /* Modify devictree settings during ramstage */ void variant_devtree_update(void); +void variant_update_descriptor(void); + struct cpu_power_limits { uint16_t mchid; u8 cpu_tdp; diff --git a/src/mainboard/google/brya/variants/nereid/Makefile.inc b/src/mainboard/google/brya/variants/nereid/Makefile.inc index 2e8157e135..16c9748225 100644 --- a/src/mainboard/google/brya/variants/nereid/Makefile.inc +++ b/src/mainboard/google/brya/variants/nereid/Makefile.inc @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only bootblock-y += gpio.c +bootblock-y += variant.c romstage-y += gpio.c romstage-y += memory.c diff --git a/src/mainboard/google/brya/variants/nereid/variant.c b/src/mainboard/google/brya/variants/nereid/variant.c index 967fc9ad02..74afb2702b 100644 --- a/src/mainboard/google/brya/variants/nereid/variant.c +++ b/src/mainboard/google/brya/variants/nereid/variant.c @@ -1,7 +1,10 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ +#include +#include #include #include +#include const char *mainboard_vbt_filename(void) { @@ -10,3 +13,30 @@ const char *mainboard_vbt_filename(void) return "vbt.bin"; } + +void variant_update_descriptor(void) +{ + /* TypeCPort2Config = "No Thunderbolt" */ + struct descriptor_byte typec_bytes[] = { + { 0xc76, 0xb7 }, + { 0xc77, 0xb6 }, + { 0xc7c, 0xee }, + { 0xca0, 0x0c }, + }; + + /* TypeCPort2Config = "DP Fixed Connection" */ + struct descriptor_byte hdmi_bytes[] = { + { 0xc76, 0x75 }, + { 0xc77, 0xc4 }, + { 0xc7c, 0x1e }, + { 0xca0, 0x0e }, + }; + + if (fw_config_probe(FW_CONFIG(DB_USB, DB_1A_HDMI))) { + printk(BIOS_INFO, "Configuring descriptor for HDMI\n"); + configure_descriptor(hdmi_bytes, ARRAY_SIZE(hdmi_bytes)); + } else { + printk(BIOS_INFO, "Configuring descriptor for Type-C\n"); + configure_descriptor(typec_bytes, ARRAY_SIZE(typec_bytes)); + } +} -- cgit v1.2.3