| 1 |
|
| 2 |
|
| 3 |
#include <arch/ioapic.h> |
| 4 |
#include <device/pci.h> |
| 5 |
#include <device/pci_ids.h> |
| 6 |
#include <soc/acpi.h> |
| 7 |
#include <soc/pci_devs.h> |
| 8 |
#include <soc/ramstage.h> |
| 9 |
#include <soc/chip_common.h> |
| 10 |
|
| 11 |
static void ioapic_read_resources(struct device *dev) |
| 12 |
{ |
| 13 |
pci_dev_read_resources(dev); |
| 14 |
|
| 15 |
u16 abar = pci_read_config16(dev, APIC_ABAR); |
| 16 |
if (!abar) |
| 17 |
return; |
| 18 |
const u32 addr = IO_APIC_ADDR | ((abar & 0xfff) << 8); |
| 19 |
|
| 20 |
printk(BIOS_DEBUG, " %s: IOAPIC Address: 0x%x\n", |
| 21 |
dev_path(dev), addr); |
| 22 |
|
| 23 |
mmio_range(dev, APIC_ABAR, addr, 0x100); |
| 24 |
} |
| 25 |
|
| 26 |
static void ioapic_init(struct device *dev) |
| 27 |
{ |
| 28 |
struct resource *resource; |
| 29 |
|
| 30 |
pci_dev_init(dev); |
| 31 |
|
| 32 |
|
| 33 |
resource = probe_resource(dev, APIC_ABAR); |
| 34 |
if (!resource) |
| 35 |
return; |
| 36 |
|
| 37 |
const union xeon_domain_path dn = { |
| 38 |
.domain_path = dev_get_domain_id(dev) |
| 39 |
}; |
| 40 |
|
| 41 |
|
| 42 |
assert(dn.stack < MAX_LOGIC_IIO_STACK); |
| 43 |
|
| 44 |
|
| 45 |
const u32 gsi_base = 24 + (dn.socket * MAX_LOGIC_IIO_STACK + dn.stack) * 8; |
| 46 |
|
| 47 |
ioapic_create_dev(dev, resource->base, gsi_base); |
| 48 |
} |
| 49 |
|
| 50 |
static const unsigned short ioapic_ids[] = { |
| 51 |
0x2036, |
| 52 |
0x2026, |
| 53 |
0 |
| 54 |
}; |
| 55 |
|
| 56 |
static struct device_operations ioapic_ops = { |
| 57 |
.read_resources = ioapic_read_resources, |
| 58 |
.set_resources = pci_dev_set_resources, |
| 59 |
.enable_resources = pci_dev_enable_resources, |
| 60 |
.init = ioapic_init, |
| 61 |
}; |
| 62 |
|
| 63 |
static const struct pci_driver ioapic_driver __pci_driver = { |
| 64 |
.ops = &ioapic_ops, |
| 65 |
.vendor = PCI_VID_INTEL, |
| 66 |
.devices = ioapic_ids, |
| 67 |
}; |