diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 15:20:36 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 15:20:36 -0700 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/pci |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/pci')
91 files changed, 63799 insertions, 0 deletions
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig new file mode 100644 index 00000000000..7f31991772e --- /dev/null +++ b/drivers/pci/Kconfig @@ -0,0 +1,59 @@ +# +# PCI configuration +# +config PCI_MSI + bool "Message Signaled Interrupts (MSI and MSI-X)" + depends on PCI + depends on (X86_LOCAL_APIC && X86_IO_APIC) || IA64 + help + This allows device drivers to enable MSI (Message Signaled + Interrupts). Message Signaled Interrupts enable a device to + generate an interrupt using an inbound Memory Write on its + PCI bus instead of asserting a device IRQ pin. + + If you don't know what to do here, say N. + +config PCI_LEGACY_PROC + bool "Legacy /proc/pci interface" + depends on PCI + ---help--- + This feature enables a procfs file -- /proc/pci -- that provides a + summary of PCI devices in the system. + + This feature has been deprecated as of v2.5.53, in favor of using the + tool lspci(8). This feature may be removed at a future date. + + lspci can provide the same data, as well as much more. lspci is a part of + the pci-utils package, which should be installed by your distribution. + See <file:Documentation/Changes> for information on where to get the latest + version. + + When in doubt, say N. + +config PCI_NAMES + bool "PCI device name database" + depends on PCI + ---help--- + By default, the kernel contains a database of all known PCI device + names to make the information in /proc/pci, /proc/ioports and + similar files comprehensible to the user. + + This database increases size of the kernel image by about 80KB. This + memory is freed after the system boots up if CONFIG_HOTPLUG is not set. + + Anyway, if you are building an installation floppy or kernel for an + embedded system where kernel image size really matters, you can disable + this feature and you'll get device ID numbers instead of names. + + When in doubt, say Y. + +config PCI_DEBUG + bool "PCI Debugging" + depends on PCI && DEBUG_KERNEL + help + Say Y here if you want the PCI core to produce a bunch of debug + messages to the system log. Select this if you are having a + problem with PCI support and want to see more of what is going on. + + When in doubt, say N. + diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile new file mode 100644 index 00000000000..7dea494c0d7 --- /dev/null +++ b/drivers/pci/Makefile @@ -0,0 +1,65 @@ +# +# Makefile for the PCI bus specific drivers. +# + +obj-y += access.o bus.o probe.o remove.o pci.o quirks.o \ + names.o pci-driver.o search.o pci-sysfs.o \ + rom.o +obj-$(CONFIG_PROC_FS) += proc.o + +ifndef CONFIG_SPARC64 +obj-y += setup-res.o +endif + +obj-$(CONFIG_HOTPLUG) += hotplug.o + +# Build the PCI Hotplug drivers if we were asked to +obj-$(CONFIG_HOTPLUG_PCI) += hotplug/ + +# +# Some architectures use the generic PCI setup functions +# +obj-$(CONFIG_ALPHA) += setup-bus.o setup-irq.o +obj-$(CONFIG_ARM) += setup-bus.o setup-irq.o +obj-$(CONFIG_PARISC) += setup-bus.o +obj-$(CONFIG_SUPERH) += setup-bus.o setup-irq.o +obj-$(CONFIG_PPC32) += setup-irq.o +obj-$(CONFIG_PPC64) += setup-bus.o +obj-$(CONFIG_MIPS) += setup-bus.o setup-irq.o +obj-$(CONFIG_X86_VISWS) += setup-irq.o +obj-$(CONFIG_PCI_MSI) += msi.o + +# +# ACPI Related PCI FW Functions +# +obj-$(CONFIG_ACPI) += pci-acpi.o + +# Cardbus & CompactPCI use setup-bus +obj-$(CONFIG_HOTPLUG) += setup-bus.o + +ifndef CONFIG_X86 +obj-y += syscall.o +endif + +ifeq ($(CONFIG_PCI_DEBUG),y) +EXTRA_CFLAGS += -DDEBUG +endif + +hostprogs-y := gen-devlist + +# Dependencies on generated files need to be listed explicitly +$(obj)/names.o: $(obj)/devlist.h $(obj)/classlist.h +$(obj)/classlist.h: $(obj)/devlist.h + +# And that's how to generate them +quiet_cmd_devlist = DEVLIST $@ + cmd_devlist = ( cd $(obj); ./gen-devlist ) < $< +$(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist + $(call cmd,devlist) + +# Files generated that shall be removed upon make clean +clean-files := devlist.h classlist.h + +# Build PCI Express stuff if needed +obj-$(CONFIG_PCIEPORTBUS) += pcie/ + diff --git a/drivers/pci/access.c b/drivers/pci/access.c new file mode 100644 index 00000000000..24a76de49f4 --- /dev/null +++ b/drivers/pci/access.c @@ -0,0 +1,62 @@ +#include <linux/pci.h> +#include <linux/module.h> +#include <linux/ioport.h> + +/* + * This interrupt-safe spinlock protects all accesses to PCI + * configuration space. + */ + +static DEFINE_SPINLOCK(pci_lock); + +/* + * Wrappers for all PCI configuration access functions. They just check + * alignment, do locking and call the low-level functions pointed to + * by pci_dev->ops. + */ + +#define PCI_byte_BAD 0 +#define PCI_word_BAD (pos & 1) +#define PCI_dword_BAD (pos & 3) + +#define PCI_OP_READ(size,type,len) \ +int pci_bus_read_config_##size \ + (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \ +{ \ + int res; \ + unsigned long flags; \ + u32 data = 0; \ + if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ + spin_lock_irqsave(&pci_lock, flags); \ + res = bus->ops->read(bus, devfn, pos, len, &data); \ + *value = (type)data; \ + spin_unlock_irqrestore(&pci_lock, flags); \ + return res; \ +} + +#define PCI_OP_WRITE(size,type,len) \ +int pci_bus_write_config_##size \ + (struct pci_bus *bus, unsigned int devfn, int pos, type value) \ +{ \ + int res; \ + unsigned long flags; \ + if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ + spin_lock_irqsave(&pci_lock, flags); \ + res = bus->ops->write(bus, devfn, pos, len, value); \ + spin_unlock_irqrestore(&pci_lock, flags); \ + return res; \ +} + +PCI_OP_READ(byte, u8, 1) +PCI_OP_READ(word, u16, 2) +PCI_OP_READ(dword, u32, 4) +PCI_OP_WRITE(byte, u8, 1) +PCI_OP_WRITE(word, u16, 2) +PCI_OP_WRITE(dword, u32, 4) + +EXPORT_SYMBOL(pci_bus_read_config_byte); +EXPORT_SYMBOL(pci_bus_read_config_word); +EXPORT_SYMBOL(pci_bus_read_config_dword); +EXPORT_SYMBOL(pci_bus_write_config_byte); +EXPORT_SYMBOL(pci_bus_write_config_word); +EXPORT_SYMBOL(pci_bus_write_config_dword); diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c new file mode 100644 index 00000000000..dbd33605cc1 --- /dev/null +++ b/drivers/pci/bus.c @@ -0,0 +1,151 @@ +/* + * drivers/pci/bus.c + * + * From setup-res.c, by: + * Dave Rusling (david.rusling@reo.mts.dec.com) + * David Mosberger (davidm@cs.arizona.edu) + * David Miller (davem@redhat.com) + * Ivan Kokshaysky (ink@jurassic.park.msu.ru) + */ +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/pci.h> +#include <linux/errno.h> +#include <linux/ioport.h> +#include <linux/proc_fs.h> +#include <linux/init.h> + +#include "pci.h" + +/** + * pci_bus_alloc_resource - allocate a resource from a parent bus + * @bus: PCI bus + * @res: resource to allocate + * @size: size of resource to allocate + * @align: alignment of resource to allocate + * @min: minimum /proc/iomem address to allocate + * @type_mask: IORESOURCE_* type flags + * @alignf: resource alignment function + * @alignf_data: data argument for resource alignment function + * + * Given the PCI bus a device resides on, the size, minimum address, + * alignment and type, try to find an acceptable resource allocation + * for a specific device resource. + */ +int +pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, + unsigned long size, unsigned long align, unsigned long min, + unsigned int type_mask, + void (*alignf)(void *, struct resource *, + unsigned long, unsigned long), + void *alignf_data) +{ + int i, ret = -ENOMEM; + + type_mask |= IORESOURCE_IO | IORESOURCE_MEM; + + for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) { + struct resource *r = bus->resource[i]; + if (!r) + continue; + + /* type_mask must match */ + if ((res->flags ^ r->flags) & type_mask) + continue; + + /* We cannot allocate a non-prefetching resource + from a pre-fetching area */ + if ((r->flags & IORESOURCE_PREFETCH) && + !(res->flags & IORESOURCE_PREFETCH)) + continue; + + /* Ok, try it out.. */ + ret = allocate_resource(r, res, size, min, -1, align, + alignf, alignf_data); + if (ret == 0) + break; + } + return ret; +} + +/** + * add a single device + * @dev: device to add + * + * This adds a single pci device to the global + * device list and adds sysfs and procfs entries + */ +void __devinit pci_bus_add_device(struct pci_dev *dev) +{ + device_add(&dev->dev); + + spin_lock(&pci_bus_lock); + list_add_tail(&dev->global_list, &pci_devices); + spin_unlock(&pci_bus_lock); + + pci_proc_attach_device(dev); + pci_create_sysfs_dev_files(dev); +} + +/** + * pci_bus_add_devices - insert newly discovered PCI devices + * @bus: bus to check for new devices + * + * Add newly discovered PCI devices (which are on the bus->devices + * list) to the global PCI device list, add the sysfs and procfs + * entries. Where a bridge is found, add the discovered bus to + * the parents list of child buses, and recurse (breadth-first + * to be compatible with 2.4) + * + * Call hotplug for each new devices. + */ +void __devinit pci_bus_add_devices(struct pci_bus *bus) +{ + struct pci_dev *dev; + + list_for_each_entry(dev, &bus->devices, bus_list) { + /* + * Skip already-present devices (which are on the + * global device list.) + */ + if (!list_empty(&dev->global_list)) + continue; + pci_bus_add_device(dev); + } + + list_for_each_entry(dev, &bus->devices, bus_list) { + + BUG_ON(list_empty(&dev->global_list)); + + /* + * If there is an unattached subordinate bus, attach + * it and then scan for unattached PCI devices. + */ + if (dev->subordinate && list_empty(&dev->subordinate->node)) { + spin_lock(&pci_bus_lock); + list_add_tail(&dev->subordinate->node, &dev->bus->children); + spin_unlock(&pci_bus_lock); + pci_bus_add_devices(dev->subordinate); + + sysfs_create_link(&dev->subordinate->class_dev.kobj, &dev->dev.kobj, "bridge"); + } + } +} + +void pci_enable_bridges(struct pci_bus *bus) +{ + struct pci_dev *dev; + + list_for_each_entry(dev, &bus->devices, bus_list) { + if (dev->subordinate) { + pci_enable_device(dev); + pci_set_master(dev); + pci_enable_bridges(dev->subordinate); + } + } +} + +EXPORT_SYMBOL(pci_bus_alloc_resource); +EXPORT_SYMBOL_GPL(pci_bus_add_device); +EXPORT_SYMBOL(pci_bus_add_devices); +EXPORT_SYMBOL(pci_enable_bridges); diff --git a/drivers/pci/gen-devlist.c b/drivers/pci/gen-devlist.c new file mode 100644 index 00000000000..8abfc499fde --- /dev/null +++ b/drivers/pci/gen-devlist.c @@ -0,0 +1,132 @@ +/* + * Generate devlist.h and classlist.h from the PCI ID file. + * + * (c) 1999--2002 Martin Mares <mj@ucw.cz> + */ + +#include <stdio.h> +#include <string.h> + +#define MAX_NAME_SIZE 200 + +static void +pq(FILE *f, const char *c, int len) +{ + int i = 1; + while (*c && i != len) { + if (*c == '"') + fprintf(f, "\\\""); + else { + fputc(*c, f); + if (*c == '?' && c[1] == '?') { + /* Avoid trigraphs */ + fprintf(f, "\" \""); + } + } + c++; + i++; + } +} + + |