soc/intel/common/block: Add option to have subsystem_id in common pci driver

This patch ensures all Intel common PCI devices can
have subsystem ID programmed along with PCI resource
enabling (.enable_resources) as part of PCI enumeration
process.

TEST=Build and boot KBL/CNL/APL/GLK to ensure PCI
subsystem ID getting programmed.
Example:
Enabling resources...
PCI: 00:00.0 subsystem <- 8086/590c
PCI: 00:00.0 cmd <- 06
PCI: 00:02.0 subsystem <- 8086/591e

Change-Id: I46307b0db78c8864c85865bd0f3328d5141971be
Signed-off-by: Subrata Banik <subrata.banik@intel.com>
Reviewed-on: https://review.coreboot.org/22768
Reviewed-by: Furquan Shaikh <furquan@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
diff --git a/src/soc/intel/common/block/cse/cse.c b/src/soc/intel/common/block/cse/cse.c
index 77a9b63..370074e 100644
--- a/src/soc/intel/common/block/cse/cse.c
+++ b/src/soc/intel/common/block/cse/cse.c
@@ -502,6 +502,7 @@
 	.read_resources		= pci_dev_read_resources,
 	.enable_resources	= pci_dev_enable_resources,
 	.init			= pci_dev_init,
+	.ops_pci		= &pci_dev_ops_pci,
 };
 
 static const unsigned short pci_device_ids[] = {
diff --git a/src/soc/intel/common/block/dsp/dsp.c b/src/soc/intel/common/block/dsp/dsp.c
index 5b4f932..365fab7 100644
--- a/src/soc/intel/common/block/dsp/dsp.c
+++ b/src/soc/intel/common/block/dsp/dsp.c
@@ -22,6 +22,7 @@
 	.read_resources         = &pci_dev_read_resources,
 	.set_resources          = &pci_dev_set_resources,
 	.enable_resources       = &pci_dev_enable_resources,
+	.ops_pci                = &pci_dev_ops_pci,
 	.scan_bus               = &scan_static_bus,
 };
 
diff --git a/src/soc/intel/common/block/graphics/graphics.c b/src/soc/intel/common/block/graphics/graphics.c
index 544ae96..4a1e557 100644
--- a/src/soc/intel/common/block/graphics/graphics.c
+++ b/src/soc/intel/common/block/graphics/graphics.c
@@ -99,6 +99,7 @@
 	.set_resources		= pci_dev_set_resources,
 	.enable_resources	= pci_dev_enable_resources,
 	.init			= graphics_soc_init,
+	.ops_pci		= &pci_dev_ops_pci,
 	.write_acpi_tables	= graphics_soc_write_acpi_opregion,
 };
 
diff --git a/src/soc/intel/common/block/i2c/i2c.c b/src/soc/intel/common/block/i2c/i2c.c
index c6f3be2..3bb7d11 100644
--- a/src/soc/intel/common/block/i2c/i2c.c
+++ b/src/soc/intel/common/block/i2c/i2c.c
@@ -172,6 +172,7 @@
 	.enable_resources		= &pci_dev_enable_resources,
 	.scan_bus			= &scan_smbus,
 	.ops_i2c_bus			= &i2c_bus_ops,
+	.ops_pci			= &pci_dev_ops_pci,
 	.init				= &lpss_i2c_dev_init,
 	.acpi_fill_ssdt_generator	= &lpss_i2c_acpi_fill_ssdt,
 };
