diff options
Diffstat (limited to 'src/devices')
-rw-r--r-- | src/devices/device.c | 17 | ||||
-rw-r--r-- | src/devices/pci_device.c | 8 | ||||
-rw-r--r-- | src/devices/pnp_device.c | 31 | ||||
-rw-r--r-- | src/devices/root_device.c | 9 |
4 files changed, 42 insertions, 23 deletions
diff --git a/src/devices/device.c b/src/devices/device.c index a2ded6d17c..5f28c0d49e 100644 --- a/src/devices/device.c +++ b/src/devices/device.c @@ -320,15 +320,6 @@ void compute_allocate_resource( 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 @@ void compute_allocate_resource( 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 a7b2ff3e89..1c8c8bea84 100644 --- a/src/devices/pci_device.c +++ b/src/devices/pci_device.c @@ -485,7 +485,7 @@ void pci_dev_enable_resources(struct device *dev) /* 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 @@ void pci_dev_enable_resources(struct device *dev) 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 @@ void pci_bus_enable_resources(struct device *dev) 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 70286ad7ac..cde571f561 100644 --- a/src/devices/pnp_device.c +++ b/src/devices/pnp_device.c @@ -132,7 +132,7 @@ struct device_operations pnp_ops = { 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 @@ static void pnp_get_ioresource(device_t dev, unsigned index, struct io_info *inf 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 8e85212506..95189e0241 100644 --- a/src/devices/root_device.c +++ b/src/devices/root_device.c @@ -151,11 +151,10 @@ void root_dev_init(device_t root) * @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, |