Skip to content

Commit

Permalink
soc/intel/*: Use SSDT to pass A4GB and A4GS
Browse files Browse the repository at this point in the history
GNVS is more fragile as you need to keep struct elements in sync with
ASL code.

Change-Id: I2cd5e6b56e4a0dbbb11f4a0ac97e8f84d53b90ec
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/64216
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Subrata Banik <subratabanik@google.com>
  • Loading branch information
ArthurHeymans committed May 16, 2022
1 parent 159520e commit 08769c6
Show file tree
Hide file tree
Showing 25 changed files with 54 additions and 51 deletions.
3 changes: 0 additions & 3 deletions src/soc/intel/alderlake/acpi.c
Expand Up @@ -445,9 +445,6 @@ void soc_fill_gnvs(struct global_nvs *gnvs)
/* Set USB2/USB3 wake enable bitmaps. */
gnvs->u2we = config->usb2_wake_enable_bitmap;
gnvs->u3we = config->usb3_wake_enable_bitmap;

/* Fill in Above 4GB MMIO resource */
sa_fill_gnvs(gnvs);
}

int soc_madt_sci_irq_polarity(int sci)
Expand Down
2 changes: 2 additions & 0 deletions src/soc/intel/alderlake/chip.c
Expand Up @@ -11,6 +11,7 @@
#include <intelblocks/irq.h>
#include <intelblocks/itss.h>
#include <intelblocks/pcie_rp.h>
#include <intelblocks/systemagent.h>
#include <intelblocks/xdci.h>
#include <soc/intel/common/vbt.h>
#include <soc/itss.h>
Expand Down Expand Up @@ -188,6 +189,7 @@ static struct device_operations pci_domain_ops = {
.scan_bus = &pci_domain_scan_bus,
#if CONFIG(HAVE_ACPI_TABLES)
.acpi_name = &soc_acpi_name,
.acpi_fill_ssdt = ssdt_set_above_4g_pci,
#endif
};

Expand Down
3 changes: 0 additions & 3 deletions src/soc/intel/apollolake/acpi.c
Expand Up @@ -86,9 +86,6 @@ void soc_fill_gnvs(struct global_nvs *gnvs)
gnvs->scdp = gpio_get_pad_portid(cfg->sdcard_cd_gpio);
gnvs->scdo = gpio_acpi_pin(cfg->sdcard_cd_gpio);
}

/* Fill in Above 4GB MMIO resource */
sa_fill_gnvs(gnvs);
}

int soc_madt_sci_irq_polarity(int sci)
Expand Down
2 changes: 0 additions & 2 deletions src/soc/intel/apollolake/acpi/globalnvs.asl
Expand Up @@ -23,6 +23,4 @@ Field (GNVS, ByteAcc, NoLock, Preserve)
SCDP, 8, // 0x29 - SD_CD GPIO portid
SCDO, 8, // 0x2A - GPIO pad offset relative to the community
UIOR, 8, // 0x2B - UART debug controller init on S3 resume
A4GB, 64, // 0x2C - 0x33 Base of above 4GB MMIO Resource
A4GS, 64, // 0x34 - 0x3B Length of above 4GB MMIO Resource
}
3 changes: 3 additions & 0 deletions src/soc/intel/apollolake/acpi/northbridge.asl
Expand Up @@ -22,6 +22,9 @@ Device (MCHC)
}
}

External (A4GS, IntObj)
External (A4GB, IntObj)

