Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 1 | /* |
| 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> |
| 19 | #include <console/console.h> |
| 20 | #include <device/pci.h> |
| 21 | #include <device/pci_ids.h> |
| 22 | #include <soc/iomap.h> |
| 23 | #include <soc/ramstage.h> |
| 24 | |
| 25 | #define RES_IN_KIB(r) ((r) >> 10) |
| 26 | |
Elyes HAOUAS | 696545d | 2018-05-25 13:11:37 +0200 | [diff] [blame^] | 27 | static void nc_read_resources(struct device *dev) |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 28 | { |
| 29 | unsigned long base_k; |
| 30 | int index = 0; |
| 31 | unsigned long size_k; |
| 32 | |
| 33 | /* Read standard PCI resources. */ |
| 34 | pci_dev_read_resources(dev); |
| 35 | |
| 36 | /* 0 -> 0xa0000 */ |
| 37 | base_k = 0; |
| 38 | size_k = 0xa0000 - base_k; |
| 39 | ram_resource(dev, index++, RES_IN_KIB(base_k), RES_IN_KIB(size_k)); |
| 40 | |
| 41 | /* |
| 42 | * Reserve everything between A segment and 1MB: |
| 43 | * |
| 44 | * 0xa0000 - 0xbffff: legacy VGA |
| 45 | * 0xc0000 - 0xdffff: RAM |
| 46 | * 0xe0000 - 0xfffff: ROM shadow |
| 47 | */ |
| 48 | base_k += size_k; |
| 49 | size_k = 0xc0000 - base_k; |
| 50 | mmio_resource(dev, index++, RES_IN_KIB(base_k), RES_IN_KIB(size_k)); |
| 51 | |
| 52 | base_k += size_k; |
| 53 | size_k = 0x100000 - base_k; |
| 54 | reserved_ram_resource(dev, index++, RES_IN_KIB(base_k), |
| 55 | RES_IN_KIB(size_k)); |
| 56 | |
| 57 | /* 0x100000 -> cbmem_top - cacheable and usable */ |
| 58 | base_k += size_k; |
| 59 | size_k = (unsigned long)cbmem_top() - base_k; |
| 60 | ram_resource(dev, index++, RES_IN_KIB(base_k), RES_IN_KIB(size_k)); |
| 61 | |
Lee Leahy | 79f065a | 2016-02-28 11:30:17 -0800 | [diff] [blame] | 62 | /* cbmem_top -> 0xc0000000 - reserved */ |
| 63 | base_k += size_k; |
| 64 | size_k = 0xc0000000 - base_k; |
| 65 | reserved_ram_resource(dev, index++, RES_IN_KIB(base_k), |
| 66 | RES_IN_KIB(size_k)); |
| 67 | |
| 68 | /* 0xc0000000 -> 4GiB is mmio. */ |
Lee Leahy | 535333d | 2016-02-14 15:10:35 -0800 | [diff] [blame] | 69 | base_k += size_k; |
| 70 | size_k = 0x100000000ull - base_k; |
| 71 | mmio_resource(dev, index++, RES_IN_KIB(base_k), RES_IN_KIB(size_k)); |
| 72 | } |
| 73 | |
| 74 | static struct device_operations nc_ops = { |
| 75 | .read_resources = &nc_read_resources, |
| 76 | .set_resources = &pci_dev_set_resources, |
| 77 | .enable_resources = &pci_dev_enable_resources, |
| 78 | }; |
| 79 | |
| 80 | static const struct pci_driver systemagent_driver __pci_driver = { |
| 81 | .ops = &nc_ops, |
| 82 | .vendor = PCI_VENDOR_ID_INTEL, |
| 83 | .device = QUARK_MC_DEVICE_ID |
| 84 | }; |