From 47f154c8e593be37ee298e976a37012f44c2a247 Mon Sep 17 00:00:00 2001 From: Jeremy Compostella Date: Thu, 1 Dec 2022 15:55:06 -0700 Subject: [PATCH] soc/intel/common/block: Add Intel VGA early graphics support This patch introduces an early graphics driver which can be used in romstage in cache-as-ram mode. The implementation relies on `libgfxinit' and provide VGA text mode support. SoCs wanting to take advantage of this driver must implement the `early_graphics_soc_panel_init' function to set the panel power sequence timing parameters. BUG=b:252792591 BRANCH=firmware-brya-14505.B TEST=Graphics bring up observed on skolas with extra patches Change-Id: Ie4ad1215e5fadd0adc1271b6bd6ddb0ea258cb5b Signed-off-by: Jeremy Compostella Reviewed-on: https://review.coreboot.org/c/coreboot/+/70299 Reviewed-by: Tarun Tuli Reviewed-by: Subrata Banik Reviewed-by: Maulik Vaghela Reviewed-by: Kapil Porwal Tested-by: build bot (Jenkins) --- src/drivers/intel/gma/gma-gfx_init.ads | 3 ++ .../intel/gma/hires_fb/gma-gfx_init.adb | 13 +++++ src/drivers/intel/gma/libgfxinit.h | 1 + .../intel/gma/text_fb/gma-gfx_init.adb | 13 +++++ src/soc/intel/common/block/graphics/Kconfig | 1 + .../intel/common/block/graphics/Makefile.inc | 1 + .../common/block/graphics/early_graphics.c | 52 +++++++++++++++++++ .../include/intelblocks/early_graphics.h | 28 ++++++++++ 8 files changed, 112 insertions(+) create mode 100644 src/soc/intel/common/block/graphics/early_graphics.c create mode 100644 src/soc/intel/common/block/include/intelblocks/early_graphics.h diff --git a/src/drivers/intel/gma/gma-gfx_init.ads b/src/drivers/intel/gma/gma-gfx_init.ads index 4998d3312e..fc45672ee0 100644 --- a/src/drivers/intel/gma/gma-gfx_init.ads +++ b/src/drivers/intel/gma/gma-gfx_init.ads @@ -11,6 +11,9 @@ is procedure gfxinit (lightup_ok : out Interfaces.C.int); pragma Export (C, gfxinit, "gma_gfxinit"); + procedure gfxstop (stop_ok : out Interfaces.C.int); + pragma Export (C, gfxstop, "gma_gfxstop"); + ---------------------------------------------------------------------------- function c_fb_add_framebuffer_info diff --git a/src/drivers/intel/gma/hires_fb/gma-gfx_init.adb b/src/drivers/intel/gma/hires_fb/gma-gfx_init.adb index b213030b2b..83516af171 100644 --- a/src/drivers/intel/gma/hires_fb/gma-gfx_init.adb +++ b/src/drivers/intel/gma/hires_fb/gma-gfx_init.adb @@ -97,4 +97,17 @@ is end if; end gfxinit; + procedure gfxstop (stop_ok : out Interfaces.C.int) + is + success : boolean; + begin + HW.GFX.GMA.Initialize (Clean_State => True, + Success => success); + if success then + stop_ok := 1; + else + stop_ok := 0; + end if; + end gfxstop; + end GMA.GFX_Init; diff --git a/src/drivers/intel/gma/libgfxinit.h b/src/drivers/intel/gma/libgfxinit.h index 9a7e1c6f90..3270b91752 100644 --- a/src/drivers/intel/gma/libgfxinit.h +++ b/src/drivers/intel/gma/libgfxinit.h @@ -17,6 +17,7 @@ enum { }; void gma_gfxinit(int *lightup_ok); +void gma_gfxstop(int *stop_ok); int gma_read_edid(unsigned char edid[], int port); #endif diff --git a/src/drivers/intel/gma/text_fb/gma-gfx_init.adb b/src/drivers/intel/gma/text_fb/gma-gfx_init.adb index d27385247e..da1e609b79 100644 --- a/src/drivers/intel/gma/text_fb/gma-gfx_init.adb +++ b/src/drivers/intel/gma/text_fb/gma-gfx_init.adb @@ -56,4 +56,17 @@ is end if; end gfxinit; + procedure gfxstop (stop_ok : out Interfaces.C.int) + is + success : boolean; + begin + HW.GFX.GMA.Initialize (Clean_State => True, + Success => success); + if success then + stop_ok := 1; + else + stop_ok := 0; + end if; + end gfxstop; + end GMA.GFX_Init; diff --git a/src/soc/intel/common/block/graphics/Kconfig b/src/soc/intel/common/block/graphics/Kconfig index 8520e53562..d586fd8ab8 100644 --- a/src/soc/intel/common/block/graphics/Kconfig +++ b/src/soc/intel/common/block/graphics/Kconfig @@ -1,5 +1,6 @@ config SOC_INTEL_COMMON_BLOCK_GRAPHICS bool + select ROMSTAGE_VGA if MAINBOARD_USE_EARLY_LIBGFXINIT help Intel Processor common Graphics support diff --git a/src/soc/intel/common/block/graphics/Makefile.inc b/src/soc/intel/common/block/graphics/Makefile.inc index ac7df44a2f..ac053de838 100644 --- a/src/soc/intel/common/block/graphics/Makefile.inc +++ b/src/soc/intel/common/block/graphics/Makefile.inc @@ -1,2 +1,3 @@ ## SPDX-License-Identifier: GPL-2.0-only +romstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GRAPHICS) += early_graphics.c ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GRAPHICS) += graphics.c diff --git a/src/soc/intel/common/block/graphics/early_graphics.c b/src/soc/intel/common/block/graphics/early_graphics.c new file mode 100644 index 0000000000..6f6a421e81 --- /dev/null +++ b/src/soc/intel/common/block/graphics/early_graphics.c @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include + +static bool initialized; + +static void device_init(void) +{ + /* Disable response in IO and MMIO space. */ + pci_and_config16(SA_DEV_IGD, PCI_COMMAND, + ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY)); + + /* Program IGD Base Address Register 0. */ + pci_write_config32(SA_DEV_IGD, PCI_BASE_ADDRESS_0, + CONFIG_GFX_GMA_DEFAULT_MMIO); + + /* Enable response in IO and MMIO space. */ + pci_or_config16(SA_DEV_IGD, PCI_COMMAND, + (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)); +} + +bool early_graphics_init(void) +{ + int ret; + + if (!CONFIG(MAINBOARD_USE_EARLY_LIBGFXINIT)) + return false; + + /* Perform minimal graphic MMIO configuration. */ + device_init(); + + /* Configure display panel. */ + early_graphics_soc_panel_init(); + + gma_gfxinit(&ret); + initialized = !!ret; + + return initialized; +} + +void early_graphics_stop(void) +{ + int ret; + + if (!initialized) + return; + + gma_gfxstop(&ret); +} diff --git a/src/soc/intel/common/block/include/intelblocks/early_graphics.h b/src/soc/intel/common/block/include/intelblocks/early_graphics.h new file mode 100644 index 0000000000..c0313cf960 --- /dev/null +++ b/src/soc/intel/common/block/include/intelblocks/early_graphics.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef SOC_INTEL_COMMON_BLOCK_GRAPHICS_EARLY_H +#define SOC_INTEL_COMMON_BLOCK_GRAPHICS_EARLY_H + +#include + +/* + * SoC override + * + * All new SoC must implement below functionality. + */ + +/* Configure display panel */ +void early_graphics_soc_panel_init(void); + +/* + * Early graphics module API + * Graphics at this stage is limited to VGA text mode. + */ + +/* Initialize graphics. Return true if VGA text mode is ready to use. */ +bool early_graphics_init(void); + +/* Clear graphics configuration, turn off the displays. */ +void early_graphics_stop(void); + +#endif /* SOC_INTEL_COMMON_BLOCK_GRAPHICS_EARLY_H */