Angel Pons | c3f58f6 | 2020-04-05 15:46:41 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | ecf9086 | 2013-09-24 12:36:14 -0500 | [diff] [blame] | 2 | |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 3 | #include <device/pci_ops.h> |
Julius Werner | 18ea2d3 | 2014-10-07 16:42:17 -0700 | [diff] [blame] | 4 | #include <soc/gfx.h> |
| 5 | #include <soc/pci_devs.h> |
| 6 | #include <soc/romstage.h> |
Aaron Durbin | ecf9086 | 2013-09-24 12:36:14 -0500 | [diff] [blame] | 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 | |
| 22 | ggc &= ~(GGC_GTT_SIZE_MASK | GGC_GSM_SIZE_MASK); |
Duncan Laurie | e3f75f8 | 2013-10-28 15:49:34 -0700 | [diff] [blame] | 23 | /* 32MB GSM is not supported with <C0 stepping. */ |
| 24 | ggc |= GGC_GTT_SIZE_2MB | GGC_GSM_SIZE_64MB; |
Aaron Durbin | ecf9086 | 2013-09-24 12:36:14 -0500 | [diff] [blame] | 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 | } |