drivers/intel/gma: Move IGD OpRegion to CBMEM
It never was in GNVS, it never belonged among the ACPI tables. Having
it in CBMEM, makes it easy to look the location up on resume, and saves
us additional boilerplate.
TEST=Booted Linux on Lenovo/X201s, confirmed ASLS is set and
intel_backlight + acpi_video synchronize, both before and
after suspend.
Change-Id: I5fdd6634e4a671a85b1df8bc9815296ff42edf29
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/40724
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/drivers/intel/gma/opregion.c b/src/drivers/intel/gma/opregion.c
index 566f351..7682af1 100644
--- a/src/drivers/intel/gma/opregion.c
+++ b/src/drivers/intel/gma/opregion.c
@@ -57,7 +57,7 @@
}
/* Write ASLS PCI register and prepare SWSCI register. */
-void intel_gma_opregion_register(uintptr_t opregion)
+static void intel_gma_opregion_register(uintptr_t opregion)
{
struct device *igd;
u16 reg16;
@@ -94,17 +94,16 @@
}
/* Restore ASLS register on S3 resume and prepare SWSCI. */
-void intel_gma_restore_opregion(void)
+static enum cb_err intel_gma_restore_opregion(void)
{
- if (acpi_is_wakeup_s3()) {
- const void *const gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS);
- uintptr_t aslb;
-
- if (gnvs && (aslb = gma_get_gnvs_aslb(gnvs)))
- intel_gma_opregion_register(aslb);
- else
- printk(BIOS_ERR, "Error: GNVS or ASLB not set.\n");
+ const igd_opregion_t *const opregion = cbmem_find(CBMEM_ID_IGD_OPREGION);
+ if (!opregion) {
+ printk(BIOS_ERR, "GMA: Failed to find IGD OpRegion.\n");
+ return CB_ERR;
}
+ /* Write ASLS PCI register and prepare SWSCI register. */
+ intel_gma_opregion_register((uintptr_t)opregion);
+ return CB_SUCCESS;
}
static enum cb_err vbt_validate(struct region_device *rdev)
@@ -224,14 +223,17 @@
}
/* Initialize IGD OpRegion, called from ACPI code and OS drivers */
-enum cb_err
-intel_gma_init_igd_opregion(igd_opregion_t *opregion)
+enum cb_err intel_gma_init_igd_opregion(void)
{
+ igd_opregion_t *opregion;
struct region_device rdev;
optionrom_vbt_t *vbt = NULL;
optionrom_vbt_t *ext_vbt;
bool found = false;
+ if (acpi_is_wakeup_s3())
+ return intel_gma_restore_opregion();
+
/* Search for vbt.bin in CBFS. */
if (locate_vbt_cbfs(&rdev) == CB_SUCCESS &&
vbt_validate(&rdev) == CB_SUCCESS) {
@@ -273,6 +275,12 @@
return CB_ERR;
}
+ opregion = cbmem_add(CBMEM_ID_IGD_OPREGION, sizeof(*opregion));
+ if (!opregion) {
+ printk(BIOS_ERR, "GMA: Failed to add IGD OpRegion to CBMEM.\n");
+ return CB_ERR;
+ }
+
memset(opregion, 0, sizeof(igd_opregion_t));
memcpy(&opregion->header.signature, IGD_OPREGION_SIGNATURE,
diff --git a/src/drivers/intel/gma/opregion.h b/src/drivers/intel/gma/opregion.h
index 079d08f..879017b 100644
--- a/src/drivers/intel/gma/opregion.h
+++ b/src/drivers/intel/gma/opregion.h
@@ -231,11 +231,7 @@
u8 coreblock_biossignon[155];
} __packed optionrom_vbt_t;
-void intel_gma_opregion_register(uintptr_t opregion);
-void intel_gma_restore_opregion(void);
-uintptr_t gma_get_gnvs_aslb(const void *gnvs);
-void gma_set_gnvs_aslb(void *gnvs, uintptr_t aslb);
-enum cb_err intel_gma_init_igd_opregion(igd_opregion_t *opregion);
+enum cb_err intel_gma_init_igd_opregion(void);
/*
* Returns the CBFS filename of the VBT blob.