coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
gfx.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/pci_ops.h>
4 #include <soc/gfx.h>
5 #include <soc/pci_devs.h>
6 #include <soc/romstage.h>
7 
8 void gfx_init(void)
9 {
10  uint32_t ggc;
11  uint8_t msac;
12  const unsigned int gfx_dev = PCI_DEV(0, GFX_DEV, GFX_FUNC);
13 
14  /* The GFX device needs to set the aperture, gtt stolen size, and
15  * graphics stolen memory stolen size before running MRC. For now
16  * just hard code the defaults. Options can be added to the device
17  * tree if needed. */
18 
19  ggc = pci_read_config32(gfx_dev, GGC);
20  msac = pci_read_config8(gfx_dev, MSAC);
21 
23  /* 32MB GSM is not supported with <C0 stepping. */
25  /* Enable VGA decoding as well. */
26  ggc &= ~(GGC_VGA_DISABLE);
27 
28  msac &= ~(APERTURE_SIZE_MASK);
29  msac |= APERTURE_SIZE_256MB;
30 
31  pci_write_config32(gfx_dev, GGC, ggc);
32  pci_write_config8(gfx_dev, MSAC, msac);
33 }
#define GGC_VGA_DISABLE
Definition: gfx.h:11
#define GGC_GSM_SIZE_MASK
Definition: gfx.h:16
#define GGC_GTT_SIZE_2MB
Definition: gfx.h:15
#define APERTURE_SIZE_256MB
Definition: gfx.h:41
#define GGC_GTT_SIZE_MASK
Definition: gfx.h:12
#define APERTURE_SIZE_MASK
Definition: gfx.h:39
#define GGC_GSM_SIZE_64MB
Definition: gfx.h:19
void gfx_init(void)
Definition: gfx.c:8
#define GGC
Definition: host_bridge.h:9
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
Definition: pci_ops.h:46
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
Definition: pci_ops.h:64
#define GFX_FUNC
Definition: pci_devs.h:12
#define GFX_DEV
Definition: pci_devs.h:11
#define MSAC
Definition: haswell.h:21
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8