blob: f1e5c634f54ec1dc8084ca11511da18f80e02c63 [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
Elyes HAOUAS696545d2018-05-25 13:11:37 +02009static void nc_read_resources(struct device *dev)
Lee Leahy535333d2016-02-14 15:10:35 -080010{
Lee Leahy535333d2016-02-14 15:10:35 -080011 int index = 0;
Lee Leahy535333d2016-02-14 15:10:35 -080012
13 /* Read standard PCI resources. */
14 pci_dev_read_resources(dev);
15
16 /* 0 -> 0xa0000 */
Kyösti Mälkki5c3cbcd2021-06-25 13:02:55 +030017 ram_from_to(dev, index++, 0, 0xa0000);
Lee Leahy535333d2016-02-14 15:10:35 -080018
19 /*
20 * Reserve everything between A segment and 1MB:
21 *
22 * 0xa0000 - 0xbffff: legacy VGA
23 * 0xc0000 - 0xdffff: RAM
24 * 0xe0000 - 0xfffff: ROM shadow
25 */
Kyösti Mälkki5c3cbcd2021-06-25 13:02:55 +030026 mmio_from_to(dev, index++, 0xa0000, 0xc0000);
Lee Leahy535333d2016-02-14 15:10:35 -080027
Kyösti Mälkki5c3cbcd2021-06-25 13:02:55 +030028 reserved_ram_from_to(dev, index++, 0xc0000, 1 * MiB);
Lee Leahy535333d2016-02-14 15:10:35 -080029
30 /* 0x100000 -> cbmem_top - cacheable and usable */
Kyösti Mälkki5c3cbcd2021-06-25 13:02:55 +030031 ram_from_to(dev, index++, 1 * MiB, (uintptr_t)cbmem_top());
Lee Leahy535333d2016-02-14 15:10:35 -080032
Lee Leahy79f065a2016-02-28 11:30:17 -080033 /* cbmem_top -> 0xc0000000 - reserved */
Kyösti Mälkki5c3cbcd2021-06-25 13:02:55 +030034 reserved_ram_from_to(dev, index++, (uintptr_t)cbmem_top(), 0xc0000000);
Lee Leahy79f065a2016-02-28 11:30:17 -080035
36 /* 0xc0000000 -> 4GiB is mmio. */
Kyösti Mälkki5c3cbcd2021-06-25 13:02:55 +030037 mmio_from_to(dev, index++, 0xc0000000, 4ull * GiB);
Lee Leahy535333d2016-02-14 15:10:35 -080038}
39
40static struct device_operations nc_ops = {
Elyes HAOUAS1d191272018-11-27 12:23:48 +010041 .read_resources = nc_read_resources,
42 .set_resources = pci_dev_set_resources,
43 .enable_resources = pci_dev_enable_resources,
Lee Leahy535333d2016-02-14 15:10:35 -080044};
45
46static const struct pci_driver systemagent_driver __pci_driver = {
47 .ops = &nc_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010048 .vendor = PCI_VID_INTEL,
Lee Leahy535333d2016-02-14 15:10:35 -080049 .device = QUARK_MC_DEVICE_ID
50};