summaryrefslogtreecommitdiff
path: root/src/mainboard/amd/birman
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2024-05-17 22:21:50 +0200
committerFelix Held <felix-coreboot@felixheld.de>2024-05-22 15:45:44 +0000
commit84f8b8eb60505af75f8e6000dfe172c0420bf7c8 (patch)
tree0aca13dd7fbf85482884d688c2e9903556508f35 /src/mainboard/amd/birman
parentbe1f05a24f59cbac1dc23b92ec97b3d083d6e077 (diff)
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>
Diffstat (limited to 'src/mainboard/amd/birman')
-rw-r--r--src/mainboard/amd/birman/Makefile.mk2
-rw-r--r--src/mainboard/amd/birman/display_card_type.c49
-rw-r--r--src/mainboard/amd/birman/display_card_type.h3
-rw-r--r--src/mainboard/amd/birman/port_descriptors_glinda.c41
-rw-r--r--src/mainboard/amd/birman/port_descriptors_phoenix.c40
5 files changed, 56 insertions, 79 deletions
diff --git a/src/mainboard/amd/birman/Makefile.mk b/src/mainboard/amd/birman/Makefile.mk
index 2df1f5925e..a784d1a7fa 100644
--- a/src/mainboard/amd/birman/Makefile.mk
+++ b/src/mainboard/amd/birman/Makefile.mk
@@ -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
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 0000000000..21f536ff4c
--- /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 0000000000..bb23fd40df
--- /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 a0dbd17b34..2af7d26de3 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 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)
diff --git a/src/mainboard/amd/birman/port_descriptors_phoenix.c b/src/mainboard/amd/birman/port_descriptors_phoenix.c
index 8ab7417d2a..da07e312f2 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 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)