blob: a2b0f7fb8829b0eba56959f4fa4ff52027cb075a [file] [log] [blame]
Aaron Durbin76c37002012-10-30 09:03:43 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2010 coresystems GmbH
5 * Copyright (C) 2011 Google Inc
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Aaron Durbin76c37002012-10-30 09:03:43 -050015 */
16
17#include <stdint.h>
18#include <stdlib.h>
19#include <console/console.h>
20#include <arch/io.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050021#include <device/pci_def.h>
22#include <elog.h>
23#include "haswell.h"
Aaron Durbin76c37002012-10-30 09:03:43 -050024
25static void haswell_setup_bars(void)
26{
Aaron Durbin76c37002012-10-30 09:03:43 -050027 printk(BIOS_DEBUG, "Setting up static northbridge registers...");
28 /* Set up all hardcoded northbridge BARs */
29 pci_write_config32(PCI_DEV(0, 0x00, 0), EPBAR, DEFAULT_EPBAR | 1);
30 pci_write_config32(PCI_DEV(0, 0x00, 0), EPBAR + 4, (0LL+DEFAULT_EPBAR) >> 32);
31 pci_write_config32(PCI_DEV(0, 0x00, 0), MCHBAR, DEFAULT_MCHBAR | 1);
32 pci_write_config32(PCI_DEV(0, 0x00, 0), MCHBAR + 4, (0LL+DEFAULT_MCHBAR) >> 32);
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080033 pci_write_config32(PCI_DEV(0, 0x00, 0), DMIBAR, (uintptr_t)DEFAULT_DMIBAR | 1);
34 pci_write_config32(PCI_DEV(0, 0x00, 0), DMIBAR + 4, (0LL+(uintptr_t)DEFAULT_DMIBAR) >> 32);
Aaron Durbin76c37002012-10-30 09:03:43 -050035
36 /* Set C0000-FFFFF to access RAM on both reads and writes */
37 pci_write_config8(PCI_DEV(0, 0x00, 0), PAM0, 0x30);
38 pci_write_config8(PCI_DEV(0, 0x00, 0), PAM1, 0x33);
39 pci_write_config8(PCI_DEV(0, 0x00, 0), PAM2, 0x33);
40 pci_write_config8(PCI_DEV(0, 0x00, 0), PAM3, 0x33);
41 pci_write_config8(PCI_DEV(0, 0x00, 0), PAM4, 0x33);
42 pci_write_config8(PCI_DEV(0, 0x00, 0), PAM5, 0x33);
43 pci_write_config8(PCI_DEV(0, 0x00, 0), PAM6, 0x33);
44
45 printk(BIOS_DEBUG, " done.\n");
Aaron Durbin76c37002012-10-30 09:03:43 -050046}
47
48static void haswell_setup_graphics(void)
49{
50 u32 reg32;
51 u16 reg16;
52 u8 reg8;
53
Aaron Durbin76c37002012-10-30 09:03:43 -050054 printk(BIOS_DEBUG, "Initializing Graphics...\n");
55
56 /* Setup IGD memory by setting GGC[7:3] = 1 for 32MB */
57 reg16 = pci_read_config16(PCI_DEV(0,0,0), GGC);
58 reg16 &= ~0x00f8;
59 reg16 |= 1 << 3;
60 /* Program GTT memory by setting GGC[9:8] = 2MB */
61 reg16 &= ~0x0300;
62 reg16 |= 2 << 8;
63 /* Enable VGA decode */
64 reg16 &= ~0x0002;
65 pci_write_config16(PCI_DEV(0,0,0), GGC, reg16);
66
67 /* Enable 256MB aperture */
68 reg8 = pci_read_config8(PCI_DEV(0, 2, 0), MSAC);
69 reg8 &= ~0x06;
70 reg8 |= 0x02;
71 pci_write_config8(PCI_DEV(0, 2, 0), MSAC, reg8);
72
73 /* Erratum workarounds */
74 reg32 = MCHBAR32(0x5f00);
75 reg32 |= (1 << 9)|(1 << 10);
76 MCHBAR32(0x5f00) = reg32;
77
78 /* Enable SA Clock Gating */
79 reg32 = MCHBAR32(0x5f00);
80 MCHBAR32(0x5f00) = reg32 | 1;
81
82 /* GPU RC6 workaround for sighting 366252 */
83 reg32 = MCHBAR32(0x5d14);
Ryan Salsamendib9bc2572017-07-04 13:35:06 -070084 reg32 |= (1UL << 31);
Aaron Durbin76c37002012-10-30 09:03:43 -050085 MCHBAR32(0x5d14) = reg32;
86
87 /* VLW */
88 reg32 = MCHBAR32(0x6120);
89 reg32 &= ~(1 << 0);
90 MCHBAR32(0x6120) = reg32;
91
92 reg32 = MCHBAR32(0x5418);
93 reg32 |= (1 << 4) | (1 << 5);
94 MCHBAR32(0x5418) = reg32;
95}
96
97void haswell_early_initialization(int chipset_type)
98{
Aaron Durbin76c37002012-10-30 09:03:43 -050099 /* Setup all BARs required for early PCIe and raminit */
100 haswell_setup_bars();
101
Duncan Laurie0a7c49e2013-06-20 12:40:55 -0700102 /* Device Enable: IGD and Mini-HD Audio */
103 pci_write_config32(PCI_DEV(0, 0, 0), DEVEN,
104 DEVEN_D0EN | DEVEN_D2EN | DEVEN_D3EN);
Aaron Durbin76c37002012-10-30 09:03:43 -0500105
106 haswell_setup_graphics();
107}