blob: 4b174cb0f673bec43d9f4be1b474e51b0ab3edeb [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Roth5474eb12018-05-26 19:22:33 -06002
Kyösti Mälkkide640782019-12-03 07:30:26 +02003#include <arch/bootblock.h>
Angel Ponsb274ec72021-01-20 14:03:44 +01004#include <assert.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02005#include <device/pci_ops.h>
Angel Ponsb274ec72021-01-20 14:03:44 +01006#include <types.h>
Angel Pons3ab19b32020-07-22 16:29:54 +02007#include "ironlake.h"
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +01008
Angel Ponsb274ec72021-01-20 14:03:44 +01009static uint32_t encode_pciexbar_length(void)
10{
11 /* NOTE: Ironlake uses a different encoding for the PCIEXBAR length field */
12 switch (CONFIG_MMCONF_BUS_NUMBER) {
13 case 256: return 0 << 1;
14 case 128: return 6 << 1;
15 case 64: return 7 << 1;
16 default: return dead_code_t(uint32_t);
17 }
18}
19
Arthur Heymans28822532019-10-10 15:50:04 +020020void bootblock_early_northbridge_init(void)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010021{
Angel Ponsb274ec72021-01-20 14:03:44 +010022 /*
23 * The QuickPath bus number is the topmost bus number, as per the value
24 * of the SAD_PCIEXBAR register. The register defaults to 256 busses on
25 * reset. Thus, hardcode the bus number when first setting up PCIEXBAR.
26 */
27 const pci_devfn_t qpi_sad = PCI_DEV(255, 0, 1);
28
29 const uint32_t reg32 = CONFIG_MMCONF_BASE_ADDRESS | encode_pciexbar_length() | 1;
30 pci_io_write_config32(qpi_sad, SAD_PCIEXBAR + 4, 0);
31 pci_io_write_config32(qpi_sad, SAD_PCIEXBAR, reg32);
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010032}