blob: 60b79380df6312ca9fb16c51d2d19d4ee8a17c72 [file] [log] [blame]
Angel Pons230e4f9d2020-04-05 15:47:14 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lee Leahy2ed7eb72016-01-01 18:08:48 -08002
Kyösti Mälkki81100bf2019-08-16 10:37:15 +03003#include <arch/romstage.h>
Lee Leahy2ed7eb72016-01-01 18:08:48 -08004#include <cbmem.h>
Elyes HAOUAS58d3fce2020-05-27 18:29:07 +02005#include <cpu/x86/mtrr.h>
Lee Leahyf626b932016-07-10 14:13:19 -07006#include <soc/reg_access.h>
Lee Leahy9fd08952016-02-02 07:17:06 -08007
Kyösti Mälkki81100bf2019-08-16 10:37:15 +03008void fill_postcar_frame(struct postcar_frame *pcf)
9{
10 uintptr_t top_of_ram;
11 uintptr_t top_of_low_usable_memory;
12
13 /* Locate the top of RAM */
Elyes Haouas9018dee2022-11-18 15:07:33 +010014 top_of_low_usable_memory = (uintptr_t)cbmem_top();
Elyes Haouasd6b6b222022-10-10 12:34:21 +020015 top_of_ram = ALIGN_UP(top_of_low_usable_memory, 16 * MiB);
Kyösti Mälkki81100bf2019-08-16 10:37:15 +030016
17 /* Cache postcar and ramstage */
18 postcar_frame_add_mtrr(pcf, top_of_ram - (16 * MiB), 16 * MiB,
19 MTRR_TYPE_WRBACK);
20
21 /* Cache RMU area */
Elyes Haouas9018dee2022-11-18 15:07:33 +010022 postcar_frame_add_mtrr(pcf, (uintptr_t)top_of_low_usable_memory,
Kyösti Mälkki81100bf2019-08-16 10:37:15 +030023 0x10000, MTRR_TYPE_WRTHROUGH);
24
25 /* Cache ESRAM */
26 postcar_frame_add_mtrr(pcf, 0x80000000, 0x80000, MTRR_TYPE_WRBACK);
27
28 pcf->skip_common_mtrr = 1;
29 /* Cache SPI flash - Write protect not supported */
30 postcar_frame_add_romcache(pcf, MTRR_TYPE_WRTHROUGH);
31}