blob: d5ca7f9ce7c844cccf50195478925651b48c9789 [file] [log] [blame]
Martin Rothb28f4662018-05-26 17:58:47 -06001/*
2 * This file is part of the coreboot project.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020014#include <device/pci_ops.h>
Patrick Rudolph1af89232018-11-11 12:50:51 +010015#include <bootblock_common.h>
16#include <southbridge/intel/i82801ix/i82801ix.h>
Patrick Rudolphfbdeb4a2019-02-14 19:47:03 +010017#include <console/console.h>
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030018
19/* Just define these here, there is no gm35.h file to include. */
20#define D0F0_PCIEXBAR_LO 0x60
21#define D0F0_PCIEXBAR_HI 0x64
22
23static void bootblock_northbridge_init(void)
24{
25 uint32_t reg;
26
27 /*
28 * The "io" variant of the config access is explicitly used to
Kyösti Mälkki6f66f412016-12-01 22:08:18 +020029 * setup the PCIEXBAR because CONFIG_MMCONF_SUPPORT is set to
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030030 * to true. That way all subsequent non-explicit config accesses use
31 * MCFG. This code also assumes that bootblock_northbridge_init() is
32 * the first thing called in the non-asm boot block code. The final
33 * assumption is that no assembly code is using the
Kyösti Mälkki6f66f412016-12-01 22:08:18 +020034 * CONFIG_MMCONF_SUPPORT option to do PCI config acceses.
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030035 *
36 * The PCIEXBAR is assumed to live in the memory mapped IO space under
37 * 4GiB.
38 */
39 reg = 0;
40 pci_io_write_config32(PCI_DEV(0,0,0), D0F0_PCIEXBAR_HI, reg);
41 reg = CONFIG_MMCONF_BASE_ADDRESS | 1; /* 256MiB - 0-255 buses. */
42 pci_io_write_config32(PCI_DEV(0,0,0), D0F0_PCIEXBAR_LO, reg);
Patrick Rudolphfbdeb4a2019-02-14 19:47:03 +010043
44 /* MCFG is now active. If it's not qemu was started for machine PC */
45 if (CONFIG(BOOTBLOCK_CONSOLE) &&
46 (pci_read_config32(PCI_DEV(0, 0, 0), D0F0_PCIEXBAR_LO) !=
47 (CONFIG_MMCONF_BASE_ADDRESS | 1)))
48 die("You must run qemu for machine Q35 (-M q35)");
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030049}
50
Patrick Rudolph1af89232018-11-11 12:50:51 +010051static void enable_spi_prefetch(void)
52{
53 u8 reg8;
54 pci_devfn_t dev;
55
56 dev = PCI_DEV(0, 0x1f, 0);
57
58 reg8 = pci_read_config8(dev, 0xdc);
59 reg8 &= ~(3 << 2);
60 reg8 |= (2 << 2); /* Prefetching and Caching Enabled */
61 pci_write_config8(dev, 0xdc, reg8);
62}
63
64static void bootblock_southbridge_init(void)
65{
66 enable_spi_prefetch();
67
68 /* Enable RCBA */
Peter Lemenkov7b428112018-10-23 11:12:46 +020069 pci_write_config32(PCI_DEV(0, 0x1f, 0), RCBA,
Patrick Rudolph1af89232018-11-11 12:50:51 +010070 (uintptr_t)DEFAULT_RCBA | 1);
71}
72
73void bootblock_soc_init(void)
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030074{
75 bootblock_northbridge_init();
76 bootblock_southbridge_init();
77}