soc/amd/common/graphics: Factor out FSP graphics init

Factor out the FSP-dependent graphics init call and header into a
separate file, so that the common graphics init can be used by non-FSP
platforms (eg Stoneyridge) without any preprocessor guards.

TEST=build google/skyrim

Change-Id: Ib025ad3adec0945b4454892d78c30b4cc79e57a0
Signed-off-by: Matt DeVillier <matt.devillier@amd.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/78599
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/soc/amd/common/block/graphics/graphics.c b/src/soc/amd/common/block/graphics/graphics.c
index 4d33cad..9dff18d 100644
--- a/src/soc/amd/common/block/graphics/graphics.c
+++ b/src/soc/amd/common/block/graphics/graphics.c
@@ -2,14 +2,15 @@
 
 #include <acpi/acpi_device.h>
 #include <acpi/acpigen.h>
+#include <amdblocks/graphics.h>
 #include <amdblocks/vbios_cache.h>
 #include <boot/coreboot_tables.h>
 #include <bootmode.h>
 #include <bootstate.h>
 #include <console/console.h>
+#include <device/device.h>
 #include <device/pci.h>
 #include <fmap.h>
-#include <fsp/graphics.h>
 #include <security/vboot/vbios_cache_hash_tpm.h>
 #include <soc/intel/common/vbt.h>
 #include <timestamp.h>
@@ -177,15 +178,8 @@
 
 static void graphics_dev_init(struct device *const dev)
 {
-	if (CONFIG(RUN_FSP_GOP)) {
-		struct resource *res = probe_resource(dev, PCI_BASE_ADDRESS_0);
-
-		if (res && res->base)
-			fsp_report_framebuffer_info(res->base, LB_FB_ORIENTATION_NORMAL);
-		else
-			printk(BIOS_ERR, "%s: Unable to find resource for %s\n",
-			       __func__, dev_path(dev));
-	}
+	if (CONFIG(RUN_FSP_GOP))
+		fsp_graphics_init(dev);
 
 	/* Initialize PCI device, load/execute BIOS Option ROM */
 	pci_dev_init(dev);
diff --git a/src/soc/amd/common/block/include/amdblocks/graphics.h b/src/soc/amd/common/block/include/amdblocks/graphics.h
new file mode 100644
index 0000000..f8811e8
--- /dev/null
+++ b/src/soc/amd/common/block/include/amdblocks/graphics.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef AMD_BLOCK_GRAPHICS_H
+#define AMD_BLOCK_GRAPHICS_H
+
+#include <device/device.h>
+
+void fsp_graphics_init(struct device *const dev);
+
+#endif /* AMD_BLOCK_GRAPHICS_H */
diff --git a/src/soc/amd/common/fsp/Makefile.inc b/src/soc/amd/common/fsp/Makefile.inc
index f26fe8f..14f1f85 100644
--- a/src/soc/amd/common/fsp/Makefile.inc
+++ b/src/soc/amd/common/fsp/Makefile.inc
@@ -3,6 +3,7 @@
 romstage-y += fsp_memmap.c
 romstage-y += fsp_reset.c
 romstage-y += fsp_validate.c
+ramstage-y += fsp_graphics.c
 ramstage-y += fsp_memmap.c
 ramstage-y += fsp_report_resources.c
 ramstage-y += fsp_reset.c
diff --git a/src/soc/amd/common/fsp/fsp_graphics.c b/src/soc/amd/common/fsp/fsp_graphics.c
new file mode 100644
index 0000000..4847e3c
--- /dev/null
+++ b/src/soc/amd/common/fsp/fsp_graphics.c
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include <amdblocks/graphics.h>
+#include <console/console.h>
+#include <device/device.h>
+#include <device/pci.h>
+#include <device/resource.h>
+#include <fsp/graphics.h>
+
+void fsp_graphics_init(struct device *const dev)
+{
+	struct resource *res = probe_resource(dev, PCI_BASE_ADDRESS_0);
+
+	if (res && res->base)
+		fsp_report_framebuffer_info(res->base, LB_FB_ORIENTATION_NORMAL);
+	else
+		printk(BIOS_ERR, "%s: Unable to find resource for %s\n",
+				__func__, dev_path(dev));
+}