blob: 88be6df8918b3746d9a7bf0901bf1103789d7abe [file] [log] [blame]
Angel Pons585495e2020-04-03 01:21:38 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Martin Rothb28f4662018-05-26 17:58:47 -06003
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02004#include <device/pci_ops.h>
Patrick Rudolph1af89232018-11-11 12:50:51 +01005#include <bootblock_common.h>
6#include <southbridge/intel/i82801ix/i82801ix.h>
Patrick Rudolphfbdeb4a2019-02-14 19:47:03 +01007#include <console/console.h>
Kyösti Mälkkib9646a22013-07-03 08:06:32 +03008
9/* Just define these here, there is no gm35.h file to include. */
10#define D0F0_PCIEXBAR_LO 0x60
11#define D0F0_PCIEXBAR_HI 0x64
12
13static void bootblock_northbridge_init(void)
14{
15 uint32_t reg;
16
17 /*
18 * The "io" variant of the config access is explicitly used to
Kyösti Mälkki6f66f412016-12-01 22:08:18 +020019 * setup the PCIEXBAR because CONFIG_MMCONF_SUPPORT is set to
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030020 * to true. That way all subsequent non-explicit config accesses use
21 * MCFG. This code also assumes that bootblock_northbridge_init() is
22 * the first thing called in the non-asm boot block code. The final
23 * assumption is that no assembly code is using the
Kyösti Mälkki6f66f412016-12-01 22:08:18 +020024 * CONFIG_MMCONF_SUPPORT option to do PCI config acceses.
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030025 *
26 * The PCIEXBAR is assumed to live in the memory mapped IO space under
27 * 4GiB.
28 */
29 reg = 0;
30 pci_io_write_config32(PCI_DEV(0,0,0), D0F0_PCIEXBAR_HI, reg);
31 reg = CONFIG_MMCONF_BASE_ADDRESS | 1; /* 256MiB - 0-255 buses. */
32 pci_io_write_config32(PCI_DEV(0,0,0), D0F0_PCIEXBAR_LO, reg);
Patrick Rudolphfbdeb4a2019-02-14 19:47:03 +010033
34 /* MCFG is now active. If it's not qemu was started for machine PC */
35 if (CONFIG(BOOTBLOCK_CONSOLE) &&
36 (pci_read_config32(PCI_DEV(0, 0, 0), D0F0_PCIEXBAR_LO) !=
37 (CONFIG_MMCONF_BASE_ADDRESS | 1)))
38 die("You must run qemu for machine Q35 (-M q35)");
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030039}
40
Patrick Rudolph1af89232018-11-11 12:50:51 +010041static void enable_spi_prefetch(void)
42{
43 u8 reg8;
44 pci_devfn_t dev;
45
46 dev = PCI_DEV(0, 0x1f, 0);
47
48 reg8 = pci_read_config8(dev, 0xdc);
49 reg8 &= ~(3 << 2);
50 reg8 |= (2 << 2); /* Prefetching and Caching Enabled */
51 pci_write_config8(dev, 0xdc, reg8);
52}
53
54static void bootblock_southbridge_init(void)
55{
56 enable_spi_prefetch();
57
58 /* Enable RCBA */
Peter Lemenkov7b428112018-10-23 11:12:46 +020059 pci_write_config32(PCI_DEV(0, 0x1f, 0), RCBA,
Patrick Rudolph1af89232018-11-11 12:50:51 +010060 (uintptr_t)DEFAULT_RCBA | 1);
61}
62
63void bootblock_soc_init(void)
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030064{
65 bootblock_northbridge_init();
66 bootblock_southbridge_init();
67}