Am Dienstag, den 25.01.2011, 13:24 +0100 schrieb Georgi, Patrick:
> I'm not quite sure if using weak functions to wrap the subsystem
> CONFIG_* values is actually the right approach, I'll work on a patch to
> discuss.
Here it is.
I tested it by providing a mainboard_pci_subsystem_vendor_id for my
board in its mainboard.c which returned a different constant value -
this was picked up by properly and reported on boot.
mainboard_pci_subsystem_device_id will work just the same.

Joseph, will this suffice to help you implement your requirement?

Everyone, any opinion on the design?
My main issue is that other code can still use the CONFIG_* values
directly. Maybe our lint mechanism should look for that?
Any other issues you have with this?

Signed-off-by: Patrick Georgi <[email protected]>
Index: coreboot/src/devices/pci_device.c
===================================================================
--- coreboot.orig/src/devices/pci_device.c
+++ coreboot/src/devices/pci_device.c
@@ -586,6 +586,16 @@ void pci_dev_set_resources(struct device
 	pci_write_config8(dev, PCI_CACHE_LINE_SIZE, 64 >> 2);
 }
 
+unsigned __attribute__((weak)) mainboard_pci_subsystem_vendor_id(__attribute__((unused)) struct device *dev)
+{
+		return CONFIG_MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID;
+}
+
+unsigned __attribute__((weak)) mainboard_pci_subsystem_device_id(__attribute__((unused)) struct device *dev)
+{
+		return CONFIG_MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID;
+}
+
 void pci_dev_enable_resources(struct device *dev)
 {
 	const struct pci_operations *ops;
@@ -595,11 +605,11 @@ void pci_dev_enable_resources(struct dev
 	ops = ops_pci(dev);
 	if (dev->on_mainboard && ops && ops->set_subsystem) {
 		printk(BIOS_DEBUG, "%s subsystem <- %02x/%02x\n", dev_path(dev),
-		       CONFIG_MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID,
-		       CONFIG_MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID);
+		       mainboard_pci_subsystem_vendor_id(dev),
+		       mainboard_pci_subsystem_device_id(dev));
 		ops->set_subsystem(dev,
-				   CONFIG_MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID,
-				   CONFIG_MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID);
+				   mainboard_pci_subsystem_vendor_id(dev),
+				   mainboard_pci_subsystem_device_id(dev));
 	}
 	command = pci_read_config16(dev, PCI_COMMAND);
 	command |= dev->command;
Index: coreboot/src/include/device/pci.h
===================================================================
--- coreboot.orig/src/include/device/pci.h
+++ coreboot/src/include/device/pci.h
@@ -103,4 +103,7 @@ static inline const struct pci_bus_opera
 	return bops;
 }
 
+unsigned mainboard_pci_subsystem_vendor_id(struct device *dev);
+unsigned mainboard_pci_subsystem_device_id(struct device *dev);
+
 #endif /* PCI_H */
Index: coreboot/src/southbridge/intel/i82801gx/pci.c
===================================================================
--- coreboot.orig/src/southbridge/intel/i82801gx/pci.c
+++ coreboot/src/southbridge/intel/i82801gx/pci.c
@@ -73,11 +73,11 @@ static void ich_pci_dev_enable_resources
 	if (dev->on_mainboard && ops && ops->set_subsystem) {
 		printk(BIOS_DEBUG, "%s subsystem <- %02x/%02x\n",
 			dev_path(dev),
-			CONFIG_MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID,
-			CONFIG_MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID);
+			mainboard_pci_subsystem_vendor_id(dev),
+			mainboard_pci_subsystem_device_id(dev));
 		ops->set_subsystem(dev,
-			CONFIG_MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID,
-			CONFIG_MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID);
+			mainboard_pci_subsystem_vendor_id(dev),
+			mainboard_pci_subsystem_device_id(dev));
 	}
 
 	command = pci_read_config16(dev, PCI_COMMAND);

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to