/* Current Resource Settings */
Method (_CRS, 0, Serialized)
{
Expand Down
2 changes: 2 additions & 0 deletions src/soc/intel/apollolake/chip.c
Expand Up @@ -22,6 +22,7 @@
#include <intelblocks/gpio.h>
#include <intelblocks/itss.h>
#include <intelblocks/pmclib.h>
#include <intelblocks/systemagent.h>
#include <option.h>
#include <soc/cpu.h>
#include <soc/heci.h>
Expand Down Expand Up @@ -202,6 +203,7 @@ static struct device_operations pci_domain_ops = {
.set_resources = pci_domain_set_resources,
.scan_bus = pci_domain_scan_bus,
.acpi_name = &soc_acpi_name,
.acpi_fill_ssdt = ssdt_set_above_4g_pci,
};

static struct device_operations cpu_bus_ops = {
Expand Down
2 changes: 0 additions & 2 deletions src/soc/intel/apollolake/include/soc/nvs.h
Expand Up @@ -28,8 +28,6 @@ struct __packed global_nvs {
uint8_t scdo; /* 0x2A - GPIO pad offset relative to the community */
uint8_t uior; /* 0x2B - UART debug controller init on S3
resume */
uint64_t a4gb; /* 0x2C - 0x33 Base of above 4GB MMIO Resource */
uint64_t a4gs; /* 0x34 - 0x3B Length of above 4GB MMIO Resource */
};

#endif /* _SOC_APOLLOLAKE_NVS_H_ */
3 changes: 0 additions & 3 deletions src/soc/intel/cannonlake/acpi.c
Expand Up @@ -179,9 +179,6 @@ void soc_fill_gnvs(struct global_nvs *gnvs)
/* Set USB2/USB3 wake enable bitmaps. */
gnvs->u2we = config->usb2_wake_enable_bitmap;
gnvs->u3we = config->usb3_wake_enable_bitmap;

/* Fill in Above 4GB MMIO resource */
sa_fill_gnvs(gnvs);
}

int soc_madt_sci_irq_polarity(int sci)
Expand Down
2 changes: 2 additions & 0 deletions src/soc/intel/cannonlake/chip.c
Expand Up @@ -10,6 +10,7 @@
#include <intelblocks/irq.h>
#include <intelblocks/itss.h>
#include <intelblocks/pcie_rp.h>
#include <intelblocks/systemagent.h>
#include <intelblocks/xdci.h>
#include <soc/intel/common/vbt.h>
#include <soc/pci_devs.h>
Expand Down Expand Up @@ -176,6 +177,7 @@ static struct device_operations pci_domain_ops = {
.scan_bus = &pci_domain_scan_bus,
#if CONFIG(HAVE_ACPI_TABLES)
.acpi_name = &soc_acpi_name,
.acpi_fill_ssdt = ssdt_set_above_4g_pci,
#endif
};

Expand Down
4 changes: 1 addition & 3 deletions src/soc/intel/common/block/acpi/acpi/globalnvs.asl
Expand Up @@ -22,7 +22,5 @@ Field (GNVS, ByteAcc, NoLock, Preserve)
U2WE, 16, // 0x2b - 0x2c USB2 Wake Enable Bitmap
U3WE, 16, // 0x2d - 0x2e USB3 Wake Enable Bitmap
UIOR, 8, // 0x2f - UART debug controller init on S3 resume
A4GB, 64, // 0x30 - 0x37 Base of above 4GB MMIO Resource
A4GS, 64, // 0x38 - 0x3f Length of above 4GB MMIO Resource
, 64, // 0x40 - 0x47 Hest log buffer (used in SMM, not ASL code)
, 64, // 0x30 - 0x37 Hest log buffer (used in SMM, not ASL code)
}
3 changes: 3 additions & 0 deletions src/soc/intel/common/block/acpi/acpi/northbridge.asl
Expand Up @@ -45,6 +45,9 @@ Device (MCHC)
}
}

External (A4GS, IntObj)
External (A4GB, IntObj)

