Ana Carolina Cabral has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/84776?usp=email )
Change subject: mb/amd/common: Add common directory ......................................................................
mb/amd/common: Add common directory
Creates a common directory for amd/mainboard. As multiple boards use the NOVA daughter card, the function that detects the connector type has been moved to this common folder and will be refactored in the following patches.
Change-Id: I5e9ded2090d6a5865e3330408f490e59fbf480f4 Signed-off-by: Ana Carolina Cabral ana.cpmelo95@gmail.com --- M Makefile.mk A src/mainboard/amd/common/Kconfig A src/mainboard/amd/common/Makefile.mk A src/mainboard/amd/common/nova/Kconfig A src/mainboard/amd/common/nova/Makefile.mk A src/mainboard/amd/common/nova/include/nova_card.h A src/mainboard/amd/common/nova/nova_card.c 7 files changed, 91 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/76/84776/1
diff --git a/Makefile.mk b/Makefile.mk index 4a2f191..2f6e130 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -118,7 +118,7 @@ subdirs-y += util/futility util/marvell util/bincfg util/supermicro util/qemu subdirs-y += util/ifdtool subdirs-y += $(wildcard src/arch/*) -subdirs-y += src/mainboard/$(MAINBOARDDIR) +subdirs-y += src/mainboard/$(MAINBOARDDIR) $(wildcard src/mainboard/*/common) subdirs-y += src/security subdirs-y += payloads payloads/external subdirs-$(CONFIG_SBOM) += src/sbom diff --git a/src/mainboard/amd/common/Kconfig b/src/mainboard/amd/common/Kconfig new file mode 100644 index 0000000..3660e47 --- /dev/null +++ b/src/mainboard/amd/common/Kconfig @@ -0,0 +1,10 @@ +## SPDX-License-Identifier: GPL-2.0-only + +config MAINBOARD_AMD_COMMON + bool + +if MAINBOARD_AMD_COMMON + source "src/mainboard/amd/common/*/Kconfig" +endif #MAINBOARD_AMD_COMMON + + diff --git a/src/mainboard/amd/common/Makefile.mk b/src/mainboard/amd/common/Makefile.mk new file mode 100644 index 0000000..b80de88 --- /dev/null +++ b/src/mainboard/amd/common/Makefile.mk @@ -0,0 +1,8 @@ +## SPDX-License-Identifier: GPL-2.0-only + +ifeq ($(CONFIG_MAINBOARD_AMD_COMMON),y) + +subdirs-y += ./* +CPPFLAGS_common += -I$(src)/mainboard/amd/common/nova/include/ + +endif # ifeq ($(MAINBOARD_AMD_COMMON),y) diff --git a/src/mainboard/amd/common/nova/Kconfig b/src/mainboard/amd/common/nova/Kconfig new file mode 100644 index 0000000..e797fff --- /dev/null +++ b/src/mainboard/amd/common/nova/Kconfig @@ -0,0 +1,6 @@ +## SPDX-License-Identifier: GPL-2.0-only + +config AMD_MAINBOARD_NOVA_CARD + bool "Enable NOVA Card" + help + This option enables Nova Card auto detection \ No newline at end of file diff --git a/src/mainboard/amd/common/nova/Makefile.mk b/src/mainboard/amd/common/nova/Makefile.mk new file mode 100644 index 0000000..4eda9971 --- /dev/null +++ b/src/mainboard/amd/common/nova/Makefile.mk @@ -0,0 +1,5 @@ +## SPDX-License-Identifier: GPL-2.0-only + +romstage-$(CONFIG_AMD_MAINBOARD_NOVA_CARD) += nova_card.c +ramstage-$(CONFIG_AMD_MAINBOARD_NOVA_CARD) += nova_card.c + diff --git a/src/mainboard/amd/common/nova/include/nova_card.h b/src/mainboard/amd/common/nova/include/nova_card.h new file mode 100644 index 0000000..1bf6ef6 --- /dev/null +++ b/src/mainboard/amd/common/nova/include/nova_card.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef MAINBOARD_DISPLAY_CARD_TYPE_H +#define MAINBOARD_DISPLAY_CARD_TYPE_H + +#include <types.h> + +struct nova_eeprom_params { + uint8_t i2c_bus; + uint8_t i2c_address; + uint16_t connector_type_offset; +}; + +uint8_t get_ddi1_type(struct nova_eeprom_params *eeprom_params); + +#endif /* MAINBOARD_DISPLAY_CARD_TYPE_H */ diff --git a/src/mainboard/amd/common/nova/nova_card.c b/src/mainboard/amd/common/nova/nova_card.c new file mode 100644 index 0000000..815c369 --- /dev/null +++ b/src/mainboard/amd/common/nova/nova_card.c @@ -0,0 +1,45 @@ +/* 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 "nova_card.h" + +uint8_t get_ddi1_type(struct nova_eeprom_params *eeprom_params) +{ + uint8_t data[2] = {0}; + + if (i2c_2ba_read_bytes(eeprom_params->i2c_bus, eeprom_params->i2c_address, + eeprom_params->connector_type_offset, data, + sizeof(data))) { + printk(BIOS_NOTICE, + "Display connector type couldn't be determined. Disabling DDI1.\n"); + return DDI_UNUSED_TYPE; + } + + uint16_t connector_type = data[1] | 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; + } +}