From b92148390ceb51db191478087bc8bfe82518e4f8 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Mon, 23 Oct 2023 10:10:50 -0500 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/78599 Reviewed-by: Felix Held Tested-by: build bot (Jenkins) --- src/soc/amd/common/block/graphics/graphics.c | 14 ++++---------- .../common/block/include/amdblocks/graphics.h | 10 ++++++++++ src/soc/amd/common/fsp/Makefile.inc | 1 + src/soc/amd/common/fsp/fsp_graphics.c | 19 +++++++++++++++++++ 4 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 src/soc/amd/common/block/include/amdblocks/graphics.h create mode 100644 src/soc/amd/common/fsp/fsp_graphics.c diff --git a/src/soc/amd/common/block/graphics/graphics.c b/src/soc/amd/common/block/graphics/graphics.c index 4d33cadf94..9dff18dd73 100644 --- a/src/soc/amd/common/block/graphics/graphics.c +++ b/src/soc/amd/common/block/graphics/graphics.c @@ -2,14 +2,15 @@ #include #include +#include #include #include #include #include #include +#include #include #include -#include #include #include #include @@ -177,15 +178,8 @@ static void graphics_set_resources(struct device *const dev) 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 0000000000..f8811e8bf8 --- /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 + +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 f26fe8f884..14f1f8510b 100644 --- a/src/soc/amd/common/fsp/Makefile.inc +++ b/src/soc/amd/common/fsp/Makefile.inc @@ -3,6 +3,7 @@ ifeq ($(CONFIG_PLATFORM_USES_FSP2_0),y) 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 0000000000..4847e3c253 --- /dev/null +++ b/src/soc/amd/common/fsp/fsp_graphics.c @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include +#include +#include + +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)); +}