soc/intel/cmn/fast-spi: Add BIOS MMIO window as reserved region

Add the boot flash MMIO window to the resources to report this region as
reserved to the OS. This is done to stay consistent with the reserved
memory ranges by coreboot and make the OS aware of them.
As x86 systems preserves the upper 16 MiB below 4G for BIOS flash
decoding use the complete window for reporting independent of the
actually used SPI flash size. This will block the preserved MMIO window.

Change-Id: Ib3a77e9233c3c63bad4de926670edb4545ceaddf
Signed-off-by: Werner Zeh <werner.zeh@siemens.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/64077
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Subrata Banik <subratabanik@google.com>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/src/soc/intel/common/block/fast_spi/fast_spi.c b/src/soc/intel/common/block/fast_spi/fast_spi.c
index 3dc7440..c07b565 100644
--- a/src/soc/intel/common/block/fast_spi/fast_spi.c
+++ b/src/soc/intel/common/block/fast_spi/fast_spi.c
@@ -22,6 +22,9 @@
 #include <spi_flash.h>
 #include <spi-generic.h>
 
+#define FLASH_MMIO_SIZE		(16 * MiB)
+#define FLASH_BASE_ADDR		((0xffffffff - FLASH_MMIO_SIZE) + 1)
+
 /*
  * Get the FAST_SPIBAR.
  */
@@ -514,8 +517,18 @@
 	acpigen_pop_len(); /* Scope */
 }
 
+
+static void fast_spi_read_resources(struct device *dev)
+{
+	/* Read standard PCI resources. */
+	pci_dev_read_resources(dev);
+
+	/* Add SPI flash MMIO window as a reserved resource. */
+	mmio_resource(dev, 0, FLASH_BASE_ADDR / KiB, FLASH_MMIO_SIZE / KiB);
+}
+
 static struct device_operations fast_spi_dev_ops = {
-	.read_resources			= pci_dev_read_resources,
+	.read_resources			= fast_spi_read_resources,
 	.set_resources			= pci_dev_set_resources,
 	.enable_resources		= pci_dev_enable_resources,
 	.acpi_fill_ssdt			= fast_spi_fill_ssdt,