chipset_enable: Probe AMD SPIBAR first and bail on ff
Testing on a ThinkPad T14s Gen3 has shown that the LPC device's
PCI config space can return all `ff' for everything from offset
0x44 on. Reasons are unknown at this point, so it seems best to
check for this and bail out.
Change-Id: I92dcbdc2eb31652faaad1dba3ad6978de0c8024b
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/200
diff --git a/chipset_enable.c b/chipset_enable.c
index 4e16782..acf62b2 100644
--- a/chipset_enable.c
+++ b/chipset_enable.c
@@ -1436,14 +1436,12 @@
return ERROR_FATAL;
}
- /* RomRange2 is supposed to be used for the mapping directly below 4G. */
- const uint32_t rom_range2 = pci_read_long(lpc, 0x6c);
- const uint32_t rom_range_end = rom_range2 | 0xffff;
- const uint32_t rom_range_start = (rom_range2 & 0xffff) << 16;
- const size_t mapped_len = rom_range_end > rom_range_start ? rom_range_end - rom_range_start + 1 : 0;
- msg_pdbg("ROM Range 2: 0x%08x..0x%08x (%zu kB)\n", rom_range_start, rom_range_end, mapped_len / KiB);
-
const uint32_t spibar = pci_read_long(lpc, 0xa0);
+ if (spibar == 0xffffffff) {
+ msg_perr("SPI100 BAR reads all `ff', aborting.\n");
+ return ERROR_FATAL;
+ }
+
msg_pdbg("AltSpiCSEnable=%u, SpiRomEnable=%u", spibar >> 0 & 1, spibar >> 1 & 1);
msg_pdbg(", AbortEnable=%u, RouteTpm2Spi=%u", spibar >> 2 & 1, spibar >> 3 & 1);
msg_pdbg(", PspSpiMmioSel=%u\n", spibar >> 4 & 1);
@@ -1468,6 +1466,13 @@
if (virt_spibar == ERROR_PTR)
return ERROR_FATAL;
+ /* RomRange2 is supposed to be used for the mapping directly below 4G. */
+ const uint32_t rom_range2 = pci_read_long(lpc, 0x6c);
+ const uint32_t rom_range_end = rom_range2 | 0xffff;
+ const uint32_t rom_range_start = (rom_range2 & 0xffff) << 16;
+ const size_t mapped_len = rom_range_end > rom_range_start ? rom_range_end - rom_range_start + 1 : 0;
+ msg_pdbg("ROM Range 2: 0x%08x..0x%08x (%zu kB)\n", rom_range_start, rom_range_end, mapped_len / KiB);
+
void *memory_mapping = NULL;
if (spirom_enable && mapped_len) {
memory_mapping = rphysmap("SPI100 memory mapping", rom_range_start, mapped_len);