Martin Roth | b28f466 | 2018-05-26 17:58:47 -0600 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; version 2 of the License. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
Kyösti Mälkki | b9646a2 | 2013-07-03 08:06:32 +0300 | [diff] [blame] | 14 | #include <arch/io.h> |
Patrick Rudolph | 1af8923 | 2018-11-11 12:50:51 +0100 | [diff] [blame] | 15 | #include <bootblock_common.h> |
| 16 | #include <southbridge/intel/i82801ix/i82801ix.h> |
Kyösti Mälkki | b9646a2 | 2013-07-03 08:06:32 +0300 | [diff] [blame] | 17 | |
| 18 | /* Just define these here, there is no gm35.h file to include. */ |
| 19 | #define D0F0_PCIEXBAR_LO 0x60 |
| 20 | #define D0F0_PCIEXBAR_HI 0x64 |
| 21 | |
| 22 | static void bootblock_northbridge_init(void) |
| 23 | { |
| 24 | uint32_t reg; |
| 25 | |
| 26 | /* |
| 27 | * The "io" variant of the config access is explicitly used to |
Kyösti Mälkki | 6f66f41 | 2016-12-01 22:08:18 +0200 | [diff] [blame] | 28 | * setup the PCIEXBAR because CONFIG_MMCONF_SUPPORT is set to |
Kyösti Mälkki | b9646a2 | 2013-07-03 08:06:32 +0300 | [diff] [blame] | 29 | * to true. That way all subsequent non-explicit config accesses use |
| 30 | * MCFG. This code also assumes that bootblock_northbridge_init() is |
| 31 | * the first thing called in the non-asm boot block code. The final |
| 32 | * assumption is that no assembly code is using the |
Kyösti Mälkki | 6f66f41 | 2016-12-01 22:08:18 +0200 | [diff] [blame] | 33 | * CONFIG_MMCONF_SUPPORT option to do PCI config acceses. |
Kyösti Mälkki | b9646a2 | 2013-07-03 08:06:32 +0300 | [diff] [blame] | 34 | * |
| 35 | * The PCIEXBAR is assumed to live in the memory mapped IO space under |
| 36 | * 4GiB. |
| 37 | */ |
| 38 | reg = 0; |
| 39 | pci_io_write_config32(PCI_DEV(0,0,0), D0F0_PCIEXBAR_HI, reg); |
| 40 | reg = CONFIG_MMCONF_BASE_ADDRESS | 1; /* 256MiB - 0-255 buses. */ |
| 41 | pci_io_write_config32(PCI_DEV(0,0,0), D0F0_PCIEXBAR_LO, reg); |
| 42 | } |
| 43 | |
Patrick Rudolph | 1af8923 | 2018-11-11 12:50:51 +0100 | [diff] [blame] | 44 | static void enable_spi_prefetch(void) |
| 45 | { |
| 46 | u8 reg8; |
| 47 | pci_devfn_t dev; |
| 48 | |
| 49 | dev = PCI_DEV(0, 0x1f, 0); |
| 50 | |
| 51 | reg8 = pci_read_config8(dev, 0xdc); |
| 52 | reg8 &= ~(3 << 2); |
| 53 | reg8 |= (2 << 2); /* Prefetching and Caching Enabled */ |
| 54 | pci_write_config8(dev, 0xdc, reg8); |
| 55 | } |
| 56 | |
| 57 | static void bootblock_southbridge_init(void) |
| 58 | { |
| 59 | enable_spi_prefetch(); |
| 60 | |
| 61 | /* Enable RCBA */ |
Peter Lemenkov | 7b42811 | 2018-10-23 11:12:46 +0200 | [diff] [blame] | 62 | pci_write_config32(PCI_DEV(0, 0x1f, 0), RCBA, |
Patrick Rudolph | 1af8923 | 2018-11-11 12:50:51 +0100 | [diff] [blame] | 63 | (uintptr_t)DEFAULT_RCBA | 1); |
| 64 | } |
| 65 | |
| 66 | void bootblock_soc_init(void) |
Kyösti Mälkki | b9646a2 | 2013-07-03 08:06:32 +0300 | [diff] [blame] | 67 | { |
| 68 | bootblock_northbridge_init(); |
| 69 | bootblock_southbridge_init(); |
| 70 | } |