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