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 | |
Elyes HAOUAS | 696545d | 2018-05-25 13:11:37 +0200 | [diff] [blame] | 9 | static void nc_read_resources(struct device *dev) |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 10 | { |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 11 | int index = 0; |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 12 | |
| 13 | /* Read standard PCI resources. */ |
| 14 | pci_dev_read_resources(dev); |
| 15 | |
| 16 | /* 0 -> 0xa0000 */ |
Kyösti Mälkki | 5c3cbcd | 2021-06-25 13:02:55 +0300 | [diff] [blame] | 17 | ram_from_to(dev, index++, 0, 0xa0000); |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 18 | |
| 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älkki | 5c3cbcd | 2021-06-25 13:02:55 +0300 | [diff] [blame] | 26 | mmio_from_to(dev, index++, 0xa0000, 0xc0000); |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 27 | |
Kyösti Mälkki | 5c3cbcd | 2021-06-25 13:02:55 +0300 | [diff] [blame] | 28 | reserved_ram_from_to(dev, index++, 0xc0000, 1 * MiB); |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 29 | |
| 30 | /* 0x100000 -> cbmem_top - cacheable and usable */ |
Kyösti Mälkki | 5c3cbcd | 2021-06-25 13:02:55 +0300 | [diff] [blame] | 31 | ram_from_to(dev, index++, 1 * MiB, (uintptr_t)cbmem_top()); |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 32 | |
Lee Leahy | 79f065a | 2016-02-28 11:30:17 -0800 | [diff] [blame] | 33 | /* cbmem_top -> 0xc0000000 - reserved */ |
Kyösti Mälkki | 5c3cbcd | 2021-06-25 13:02:55 +0300 | [diff] [blame] | 34 | reserved_ram_from_to(dev, index++, (uintptr_t)cbmem_top(), 0xc0000000); |
Lee Leahy | 79f065a | 2016-02-28 11:30:17 -0800 | [diff] [blame] | 35 | |
| 36 | /* 0xc0000000 -> 4GiB is mmio. */ |
Kyösti Mälkki | 5c3cbcd | 2021-06-25 13:02:55 +0300 | [diff] [blame] | 37 | mmio_from_to(dev, index++, 0xc0000000, 4ull * GiB); |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | static struct device_operations nc_ops = { |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 41 | .read_resources = nc_read_resources, |
| 42 | .set_resources = pci_dev_set_resources, |
| 43 | .enable_resources = pci_dev_enable_resources, |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | static const struct pci_driver systemagent_driver __pci_driver = { |
| 47 | .ops = &nc_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 48 | .vendor = PCI_VID_INTEL, |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 49 | .device = QUARK_MC_DEVICE_ID |
| 50 | }; |