Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [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 | |
| 14 | // Use simple device model for this file even in ramstage |
| 15 | #define __SIMPLE_DEVICE__ |
| 16 | |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 17 | #include <device/pci_ops.h> |
Kyösti Mälkki | a963acd | 2019-08-16 20:34:25 +0300 | [diff] [blame^] | 18 | #include <arch/romstage.h> |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 19 | #include <cbmem.h> |
| 20 | #include <console/console.h> |
| 21 | #include <cpu/intel/romstage.h> |
| 22 | #include <cpu/x86/mtrr.h> |
| 23 | #include <program_loading.h> |
| 24 | #include "e7505.h" |
| 25 | |
| 26 | void *cbmem_top(void) |
| 27 | { |
| 28 | pci_devfn_t mch = PCI_DEV(0, 0, 0); |
| 29 | uintptr_t tolm; |
| 30 | |
| 31 | /* This is at 128 MiB boundary. */ |
| 32 | tolm = pci_read_config16(mch, TOLM) >> 11; |
| 33 | tolm <<= 27; |
| 34 | |
| 35 | return (void *)tolm; |
| 36 | } |
| 37 | |
Kyösti Mälkki | 55b7263 | 2019-07-08 22:36:38 +0300 | [diff] [blame] | 38 | void northbridge_write_smram(u8 smram); |
| 39 | |
| 40 | void northbridge_write_smram(u8 smram) |
| 41 | { |
| 42 | pci_devfn_t mch = PCI_DEV(0, 0, 0); |
| 43 | pci_write_config8(mch, SMRAMC, smram); |
| 44 | } |
| 45 | |
Kyösti Mälkki | 5bc641a | 2019-08-09 09:37:49 +0300 | [diff] [blame] | 46 | void fill_postcar_frame(struct postcar_frame *pcf) |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 47 | { |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 48 | uintptr_t top_of_ram; |
| 49 | |
Kyösti Mälkki | 371e7d9 | 2018-06-19 17:53:50 +0300 | [diff] [blame] | 50 | /* |
| 51 | * Choose to NOT set ROM as WP cacheable here. |
| 52 | * Timestamps indicate the CPU this northbridge code is |
| 53 | * connected to, performs better for memcpy() and un-lzma |
| 54 | * operations when source is left as UC. |
| 55 | */ |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 56 | |
Kyösti Mälkki | 544878b | 2019-08-09 11:41:15 +0300 | [diff] [blame] | 57 | pcf->skip_common_mtrr = 1; |
| 58 | |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 59 | /* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */ |
Kyösti Mälkki | 5bc641a | 2019-08-09 09:37:49 +0300 | [diff] [blame] | 60 | 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] | 61 | |
| 62 | /* Cache CBMEM region as WB. */ |
| 63 | top_of_ram = (uintptr_t)cbmem_top(); |
Kyösti Mälkki | 5bc641a | 2019-08-09 09:37:49 +0300 | [diff] [blame] | 64 | 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] | 65 | MTRR_TYPE_WRBACK); |
Kyösti Mälkki | 717b6e3 | 2018-05-17 14:16:03 +0300 | [diff] [blame] | 66 | } |