diff --git a/src/soc/intel/common/block/lpc/lpc.c b/src/soc/intel/common/block/lpc/lpc.c
index 9d54e11..6b886e3 100644
--- a/src/soc/intel/common/block/lpc/lpc.c
+++ b/src/soc/intel/common/block/lpc/lpc.c
@@ -89,13 +89,14 @@
 }
 
 static struct device_operations device_ops = {
-	.read_resources = soc_lpc_read_resources,
-	.set_resources = set_resources,
-	.enable_resources = pci_dev_enable_resources,
-	.write_acpi_tables = southbridge_write_acpi_tables,
-	.acpi_inject_dsdt_generator = southbridge_inject_dsdt,
-	.init = lpc_init,
-	.scan_bus = scan_lpc_bus,
+	.read_resources			= soc_lpc_read_resources,
+	.set_resources			= set_resources,
+	.enable_resources		= pci_dev_enable_resources,
+	.write_acpi_tables		= southbridge_write_acpi_tables,
+	.acpi_inject_dsdt_generator	= southbridge_inject_dsdt,
+	.init				= lpc_init,
+	.scan_bus			= scan_lpc_bus,
+	.ops_pci			= &pci_dev_ops_pci,
 };
 
 static const unsigned short pci_device_ids[] = {
diff --git a/src/soc/intel/common/block/p2sb/p2sb.c b/src/soc/intel/common/block/p2sb/p2sb.c
index 63b9c85..6a9bd34 100644
--- a/src/soc/intel/common/block/p2sb/p2sb.c
+++ b/src/soc/intel/common/block/p2sb/p2sb.c
@@ -64,6 +64,7 @@
 static const struct device_operations device_ops = {
 	.read_resources		= read_resources,
 	.set_resources		= DEVICE_NOOP,
+	.ops_pci		= &pci_dev_ops_pci,
 };
 
 static const unsigned short pci_device_ids[] = {
diff --git a/src/soc/intel/common/block/pcie/pcie.c b/src/soc/intel/common/block/pcie/pcie.c
index 19133f0..7d383fd 100644
--- a/src/soc/intel/common/block/pcie/pcie.c
+++ b/src/soc/intel/common/block/pcie/pcie.c
@@ -24,6 +24,8 @@
 #define PCIE_LTR_MAX_NO_SNOOP_LATENCY_VALUE	0x1003
 /* Latency tolerance reporting, max snoop latency value 3.14ms */
 #define PCIE_LTR_MAX_SNOOP_LATENCY_VALUE	0x1003
+/* PCI-E Sub-System ID */
+#define PCIE_SUBSYSTEM_VENDOR_ID	0x94
 
 static void pch_pcie_init(struct device *dev)
 {
@@ -69,8 +71,16 @@
 			PCIE_LTR_MAX_SNOOP_LATENCY_VALUE);
 }
 
+static void pcie_dev_set_subsystem(struct device *dev,
+		unsigned vendor, unsigned device)
+{
+	pci_write_config32(dev, PCIE_SUBSYSTEM_VENDOR_ID,
+			((device & 0xffff) << 16) | (vendor & 0xffff));
+}
+
 static struct pci_operations pcie_ops = {
 	.set_L1_ss_latency = pcie_set_L1_ss_max_latency,
+	.set_subsystem = pcie_dev_set_subsystem,
 };
 
 static struct device_operations device_ops = {
diff --git a/src/soc/intel/common/block/pmc/pmc.c b/src/soc/intel/common/block/pmc/pmc.c
index 708e705..e1efe46 100644
--- a/src/soc/intel/common/block/pmc/pmc.c
+++ b/src/soc/intel/common/block/pmc/pmc.c
@@ -99,6 +99,7 @@
 	.set_resources		= &pci_dev_set_resources,
 	.enable_resources	= &pci_dev_enable_resources,
 	.init			= &pmc_soc_init,
+	.ops_pci		= &pci_dev_ops_pci,
 	.scan_bus		= &scan_lpc_bus,
 };
 
diff --git a/src/soc/intel/common/block/sata/sata.c b/src/soc/intel/common/block/sata/sata.c
index f300656..791510e 100644
--- a/src/soc/intel/common/block/sata/sata.c
+++ b/src/soc/intel/common/block/sata/sata.c
@@ -61,8 +61,9 @@
 static struct device_operations sata_ops = {
 	.read_resources		= &pci_dev_read_resources,
 	.set_resources		= &pci_dev_set_resources,
-	.enable_resources		= &pci_dev_enable_resources,
-	.final		= sata_final,
+	.enable_resources	= &pci_dev_enable_resources,
+	.final			= sata_final,
+	.ops_pci		= &pci_dev_ops_pci,
 };
 
 static const unsigned short pci_device_ids[] = {
diff --git a/src/soc/intel/common/block/scs/sd.c b/src/soc/intel/common/block/scs/sd.c
index d6f4843..66eaddf5 100644
--- a/src/soc/intel/common/block/scs/sd.c
+++ b/src/soc/intel/common/block/scs/sd.c
@@ -55,12 +55,13 @@
 #endif
 
 static struct device_operations dev_ops = {
-	.read_resources		  = &pci_dev_read_resources,
-	.set_resources		  = &pci_dev_set_resources,
-	.enable_resources	  = &pci_dev_enable_resources,
+	.read_resources			= &pci_dev_read_resources,
+	.set_resources			= &pci_dev_set_resources,
+	.enable_resources	 	= &pci_dev_enable_resources,
 #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
 	.acpi_fill_ssdt_generator	= &sd_fill_ssdt,
 #endif
+	.ops_pci			= &pci_dev_ops_pci,
 };
 
 static const unsigned short pci_device_ids[] = {
diff --git a/src/soc/intel/common/block/smbus/smbus.c b/src/soc/intel/common/block/smbus/smbus.c
index e526baf..880a061 100644
--- a/src/soc/intel/common/block/smbus/smbus.c
+++ b/src/soc/intel/common/block/smbus/smbus.c
@@ -83,6 +83,7 @@
 	.enable_resources	= &pci_dev_enable_resources,
 	.scan_bus		= &scan_smbus,
 	.init			= &pch_smbus_init,
+	.ops_pci		= &pci_dev_ops_pci,
 	.ops_smbus_bus		= &lops_smbus_bus,
 };
 
diff --git a/src/soc/intel/common/block/spi/spi.c b/src/soc/intel/common/block/spi/spi.c
index 9a34044..3a51466 100644
--- a/src/soc/intel/common/block/spi/spi.c
+++ b/src/soc/intel/common/block/spi/spi.c
@@ -49,6 +49,7 @@
 	.enable_resources		= &pci_dev_enable_resources,
 	.scan_bus			= &scan_generic_bus,
 	.ops_spi_bus			= &spi_bus_ops,
+	.ops_pci			= &pci_dev_ops_pci,
 };
 
 static const unsigned short pci_device_ids[] = {
diff --git a/src/soc/intel/common/block/sram/sram.c b/src/soc/intel/common/block/sram/sram.c
index 05fc5c7..49367e1 100644
--- a/src/soc/intel/common/block/sram/sram.c
+++ b/src/soc/intel/common/block/sram/sram.c
@@ -43,6 +43,7 @@
 	.set_resources		= pci_dev_set_resources,
 	.enable_resources	= pci_dev_enable_resources,
 	.init			= soc_sram_init,
+	.ops_pci		= &pci_dev_ops_pci,
 };
 
 static const unsigned short pci_device_ids[] = {
diff --git a/src/soc/intel/common/block/systemagent/systemagent.c b/src/soc/intel/common/block/systemagent/systemagent.c
index 5be9fe1..f6301dd 100644
--- a/src/soc/intel/common/block/systemagent/systemagent.c
+++ b/src/soc/intel/common/block/systemagent/systemagent.c
@@ -281,6 +281,7 @@
 	.set_resources    = &pci_dev_set_resources,
 	.enable_resources = &pci_dev_enable_resources,
 	.init             = soc_systemagent_init,
+	.ops_pci          = &pci_dev_ops_pci,
 };
 
 static const unsigned short systemagent_ids[] = {
diff --git a/src/soc/intel/common/block/uart/uart.c b/src/soc/intel/common/block/uart/uart.c
index 7685415..1be3a87 100644
--- a/src/soc/intel/common/block/uart/uart.c
+++ b/src/soc/intel/common/block/uart/uart.c
@@ -144,6 +144,7 @@
 	.read_resources		= &pch_uart_read_resources,
 	.set_resources		= &pci_dev_set_resources,
 	.enable_resources	= &uart_common_enable_resources,
+	.ops_pci		= &pci_dev_ops_pci,
 };
 
 static const unsigned short pci_device_ids[] = {
diff --git a/src/soc/intel/common/block/xdci/xdci.c b/src/soc/intel/common/block/xdci/xdci.c
index 7b74b21..10e6f0d 100644
--- a/src/soc/intel/common/block/xdci/xdci.c
+++ b/src/soc/intel/common/block/xdci/xdci.c
@@ -27,6 +27,7 @@
 	.set_resources		= &pci_dev_set_resources,
 	.enable_resources	= &pci_dev_enable_resources,
 	.init			= soc_xdci_init,
+	.ops_pci		= &pci_dev_ops_pci,
 };
 
 static const unsigned short pci_device_ids[] = {
diff --git a/src/soc/intel/common/block/xhci/xhci.c b/src/soc/intel/common/block/xhci/xhci.c
index ac7bd58..49a5169 100644
--- a/src/soc/intel/common/block/xhci/xhci.c
+++ b/src/soc/intel/common/block/xhci/xhci.c
@@ -27,6 +27,7 @@
 	.set_resources		= &pci_dev_set_resources,
 	.enable_resources	= &pci_dev_enable_resources,
 	.init			= soc_xhci_init,
+	.ops_pci		= &pci_dev_ops_pci,
 };
 
 static const unsigned short pci_device_ids[] = {