| 1 |
|
| 2 |
|
| 3 |
#include <acpi/acpi.h> |
| 4 |
#include <acpi/acpigen.h> |
| 5 |
#include <device/device.h> |
| 6 |
#include <device/pci.h> |
| 7 |
#include <device/pci_ids.h> |
| 8 |
#include <stdint.h> |
| 9 |
#include <soc/iomap.h> |
| 10 |
#include <soc/iosf.h> |
| 11 |
#include <soc/pci_devs.h> |
| 12 |
#include <soc/ramstage.h> |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
uint32_t nc_read_top_of_low_memory(void) |
| 52 |
{ |
| 53 |
static uint32_t tolm; |
| 54 |
|
| 55 |
if (tolm) |
| 56 |
return tolm; |
| 57 |
|
| 58 |
tolm = iosf_bunit_read(BUNIT_BMBOUND) & ~((1 << 27) - 1); |
| 59 |
|
| 60 |
return tolm; |
| 61 |
} |
| 62 |
|
| 63 |
static void nc_read_resources(struct device *dev) |
| 64 |
{ |
| 65 |
uint64_t mmconf; |
| 66 |
uint64_t bmbound; |
| 67 |
uint64_t bmbound_hi; |
| 68 |
uint64_t smmrrh; |
| 69 |
uint64_t smmrrl; |
| 70 |
int index = 0; |
| 71 |
|
| 72 |
|
| 73 |
pci_dev_read_resources(dev); |
| 74 |
|
| 75 |
|
| 76 |
mmconf = iosf_bunit_read(BUNIT_MMCONF_REG) & ~((1 << 28) - 1); |
| 77 |
mmio_range(dev, BUNIT_MMCONF_REG, mmconf, CONFIG_ECAM_MMCONF_BUS_NUMBER * MiB); |
| 78 |
|
| 79 |
|
| 80 |
ram_from_to(dev, index++, 0, 0xa0000); |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
smmrrl = (iosf_bunit_read(BUNIT_SMRRL) & 0xffff) * MiB; |
| 85 |
smmrrh = ((iosf_bunit_read(BUNIT_SMRRH) & 0xffff) + 1) * MiB; |
| 86 |
|
| 87 |
|
| 88 |
ram_from_to(dev, index++, 0xc0000, smmrrl); |
| 89 |
|
| 90 |
if (smmrrh > smmrrl) |
| 91 |
reserved_ram_from_to(dev, index++, smmrrl, smmrrh); |
| 92 |
|
| 93 |
|
| 94 |
bmbound = nc_read_top_of_low_memory(); |
| 95 |
mmio_from_to(dev, index++, smmrrh, bmbound); |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
bmbound_hi = iosf_bunit_read(BUNIT_BMBOUND_HI) & ~((1 << 24) - 1); |
| 102 |
bmbound_hi <<= 4; |
| 103 |
upper_ram_end(dev, index++, bmbound_hi); |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
mmio_from_to(dev, index++, 0xa0000, 0xc0000); |
| 112 |
reserved_ram_from_to(dev, index++, 0xc0000, 1 * MiB); |
| 113 |
} |
| 114 |
|
| 115 |
static void nc_generate_ssdt(const struct device *dev) |
| 116 |
{ |
| 117 |
generate_cpu_entries(dev); |
| 118 |
|
| 119 |
acpigen_write_scope("\\"); |
| 120 |
acpigen_write_name_dword("TOLM", nc_read_top_of_low_memory()); |
| 121 |
acpigen_pop_len(); |
| 122 |
} |
| 123 |
|
| 124 |
static struct device_operations nc_ops = { |
| 125 |
.read_resources = nc_read_resources, |
| 126 |
.acpi_fill_ssdt = nc_generate_ssdt, |
| 127 |
.ops_pci = &soc_pci_ops, |
| 128 |
}; |
| 129 |
|
| 130 |
static const struct pci_driver nc_driver __pci_driver = { |
| 131 |
.ops = &nc_ops, |
| 132 |
.vendor = PCI_VID_INTEL, |
| 133 |
.device = SOC_DEVID, |
| 134 |
}; |