Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | 5474eb1 | 2018-05-26 19:22:33 -0600 | [diff] [blame] | 2 | |
Kyösti Mälkki | de64078 | 2019-12-03 07:30:26 +0200 | [diff] [blame] | 3 | #include <arch/bootblock.h> |
Angel Pons | b274ec7 | 2021-01-20 14:03:44 +0100 | [diff] [blame] | 4 | #include <assert.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 5 | #include <device/pci_ops.h> |
Angel Pons | b274ec7 | 2021-01-20 14:03:44 +0100 | [diff] [blame] | 6 | #include <types.h> |
Angel Pons | 3ab19b3 | 2020-07-22 16:29:54 +0200 | [diff] [blame] | 7 | #include "ironlake.h" |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 8 | |
Angel Pons | b274ec7 | 2021-01-20 14:03:44 +0100 | [diff] [blame] | 9 | static 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 Heymans | 2882253 | 2019-10-10 15:50:04 +0200 | [diff] [blame] | 20 | void bootblock_early_northbridge_init(void) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 21 | { |
Angel Pons | b274ec7 | 2021-01-20 14:03:44 +0100 | [diff] [blame] | 22 | /* |
| 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 Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 32 | } |