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>
This commit is contained in:
Felix Held
2024-05-17 22:21:50 +02:00
parent be1f05a24f
commit 84f8b8eb60
5 changed files with 56 additions and 79 deletions

View File

@@ -4,10 +4,12 @@ bootblock-y += bootblock.c
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

View File

@@ -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;
}
}

View File

@@ -0,0 +1,3 @@
/* SPDX-License-Identifier: GPL-2.0-only */
uint8_t get_ddi1_type(void);

View File

@@ -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 fsp_ddi_descriptor birman_ddi_descriptors[] = {
}
};
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)

View File

@@ -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 fsp_ddi_descriptor birman_ddi_descriptors[] = {
}
};
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)