Angel Pons | 236c637 | 2020-04-03 01:21:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
| 3 | |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 4 | /* |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 5 | * Ported to Intel XE7501DEVKIT by Agami Aruma |
| 6 | * Ported to AOpen DXPL Plus-U by Kyösti Mälkki |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame^] | 9 | #include <acpi/acpi.h> |
Elyes HAOUAS | ed69de3 | 2019-12-19 17:36:53 +0100 | [diff] [blame] | 10 | #include <device/pci_def.h> |
Kyösti Mälkki | 5e4a26a | 2019-07-03 07:50:45 +0300 | [diff] [blame] | 11 | |
| 12 | #define IOAPIC_ICH4 2 |
| 13 | #define IOAPIC_P64H2_BUS_B 3 /* IOAPIC 3 at 02:1c.0 */ |
| 14 | #define IOAPIC_P64H2_BUS_A 4 /* IOAPIC 4 at 02:1e.0 */ |
| 15 | |
| 16 | #define INTEL_IOAPIC_NUM_INTERRUPTS 24 /* Both ICH-4 and P64-H2 */ |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 17 | |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 18 | unsigned long acpi_fill_madt(unsigned long current) |
| 19 | { |
| 20 | unsigned int irq_start = 0; |
Kyösti Mälkki | 5e4a26a | 2019-07-03 07:50:45 +0300 | [diff] [blame] | 21 | struct device *bdev, *dev = NULL; |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 22 | struct resource* res = NULL; |
| 23 | |
Elyes HAOUAS | 4682986 | 2016-10-07 17:35:50 +0200 | [diff] [blame] | 24 | /* SJM: Hard-code CPU LAPIC entries for now */ |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 25 | current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, 0, 0); |
| 26 | current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, 1, 6); |
| 27 | current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, 2, 1); |
| 28 | current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current, 3, 7); |
| 29 | |
Elyes HAOUAS | 4682986 | 2016-10-07 17:35:50 +0200 | [diff] [blame] | 30 | /* Southbridge IOAPIC */ |
Kyösti Mälkki | 5e4a26a | 2019-07-03 07:50:45 +0300 | [diff] [blame] | 31 | current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *)current, IOAPIC_ICH4, |
| 32 | 0xfec00000, irq_start); |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 33 | irq_start += INTEL_IOAPIC_NUM_INTERRUPTS; |
| 34 | |
Kyösti Mälkki | 5e4a26a | 2019-07-03 07:50:45 +0300 | [diff] [blame] | 35 | bdev = pcidev_on_root(2, 0); |
Elyes HAOUAS | 4682986 | 2016-10-07 17:35:50 +0200 | [diff] [blame] | 36 | /* P64H2 Bus B IOAPIC */ |
Kyösti Mälkki | 5e4a26a | 2019-07-03 07:50:45 +0300 | [diff] [blame] | 37 | if (bdev) |
| 38 | dev = pcidev_path_behind(bdev->link_list, PCI_DEVFN(28, 0)); |
| 39 | if (dev) { |
| 40 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 41 | current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *)current, |
| 42 | IOAPIC_P64H2_BUS_B, res->base, irq_start); |
| 43 | irq_start += INTEL_IOAPIC_NUM_INTERRUPTS; |
| 44 | } |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 45 | |
Elyes HAOUAS | 4682986 | 2016-10-07 17:35:50 +0200 | [diff] [blame] | 46 | /* P64H2 Bus A IOAPIC */ |
Kyösti Mälkki | 5e4a26a | 2019-07-03 07:50:45 +0300 | [diff] [blame] | 47 | if (bdev) |
| 48 | dev = pcidev_path_behind(bdev->link_list, PCI_DEVFN(28, 0)); |
| 49 | if (dev) { |
| 50 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 51 | current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *)current, |
| 52 | IOAPIC_P64H2_BUS_A, res->base, irq_start); |
| 53 | irq_start += INTEL_IOAPIC_NUM_INTERRUPTS; |
| 54 | } |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 55 | |
Elyes HAOUAS | 4682986 | 2016-10-07 17:35:50 +0200 | [diff] [blame] | 56 | /* Map ISA IRQ 0 to IRQ 2 */ |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 57 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)current, 1, 0, 2, 0); |
| 58 | |
Elyes HAOUAS | 4682986 | 2016-10-07 17:35:50 +0200 | [diff] [blame] | 59 | /* IRQ9 differs from ISA standard - ours is active high, level-triggered */ |
Kyösti Mälkki | 9116270 | 2011-11-03 15:22:01 +0200 | [diff] [blame] | 60 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)current, 0, 9, 9, 0xD); |
| 61 | |
| 62 | return current; |
| 63 | } |