Method (_CRS, 0, Serialized)
{
Name (MCRS, ResourceTemplate ()
Expand Down
4 changes: 1 addition & 3 deletions src/soc/intel/common/block/include/intelblocks/nvs.h
Expand Up @@ -24,9 +24,7 @@ struct __packed global_nvs {
u16 u2we; /* 0x2b - 0x2c USB2 Wake Enable Bitmap */
u16 u3we; /* 0x2d - 0x2e USB3 Wake Enable Bitmap */
u8 uior; /* 0x2f - UART debug controller init on S3 resume */
u64 a4gb; /* 0x30 - 0x37 Base of above 4GB MMIO Resource */
u64 a4gs; /* 0x38 - 0x3f Length of above 4GB MMIO Resource */
u64 hest_log_addr; /* 0x40 - 47 err log addr (used in SMM, not ASL code) */
u64 hest_log_addr; /* 0x30 - 0x37 err log addr (used in SMM, not ASL code) */
};

#endif
5 changes: 3 additions & 2 deletions src/soc/intel/common/block/include/intelblocks/systemagent.h
Expand Up @@ -77,8 +77,6 @@ uintptr_t sa_get_gsm_base(void);
uintptr_t sa_get_tseg_base(void);
/* API to get TSEG size */
size_t sa_get_tseg_size(void);
/* Fill MMIO resource above 4GB into GNVS */
void sa_fill_gnvs(struct global_nvs *gnvs);
/* API to lock PAM registers */
void sa_lock_pam(void);

Expand All @@ -104,4 +102,7 @@ int soc_get_uncore_prmmr_base_and_mask(uint64_t *base, uint64_t *mask);
/* Returns the maximum supported capacity of a channel as encoded by DDRSZ in MiB */
uint32_t soc_systemagent_max_chan_capacity_mib(u8 capid0_a_ddrsz);

/* To be called in the acpi_fill_ssdt op of the domain */
void ssdt_set_above_4g_pci(const struct device *dev);

#endif /* SOC_INTEL_COMMON_BLOCK_SA_H */
33 changes: 21 additions & 12 deletions src/soc/intel/common/block/systemagent/systemagent.c
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <acpi/acpigen.h>
#include <cbmem.h>
#include <console/console.h>
#include <cpu/cpu.h>
Expand Down Expand Up @@ -119,7 +120,7 @@ static const struct sa_mem_map_descriptor sa_memory_map[MAX_MAP_ENTRIES] = {
};

/* Read DRAM memory map register value through PCI configuration space */
static void sa_read_map_entry(struct device *dev,
static void sa_read_map_entry(const struct device *dev,
const struct sa_mem_map_descriptor *entry, uint64_t *result)
{
uint64_t value = 0;
Expand All @@ -136,17 +137,6 @@ static void sa_read_map_entry(struct device *dev,
*result = value;
}

/* Fill MMIO resource above 4GB into GNVS */
void sa_fill_gnvs(struct global_nvs *gnvs)
{
struct device *sa_dev = pcidev_path_on_root(SA_DEVFN_ROOT);

sa_read_map_entry(sa_dev, &sa_memory_map[SA_TOUUD_REG], &gnvs->a4gb);
gnvs->a4gs = POWER_OF_2(cpu_phys_address_size()) - gnvs->a4gb;
printk(BIOS_DEBUG, "PCI space above 4GB MMIO is at 0x%llx, len = 0x%llx\n",
gnvs->a4gb, gnvs->a4gs);
}

static void sa_get_mem_map(struct device *dev, uint64_t *values)
{
int i;
Expand Down Expand Up @@ -315,6 +305,25 @@ void sa_lock_pam(void)
pci_or_config8(dev, PAM0, PAM_LOCK);
}

void ssdt_set_above_4g_pci(const struct device *dev)
{
if (dev->path.type != DEVICE_PATH_DOMAIN)
return;

uint64_t touud;
sa_read_map_entry(pcidev_path_on_root(SA_DEVFN_ROOT), &sa_memory_map[SA_TOUUD_REG],
&touud);
const uint64_t len = POWER_OF_2(cpu_phys_address_size()) - touud;

const char *scope = acpi_device_path(dev);
acpigen_write_scope(scope);
acpigen_write_name_qword("A4GB", touud);
acpigen_write_name_qword("A4GS", len);
acpigen_pop_len();

printk(BIOS_DEBUG, "PCI space above 4GB MMIO is at 0x%llx, len = 0x%llx\n", touud, len);
}

static struct device_operations systemagent_ops = {
.read_resources = systemagent_read_resources,
.set_resources = pci_dev_set_resources,
Expand Down
3 changes: 0 additions & 3 deletions src/soc/intel/elkhartlake/acpi.c
Expand Up @@ -243,9 +243,6 @@ void soc_fill_gnvs(struct global_nvs *gnvs)
/* Set USB2/USB3 wake enable bitmaps. */
gnvs->u2we = config->usb2_wake_enable_bitmap;
gnvs->u3we = config->usb3_wake_enable_bitmap;

/* Fill in Above 4GB MMIO resource */
sa_fill_gnvs(gnvs);
}

int soc_madt_sci_irq_polarity(int sci)
Expand Down
2 changes: 2 additions & 0 deletions src/soc/intel/elkhartlake/chip.c
Expand Up @@ -9,6 +9,7 @@
#include <intelblocks/gpio.h>
#include <intelblocks/itss.h>
#include <intelblocks/pcie_rp.h>
#include <intelblocks/systemagent.h>
#include <intelblocks/xdci.h>
#include <soc/intel/common/vbt.h>
#include <soc/itss.h>
Expand Down Expand Up @@ -134,6 +135,7 @@ static struct device_operations pci_domain_ops = {
.scan_bus = &pci_domain_scan_bus,
#if CONFIG(HAVE_ACPI_TABLES)
.acpi_name = &soc_acpi_name,
.acpi_fill_ssdt = ssdt_set_above_4g_pci,
#endif
};

Expand Down
3 changes: 0 additions & 3 deletions src/soc/intel/icelake/acpi.c
Expand Up @@ -174,9 +174,6 @@ void soc_fill_gnvs(struct global_nvs *gnvs)
/* Set USB2/USB3 wake enable bitmaps. */
gnvs->u2we = config->usb2_wake_enable_bitmap;
gnvs->u3we = config->usb3_wake_enable_bitmap;

/* Fill in Above 4GB MMIO resource */
sa_fill_gnvs(gnvs);
}

int soc_madt_sci_irq_polarity(int sci)
Expand Down
6 changes: 4 additions & 2 deletions src/soc/intel/icelake/chip.c
Expand Up @@ -8,6 +8,7 @@
#include <intelblocks/cfg.h>
#include <intelblocks/gpio.h>
#include <intelblocks/itss.h>
#include <intelblocks/systemagent.h>
#include <intelblocks/xdci.h>
#include <soc/intel/common/vbt.h>
#include <soc/itss.h>
Expand Down Expand Up @@ -124,9 +125,10 @@ static struct device_operations pci_domain_ops = {
.read_resources = &pci_domain_read_resources,
.set_resources = &pci_domain_set_resources,
.scan_bus = &pci_domain_scan_bus,
#if CONFIG(HAVE_ACPI_TABLES)
#if CONFIG(HAVE_ACPI_TABLES)
.acpi_name = &soc_acpi_name,
#endif
.acpi_fill_ssdt = ssdt_set_above_4g_pci,
#endif
};

static struct device_operations cpu_bus_ops = {
Expand Down
3 changes: 0 additions & 3 deletions src/soc/intel/jasperlake/acpi.c
Expand Up @@ -254,9 +254,6 @@ void soc_fill_gnvs(struct global_nvs *gnvs)
/* Set USB2/USB3 wake enable bitmaps. */
gnvs->u2we = config->usb2_wake_enable_bitmap;
gnvs->u3we = config->usb3_wake_enable_bitmap;

/* Fill in Above 4GB MMIO resource */
sa_fill_gnvs(gnvs);
}

int soc_madt_sci_irq_polarity(int sci)
Expand Down
2 changes: 2 additions & 0 deletions src/soc/intel/jasperlake/chip.c
Expand Up @@ -9,6 +9,7 @@
#include <intelblocks/gpio.h>
#include <intelblocks/itss.h>
#include <intelblocks/pcie_rp.h>
#include <intelblocks/systemagent.h>
#include <intelblocks/xdci.h>
#include <soc/intel/common/vbt.h>
#include <soc/itss.h>
Expand Down Expand Up @@ -138,6 +139,7 @@ static struct device_operations pci_domain_ops = {
.scan_bus = &pci_domain_scan_bus,
#if CONFIG(HAVE_ACPI_TABLES)
.acpi_name = &soc_acpi_name,
.acpi_fill_ssdt = ssdt_set_above_4g_pci,
#endif
};

Expand Down
3 changes: 0 additions & 3 deletions src/soc/intel/skylake/acpi.c
Expand Up @@ -176,9 +176,6 @@ void soc_fill_gnvs(struct global_nvs *gnvs)
/* Set USB2/USB3 wake enable bitmaps. */
gnvs->u2we = config->usb2_wake_enable_bitmap;
gnvs->u3we = config->usb3_wake_enable_bitmap;

/* Fill in Above 4GB MMIO resource */
sa_fill_gnvs(gnvs);
}

static unsigned long soc_fill_dmar(unsigned long current)
Expand Down
3 changes: 3 additions & 0 deletions src/soc/intel/skylake/acpi/systemagent.asl
Expand Up @@ -48,6 +48,9 @@ Device (MCHC)
}
}

