blob: b1ac3d1124de2447669ea2f8e9e2d9f2be44ddd9 [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Kyösti Mälkki717b6e32018-05-17 14:16:03 +03002
3// Use simple device model for this file even in ramstage
4#define __SIMPLE_DEVICE__
5
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02006#include <device/pci_ops.h>
Kyösti Mälkkia963acd2019-08-16 20:34:25 +03007#include <arch/romstage.h>
Kyösti Mälkki717b6e32018-05-17 14:16:03 +03008#include <cbmem.h>
Kyösti Mälkki717b6e32018-05-17 14:16:03 +03009#include <cpu/x86/mtrr.h>
10#include <program_loading.h>
11#include "e7505.h"
12
Arthur Heymans340e4b82019-10-23 17:25:58 +020013void *cbmem_top_chipset(void)
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030014{
Elyes HAOUASd13bd052020-04-22 16:39:20 +020015 const pci_devfn_t mch = PCI_DEV(0, 0, 0);
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030016 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älkki55b72632019-07-08 22:36:38 +030025void northbridge_write_smram(u8 smram);
26
27void northbridge_write_smram(u8 smram)
28{
Elyes HAOUASd13bd052020-04-22 16:39:20 +020029 const pci_devfn_t mch = PCI_DEV(0, 0, 0);
Kyösti Mälkki55b72632019-07-08 22:36:38 +030030 pci_write_config8(mch, SMRAMC, smram);
31}
32
Kyösti Mälkki5bc641a2019-08-09 09:37:49 +030033void fill_postcar_frame(struct postcar_frame *pcf)
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030034{
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030035 uintptr_t top_of_ram;
36
Kyösti Mälkki371e7d92018-06-19 17:53:50 +030037 /*
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älkki717b6e32018-05-17 14:16:03 +030043
Kyösti Mälkki544878b2019-08-09 11:41:15 +030044 pcf->skip_common_mtrr = 1;
45
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030046 /* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
Kyösti Mälkki5bc641a2019-08-09 09:37:49 +030047 postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030048
49 /* Cache CBMEM region as WB. */
50 top_of_ram = (uintptr_t)cbmem_top();
Kyösti Mälkki5bc641a2019-08-09 09:37:49 +030051 postcar_frame_add_mtrr(pcf, top_of_ram - 8*MiB, 8*MiB,
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030052 MTRR_TYPE_WRBACK);
Kyösti Mälkki717b6e32018-05-17 14:16:03 +030053}