| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <acpi/acpi.h> |
| 5 |
#include <arch/hpet.h> |
| 6 |
#include <device/pci_ops.h> |
| 7 |
#include <stdint.h> |
| 8 |
#include <cpu/intel/model_2065x/model_2065x.h> |
| 9 |
#include <device/device.h> |
| 10 |
#include <device/pci.h> |
| 11 |
#include <device/pci_ids.h> |
| 12 |
#include "chip.h" |
| 13 |
#include <commonlib/bsd/helpers.h> |
| 14 |
#include "ironlake.h" |
| 15 |
#include <cpu/intel/smm_reloc.h> |
| 16 |
|
| 17 |
static int bridge_revision_id = -1; |
| 18 |
|
| 19 |
int bridge_silicon_revision(void) |
| 20 |
{ |
| 21 |
if (bridge_revision_id < 0) { |
| 22 |
uint8_t stepping = cpuid_eax(1) & 0x0f; |
| 23 |
uint8_t bridge_id = pci_read_config16(pcidev_on_root(0, 0), PCI_DEVICE_ID); |
| 24 |
bridge_revision_id = (bridge_id & 0xf0) | stepping; |
| 25 |
} |
| 26 |
return bridge_revision_id; |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
static void add_fixed_resources(struct device *dev, int index) |
| 38 |
{ |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
mmio_range(dev, index++, HPET_BASE_ADDRESS, 0x00100000); |
| 49 |
mmio_from_to(dev, index++, 0xa0000, 0xc0000); |
| 50 |
reserved_ram_from_to(dev, index++, 0xc0000, 1 * MiB); |
| 51 |
} |
| 52 |
|
| 53 |
#if CONFIG(HAVE_ACPI_TABLES) |
| 54 |
static const char *northbridge_acpi_name(const struct device *dev) |
| 55 |
{ |
| 56 |
if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 57 |
return "PCI0"; |
| 58 |
|
| 59 |
if (!is_pci_dev_on_bus(dev, 0)) |
| 60 |
return NULL; |
| 61 |
|
| 62 |
switch (dev->path.pci.devfn) { |
| 63 |
case PCI_DEVFN(0, 0): |
| 64 |
return "MCHC"; |
| 65 |
} |
| 66 |
|
| 67 |
return NULL; |
| 68 |
} |
| 69 |
#endif |
| 70 |
|
| 71 |
struct device_operations ironlake_pci_domain_ops = { |
| 72 |
.read_resources = pci_domain_read_resources, |
| 73 |
.set_resources = pci_domain_set_resources, |
| 74 |
.scan_bus = pci_host_bridge_scan_bus, |
| 75 |
#if CONFIG(HAVE_ACPI_TABLES) |
| 76 |
.acpi_name = northbridge_acpi_name, |
| 77 |
#endif |
| 78 |
}; |
| 79 |
|
| 80 |
static void mc_read_resources(struct device *dev) |
| 81 |
{ |
| 82 |
uint32_t tseg_base, tseg_end; |
| 83 |
uint64_t touud; |
| 84 |
uint16_t reg16; |
| 85 |
int index = 3; |
| 86 |
|
| 87 |
pci_dev_read_resources(dev); |
| 88 |
|
| 89 |
mmconf_resource(dev, 0x50); |
| 90 |
|
| 91 |
tseg_base = pci_read_config32(pcidev_on_root(0, 0), TSEG); |
| 92 |
tseg_end = tseg_base + CONFIG_SMM_TSEG_SIZE; |
| 93 |
touud = pci_read_config16(pcidev_on_root(0, 0), |
| 94 |
TOUUD); |
| 95 |
|
| 96 |
printk(BIOS_DEBUG, "ram_before_4g_top: 0x%x\n", tseg_base); |
| 97 |
printk(BIOS_DEBUG, "TOUUD: 0x%x\n", (unsigned int)touud); |
| 98 |
|
| 99 |
|
| 100 |
ram_range(dev, index++, 0, 0xa0000); |
| 101 |
ram_from_to(dev, index++, 1 * MiB, tseg_base); |
| 102 |
|
| 103 |
mmio_range(dev, index++, tseg_base, CONFIG_SMM_TSEG_SIZE); |
| 104 |
|
| 105 |
reg16 = pci_read_config16(pcidev_on_root(0, 0), GGC); |
| 106 |
const int uma_sizes_gtt[16] = |
| 107 |
{ 0, 1, 0, 2, 0, 0, 0, 0, 0, 2, 3, 4, 42, 42, 42, 42 }; |
| 108 |
|
| 109 |
const int uma_sizes_igd[16] = { |
| 110 |
0, 0, 0, 0, 0, 32, 48, 64, 128, 256, 96, 160, 224, 352, 256, 512 |
| 111 |
}; |
| 112 |
u32 igd_base, gtt_base; |
| 113 |
int uma_size_igd, uma_size_gtt; |
| 114 |
|
| 115 |
uma_size_igd = uma_sizes_igd[(reg16 >> 4) & 0xF]; |
| 116 |
uma_size_gtt = uma_sizes_gtt[(reg16 >> 8) & 0xF]; |
| 117 |
|
| 118 |
igd_base = |
| 119 |
pci_read_config32(pcidev_on_root(0, 0), IGD_BASE); |
| 120 |
gtt_base = |
| 121 |
pci_read_config32(pcidev_on_root(0, 0), GTT_BASE); |
| 122 |
if (gtt_base > tseg_end) { |
| 123 |
|
| 124 |
|
| 125 |
mmio_from_to(dev, index++, tseg_end, gtt_base); |
| 126 |
} |
| 127 |
mmio_range(dev, index++, gtt_base, uma_size_gtt * MiB); |
| 128 |
mmio_range(dev, index++, igd_base, uma_size_igd * MiB); |
| 129 |
|
| 130 |
upper_ram_end(dev, index++, touud * MiB); |
| 131 |
|
| 132 |
|
| 133 |
if (touud >= 8192 - 64) |
| 134 |
bad_ram_range(dev, index++, 0x1fc000000ULL, 0x004000000); |
| 135 |
|
| 136 |
add_fixed_resources(dev, index); |
| 137 |
} |
| 138 |
|
| 139 |
static void northbridge_init(struct device *dev) |
| 140 |
{ |
| 141 |
|
| 142 |
dmibar_write32(DMIUESTS, 0xffffffff); |
| 143 |
dmibar_write32(DMICESTS, 0xffffffff); |
| 144 |
|
| 145 |
dmibar_setbits32(DMILLTC, 1 << 29); |
| 146 |
|
| 147 |
dmibar_setbits32(0x1f8, 1 << 16); |
| 148 |
|
| 149 |
dmibar_setbits32(DMILCTL, 1 << 1 | 1 << 0); |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
static void ironlake_init(void *const chip_info) |
| 154 |
{ |
| 155 |
u32 deven_mask = UINT32_MAX; |
| 156 |
const struct device *dev; |
| 157 |
|
| 158 |
dev = pcidev_on_root(1, 0); |
| 159 |
if (!dev || !dev->enabled) { |
| 160 |
printk(BIOS_DEBUG, "Disabling PEG10.\n"); |
| 161 |
deven_mask &= ~DEVEN_PEG10; |
| 162 |
} |
| 163 |
dev = pcidev_on_root(2, 0); |
| 164 |
if (!dev || !dev->enabled) { |
| 165 |
printk(BIOS_DEBUG, "Disabling IGD.\n"); |
| 166 |
deven_mask &= ~DEVEN_IGD; |
| 167 |
} |
| 168 |
const struct device *const d0f0 = pcidev_on_root(0, 0); |
| 169 |
if (d0f0) |
| 170 |
pci_update_config32(d0f0, DEVEN, deven_mask, 0); |
| 171 |
} |
| 172 |
|
| 173 |
static struct device_operations mc_ops = { |
| 174 |
.read_resources = mc_read_resources, |
| 175 |
.set_resources = pci_dev_set_resources, |
| 176 |
.enable_resources = pci_dev_enable_resources, |
| 177 |
.init = northbridge_init, |
| 178 |
.acpi_fill_ssdt = generate_cpu_entries, |
| 179 |
.ops_pci = &pci_dev_ops_pci, |
| 180 |
}; |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
static const unsigned short pci_device_ids[] = { |
| 194 |
|
| 195 |
0x0040, |
| 196 |
0x0044, |
| 197 |
0x0048, |
| 198 |
|
| 199 |
|
| 200 |
0x0062, |
| 201 |
0x0069, |
| 202 |
0x006a, |
| 203 |
0 |
| 204 |
}; |
| 205 |
|
| 206 |
static const struct pci_driver mc_driver_ilk __pci_driver = { |
| 207 |
.ops = &mc_ops, |
| 208 |
.vendor = PCI_VID_INTEL, |
| 209 |
.devices = pci_device_ids, |
| 210 |
}; |
| 211 |
|
| 212 |
struct device_operations ironlake_cpu_bus_ops = { |
| 213 |
.read_resources = noop_read_resources, |
| 214 |
.set_resources = noop_set_resources, |
| 215 |
.init = mp_cpu_bus_init, |
| 216 |
}; |
| 217 |
|
| 218 |
struct chip_operations northbridge_intel_ironlake_ops = { |
| 219 |
.name = "Intel Ironlake integrated Northbridge", |
| 220 |
.init = ironlake_init, |
| 221 |
}; |