summaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-02-16 01:07:24 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-02-16 01:07:24 +0000
commit95db6b748fc86297827fbd9c9ef174d491c9ad89 (patch)
tree27a92a942821cde1edda9a1b088718d436b3efe4 /drivers/pci
parent45b27b0a0652331d104c953a5b192d843fff88f8 (diff)
Merge with Linux 2.3.40.
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/Makefile4
-rw-r--r--drivers/pci/helper.c69
-rw-r--r--drivers/pci/pci.c133
-rw-r--r--drivers/pci/pci.ids9
-rw-r--r--drivers/pci/pcisyms.c10
-rw-r--r--drivers/pci/proc.c4
-rw-r--r--drivers/pci/setup-bus.c (renamed from drivers/pci/setup.c)177
-rw-r--r--drivers/pci/setup-irq.c71
-rw-r--r--drivers/pci/setup-res.c164
-rw-r--r--drivers/pci/syscall.c4
10 files changed, 391 insertions, 254 deletions
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 41829a29c..945b19bd4 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -24,10 +24,10 @@ ifdef CONFIG_PROC_FS
O_OBJS += proc.o
endif
-L_OBJS += compat.o names.o helper.o
+L_OBJS += compat.o names.o setup-res.o setup-bus.o setup-irq.o
ifndef CONFIG_X86
-L_OBJS += syscall.o setup.o
+L_OBJS += syscall.o
endif
include $(TOPDIR)/Rules.make
diff --git a/drivers/pci/helper.c b/drivers/pci/helper.c
deleted file mode 100644
index cd21631e3..000000000
--- a/drivers/pci/helper.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * $Id$
- *
- * drivers/pci/helper.c
- *
- * Copyright 1999 Jeff Garzik <jgarzik@mandrakesoft.com>
- * This software is free. See the file COPYING for licensing details.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/pci.h>
-
-
-int pci_simple_probe (const struct pci_simple_probe_entry *list,
- size_t match_limit, pci_simple_probe_callback cb,
- void *drvr_data)
-{
- struct pci_dev *dev;
- const struct pci_simple_probe_entry *ent;
- size_t matches = 0;
- unsigned short vendor, device;
- int rc;
-
- if (!list || !cb)
- return -1;
-
- dev = pci_find_device (PCI_ANY_ID, PCI_ANY_ID, NULL);
- while (dev) {
- ent = list;
- while (ent->vendor && ent->device) {
- vendor = ent->vendor;
- device = ent->device;
-
- if (((vendor != 0xFFFF) &&
- (vendor != dev->vendor)) ||
- ((device != 0xFFFF) &&
- (device != dev->device))) {
- ent++;
- continue;
- }
-
- if (((ent->subsys_vendor) &&
- (ent->subsys_vendor != dev->subsystem_vendor)) ||
- ((ent->subsys_device) &&
- (ent->subsys_device != dev->subsystem_device))) {
- ent++;
- continue;
- }
-
- rc = (* cb) (dev, matches, ent, drvr_data);
- if (rc < 0)
- return rc;
-
- matches++;
-
- if (match_limit && match_limit == matches)
- return matches;
-
- break; /* stop list search on first match */
- }
-
- dev = pci_find_device (PCI_ANY_ID, PCI_ANY_ID, dev);
- }
-
- return matches;
-}
-
-
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 1f98f50de..f109cef46 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -9,6 +9,7 @@
* Copyright 1997 -- 2000 Martin Mares <mj@suse.cz>
*/
+#include <linux/config.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/pci.h>
@@ -195,6 +196,138 @@ pci_enable_device(struct pci_dev *dev)
return 0;
}
+/*
+ * Registration of PCI drivers and handling of hot-pluggable devices.
+ */
+
+static LIST_HEAD(pci_drivers);
+
+const struct pci_device_id *
+pci_match_device(const struct pci_device_id *ids, struct pci_dev *dev)
+{
+ while (ids->vendor || ids->subvendor || ids->class_mask) {
+ if ((ids->vendor == PCI_ANY_ID || ids->vendor == dev->vendor) &&
+ (ids->device == PCI_ANY_ID || ids->device == dev->device) &&
+ (ids->subvendor == PCI_ANY_ID || ids->subvendor == dev->subsystem_vendor) &&
+ (ids->subdevice == PCI_ANY_ID || ids->subdevice == dev->subsystem_device) &&
+ !((ids->class ^ dev->class) & ids->class_mask))
+ return ids;
+ ids++;
+ }
+ return NULL;
+}
+
+static int
+pci_announce_device(struct pci_driver *drv, struct pci_dev *dev)
+{
+ const struct pci_device_id *id;
+
+ if (drv->id_table) {
+ id = pci_match_device(drv->id_table, dev);
+ if (!id)
+ return 0;
+ } else
+ id = NULL;
+ if (drv->probe(dev, id) >= 0) {
+ dev->driver = drv;
+ return 1;
+ }
+ return 0;
+}
+
+int
+pci_register_driver(struct pci_driver *drv)
+{
+ struct pci_dev *dev;
+ int count = 0;
+
+ list_add_tail(&drv->node, &pci_drivers);
+ pci_for_each_dev(dev) {
+ if (!pci_dev_driver(dev))
+ count += pci_announce_device(drv, dev);
+ }
+ return count;
+}
+
+void
+pci_unregister_driver(struct pci_driver *drv)
+{
+ struct pci_dev *dev;
+
+ list_del(&drv->node);
+ pci_for_each_dev(dev) {
+ if (dev->driver == drv) {
+ if (drv->remove)
+ drv->remove(dev);
+ dev->driver = NULL;
+ }
+ }
+}
+
+#ifdef CONFIG_HOTPLUG
+
+void
+pci_insert_device(struct pci_dev *dev, struct pci_bus *bus)
+{
+ struct list_head *ln;
+
+ list_add_tail(&dev->bus_list, &bus->devices);
+ list_add_tail(&dev->global_list, &pci_devices);
+#ifdef CONFIG_PROC_FS
+ pci_proc_attach_device(dev);
+#endif
+ for(ln=pci_drivers.next; ln != &pci_drivers; ln=ln->next) {
+ struct pci_driver *drv = list_entry(ln, struct pci_driver, node);
+ if (drv->remove && pci_announce_device(drv, dev))
+ break;
+ }
+}
+
+static void pci_free_resources(struct pci_dev *dev)
+{
+ int i;
+
+ for (i = 0; i < PCI_NUM_RESOURCES; i++) {
+ struct resource *res = dev->resource + i;
+ if (res->parent)
+ release_resource(res);
+ }
+}
+
+void
+pci_remove_device(struct pci_dev *dev)
+{
+ if (dev->driver->remove)
+ dev->driver->remove(dev);
+ dev->driver = NULL;
+ list_del(&dev->bus_list);
+ list_del(&dev->global_list);
+ pci_free_resources(dev);
+#ifdef CONFIG_PROC_FS
+ pci_proc_detach_device(dev);
+#endif
+}
+
+#endif
+
+static struct pci_driver pci_compat_driver = {
+ name: "compat"
+};
+
+struct pci_driver *
+pci_dev_driver(struct pci_dev *dev)
+{
+ if (dev->driver)
+ return dev->driver;
+ else {
+ int i;
+ for(i=0; i<=PCI_ROM_RESOURCE; i++)
+ if (dev->resource[i].flags & IORESOURCE_BUSY)
+ return &pci_compat_driver;
+ }
+ return NULL;
+}
+
/*
* This interrupt-safe spinlock protects all accesses to PCI
diff --git a/drivers/pci/pci.ids b/drivers/pci/pci.ids
index 4bac2162d..49e031869 100644
--- a/drivers/pci/pci.ids
+++ b/drivers/pci/pci.ids
@@ -356,6 +356,12 @@
2001 79c978 [HomePNA]
2020 53c974 [PCscsi]
2040 79c974
+ 7006 IronGate Host
+ 7403 Viper Power Management
+ 7408 Viper ISA
+ 7409 Viper IDE
+ 740B Viper ACPI
+ 740C Viper USB
1023 Trident Microsystems
0194 82C194
2000 4DWave DX
@@ -931,8 +937,9 @@
0640 PCI0640
0643 PCI0643
0646 PCI0646
- 0650 PBC0650A
0647 PCI0647
+ 0648 PCI0648
+ 0650 PBC0650A
0670 USB0670
0673 USB0673
1096 Alacron
diff --git a/drivers/pci/pcisyms.c b/drivers/pci/pcisyms.c
index 28adb8e8a..64b6a0f3e 100644
--- a/drivers/pci/pcisyms.c
+++ b/drivers/pci/pcisyms.c
@@ -24,13 +24,15 @@ EXPORT_SYMBOL(pci_find_class);
EXPORT_SYMBOL(pci_find_device);
EXPORT_SYMBOL(pci_find_slot);
EXPORT_SYMBOL(pci_set_master);
-EXPORT_SYMBOL(pci_simple_probe);
EXPORT_SYMBOL(pci_set_power_state);
EXPORT_SYMBOL(pci_assign_resource);
+EXPORT_SYMBOL(pci_register_driver);
+EXPORT_SYMBOL(pci_unregister_driver);
+
+#ifdef CONFIG_HOTPLUG
EXPORT_SYMBOL(pci_setup_device);
-#ifdef CONFIG_PROC_FS
-EXPORT_SYMBOL(pci_proc_attach_device);
-EXPORT_SYMBOL(pci_proc_detach_device);
+EXPORT_SYMBOL(pci_insert_device);
+EXPORT_SYMBOL(pci_remove_device);
#endif
/* Obsolete functions */
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index e2cb9e9d6..b687d6122 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -224,6 +224,7 @@ get_pci_dev_info(char *buf, char **start, off_t pos, int count)
cnt = 0;
pci_for_each_dev(dev) {
+ struct pci_driver *drv = pci_dev_driver(dev);
len = sprintf(buf, "%02x%02x\t%04x%04x\t%x",
dev->bus->number,
dev->devfn,
@@ -237,6 +238,9 @@ get_pci_dev_info(char *buf, char **start, off_t pos, int count)
for(i=0; i<7; i++)
len += sprintf(buf+len, LONG_FORMAT, dev->resource[i].start < dev->resource[i].end ?
dev->resource[i].end - dev->resource[i].start + 1 : 0);
+ buf[len++] = '\t';
+ if (drv)
+ len += sprintf(buf+len, "%s", drv->name);
buf[len++] = '\n';
at += len;
if (at >= pos) {
diff --git a/drivers/pci/setup.c b/drivers/pci/setup-bus.c
index 96d35c2ba..401185890 100644
--- a/drivers/pci/setup.c
+++ b/drivers/pci/setup-bus.c
@@ -1,5 +1,5 @@
/*
- * drivers/pci/setup.c
+ * drivers/pci/setup-bus.c
*
* Extruded from code written by
* Dave Rusling (david.rusling@reo.mts.dec.com)
@@ -9,8 +9,6 @@
* Support routines for initializing a PCI subsystem.
*/
-/* fixed for multiple pci buses, 1999 Andrea Arcangeli <andrea@suse.de> */
-
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/pci.h>
@@ -26,129 +24,6 @@
# define DBGC(args)
#endif
-int __init
-pci_claim_resource(struct pci_dev *dev, int resource)
-{
- struct resource *res = &dev->resource[resource];
- struct resource *root = pci_find_parent_resource(dev, res);
- int err;
-
- err = -EINVAL;
- if (root != NULL) {
- err = request_resource(root, res);
- if (err) {
- printk(KERN_ERR "PCI: Address space collision on "
- "region %d of device %s [%lx:%lx]\n",
- resource, dev->name, res->start, res->end);
- }
- } else {
- printk(KERN_ERR "PCI: No parent found for region %d "
- "of device %s\n", resource, dev->name);
- }
-
- return err;
-}
-
-static void
-pdev_assign_unassigned_resources(struct pci_dev *dev, u32 min_io, u32 min_mem)
-{
- u32 reg;
- u16 cmd;
- int i;
-
- DBGC(("PCI assign unassigned: (%s)\n", dev->name));
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
-
- for (i = 0; i < PCI_NUM_RESOURCES; i++) {
- struct resource *root, *res;
- unsigned long size, min;
-
- res = &dev->resource[i];
-
- if (res->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- else if (res->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
-
- /* If it is already assigned or the resource does
- not exist, there is nothing to do. */
- if (res->parent != NULL || res->flags == 0)
- continue;
-
- /* Determine the root we allocate from. */
- res->end -= res->start;
- res->start = 0;
- root = pci_find_parent_resource(dev, res);
- if (root == NULL)
- continue;
-
- min = (res->flags & IORESOURCE_IO ? min_io : min_mem);
- min += root->start;
- size = res->end + 1;
- DBGC((" for root[%lx:%lx] min[%lx] size[%lx]\n",
- root->start, root->end, min, size));
-
- if (allocate_resource(root, res, size, min, -1, size, pcibios_align_resource, dev) < 0) {
- printk(KERN_ERR
- "PCI: Failed to allocate resource %d for %s\n",
- i, dev->name);
- continue;
- }
-
- DBGC((" got res[%lx:%lx] for resource %d\n",
- res->start, res->end, i));
-
- /* Update PCI config space. */
- pcibios_update_resource(dev, root, res, i);
- }
-
- /* Special case, disable the ROM. Several devices act funny
- (ie. do not respond to memory space writes) when it is left
- enabled. A good example are QlogicISP adapters. */
-
- if (dev->rom_base_reg) {
- pci_read_config_dword(dev, dev->rom_base_reg, &reg);
- reg &= ~PCI_ROM_ADDRESS_ENABLE;
- pci_write_config_dword(dev, dev->rom_base_reg, reg);
- dev->resource[PCI_ROM_RESOURCE].flags &= ~PCI_ROM_ADDRESS_ENABLE;
- }
-
- /* All of these (may) have I/O scattered all around and may not
- use I/O base address registers at all. So we just have to
- always enable IO to these devices. */
- if ((dev->class >> 8) == PCI_CLASS_NOT_DEFINED
- || (dev->class >> 8) == PCI_CLASS_NOT_DEFINED_VGA
- || (dev->class >> 8) == PCI_CLASS_STORAGE_IDE
- || (dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
- cmd |= PCI_COMMAND_IO;
- }
-
- /* ??? Always turn on bus mastering. If the device doesn't support
- it, the bit will go into the bucket. */
- cmd |= PCI_COMMAND_MASTER;
-
- /* Enable the appropriate bits in the PCI command register. */
- pci_write_config_word(dev, PCI_COMMAND, cmd);
-
- DBGC((" cmd reg 0x%x\n", cmd));
-
- /* If this is a PCI bridge, set the cache line correctly. */
- if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
- pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE,
- (L1_CACHE_BYTES / sizeof(u32)));
- }
-}
-
-void __init
-pci_assign_unassigned_resources(u32 min_io, u32 min_mem)
-{
- struct pci_dev *dev;
-
- pci_for_each_dev(dev) {
- pdev_assign_unassigned_resources(dev, min_io, min_mem);
- }
-}
#define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
#define ROUND_DOWN(x, a) ((x) & ~((a) - 1))
@@ -279,53 +154,3 @@ pci_set_bus_ranges(void)
for(ln=pci_root_buses.next; ln != &pci_root_buses; ln=ln->next)
pbus_set_ranges(pci_bus_b(ln), NULL);
}
-
-static void __init
-pdev_fixup_irq(struct pci_dev *dev,
- u8 (*swizzle)(struct pci_dev *, u8 *),
- int (*map_irq)(struct pci_dev *, u8, u8))
-{
- u8 pin, slot;
- int irq;
-
- /* If this device is not on the primary bus, we need to figure out
- which interrupt pin it will come in on. We know which slot it
- will come in on 'cos that slot is where the bridge is. Each
- time the interrupt line passes through a PCI-PCI bridge we must
- apply the swizzle function. */
-
- pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
- /* Cope with 0 and illegal. */
- if (pin == 0 || pin > 4)
- pin = 1;
-
- /* Follow the chain of bridges, swizzling as we go. */
- slot = (*swizzle)(dev, &pin);
-
- irq = (*map_irq)(dev, slot, pin);
- if (irq == -1)
- irq = 0;
- dev->irq = irq;
-
- DBGC(("PCI fixup irq: (%s) got %d\n", dev->name, dev->irq));
-
- /* Always tell the device, so the driver knows what is
- the real IRQ to use; the device does not use it. */
- pcibios_update_irq(dev, irq);
-}
-
-void __init
-pci_fixup_irqs(u8 (*swizzle)(struct pci_dev *, u8 *),
- int (*map_irq)(struct pci_dev *, u8, u8))
-{
- struct pci_dev *dev;
- pci_for_each_dev(dev) {
- pdev_fixup_irq(dev, swizzle, map_irq);
- }
-}
-
-int
-pcibios_enable_device(struct pci_dev *dev)
-{
- return 0;
-}
diff --git a/drivers/pci/setup-irq.c b/drivers/pci/setup-irq.c
new file mode 100644
index 000000000..f15eba9dd
--- /dev/null
+++ b/drivers/pci/setup-irq.c
@@ -0,0 +1,71 @@
+/*
+ * drivers/pci/setup-irq.c
+ *
+ * Extruded from code written by
+ * Dave Rusling (david.rusling@reo.mts.dec.com)
+ * David Mosberger (davidm@cs.arizona.edu)
+ * David Miller (davem@redhat.com)
+ *
+ * Support routines for initializing a PCI subsystem.
+ */
+
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/errno.h>
+#include <linux/ioport.h>
+#include <linux/cache.h>
+
+
+#define DEBUG_CONFIG 0
+#if DEBUG_CONFIG
+# define DBGC(args) printk args
+#else
+# define DBGC(args)
+#endif
+
+
+static void __init
+pdev_fixup_irq(struct pci_dev *dev,
+ u8 (*swizzle)(struct pci_dev *, u8 *),
+ int (*map_irq)(struct pci_dev *, u8, u8))
+{
+ u8 pin, slot;
+ int irq;
+
+ /* If this device is not on the primary bus, we need to figure out
+ which interrupt pin it will come in on. We know which slot it
+ will come in on 'cos that slot is where the bridge is. Each
+ time the interrupt line passes through a PCI-PCI bridge we must
+ apply the swizzle function. */
+
+ pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
+ /* Cope with 0 and illegal. */
+ if (pin == 0 || pin > 4)
+ pin = 1;
+
+ /* Follow the chain of bridges, swizzling as we go. */
+ slot = (*swizzle)(dev, &pin);
+
+ irq = (*map_irq)(dev, slot, pin);
+ if (irq == -1)
+ irq = 0;
+ dev->irq = irq;
+
+ DBGC(("PCI fixup irq: (%s) got %d\n", dev->name, dev->irq));
+
+ /* Always tell the device, so the driver knows what is
+ the real IRQ to use; the device does not use it. */
+ pcibios_update_irq(dev, irq);
+}
+
+void __init
+pci_fixup_irqs(u8 (*swizzle)(struct pci_dev *, u8 *),
+ int (*map_irq)(struct pci_dev *, u8, u8))
+{
+ struct pci_dev *dev;
+ pci_for_each_dev(dev) {
+ pdev_fixup_irq(dev, swizzle, map_irq);
+ }
+}
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
new file mode 100644
index 000000000..84639a5a2
--- /dev/null
+++ b/drivers/pci/setup-res.c
@@ -0,0 +1,164 @@
+/*
+ * drivers/pci/setup-res.c
+ *
+ * Extruded from code written by
+ * Dave Rusling (david.rusling@reo.mts.dec.com)
+ * David Mosberger (davidm@cs.arizona.edu)
+ * David Miller (davem@redhat.com)
+ *
+ * Support routines for initializing a PCI subsystem.
+ */
+
+/* fixed for multiple pci buses, 1999 Andrea Arcangeli <andrea@suse.de> */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/errno.h>
+#include <linux/ioport.h>
+#include <linux/cache.h>
+
+
+#define DEBUG_CONFIG 0
+#if DEBUG_CONFIG
+# define DBGC(args) printk args
+#else
+# define DBGC(args)
+#endif
+
+
+int __init
+pci_claim_resource(struct pci_dev *dev, int resource)
+{
+ struct resource *res = &dev->resource[resource];
+ struct resource *root = pci_find_parent_resource(dev, res);
+ int err;
+
+ err = -EINVAL;
+ if (root != NULL) {
+ err = request_resource(root, res);
+ if (err) {
+ printk(KERN_ERR "PCI: Address space collision on "
+ "region %d of device %s [%lx:%lx]\n",
+ resource, dev->name, res->start, res->end);
+ }
+ } else {
+ printk(KERN_ERR "PCI: No parent found for region %d "
+ "of device %s\n", resource, dev->name);
+ }
+
+ return err;
+}
+
+int
+pci_assign_resource(struct pci_dev *dev, int i)
+{
+ struct resource *root, *res;
+ unsigned long size, min;
+
+ res = &dev->resource[i];
+
+ /* Determine the root we allocate from. */
+ res->end -= res->start;
+ res->start = 0;
+ root = pci_find_parent_resource(dev, res);
+ if (root == NULL) {
+ printk(KERN_ERR "PCI: Cannot find parent resource for "
+ "device %s\n", dev->slot_name);
+ return -EINVAL;
+ }
+
+ min = (res->flags & IORESOURCE_IO ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM);
+ size = res->end + 1;
+ DBGC((" for root[%lx:%lx] min[%lx] size[%lx]\n",
+ root->start, root->end, min, size));
+
+ if (allocate_resource(root, res, size, min, -1, size,
+ pcibios_align_resource, dev) < 0) {
+ printk(KERN_ERR "PCI: Failed to allocate resource %d for %s\n",
+ i, dev->name);
+ return -EBUSY;
+ }
+
+ DBGC((" got res[%lx:%lx] for resource %d\n",
+ res->start, res->end, i));
+
+ /* Update PCI config space. */
+ pcibios_update_resource(dev, root, res, i);
+
+ return 0;
+}
+
+static void
+pdev_assign_unassigned_resources(struct pci_dev *dev)
+{
+ u32 reg;
+ u16 cmd;
+ int i;
+
+ DBGC(("PCI assign unassigned: (%s)\n", dev->name));
+
+ pci_read_config_word(dev, PCI_COMMAND, &cmd);
+
+ for (i = 0; i < PCI_NUM_RESOURCES; i++) {
+ struct resource *res = &dev->resource[i];
+
+ if (res->flags & IORESOURCE_IO)
+ cmd |= PCI_COMMAND_IO;
+ else if (res->flags & IORESOURCE_MEM)
+ cmd |= PCI_COMMAND_MEMORY;
+
+ /* If it is already assigned or the resource does
+ not exist, there is nothing to do. */
+ if (res->parent != NULL || res->flags == 0)
+ continue;
+
+ pci_assign_resource(dev, i);
+ }
+
+ /* Special case, disable the ROM. Several devices act funny
+ (ie. do not respond to memory space writes) when it is left
+ enabled. A good example are QlogicISP adapters. */
+
+ if (dev->rom_base_reg) {
+ pci_read_config_dword(dev, dev->rom_base_reg, &reg);
+ reg &= ~PCI_ROM_ADDRESS_ENABLE;
+ pci_write_config_dword(dev, dev->rom_base_reg, reg);
+ dev->resource[PCI_ROM_RESOURCE].flags &= ~PCI_ROM_ADDRESS_ENABLE;
+ }
+
+ /* All of these (may) have I/O scattered all around and may not
+ use I/O base address registers at all. So we just have to
+ always enable IO to these devices. */
+ if ((dev->class >> 8) == PCI_CLASS_NOT_DEFINED
+ || (dev->class >> 8) == PCI_CLASS_NOT_DEFINED_VGA
+ || (dev->class >> 8) == PCI_CLASS_STORAGE_IDE
+ || (dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
+ cmd |= PCI_COMMAND_IO;
+ }
+
+ /* ??? Always turn on bus mastering. If the device doesn't support
+ it, the bit will go into the bucket. */
+ cmd |= PCI_COMMAND_MASTER;
+
+ /* Enable the appropriate bits in the PCI command register. */
+ pci_write_config_word(dev, PCI_COMMAND, cmd);
+
+ DBGC((" cmd reg 0x%x\n", cmd));
+
+ /* If this is a PCI bridge, set the cache line correctly. */
+ if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
+ pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE,
+ (L1_CACHE_BYTES / sizeof(u32)));
+ }
+}
+
+void __init
+pci_assign_unassigned_resources(void)
+{
+ struct pci_dev *dev;
+
+ pci_for_each_dev(dev) {
+ pdev_assign_unassigned_resources(dev);
+ }
+}
diff --git a/drivers/pci/syscall.c b/drivers/pci/syscall.c
index a58098024..c935efd9a 100644
--- a/drivers/pci/syscall.c
+++ b/drivers/pci/syscall.c
@@ -120,7 +120,7 @@ sys_pciconfig_write(unsigned long bus, unsigned long dfn,
err = get_user(word, (u16 *)buf);
if (err)
break;
- err = pci_write_config_byte(dev, off, word);
+ err = pci_write_config_word(dev, off, word);
if (err != PCIBIOS_SUCCESSFUL)
err = -EIO;
break;
@@ -129,7 +129,7 @@ sys_pciconfig_write(unsigned long bus, unsigned long dfn,
err = get_user(dword, (u32 *)buf);
if (err)
break;
- pci_write_config_byte(dev, off, dword);
+ err = pci_write_config_dword(dev, off, dword);
if (err != PCIBIOS_SUCCESSFUL)
err = -EIO;
break;