payloads/external/tianocore: Hook up debug builds to serial support

ConSplitterDxe uses the intersection of all outputs, which includes
serial, for the list of supported text modes. When serial output is
supported, this slows down performance and limits the size of
FrontPage.

Only enable edk2's serial support when it's a debug build as
it's the only case where there will be debug output.

Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Change-Id: Ic3633767dabb3543e865aa65c4101840a7b69cc1
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65643
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
diff --git a/payloads/external/Makefile.inc b/payloads/external/Makefile.inc
index 14a7ebb..e560cbe 100644
--- a/payloads/external/Makefile.inc
+++ b/payloads/external/Makefile.inc
@@ -176,6 +176,7 @@
 		CONFIG_TIANOCORE_HAVE_EFI_SHELL=$(CONFIG_TIANOCORE_HAVE_EFI_SHELL) \
 		CONFIG_TIANOCORE_PRIORITIZE_INTERNAL=$(CONFIG_TIANOCORE_PRIORITIZE_INTERNAL) \
 		CONFIG_TIANOCORE_PS2_SUPPORT=$(CONFIG_TIANOCORE_PS2_SUPPORT) \
+		CONFIG_TIANOCORE_SERIAL_SUPPORT=$(TIANOCORE_SERIAL_SUPPORT) \
 		CONFIG_TIANOCORE_SD_MMC_TIMEOUT=$(CONFIG_TIANOCORE_SD_MMC_TIMEOUT) \
 		CONFIG_TIANOCORE_USE_8254_TIMER=$(CONFIG_TIANOCORE_USE_8254_TIMER) \
 		CONFIG_ECAM_MMCONF_BASE_ADDRESS=$(CONFIG_ECAM_MMCONF_BASE_ADDRESS) \
diff --git a/payloads/external/tianocore/Kconfig b/payloads/external/tianocore/Kconfig
index c0c86ae..d30386e 100644
--- a/payloads/external/tianocore/Kconfig
+++ b/payloads/external/tianocore/Kconfig
@@ -175,6 +175,14 @@
 	  The amount of time allowed to initialize the SD Card reader and/or eMMC drive.
 	  Most only require 1000μs, but certain readers can take 1000000μs.
 
+config TIANOCORE_SERIAL_SUPPORT
+	bool "Support serial output"
+	default y if TIANOCORE_DEBUG
+	default n
+	help
+	  Enable serial port output in edk2. Serial output limits the performance of edk2's
+	  FrontPage.
+
 endif
 
 if TIANOCORE_COREBOOTPAYLOAD
diff --git a/payloads/external/tianocore/Makefile b/payloads/external/tianocore/Makefile
index bcadcb2..7dcaf20 100644
--- a/payloads/external/tianocore/Makefile
+++ b/payloads/external/tianocore/Makefile
@@ -36,6 +36,10 @@
 ifeq ($(CONFIG_TIANOCORE_RELEASE),y)
 BUILD_STR += -b RELEASE
 endif
+# DISABLE_SERIAL_TERMINAL	= FALSE
+ifneq ($(CONFIG_TIANOCORE_SERIAL_SUPPORT),y)
+BUILD_STR += -D DISABLE_SERIAL_TERMINAL=TRUE
+endif
 # FOLLOW_BGRT_SPEC		= FALSE
 ifeq ($(CONFIG_TIANOCORE_FOLLOW_BGRT_SPEC),y)
 BUILD_STR += -D FOLLOW_BGRT_SPEC=TRUE