Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 2 | |
| 3 | #include <types.h> |
Angel Pons | c0c9516 | 2020-08-03 13:55:18 +0200 | [diff] [blame] | 4 | #include <commonlib/helpers.h> |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 5 | #include <console/console.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 6 | #include <acpi/acpi.h> |
| 7 | #include <acpi/acpigen.h> |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 8 | #include <device/device.h> |
Elyes HAOUAS | 748caed | 2019-12-19 17:02:08 +0100 | [diff] [blame] | 9 | #include <device/pci_def.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 10 | #include <device/pci_ops.h> |
Elyes HAOUAS | a1e22b8 | 2019-03-18 22:49:36 +0100 | [diff] [blame] | 11 | |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 12 | #include "gm45.h" |
| 13 | |
Vladimir Serbinenko | 8d70e94 | 2014-11-09 13:22:27 +0100 | [diff] [blame] | 14 | static unsigned long acpi_fill_dmar(unsigned long current) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 15 | { |
Arthur Heymans | 15063e8 | 2019-08-12 09:41:42 +0200 | [diff] [blame] | 16 | const struct device *dev; |
| 17 | |
| 18 | dev = pcidev_on_root(3, 0); |
| 19 | int me_active = dev && dev->enabled; |
| 20 | |
Arthur Heymans | 0845636 | 2019-08-12 09:21:30 +0200 | [diff] [blame] | 21 | dev = pcidev_on_root(2, 0); |
| 22 | int igd_active = dev && dev->enabled; |
| 23 | |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 24 | int stepping = pci_read_config8(pcidev_on_root(0, 0), |
| 25 | PCI_CLASS_REVISION); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 26 | |
| 27 | unsigned long tmp = current; |
| 28 | current += acpi_create_dmar_drhd(current, 0, 0, IOMMU_BASE1); |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 29 | current += acpi_create_dmar_ds_pci(current, 0, 0x1b, 0); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 30 | acpi_dmar_drhd_fixup(tmp, current); |
| 31 | |
Arthur Heymans | 0845636 | 2019-08-12 09:21:30 +0200 | [diff] [blame] | 32 | if (stepping != STEPPING_B2 && igd_active) { |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 33 | tmp = current; |
| 34 | current += acpi_create_dmar_drhd(current, 0, 0, IOMMU_BASE2); |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 35 | current += acpi_create_dmar_ds_pci(current, 0, 0x2, 0); |
| 36 | current += acpi_create_dmar_ds_pci(current, 0, 0x2, 1); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 37 | acpi_dmar_drhd_fixup(tmp, current); |
| 38 | } |
| 39 | |
| 40 | if (me_active) { |
| 41 | tmp = current; |
| 42 | current += acpi_create_dmar_drhd(current, 0, 0, IOMMU_BASE3); |
Matt DeVillier | 7866d49 | 2018-03-29 14:59:57 +0200 | [diff] [blame] | 43 | current += acpi_create_dmar_ds_pci(current, 0, 0x3, 0); |
| 44 | current += acpi_create_dmar_ds_pci(current, 0, 0x3, 1); |
| 45 | current += acpi_create_dmar_ds_pci(current, 0, 0x3, 2); |
| 46 | current += acpi_create_dmar_ds_pci(current, 0, 0x3, 3); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 47 | acpi_dmar_drhd_fixup(tmp, current); |
| 48 | } |
| 49 | |
| 50 | current += acpi_create_dmar_drhd(current, DRHD_INCLUDE_PCI_ALL, 0, IOMMU_BASE4); |
| 51 | |
| 52 | /* TODO: reserve GTT for 0.2.0 and 0.2.1? */ |
| 53 | return current; |
| 54 | } |
Vladimir Serbinenko | 33769a5 | 2014-08-30 22:39:20 +0200 | [diff] [blame] | 55 | |
Furquan Shaikh | 0f007d8 | 2020-04-24 06:41:18 -0700 | [diff] [blame] | 56 | unsigned long northbridge_write_acpi_tables(const struct device *device, |
Alexander Couzens | 83fc32f | 2015-04-12 22:28:37 +0200 | [diff] [blame] | 57 | unsigned long start, |
| 58 | struct acpi_rsdp *rsdp) |
Vladimir Serbinenko | 33769a5 | 2014-08-30 22:39:20 +0200 | [diff] [blame] | 59 | { |
| 60 | unsigned long current; |
Vladimir Serbinenko | 33769a5 | 2014-08-30 22:39:20 +0200 | [diff] [blame] | 61 | acpi_dmar_t *dmar; |
Vladimir Serbinenko | 33769a5 | 2014-08-30 22:39:20 +0200 | [diff] [blame] | 62 | |
| 63 | current = start; |
| 64 | |
Vladimir Serbinenko | 33769a5 | 2014-08-30 22:39:20 +0200 | [diff] [blame] | 65 | printk(BIOS_DEBUG, "ACPI: * DMAR\n"); |
Elyes Haouas | 3a99807 | 2022-11-18 15:11:02 +0100 | [diff] [blame] | 66 | dmar = (acpi_dmar_t *)current; |
Nico Huber | e561f35 | 2015-10-26 11:51:25 +0100 | [diff] [blame] | 67 | acpi_create_dmar(dmar, 0, acpi_fill_dmar); |
Vladimir Serbinenko | 33769a5 | 2014-08-30 22:39:20 +0200 | [diff] [blame] | 68 | current += dmar->header.length; |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 69 | current = acpi_align_current(current); |
Vladimir Serbinenko | 33769a5 | 2014-08-30 22:39:20 +0200 | [diff] [blame] | 70 | acpi_add_table(rsdp, dmar); |
Vladimir Serbinenko | 33769a5 | 2014-08-30 22:39:20 +0200 | [diff] [blame] | 71 | |
Aaron Durbin | 07a1b28 | 2015-12-10 17:07:38 -0600 | [diff] [blame] | 72 | current = acpi_align_current(current); |
Vladimir Serbinenko | 33769a5 | 2014-08-30 22:39:20 +0200 | [diff] [blame] | 73 | |
| 74 | printk(BIOS_DEBUG, "current = %lx\n", current); |
| 75 | |
| 76 | return current; |
| 77 | } |