blob: 8fa81c715abe97a65e6e59932292a3708293569c [file] [log] [blame]
Kyösti Mälkkie87564f2017-04-15 20:07:53 +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#define __SIMPLE_DEVICE__
15
16#include <stdint.h>
17#include <arch/io.h>
18#include <cbmem.h>
19
20#define CBMEM_TOP_SCRATCHPAD 0x78
21
Kyösti Mälkki70d92b92017-04-19 19:57:01 +030022void backup_top_of_low_cacheable(uintptr_t ramtop)
Kyösti Mälkkie87564f2017-04-15 20:07:53 +030023{
24 uint16_t top_cache = ramtop >> 16;
25 pci_write_config16(PCI_DEV(0,0,0), CBMEM_TOP_SCRATCHPAD, top_cache);
26}
27
Kyösti Mälkki70d92b92017-04-19 19:57:01 +030028uintptr_t restore_top_of_low_cacheable(void)
Kyösti Mälkkie87564f2017-04-15 20:07:53 +030029{
30 uint16_t top_cache;
31 top_cache = pci_read_config16(PCI_DEV(0,0,0), CBMEM_TOP_SCRATCHPAD);
32 return (top_cache << 16);
33}