Angel Pons | 230e4f9d | 2020-04-05 15:47:14 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 2 | |
| 3 | #include <cbmem.h> |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 4 | #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 HAOUAS | 696545d | 2018-05-25 13:11:37 +0200 | [diff] [blame] | 11 | static void nc_read_resources(struct device *dev) |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 12 | { |
| 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 Leahy | 79f065a | 2016-02-28 11:30:17 -0800 | [diff] [blame] | 46 | /* 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 Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 53 | 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 | |
| 58 | static struct device_operations nc_ops = { |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 59 | .read_resources = nc_read_resources, |
| 60 | .set_resources = pci_dev_set_resources, |
| 61 | .enable_resources = pci_dev_enable_resources, |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | static const struct pci_driver systemagent_driver __pci_driver = { |
| 65 | .ops = &nc_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame^] | 66 | .vendor = PCI_VID_INTEL, |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 67 | .device = QUARK_MC_DEVICE_ID |
| 68 | }; |