blob: 5cb0c812d7a6857754e8ce1bfc4d6e375b61d6af [file] [log] [blame]
Angel Pons230e4f9d2020-04-05 15:47:14 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lee Leahy535333d2016-02-14 15:10:35 -08002
3#include <cbmem.h>
Lee Leahy535333d2016-02-14 15:10:35 -08004#include <device/pci.h>
5#include <device/pci_ids.h>
6#include <soc/iomap.h>
7#include <soc/ramstage.h>
8
9#define RES_IN_KIB(r) ((r) >> 10)
10
Elyes HAOUAS696545d2018-05-25 13:11:37 +020011static void nc_read_resources(struct device *dev)
Lee Leahy535333d2016-02-14 15:10:35 -080012{
13 unsigned long base_k;
14 int index = 0;
15 unsigned long size_k;
16
17 /* Read standard PCI resources. */
18 pci_dev_read_resources(dev);
19
20 /* 0 -> 0xa0000 */
21 base_k = 0;
22 size_k = 0xa0000 - base_k;
23 ram_resource(dev, index++, RES_IN_KIB(base_k), RES_IN_KIB(size_k));
24
25 /*
26 * Reserve everything between A segment and 1MB:
27 *
28 * 0xa0000 - 0xbffff: legacy VGA
29 * 0xc0000 - 0xdffff: RAM
30 * 0xe0000 - 0xfffff: ROM shadow
31 */
32 base_k += size_k;
33 size_k = 0xc0000 - base_k;
34 mmio_resource(dev, index++, RES_IN_KIB(base_k), RES_IN_KIB(size_k));
35
36 base_k += size_k;
37 size_k = 0x100000 - base_k;
38 reserved_ram_resource(dev, index++, RES_IN_KIB(base_k),
39 RES_IN_KIB(size_k));
40
41 /* 0x100000 -> cbmem_top - cacheable and usable */
42 base_k += size_k;
43 size_k = (unsigned long)cbmem_top() - base_k;
44 ram_resource(dev, index++, RES_IN_KIB(base_k), RES_IN_KIB(size_k));
45
Lee Leahy79f065a2016-02-28 11:30:17 -080046 /* cbmem_top -> 0xc0000000 - reserved */
47 base_k += size_k;
48 size_k = 0xc0000000 - base_k;
49 reserved_ram_resource(dev, index++, RES_IN_KIB(base_k),
50 RES_IN_KIB(size_k));
51
52 /* 0xc0000000 -> 4GiB is mmio. */
Lee Leahy535333d2016-02-14 15:10:35 -080053 base_k += size_k;
54 size_k = 0x100000000ull - base_k;
55 mmio_resource(dev, index++, RES_IN_KIB(base_k), RES_IN_KIB(size_k));
56}
57
58static struct device_operations nc_ops = {
Elyes HAOUAS1d191272018-11-27 12:23:48 +010059 .read_resources = nc_read_resources,
60 .set_resources = pci_dev_set_resources,
61 .enable_resources = pci_dev_enable_resources,
Lee Leahy535333d2016-02-14 15:10:35 -080062};
63
64static const struct pci_driver systemagent_driver __pci_driver = {
65 .ops = &nc_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010066 .vendor = PCI_VID_INTEL,
Lee Leahy535333d2016-02-14 15:10:35 -080067 .device = QUARK_MC_DEVICE_ID
68};