- Bump the LinuxBIOS major version
- Rename chip_config chip_operations throughout the tree
- Fix Config.lb on most of the Opteron Ports
- Fix the amd 8000 chipset support for setting the subsystem vendor and device ids
- Add detection of devices that are on the motherboard (i.e. In Config.lb)
- Baby step in getting the resource limit handling correct, Ignore fixed resources
- Only call enable_childrens_resources on devices we know will have children
  For some busses like i2c it is non-sense and we don't want it.
- Set the resource limits for pnp devices resources.
- Improve the resource size detection for pnp devices.
- Added a configuration register to amd8111_ide.c so we can enable/disable individual ide channels
- Added a header file to hold the prototype of isa_dma_init
- Fixed most of the superio chips so the should work now, the via superio pci device is the exception.
- The code compiles and runs so it is time for me to go to bed.


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1698 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
diff --git a/src/devices/device.c b/src/devices/device.c
index a2ded6d..5f28c0d 100644
--- a/src/devices/device.c
+++ b/src/devices/device.c
@@ -320,15 +320,6 @@
 			bridge->align = resource->align;
 		}
 
-		/* Propogate the resource limit to the bridge register */
-		if (bridge->limit > resource->limit) {
-			bridge->limit = resource->limit;
-		}
-		/* Artificially deny limits between DEVICE_MEM_HIGH and 0xffffffff */
-		if ((bridge->limit > DEVICE_MEM_HIGH) && (bridge->limit <= 0xffffffff)) {
-			bridge->limit = DEVICE_MEM_HIGH;
-		}
-
 		/* Make certain we are dealing with a good minimum size */
 		size = resource->size;
 		align = resource->align;
@@ -338,6 +329,14 @@
 		if (resource->flags & IORESOURCE_FIXED) {
 			continue;
 		}
+		/* Propogate the resource limit to the bridge register */
+		if (bridge->limit > resource->limit) {
+			bridge->limit = resource->limit;
+		}
+		/* Artificially deny limits between DEVICE_MEM_HIGH and 0xffffffff */
+		if ((bridge->limit > DEVICE_MEM_HIGH) && (bridge->limit <= 0xffffffff)) {
+			bridge->limit = DEVICE_MEM_HIGH;
+		}
 		if (resource->flags & IORESOURCE_IO) {
 			/* Don't allow potential aliases over the
 			 * legacy pci expansion card addresses.
diff --git a/src/devices/pci_device.c b/src/devices/pci_device.c
index a7b2ff3..1c8c8be 100644
--- a/src/devices/pci_device.c
+++ b/src/devices/pci_device.c
@@ -485,7 +485,7 @@
 
 	/* Set the subsystem vendor and device id for mainboard devices */
 	ops = ops_pci(dev);
-	if (dev->chip_ops && ops && ops->set_subsystem) {
+	if (dev->on_mainboard && ops && ops->set_subsystem) {
 		printk_debug("%s subsystem <- %02x/%02x\n",
 			dev_path(dev), 
 			MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID,
@@ -499,8 +499,6 @@
 	command |= (PCI_COMMAND_PARITY + PCI_COMMAND_SERR); /* error check */
 	printk_debug("%s cmd <- %02x\n", dev_path(dev), command);
 	pci_write_config16(dev, PCI_COMMAND, command);
-
-	enable_childrens_resources(dev);
 }
 
 void pci_bus_enable_resources(struct device *dev)
@@ -513,9 +511,11 @@
 	pci_write_config16(dev, PCI_BRIDGE_CONTROL, ctrl);
 
 	pci_dev_enable_resources(dev);
+
+	enable_childrens_resources(dev);
 }
 
-static void pci_dev_set_subsystem(device_t dev, unsigned vendor, unsigned device)
+void pci_dev_set_subsystem(device_t dev, unsigned vendor, unsigned device)
 {
 	pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, 
 		((device & 0xffff) << 16) | (vendor & 0xffff));
diff --git a/src/devices/pnp_device.c b/src/devices/pnp_device.c
index 70286ad..cde571f 100644
--- a/src/devices/pnp_device.c
+++ b/src/devices/pnp_device.c
@@ -132,7 +132,7 @@
 static void pnp_get_ioresource(device_t dev, unsigned index, struct io_info *info)
 {
 	struct resource *resource;
-	uint32_t size;
+	unsigned moving, gran, step;
 
 	resource = new_resource(dev, index);
 	
@@ -140,11 +140,32 @@
 	resource->limit = 0xffff;
 	resource->flags |= IORESOURCE_IO;
 	
+	/* Get the resource size */
+	moving = info->mask;
+	gran = 15;
+	step = 1 << gran;
+	/* Find the first bit that moves */
+	while((moving & step) == 0) {
+		gran--;
+		step >>= 1;
+	}
+	/* Now find the first bit that does not move */
+	while((moving & step) != 0) {
+		gran--;
+		step >>= 1;
+	}
+	/* Of the moving bits the last bit in the first group,
+	 * tells us the size of this resource.
+	 */
+	if ((moving & step) == 0) {
+		gran++;
+		step <<= 1;
+	}
 	/* Set the resource size and alignment */
-	size = (0xffff & info->mask);
-	resource->size  = (~(size | 0xfffff800) + 1);
-	resource->align = log2(resource->size);
-	resource->gran  = resource->align;
+	resource->gran  = gran;
+	resource->align = gran;
+	resource->limit = info->mask | (step - 1);
+	resource->size  = 1 << gran;
 }
 
 static void get_resources(device_t dev, struct pnp_info *info)
diff --git a/src/devices/root_device.c b/src/devices/root_device.c
index 8e85212..95189e0 100644
--- a/src/devices/root_device.c
+++ b/src/devices/root_device.c
@@ -151,11 +151,10 @@
  * @brief Default device operation for root device
  *
  * This is the default device operation for root devices in PCI based systems.
- * The static enumeration code chip_control::enumerate() of mainboards usually
- * override this operation with their own device operations. An notable
- * example is mainboard operations for AMD K8 mainboards. They replace the
- * scan_bus() method with amdk8_scan_root_bus() due to the special device
- * layout of AMD K8 systems.
+ * These operations should be fully usable as is.  However the 
+ * chip_operations::dev_enable of a motherboard can override this if you
+ * want non-default behavior.  Currently src/mainboard/arima/hdama/mainbaord.c
+ * does this for debugging purposes.
  */
 struct device_operations default_dev_ops_root = {
 	.read_resources   = root_dev_read_resources,