External (A4GS, IntObj)
External (A4GB, IntObj)

Method (_CRS, 0, Serialized)
{
Name (MCRS, ResourceTemplate ()
Expand Down
4 changes: 3 additions & 1 deletion src/soc/intel/skylake/chip.c
Expand Up @@ -17,6 +17,7 @@
#include <intelblocks/power_limit.h>
#include <intelblocks/xdci.h>
#include <intelblocks/p2sb.h>
#include <intelblocks/systemagent.h>
#include <intelpch/lockdown.h>
#include <soc/intel/common/vbt.h>
#include <soc/interrupt.h>
Expand Down Expand Up @@ -190,7 +191,8 @@ static struct device_operations pci_domain_ops = {
.set_resources = &pci_domain_set_resources,
.scan_bus = &pci_domain_scan_bus,
#if CONFIG(HAVE_ACPI_TABLES)
.acpi_name = &soc_acpi_name,
.acpi_name = &soc_acpi_name,
.acpi_fill_ssdt = ssdt_set_above_4g_pci,
#endif
};

Expand Down
3 changes: 0 additions & 3 deletions src/soc/intel/tigerlake/acpi.c
Expand Up @@ -269,9 +269,6 @@ void soc_fill_gnvs(struct global_nvs *gnvs)
/* Set USB2/USB3 wake enable bitmaps. */
gnvs->u2we = config->usb2_wake_enable_bitmap;
gnvs->u3we = config->usb3_wake_enable_bitmap;

/* Fill in Above 4GB MMIO resource */
sa_fill_gnvs(gnvs);
}

int soc_madt_sci_irq_polarity(int sci)
Expand Down
2 changes: 2 additions & 0 deletions src/soc/intel/tigerlake/chip.c
Expand Up @@ -10,6 +10,7 @@
#include <intelblocks/irq.h>
#include <intelblocks/itss.h>
#include <intelblocks/pcie_rp.h>
#include <intelblocks/systemagent.h>
#include <intelblocks/xdci.h>
#include <soc/intel/common/vbt.h>
#include <soc/itss.h>
Expand Down Expand Up @@ -180,6 +181,7 @@ static struct device_operations pci_domain_ops = {
.scan_bus = &pci_domain_scan_bus,
#if CONFIG(HAVE_ACPI_TABLES)
.acpi_name = &soc_acpi_name,
.acpi_fill_ssdt = ssdt_set_above_4g_pci,
#endif
};

Expand Down

0 comments on commit 08769c6

Please sign in to comment.