blob: 58f49da1d3c8477264f8ed424603a0908b9790a8 [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>
Angel Pons37cae542021-02-02 16:28:07 +01005#include <device/pci_ops.h>
Angel Ponsb274ec72021-01-20 14:03:44 +01006#include <types.h>
Elyes HAOUAS77d3b652021-01-31 08:28:45 +01007
Angel Pons3ab19b32020-07-22 16:29:54 +02008#include "ironlake.h"
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +01009
Angel Ponsb274ec72021-01-20 14:03:44 +010010static uint32_t encode_pciexbar_length(void)
11{
12 /* NOTE: Ironlake uses a different encoding for the PCIEXBAR length field */
Shelley Chen4e9bb332021-10-20 15:43:45 -070013 switch (CONFIG_ECAM_MMCONF_BUS_NUMBER) {
Angel Ponsb274ec72021-01-20 14:03:44 +010014 case 256: return 0 << 1;
15 case 128: return 6 << 1;
16 case 64: return 7 << 1;
17 default: return dead_code_t(uint32_t);
18 }
19}
20
Arthur Heymans28822532019-10-10 15:50:04 +020021void bootblock_early_northbridge_init(void)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010022{
Angel Ponsb274ec72021-01-20 14:03:44 +010023 /*
24 * The QuickPath bus number is the topmost bus number, as per the value
Martin Roth50863da2021-10-01 14:37:30 -060025 * of the SAD_PCIEXBAR register. The register defaults to 256 buses on
Angel Ponsb274ec72021-01-20 14:03:44 +010026 * reset. Thus, hardcode the bus number when first setting up PCIEXBAR.
27 */
28 const pci_devfn_t qpi_sad = PCI_DEV(255, 0, 1);
29
Shelley Chen4e9bb332021-10-20 15:43:45 -070030 const uint32_t reg32 = CONFIG_ECAM_MMCONF_BASE_ADDRESS | encode_pciexbar_length() | 1;
Angel Ponsb274ec72021-01-20 14:03:44 +010031 pci_io_write_config32(qpi_sad, SAD_PCIEXBAR + 4, 0);
32 pci_io_write_config32(qpi_sad, SAD_PCIEXBAR, reg32);
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010033}