blob: 0507efcfa3f254fd2eaa86115bf3d7f8df468ccc [file] [log] [blame]
Lee Leahy535333d2016-02-14 15:10:35 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
5 * Copyright (C) 2014 Google Inc.
6 * Copyright (C) 2015 Intel Corporation.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#include <cbmem.h>
Lee Leahy535333d2016-02-14 15:10:35 -080019#include <device/pci.h>
20#include <device/pci_ids.h>
21#include <soc/iomap.h>
22#include <soc/ramstage.h>
23
24#define RES_IN_KIB(r) ((r) >> 10)
25
Elyes HAOUAS696545d2018-05-25 13:11:37 +020026static void nc_read_resources(struct device *dev)
Lee Leahy535333d2016-02-14 15:10:35 -080027{
28 unsigned long base_k;
29 int index = 0;
30 unsigned long size_k;
31
32 /* Read standard PCI resources. */
33 pci_dev_read_resources(dev);
34
35 /* 0 -> 0xa0000 */
36 base_k = 0;
37 size_k = 0xa0000 - base_k;
38 ram_resource(dev, index++, RES_IN_KIB(base_k), RES_IN_KIB(size_k));
39
40 /*
41 * Reserve everything between A segment and 1MB:
42 *
43 * 0xa0000 - 0xbffff: legacy VGA
44 * 0xc0000 - 0xdffff: RAM
45 * 0xe0000 - 0xfffff: ROM shadow
46 */
47 base_k += size_k;
48 size_k = 0xc0000 - base_k;
49 mmio_resource(dev, index++, RES_IN_KIB(base_k), RES_IN_KIB(size_k));
50
51 base_k += size_k;
52 size_k = 0x100000 - base_k;
53 reserved_ram_resource(dev, index++, RES_IN_KIB(base_k),
54 RES_IN_KIB(size_k));
55
56 /* 0x100000 -> cbmem_top - cacheable and usable */
57 base_k += size_k;
58 size_k = (unsigned long)cbmem_top() - base_k;
59 ram_resource(dev, index++, RES_IN_KIB(base_k), RES_IN_KIB(size_k));
60
Lee Leahy79f065a2016-02-28 11:30:17 -080061 /* cbmem_top -> 0xc0000000 - reserved */
62 base_k += size_k;
63 size_k = 0xc0000000 - base_k;
64 reserved_ram_resource(dev, index++, RES_IN_KIB(base_k),
65 RES_IN_KIB(size_k));
66
67 /* 0xc0000000 -> 4GiB is mmio. */
Lee Leahy535333d2016-02-14 15:10:35 -080068 base_k += size_k;
69 size_k = 0x100000000ull - base_k;
70 mmio_resource(dev, index++, RES_IN_KIB(base_k), RES_IN_KIB(size_k));
71}
72
73static struct device_operations nc_ops = {
Elyes HAOUAS1d191272018-11-27 12:23:48 +010074 .read_resources = nc_read_resources,
75 .set_resources = pci_dev_set_resources,
76 .enable_resources = pci_dev_enable_resources,
Lee Leahy535333d2016-02-14 15:10:35 -080077};
78
79static const struct pci_driver systemagent_driver __pci_driver = {
80 .ops = &nc_ops,
81 .vendor = PCI_VENDOR_ID_INTEL,
82 .device = QUARK_MC_DEVICE_ID
83};