aboutsummaryrefslogtreecommitdiff
path: root/src/northbridge/intel
diff options
context:
space:
mode:
authorBill XIE <persmule@hardenedlinux.org>2023-04-03 21:54:56 +0800
committerFelix Held <felix-coreboot@felixheld.de>2023-04-06 12:21:23 +0000
commitf63cdcffbfb426788d5c43a9d222053fdad4563f (patch)
tree50316fe522e9882729ce196c4f7a1bee3a27177e /src/northbridge/intel
parentccbe9a54358049761d4e296c03ff972cfeb8555b (diff)
nb/intel/gm45: Export EDID-reading routine as a function
It will cache decoded EDID string in a static array. If called more than once, a pointer to the static array is directly returned, without reading EDID again. Signed-off-by: Bill XIE <persmule@hardenedlinux.org> Change-Id: Ibdbe4d76f9b59e7ae83b60cda042c2d1c39827ca Reviewed-on: https://review.coreboot.org/c/coreboot/+/74180 Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'src/northbridge/intel')
-rw-r--r--src/northbridge/intel/gm45/gm45.h3
-rw-r--r--src/northbridge/intel/gm45/gma.c42
2 files changed, 36 insertions, 9 deletions
diff --git a/src/northbridge/intel/gm45/gm45.h b/src/northbridge/intel/gm45/gm45.h
index f28c6d1495..c85a16ce59 100644
--- a/src/northbridge/intel/gm45/gm45.h
+++ b/src/northbridge/intel/gm45/gm45.h
@@ -447,6 +447,9 @@ int get_blc_values(const struct blc_pwm_t **entries);
u16 get_blc_pwm_freq_value(const char *edid_ascii_string);
#include <device/device.h>
+#include <edid.h>
+
+const char *gm45_get_lvds_edid_str(struct device *dev);
struct acpi_rsdp;
unsigned long northbridge_write_acpi_tables(const struct device *device, unsigned long start,
diff --git a/src/northbridge/intel/gm45/gma.c b/src/northbridge/intel/gm45/gma.c
index 804382224d..6759e743f5 100644
--- a/src/northbridge/intel/gm45/gma.c
+++ b/src/northbridge/intel/gm45/gma.c
@@ -143,16 +143,46 @@ static void gma_pm_init_post_vbios(struct device *const dev,
reg8));
}
-static void gma_func0_init(struct device *dev)
+const char *gm45_get_lvds_edid_str(struct device *dev)
{
u8 *mmio;
u8 edid_data_lvds[128];
struct edid edid_lvds;
+ static char edid_str[EDID_ASCII_STRING_LENGTH + 1];
+
+ if (edid_str[0])
+ return edid_str;
+ if (!gtt_res)
+ gtt_res = probe_resource(dev, PCI_BASE_ADDRESS_0);
+ if (!gtt_res)
+ return NULL;
+ mmio = res2mmio(gtt_res, 0, 0);
+
+ printk(BIOS_DEBUG, "LVDS EDID\n");
+ intel_gmbus_read_edid(mmio + GMBUS0, GMBUS_PORT_PANEL, 0x50,
+ edid_data_lvds, sizeof(edid_data_lvds));
+ intel_gmbus_stop(mmio + GMBUS0);
+
+ if (decode_edid(edid_data_lvds, sizeof(edid_data_lvds), &edid_lvds)
+ != EDID_CONFORMANT)
+ return NULL;
+ memcpy(edid_str, edid_lvds.ascii_string, sizeof(edid_str));
+ return edid_str;
+}
+
+static void gma_func0_init(struct device *dev)
+{
+ u8 *mmio;
const struct northbridge_intel_gm45_config *const conf = dev->chip_info;
+ const char *edid_str;
intel_gma_init_igd_opregion();
- gtt_res = probe_resource(dev, PCI_BASE_ADDRESS_0);
+ edid_str = gm45_get_lvds_edid_str(dev);
+ if (!edid_str)
+ printk(BIOS_ERR, "Failed to obtain LVDS EDID string!\n");
+
+ /* gtt_res should have been inited in gm45_get_lvds_edid_str() */
if (!gtt_res)
return;
mmio = res2mmio(gtt_res, 0, 0);
@@ -173,14 +203,8 @@ static void gma_func0_init(struct device *dev)
pci_dev_init(dev);
}
- printk(BIOS_DEBUG, "LVDS EDID\n");
- intel_gmbus_read_edid(mmio + GMBUS0, GMBUS_PORT_PANEL, 0x50,
- edid_data_lvds, sizeof(edid_data_lvds));
- intel_gmbus_stop(mmio + GMBUS0);
- decode_edid(edid_data_lvds, sizeof(edid_data_lvds), &edid_lvds);
-
/* Post VBIOS init */
- gma_pm_init_post_vbios(dev, edid_lvds.ascii_string);
+ gma_pm_init_post_vbios(dev, edid_str);
if (CONFIG(MAINBOARD_USE_LIBGFXINIT) && !acpi_is_wakeup_s3()) {
int vga_disable = (pci_read_config16(dev, D0F0_GGC) & 2) >> 1;