Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 2 | |
| 3 | // Use simple device model for this file even in ramstage |
| 4 | #define __SIMPLE_DEVICE__ |
| 5 | |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 6 | #include <device/pci_ops.h> |
Kyösti Mälkki | a963acd | 2019-08-16 20:34:25 +0300 | [diff] [blame] | 7 | #include <arch/romstage.h> |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 8 | #include <cbmem.h> |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 9 | #include <cpu/x86/mtrr.h> |
| 10 | #include <program_loading.h> |
| 11 | #include "e7505.h" |
| 12 | |
Arthur Heymans | 340e4b8 | 2019-10-23 17:25:58 +0200 | [diff] [blame] | 13 | void *cbmem_top_chipset(void) |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 14 | { |
Elyes HAOUAS | d13bd05 | 2020-04-22 16:39:20 +0200 | [diff] [blame] | 15 | const pci_devfn_t mch = PCI_DEV(0, 0, 0); |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 16 | uintptr_t tolm; |
| 17 | |
| 18 | /* This is at 128 MiB boundary. */ |
| 19 | tolm = pci_read_config16(mch, TOLM) >> 11; |
| 20 | tolm <<= 27; |
| 21 | |
| 22 | return (void *)tolm; |
| 23 | } |
| 24 | |
Kyösti Mälkki | 55b7263 | 2019-07-08 22:36:38 +0300 | [diff] [blame] | 25 | void northbridge_write_smram(u8 smram); |
| 26 | |
| 27 | void northbridge_write_smram(u8 smram) |
| 28 | { |
Elyes HAOUAS | d13bd05 | 2020-04-22 16:39:20 +0200 | [diff] [blame] | 29 | const pci_devfn_t mch = PCI_DEV(0, 0, 0); |
Kyösti Mälkki | 55b7263 | 2019-07-08 22:36:38 +0300 | [diff] [blame] | 30 | pci_write_config8(mch, SMRAMC, smram); |
| 31 | } |
| 32 | |
Kyösti Mälkki | 5bc641a | 2019-08-09 09:37:49 +0300 | [diff] [blame] | 33 | void fill_postcar_frame(struct postcar_frame *pcf) |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 34 | { |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 35 | uintptr_t top_of_ram; |
| 36 | |
Kyösti Mälkki | 371e7d9 | 2018-06-19 17:53:50 +0300 | [diff] [blame] | 37 | /* |
| 38 | * Choose to NOT set ROM as WP cacheable here. |
| 39 | * Timestamps indicate the CPU this northbridge code is |
| 40 | * connected to, performs better for memcpy() and un-lzma |
| 41 | * operations when source is left as UC. |
| 42 | */ |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 43 | |
Kyösti Mälkki | 544878b | 2019-08-09 11:41:15 +0300 | [diff] [blame] | 44 | pcf->skip_common_mtrr = 1; |
| 45 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 46 | /* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */ |
Kyösti Mälkki | 5bc641a | 2019-08-09 09:37:49 +0300 | [diff] [blame] | 47 | postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK); |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 48 | |
| 49 | /* Cache CBMEM region as WB. */ |
| 50 | top_of_ram = (uintptr_t)cbmem_top(); |
Kyösti Mälkki | 5bc641a | 2019-08-09 09:37:49 +0300 | [diff] [blame] | 51 | postcar_frame_add_mtrr(pcf, top_of_ram - 8*MiB, 8*MiB, |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 52 | MTRR_TYPE_WRBACK); |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 53 | } |