drivers/intel/ish: Hook get ISH version into `.final`

This patch creates .final hook to call into get ISH version function
if platform has required config
(`SOC_INTEL_STORE_CSE_FPT_PARTITION_VERSION`) support.

BUG=b:273661726
TEST=The ISHC version, 5.4.2.7779, was retrieved on the google/nivviks.

Signed-off-by: Dinesh Gehlot <digehlot@google.com>
Change-Id: Ib3f983d5de5b169474bcdb1e9e2934174a9dadf8
Reviewed-on: https://review.coreboot.org/c/coreboot/+/74209
Reviewed-by: Kangheui Won <khwon@chromium.org>
Reviewed-by: Sridhar Siricilla <sridhar.siricilla@intel.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/drivers/intel/ish/ish.c b/src/drivers/intel/ish/ish.c
index a232217..0415af0 100644
--- a/src/drivers/intel/ish/ish.c
+++ b/src/drivers/intel/ish/ish.c
@@ -2,9 +2,11 @@
 
 #include <acpi/acpi_device.h>
 #include <acpi/acpigen.h>
+#include <cbmem.h>
 #include <console/console.h>
 #include <device/pci.h>
 #include <device/pci_ids.h>
+#include <intelblocks/cse.h>
 #include "chip.h"
 
 static void ish_fill_ssdt_generator(const struct device *dev)
@@ -46,6 +48,25 @@
 	dev->ops = &intel_ish_ops;
 }
 
+static void intel_ish_get_version(void)
+{
+	struct cse_fw_partition_info *version = cbmem_find(CBMEM_ID_CSE_PARTITION_VERSION);
+	if (version == NULL)
+		return;
+
+	printk(BIOS_DEBUG, "ISH version: %d.%d.%d.%d\n",
+		version->ish_partition_info.cur_ish_fw_version.major,
+		version->ish_partition_info.cur_ish_fw_version.minor,
+		version->ish_partition_info.cur_ish_fw_version.hotfix,
+		version->ish_partition_info.cur_ish_fw_version.build);
+}
+
+static void intel_ish_final(struct device *dev)
+{
+	if (CONFIG(SOC_INTEL_STORE_CSE_FPT_PARTITION_VERSION))
+		intel_ish_get_version();
+}
+
 /* Copy of default_pci_ops_dev with scan_bus addition */
 static const struct device_operations pci_ish_device_ops = {
 	.read_resources   = pci_dev_read_resources,
@@ -54,6 +75,7 @@
 	.init             = pci_dev_init,
 	.scan_bus         = &scan_generic_bus, /* Non-default */
 	.ops_pci          = &pci_dev_ops_pci,
+	.final            = intel_ish_final,
 };
 
 static const unsigned short pci_device_ids[] = {