blob: c3b59e9415663e20d0eeb82bfbf26eacd3805619 [file] [log] [blame]
Kyösti Mälkki717b6e32018-05-17 14:16:03 +03001/*
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älkkif1b58b72019-03-01 13:43:02 +020017#include <device/pci_ops.h>
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030018#include <arch/cpu.h>
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
26void *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älkki55b72632019-07-08 22:36:38 +030038void northbridge_write_smram(u8 smram);
39
40void 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älkki5bc641a2019-08-09 09:37:49 +030046void fill_postcar_frame(struct postcar_frame *pcf)
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030047{
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030048 uintptr_t top_of_ram;
49
Kyösti Mälkki371e7d92018-06-19 17:53:50 +030050 /*
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älkki717b6e32018-05-17 14:16:03 +030056
57 /* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
Kyösti Mälkki5bc641a2019-08-09 09:37:49 +030058 postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030059
60 /* Cache CBMEM region as WB. */
61 top_of_ram = (uintptr_t)cbmem_top();
Kyösti Mälkki5bc641a2019-08-09 09:37:49 +030062 postcar_frame_add_mtrr(pcf, top_of_ram - 8*MiB, 8*MiB,
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030063 MTRR_TYPE_WRBACK);
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030064}