Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
[safe/jmp/linux-2.6] / include / linux / pci.h
index 9b34bc8..f3c617e 100644 (file)
@@ -20,9 +20,6 @@
 /* Include the pci register defines */
 #include <linux/pci_regs.h>
 
-/* Include the ID list */
-#include <linux/pci_ids.h>
-
 /*
  * The PCI interface treats multi-function devices as independent
  * devices.  The slot/function address of each device is encoded
 #include <linux/list.h>
 #include <linux/compiler.h>
 #include <linux/errno.h>
+#include <asm/atomic.h>
 #include <linux/device.h>
 
+/* Include the ID list */
+#include <linux/pci_ids.h>
+
 /* File state for mmap()s on /proc/bus/pci/X/Y */
 enum pci_mmap_state {
        pci_mmap_io,
@@ -159,7 +160,6 @@ struct pci_dev {
        unsigned int    transparent:1;  /* Transparent PCI bridge */
        unsigned int    multifunction:1;/* Part of multi-function device */
        /* keep track of device state */
-       unsigned int    is_enabled:1;   /* pci_enable_device has been called */
        unsigned int    is_busmaster:1; /* device is busmaster */
        unsigned int    no_msi:1;       /* device may not use msi */
        unsigned int    no_d1d2:1;   /* only allow d0 or d3 */
@@ -167,6 +167,7 @@ struct pci_dev {
        unsigned int    broken_parity_status:1; /* Device generates false positive parity */
        unsigned int    msi_enabled:1;
        unsigned int    msix_enabled:1;
+       atomic_t        enable_cnt;     /* pci_enable_device has been called */
 
        u32             saved_config_space[16]; /* config space saved at suspend time */
        struct hlist_head saved_cap_space;
@@ -395,6 +396,21 @@ struct pci_driver {
  */
 #define pci_module_init        pci_register_driver
 
+/**
+ * PCI_VDEVICE - macro used to describe a specific pci device in short form
+ * @vend: the vendor name
+ * @dev: the 16 bit PCI Device ID
+ *
+ * This macro is used to create a struct pci_device_id that matches a
+ * specific PCI device.  The subvendor, and subdevice fields will be set
+ * to PCI_ANY_ID. The macro allows the next field to follow as the device
+ * private data.
+ */
+
+#define PCI_VDEVICE(vendor, device)            \
+       PCI_VENDOR_ID_##vendor, (device),       \
+       PCI_ANY_ID, PCI_ANY_ID, 0, 0
+
 /* these external functions are only available when PCI support is enabled */
 #ifdef CONFIG_PCI
 
@@ -443,6 +459,7 @@ extern void pci_remove_bus(struct pci_bus *b);
 extern void pci_remove_bus_device(struct pci_dev *dev);
 extern void pci_stop_bus_device(struct pci_dev *dev);
 void pci_setup_cardbus(struct pci_bus *bus);
+extern void pci_sort_breadthfirst(void);
 
 /* Generic PCI functions exported to card drivers */
 
@@ -452,15 +469,23 @@ struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn);
 int pci_find_capability (struct pci_dev *dev, int cap);
 int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap);
 int pci_find_ext_capability (struct pci_dev *dev, int cap);
-struct pci_bus * pci_find_next_bus(const struct pci_bus *from);
+int pci_find_ht_capability (struct pci_dev *dev, int ht_cap);
+int pci_find_next_ht_capability (struct pci_dev *dev, int pos, int ht_cap);
+struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
+
+struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
+                               struct pci_dev *from);
+struct pci_dev *pci_get_device_reverse(unsigned int vendor, unsigned int device,
+                               struct pci_dev *from);
 
-struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from);
 struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device,
                                unsigned int ss_vendor, unsigned int ss_device,
                                struct pci_dev *from);
 struct pci_dev *pci_get_slot (struct pci_bus *bus, unsigned int devfn);
+struct pci_dev *pci_get_bus_and_slot (unsigned int bus, unsigned int devfn);
 struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from);
 int pci_dev_present(const struct pci_device_id *ids);
+const struct pci_device_id *pci_find_present(const struct pci_device_id *ids);
 
 int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val);
 int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val);
@@ -595,11 +620,6 @@ struct msix_entry {
        u16     entry;  /* driver uses to specify entry, OS writes */
 };
 
-struct msi_msg {
-       u32     address_lo;     /* low 32 bits of msi message address */
-       u32     address_hi;     /* high 32 bits of msi message address */
-       u32     data;           /* 16 bits of msi message data */
-};
 
 #ifndef CONFIG_PCI_MSI
 static inline void pci_scan_msi_device(struct pci_dev *dev) {}
@@ -617,85 +637,12 @@ extern int pci_enable_msix(struct pci_dev* dev,
        struct msix_entry *entries, int nvec);
 extern void pci_disable_msix(struct pci_dev *dev);
 extern void msi_remove_pci_irq_vectors(struct pci_dev *dev);
