We define IO_APIC_ADDR in <arch/ioapic.h>, let's use it.
[coreboot.git] / src / southbridge / broadcom / bcm5785 / bcm5785_lpc.c
index 85f9eaf6c48c8ad60732c08251a467c6487ac6f7..bf70ef323ca030a1f54e035bb41c33642e594ecc 100644 (file)
@@ -13,6 +13,7 @@
 #include <pc80/isa-dma.h>
 #include <bitops.h>
 #include <arch/io.h>
+#include <arch/ioapic.h>
 #include "bcm5785.h"
 
 static void lpc_init(device_t dev)
@@ -47,46 +48,35 @@ static void bcm5785_lpc_read_resources(device_t dev)
                     IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
 
        res = new_resource(dev, 3); /* IOAPIC */
-       res->base = 0xfec00000;
+       res->base = IO_APIC_ADDR;
        res->size = 0x00001000;
        res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
 }
 
-/**     
+/**
  * @brief Enable resources for children devices
- *      
+ *
  * @param dev the device whos children's resources are to be enabled
- *      
- * This function is call by the global enable_resources() indirectly via the
- * device_operation::enable_resources() method of devices.
- *      
- * Indirect mutual recursion:
- *      enable_childrens_resources() -> enable_resources()
- *      enable_resources() -> device_operation::enable_resources()
- *      device_operation::enable_resources() -> enable_children_resources()
- */     
+ *
+ */
 static void bcm5785_lpc_enable_childrens_resources(device_t dev)
-{       
-        unsigned link; 
+{
+       struct bus *link;
        uint32_t reg;
-       int i;
-       int var_num = 0;
-       
+
        reg = pci_read_config8(dev, 0x44);
 
-        for (link = 0; link < dev->links; link++) {
+       for (link = dev->link_list; link; link = link->next) {
                 device_t child;
-                for (child = dev->link[link].children; child; child = child->sibling) {
-                        enable_resources(child);
+                for (child = link->children; child; child = child->sibling) {
                        if(child->enabled && (child->path.type == DEVICE_PATH_PNP)) {
-                               for(i=0;i<child->resources;i++) {
-                                       struct resource *res;
+                               struct resource *res;
+                               for(res = child->resource_list; res; res = res->next) {
                                        unsigned long base, end; // don't need long long
-                                       res = &child->resource[i];
                                        if(!(res->flags & IORESOURCE_IO)) continue;
                                        base = res->base;
                                        end = resource_end(res);
-                                       printk_debug("bcm5785lpc decode:%s, base=0x%08x, end=0x%08x\r\n",dev_path(child),base, end);
+                                       printk(BIOS_DEBUG, "bcm5785lpc decode:%s, base=0x%08lx, end=0x%08lx\n",dev_path(child),base, end);
                                        switch(base) {
                                        case 0x60: //KBC
                                        case 0x64:
@@ -94,10 +84,10 @@ static void bcm5785_lpc_enable_childrens_resources(device_t dev)
                                        case 0x3f8: // COM1
                                                reg |= (1<<6);  break;
                                        case 0x2f8: // COM2
-                                               reg |= (1<<7);  break; 
+                                               reg |= (1<<7);  break;
                                        case 0x378: // Parallal 1
                                                reg |= (1<<0); break;
-                                       case 0x3f0: // FD0 
+                                       case 0x3f0: // FD0
                                                reg |= (1<<26); break;
                                        case 0x220:  // Aduio 0
                                                reg |= (1<<14); break;
@@ -109,7 +99,7 @@ static void bcm5785_lpc_enable_childrens_resources(device_t dev)
                 }
         }
        pci_write_config32(dev, 0x44, reg);
-       
+
 
 }