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 | a6b0922 | 2021-01-20 13:00:02 +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 | a6b0922 | 2021-01-20 13:00:02 +0100 | [diff] [blame^] | 6 | #include <types.h> |
Arthur Heymans | e27c013 | 2019-11-12 23:34:13 +0100 | [diff] [blame] | 7 | #include "i945.h" |
Kyösti Mälkki | 032c23d | 2013-07-01 11:21:53 +0300 | [diff] [blame] | 8 | |
Angel Pons | a6b0922 | 2021-01-20 13:00:02 +0100 | [diff] [blame^] | 9 | static uint32_t encode_pciexbar_length(void) |
| 10 | { |
| 11 | switch (CONFIG_MMCONF_BUS_NUMBER) { |
| 12 | case 256: return 0 << 1; |
| 13 | case 128: return 1 << 1; |
| 14 | case 64: return 2 << 1; |
| 15 | default: return dead_code_t(uint32_t); |
| 16 | } |
| 17 | } |
| 18 | |
Arthur Heymans | e27c013 | 2019-11-12 23:34:13 +0100 | [diff] [blame] | 19 | void bootblock_early_northbridge_init(void) |
Kyösti Mälkki | 032c23d | 2013-07-01 11:21:53 +0300 | [diff] [blame] | 20 | { |
Kyösti Mälkki | 032c23d | 2013-07-01 11:21:53 +0300 | [diff] [blame] | 21 | /* |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 22 | * The "io" variant of the config access is explicitly used to setup the PCIEXBAR |
Martin Roth | f48acbd | 2020-07-24 12:24:27 -0600 | [diff] [blame] | 23 | * because CONFIG(MMCONF_SUPPORT) is set to true. That way all subsequent non-explicit |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 24 | * config accesses use MCFG. This code also assumes that bootblock_northbridge_init() is |
| 25 | * the first thing called in the non-asm boot block code. The final assumption is that |
Martin Roth | f48acbd | 2020-07-24 12:24:27 -0600 | [diff] [blame] | 26 | * no assembly code is using the CONFIG(MMCONF_SUPPORT) option to do PCI config accesses. |
Kyösti Mälkki | 032c23d | 2013-07-01 11:21:53 +0300 | [diff] [blame] | 27 | * |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 28 | * The PCIEXBAR is assumed to live in the memory mapped IO space under 4GiB. |
Kyösti Mälkki | 032c23d | 2013-07-01 11:21:53 +0300 | [diff] [blame] | 29 | */ |
Angel Pons | a6b0922 | 2021-01-20 13:00:02 +0100 | [diff] [blame^] | 30 | const uint32_t reg = CONFIG_MMCONF_BASE_ADDRESS | encode_pciexbar_length() | 1; |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 31 | pci_io_write_config32(HOST_BRIDGE, PCIEXBAR, reg); |
Kyösti Mälkki | 032c23d | 2013-07-01 11:21:53 +0300 | [diff] [blame] | 32 | } |