-
-/*
- * MSI operation vector.  Used by the msi core code (drivers/pci/msi.c)
- * to abstract platform-specific tasks relating to MSI address generation
- * and resource management.
- */
-struct msi_ops {
-       int needs_64bit_address;
-       /**
-        * setup - generate an MSI bus address and data for a given vector
-        * @pdev: PCI device context (in)
-        * @irq: irq allocated by the msi core (in)
-        * @msg: PCI bus address and data for msi message (out)
-        *
-        * Description: The setup op is used to generate a PCI bus addres and
-        * data which the msi core will program into the card MSI capability
-        * registers.  The setup routine is responsible for picking an initial
-        * cpu to target the MSI at.  The setup routine is responsible for
-        * examining pdev to determine the MSI capabilities of the card and
-        * generating a suitable address/data.  The setup routine is
-        * responsible for allocating and tracking any system resources it
-        * needs to route the MSI to the cpu it picks, and for associating
-        * those resources with the passed in vector.
-        *
-        * Returns 0 if the MSI address/data was successfully setup.
-        **/
-
-       int     (*setup)    (struct pci_dev *pdev, unsigned int irq,
-                            struct msi_msg *msg);
-
-       /**
-        * teardown - release resources allocated by setup
-        * @vector: vector context for resources (in)
-        *
-        * Description:  The teardown op is used to release any resources
-        * that were allocated in the setup routine associated with the passed
-        * in vector.
-        **/
-
-       void    (*teardown) (unsigned int irq);
-
-       /**
-        * target - retarget an MSI at a different cpu
-        * @vector: vector context for resources (in)
-        * @cpu:  new cpu to direct vector at (in)
-        * @addr_hi: new value of PCI bus upper 32 bits (in/out)
-        * @addr_lo: new value of PCI bus lower 32 bits (in/out)
-        *
-        * Description:  The target op is used to redirect an MSI vector
-        * at a different cpu.  addr_hi/addr_lo coming in are the existing
-        * values that the MSI core has programmed into the card.  The
-        * target code is responsible for freeing any resources (if any)
-        * associated with the old address, and generating a new PCI bus
-        * addr_hi/addr_lo that will redirect the vector at the indicated cpu.
-        **/
-
-       void    (*target)   (unsigned int irq, cpumask_t cpumask,
-                            struct msi_msg *msg);
-};
-
-extern int msi_register(struct msi_ops *ops);
-
 #endif
 
 #ifdef CONFIG_HT_IRQ
-/* Helper functions.. */
-void write_ht_irq_low(unsigned int irq, u32 data);
-void write_ht_irq_high(unsigned int irq, u32 data);
-u32  read_ht_irq_low(unsigned int irq);
-u32  read_ht_irq_high(unsigned int irq);
-void mask_ht_irq(unsigned int irq);
-void unmask_ht_irq(unsigned int irq);
-
 /* The functions a driver should call */
 int  ht_create_irq(struct pci_dev *dev, int idx);
 void ht_destroy_irq(unsigned int irq);
-
-/* The arch hook for getting things started */
-int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev);
 #endif /* CONFIG_HT_IRQ */
 
 extern void pci_block_user_cfg_access(struct pci_dev *dev);
@@ -736,7 +683,12 @@ static inline struct pci_dev *pci_find_device(unsigned int vendor, unsigned int
 static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn)
 { return NULL; }
 
-static inline struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from)
+static inline struct pci_dev *pci_get_device(unsigned int vendor,
+                               unsigned int device, struct pci_dev *from)
+{ return NULL; }
+
+static inline struct pci_dev *pci_get_device_reverse(unsigned int vendor,
+                               unsigned int device, struct pci_dev *from)
 { return NULL; }
 
 static inline struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device,
@@ -747,6 +699,7 @@ static inline struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *
 { return NULL; }
 
 #define pci_dev_present(ids)   (0)
+#define pci_find_present(ids)  (NULL)
 #define pci_dev_put(dev)       do { } while (0)
 
 static inline void pci_set_master(struct pci_dev *dev) { }
@@ -849,6 +802,7 @@ enum pci_fixup_pass {
        pci_fixup_header,       /* After reading configuration header */
        pci_fixup_final,        /* Final phase of device fixups */
        pci_fixup_enable,       /* pci_enable_device() time */
+       pci_fixup_resume,       /* pci_enable_device() time */
 };
 
 /* Anonymous variables would be nice... */
@@ -867,6 +821,9 @@ enum pci_fixup_pass {
 #define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook)                 \
        DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable,                    \
                        vendor##device##hook, vendor, device, hook)
+#define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook)                 \
+       DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume,                    \
+                       resume##vendor##device##hook, vendor, device, hook)
 
 
 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);