blob: 5cf2eb7bee8776939b71a31922ca8ae4e4f78fc8 [file] [log] [blame]
Angel Pons585495e2020-04-03 01:21:38 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Rothb28f4662018-05-26 17:58:47 -06002
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02003#include <device/pci_ops.h>
Patrick Rudolph1af89232018-11-11 12:50:51 +01004#include <bootblock_common.h>
Angel Pons22a6d112020-06-21 18:50:22 +02005#include <southbridge/intel/common/early_spi.h>
Patrick Rudolph1af89232018-11-11 12:50:51 +01006#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
Angel Pons899525d2021-01-28 10:57:13 +01009#include "q35.h"
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030010
11static void bootblock_northbridge_init(void)
12{
13 uint32_t reg;
14
15 /*
16 * The "io" variant of the config access is explicitly used to
Martin Rothf48acbd2020-07-24 12:24:27 -060017 * setup the PCIEXBAR because CONFIG(MMCONF_SUPPORT) is set to
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030018 * to true. That way all subsequent non-explicit config accesses use
19 * MCFG. This code also assumes that bootblock_northbridge_init() is
20 * the first thing called in the non-asm boot block code. The final
21 * assumption is that no assembly code is using the
Martin Rothf48acbd2020-07-24 12:24:27 -060022 * CONFIG(MMCONF_SUPPORT) option to do PCI config acceses.
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030023 *
24 * The PCIEXBAR is assumed to live in the memory mapped IO space under
25 * 4GiB.
26 */
27 reg = 0;
28 pci_io_write_config32(PCI_DEV(0,0,0), D0F0_PCIEXBAR_HI, reg);
29 reg = CONFIG_MMCONF_BASE_ADDRESS | 1; /* 256MiB - 0-255 buses. */
30 pci_io_write_config32(PCI_DEV(0,0,0), D0F0_PCIEXBAR_LO, reg);
Patrick Rudolphfbdeb4a2019-02-14 19:47:03 +010031
32 /* MCFG is now active. If it's not qemu was started for machine PC */
33 if (CONFIG(BOOTBLOCK_CONSOLE) &&
34 (pci_read_config32(PCI_DEV(0, 0, 0), D0F0_PCIEXBAR_LO) !=
35 (CONFIG_MMCONF_BASE_ADDRESS | 1)))
36 die("You must run qemu for machine Q35 (-M q35)");
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030037}
38
Patrick Rudolph1af89232018-11-11 12:50:51 +010039static void bootblock_southbridge_init(void)
40{
Angel Pons22a6d112020-06-21 18:50:22 +020041 enable_spi_prefetching_and_caching();
Patrick Rudolph1af89232018-11-11 12:50:51 +010042
43 /* Enable RCBA */
Peter Lemenkov7b428112018-10-23 11:12:46 +020044 pci_write_config32(PCI_DEV(0, 0x1f, 0), RCBA,
Patrick Rudolph1af89232018-11-11 12:50:51 +010045 (uintptr_t)DEFAULT_RCBA | 1);
46}
47
48void bootblock_soc_init(void)
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030049{
50 bootblock_northbridge_init();
51 bootblock_southbridge_init();
52}