Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/82582?usp=email )
Change subject: mb/amd/birman: factor out get_ddi1_type ......................................................................
mb/amd/birman: factor out get_ddi1_type
Both port descriptor files used in the FSP case contain an identical get_ddi1_type implementation, so factor it out into a separate file. This will also allow using the same function in the openSIL case in a following patch.
Signed-off-by: Felix Held felix-coreboot@felixheld.de Change-Id: I6f5b75b9bdbdc67901d157079785c8fa2915bf0c Reviewed-on: https://review.coreboot.org/c/coreboot/+/82582 Reviewed-by: Matt DeVillier matt.devillier@amd.corp-partner.google.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/mainboard/amd/birman/Makefile.mk A src/mainboard/amd/birman/display_card_type.c A src/mainboard/amd/birman/display_card_type.h M src/mainboard/amd/birman/port_descriptors_glinda.c M src/mainboard/amd/birman/port_descriptors_phoenix.c 5 files changed, 56 insertions(+), 79 deletions(-)
Approvals: Matt DeVillier: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/src/mainboard/amd/birman/Makefile.mk b/src/mainboard/amd/birman/Makefile.mk index 2df1f59..a784d1a 100644 --- a/src/mainboard/amd/birman/Makefile.mk +++ b/src/mainboard/amd/birman/Makefile.mk @@ -4,10 +4,12 @@ bootblock-y += early_gpio.c bootblock-y += ec.c
+romstage-y += display_card_type.c romstage-$(CONFIG_BOARD_AMD_BIRMAN_PHOENIX_FSP) += port_descriptors_phoenix.c romstage-$(CONFIG_BOARD_AMD_BIRMAN_GLINDA) += port_descriptors_glinda.c
ramstage-y += chromeos.c +ramstage-y += display_card_type.c ramstage-y += gpio.c ramstage-$(CONFIG_BOARD_AMD_BIRMAN_PHOENIX_OPENSIL) += update_devicetree_phoenix_opensil.c ramstage-$(CONFIG_BOARD_AMD_BIRMAN_PHOENIX_FSP) += port_descriptors_phoenix.c diff --git a/src/mainboard/amd/birman/display_card_type.c b/src/mainboard/amd/birman/display_card_type.c new file mode 100644 index 0000000..21f536f --- /dev/null +++ b/src/mainboard/amd/birman/display_card_type.c @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/console.h> +#include <device/i2c_simple.h> +#if CONFIG(PLATFORM_USES_FSP2_0) +#include <soc/platform_descriptors.h> +#else +#include <soc/amd/phoenix/chip_opensil.h> +#endif +#include <types.h> +#include "display_card_type.h" + +uint8_t get_ddi1_type(void) +{ + const uint8_t eeprom_i2c_bus = 2; + const uint8_t eeprom_i2c_address = 0x55; + const uint16_t eeprom_connector_type_offset = 2; + uint8_t eeprom_connector_type_data[2]; + uint16_t connector_type; + + if (i2c_2ba_read_bytes(eeprom_i2c_bus, eeprom_i2c_address, + eeprom_connector_type_offset, eeprom_connector_type_data, + sizeof(eeprom_connector_type_data))) { + printk(BIOS_NOTICE, + "Display connector type couldn't be determined. Disabling DDI1.\n"); + return DDI_UNUSED_TYPE; + } + + connector_type = eeprom_connector_type_data[1] | eeprom_connector_type_data[0] << 8; + + switch (connector_type) { + case 0x0c: + printk(BIOS_DEBUG, "Configuring DDI1 as HDMI.\n"); + return DDI_HDMI; + case 0x13: + printk(BIOS_DEBUG, "Configuring DDI1 as DP.\n"); + return DDI_DP; + case 0x14: + printk(BIOS_DEBUG, "Configuring DDI1 as eDP.\n"); + return DDI_EDP; + case 0x17: + printk(BIOS_DEBUG, "Configuring DDI1 as USB-C.\n"); + return DDI_DP_W_TYPEC; + default: + printk(BIOS_WARNING, "Unexpected display connector type %x. Disabling DDI1.\n", + connector_type); + return DDI_UNUSED_TYPE; + } +} diff --git a/src/mainboard/amd/birman/display_card_type.h b/src/mainboard/amd/birman/display_card_type.h new file mode 100644 index 0000000..bb23fd4 --- /dev/null +++ b/src/mainboard/amd/birman/display_card_type.h @@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +uint8_t get_ddi1_type(void); diff --git a/src/mainboard/amd/birman/port_descriptors_glinda.c b/src/mainboard/amd/birman/port_descriptors_glinda.c index a0dbd17..2af7d26 100644 --- a/src/mainboard/amd/birman/port_descriptors_glinda.c +++ b/src/mainboard/amd/birman/port_descriptors_glinda.c @@ -1,10 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0-only */
-#include <console/console.h> -#include <device/i2c_simple.h> #include <gpio.h> #include <soc/platform_descriptors.h> #include <types.h> +#include "display_card_type.h"
/* TODO: Update for birman */
@@ -79,44 +78,6 @@ } };
-static uint8_t get_ddi1_type(void) -{ - const uint8_t eeprom_i2c_bus = 2; - const uint8_t eeprom_i2c_address = 0x55; - const uint16_t eeprom_connector_type_offset = 2; - uint8_t eeprom_connector_type_data[2]; - uint16_t connector_type; - - if (i2c_2ba_read_bytes(eeprom_i2c_bus, eeprom_i2c_address, - eeprom_connector_type_offset, eeprom_connector_type_data, - sizeof(eeprom_connector_type_data))) { - printk(BIOS_NOTICE, - "Display connector type couldn't be determined. Disabling DDI1.\n"); - return DDI_UNUSED_TYPE; - } - - connector_type = eeprom_connector_type_data[1] | eeprom_connector_type_data[0] << 8; - - switch (connector_type) { - case 0x0c: - printk(BIOS_DEBUG, "Configuring DDI1 as HDMI.\n"); - return DDI_HDMI; - case 0x13: - printk(BIOS_DEBUG, "Configuring DDI1 as DP.\n"); - return DDI_DP; - case 0x14: - printk(BIOS_DEBUG, "Configuring DDI1 as eDP.\n"); - return DDI_EDP; - case 0x17: - printk(BIOS_DEBUG, "Configuring DDI1 as USB-C.\n"); - return DDI_DP_W_TYPEC; - default: - printk(BIOS_WARNING, "Unexpected display connector type %x. Disabling DDI1.\n", - connector_type); - return DDI_UNUSED_TYPE; - } -} - void mainboard_get_dxio_ddi_descriptors( const fsp_dxio_descriptor **dxio_descs, size_t *dxio_num, const fsp_ddi_descriptor **ddi_descs, size_t *ddi_num) diff --git a/src/mainboard/amd/birman/port_descriptors_phoenix.c b/src/mainboard/amd/birman/port_descriptors_phoenix.c index 8ab7417..da07e31 100644 --- a/src/mainboard/amd/birman/port_descriptors_phoenix.c +++ b/src/mainboard/amd/birman/port_descriptors_phoenix.c @@ -1,11 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0-only */
#include <console/console.h> -#include <device/i2c_simple.h> #include <gpio.h> #include <soc/platform_descriptors.h> #include <soc/soc_util.h> #include <types.h> +#include "display_card_type.h"
#define phx_mxm_dxio_descriptor { \ .engine_type = PCIE_ENGINE, \ @@ -163,44 +163,6 @@ } };
-static uint8_t get_ddi1_type(void) -{ - const uint8_t eeprom_i2c_bus = 2; - const uint8_t eeprom_i2c_address = 0x55; - const uint16_t eeprom_connector_type_offset = 2; - uint8_t eeprom_connector_type_data[2]; - uint16_t connector_type; - - if (i2c_2ba_read_bytes(eeprom_i2c_bus, eeprom_i2c_address, - eeprom_connector_type_offset, eeprom_connector_type_data, - sizeof(eeprom_connector_type_data))) { - printk(BIOS_NOTICE, - "Display connector type couldn't be determined. Disabling DDI1.\n"); - return DDI_UNUSED_TYPE; - } - - connector_type = eeprom_connector_type_data[1] | eeprom_connector_type_data[0] << 8; - - switch (connector_type) { - case 0x0c: - printk(BIOS_DEBUG, "Configuring DDI1 as HDMI.\n"); - return DDI_HDMI; - case 0x13: - printk(BIOS_DEBUG, "Configuring DDI1 as DP.\n"); - return DDI_DP; - case 0x14: - printk(BIOS_DEBUG, "Configuring DDI1 as eDP.\n"); - return DDI_EDP; - case 0x17: - printk(BIOS_DEBUG, "Configuring DDI1 as USB-C.\n"); - return DDI_DP_W_TYPEC; - default: - printk(BIOS_WARNING, "Unexpected display connector type %x. Disabling DDI1.\n", - connector_type); - return DDI_UNUSED_TYPE; - } -} - void mainboard_get_dxio_ddi_descriptors( const fsp_dxio_descriptor **dxio_descs, size_t *dxio_num, const fsp_ddi_descriptor **ddi_descs, size_t *ddi_num)