blob: eb0b5e7c34568f2935953b237d1fb89dbfc0847d [file] [log] [blame]
Angel Ponsc3f58f62020-04-05 15:46:41 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbinecf90862013-09-24 12:36:14 -05002
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02003#include <device/pci_ops.h>
Julius Werner18ea2d32014-10-07 16:42:17 -07004#include <soc/gfx.h>
5#include <soc/pci_devs.h>
6#include <soc/romstage.h>
Aaron Durbinecf90862013-09-24 12:36:14 -05007
8void 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
22 ggc &= ~(GGC_GTT_SIZE_MASK | GGC_GSM_SIZE_MASK);
Duncan Lauriee3f75f82013-10-28 15:49:34 -070023 /* 32MB GSM is not supported with <C0 stepping. */
24 ggc |= GGC_GTT_SIZE_2MB | GGC_GSM_SIZE_64MB;
Aaron Durbinecf90862013-09-24 12:36:14 -050025 /* 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}