diff options
-rw-r--r-- | include/linux/pci.h | 343 |
1 files changed, 236 insertions, 107 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index 163b4524172..616f7ee8633 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -28,7 +28,7 @@ * 7:3 = slot * 2:0 = function */ -#define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) +#define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) #define PCI_FUNC(devfn) ((devfn) & 0x07) @@ -219,7 +219,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev) } static inline struct pci_cap_saved_state *pci_find_saved_cap( - struct pci_dev *pci_dev,char cap) + struct pci_dev *pci_dev, char cap) { struct pci_cap_saved_state *tmp; struct hlist_node *pos; @@ -351,11 +351,10 @@ enum pci_ers_result { }; /* PCI bus error event callbacks */ -struct pci_error_handlers -{ +struct pci_error_handlers { /* PCI bus error detected on this device */ pci_ers_result_t (*error_detected)(struct pci_dev *dev, - enum pci_channel_state error); + enum pci_channel_state error); /* MMIO has been re-enabled, but not DMA */ pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev); @@ -390,7 +389,7 @@ struct pci_driver { struct pci_dynids dynids; }; -#define to_pci_driver(drv) container_of(drv,struct pci_driver, driver) +#define to_pci_driver(drv) container_of(drv, struct pci_driver, driver) /** * PCI_DEVICE - macro used to describe a specific pci device @@ -448,7 +447,7 @@ extern int no_pci_devices(void); void pcibios_fixup_bus(struct pci_bus *); int __must_check pcibios_enable_device(struct pci_dev *, int mask); -char *pcibios_setup (char *str); +char *pcibios_setup(char *str); /* Used only when drivers/pci/setup.c is used */ void pcibios_align_resource(void *, struct resource *, resource_size_t, @@ -459,8 +458,10 @@ void pcibios_update_irq(struct pci_dev *, int irq); extern struct pci_bus *pci_find_bus(int domain, int busnr); void pci_bus_add_devices(struct pci_bus *bus); -struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata); -static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata) +struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, + struct pci_ops *ops, void *sysdata); +static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, + void *sysdata) { struct pci_bus *root_bus; root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata); @@ -468,15 +469,18 @@ static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *s pci_bus_add_devices(root_bus); return root_bus; } -struct pci_bus *pci_create_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata); -struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr); +struct pci_bus *pci_create_bus(struct device *parent, int bus, + struct pci_ops *ops, void *sysdata); +struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, + int busnr); int pci_scan_slot(struct pci_bus *bus, int devfn); -struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn); +struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn); void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); unsigned int pci_scan_child_bus(struct pci_bus *bus); int __must_check pci_bus_add_device(struct pci_dev *dev); void pci_read_bridge_bases(struct pci_bus *child); -struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res); +struct resource *pci_find_parent_resource(const struct pci_dev *dev, + struct resource *res); int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); extern struct pci_dev *pci_dev_get(struct pci_dev *dev); extern void pci_dev_put(struct pci_dev *dev); @@ -489,15 +493,18 @@ extern void pci_sort_breadthfirst(void); /* Generic PCI functions exported to card drivers */ #ifdef CONFIG_PCI_LEGACY -struct pci_dev __deprecated *pci_find_device (unsigned int vendor, unsigned int device, const struct pci_dev *from); -struct pci_dev __deprecated *pci_find_slot (unsigned int bus, unsigned int devfn); +struct pci_dev __deprecated *pci_find_device(unsigned int vendor, + unsigned int device, + const struct pci_dev *from); +struct pci_dev __deprecated *pci_find_slot(unsigned int bus, + unsigned int devfn); #endif /* CONFIG_PCI_LEGACY */ -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); -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); +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); +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); void pcie_wait_pending_transaction(struct pci_dev *dev); struct pci_bus *pci_find_next_bus(const struct pci_bus *from); @@ -506,45 +513,53 @@ struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, struct pci_dev *pci_get_device_reverse(unsigned int vendor, unsigned int device, struct pci_dev *from); -struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device, +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); +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); -int pci_bus_read_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 *val); -int pci_bus_write_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 val); -int pci_bus_write_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 val); -int pci_bus_write_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 val); +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); +int pci_bus_read_config_dword(struct pci_bus *bus, unsigned int devfn, + int where, u32 *val); +int pci_bus_write_config_byte(struct pci_bus *bus, unsigned int devfn, + int where, u8 val); +int pci_bus_write_config_word(struct pci_bus *bus, unsigned int devfn, + int where, u16 val); +int pci_bus_write_config_dword(struct pci_bus *bus, unsigned int devfn, + int where, u32 val); static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val) { - return pci_bus_read_config_byte (dev->bus, dev->devfn, where, val); + return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val); } static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val) { - return pci_bus_read_config_word (dev->bus, dev->devfn, where, val); + return pci_bus_read_config_word(dev->bus, dev->devfn, where, val); } -static inline int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val) +static inline int pci_read_config_dword(struct pci_dev *dev, int where, + u32 *val) { - return pci_bus_read_config_dword (dev->bus, dev->devfn, where, val); + return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val); } static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val) { - return pci_bus_write_config_byte (dev->bus, dev->devfn, where, val); + return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val); } static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val) { - return pci_bus_write_config_word (dev->bus, dev->devfn, where, val); + return pci_bus_write_config_word(dev->bus, dev->devfn, where, val); } -static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val) +static inline int pci_write_config_dword(struct pci_dev *dev, int where, + u32 val) { - return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); + return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val); } int __must_check pci_enable_device(struct pci_dev *dev); @@ -593,7 +608,7 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); /* Functions for PCI Hotplug drivers to use */ -int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); +int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ void pci_bus_assign_resources(struct pci_bus *bus); @@ -630,16 +645,18 @@ static inline int __must_check pci_register_driver(struct pci_driver *driver) return __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME); } -void pci_unregister_driver(struct pci_driver *); -void pci_remove_behind_bridge(struct pci_dev *); -struct pci_driver *pci_dev_driver(const struct pci_dev *); -const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, struct pci_dev *dev); -int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass); +void pci_unregister_driver(struct pci_driver *dev); +void pci_remove_behind_bridge(struct pci_dev *dev); +struct pci_driver *pci_dev_driver(const struct pci_dev *dev); +const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, + struct pci_dev *dev); +int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, + int pass); void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), void *userdata); int pci_cfg_space_size(struct pci_dev *dev); -unsigned char pci_bus_max_busnr(struct pci_bus* bus); +unsigned char pci_bus_max_busnr(struct pci_bus *bus); /* kmem_cache style wrapper around pci_alloc_consistent() */ @@ -668,17 +685,32 @@ struct msix_entry { #ifndef CONFIG_PCI_MSI -static inline int pci_enable_msi(struct pci_dev *dev) {return -1;} -static inline void pci_disable_msi(struct pci_dev *dev) {} -static inline int pci_enable_msix(struct pci_dev* dev, - struct msix_entry *entries, int nvec) {return -1;} -static inline void pci_disable_msix(struct pci_dev *dev) {} -static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev) {} -static inline void pci_restore_msi_state(struct pci_dev *dev) {} +static inline int pci_enable_msi(struct pci_dev *dev) +{ + return -1; +} + +static inline void pci_disable_msi(struct pci_dev *dev) +{ } + +static inline int pci_enable_msix(struct pci_dev *dev, + struct msix_entry *entries, int nvec) +{ + return -1; +} + +static inline void pci_disable_msix(struct pci_dev *dev) +{ } + +static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev) +{ } + +static inline void pci_restore_msi_state(struct pci_dev *dev) +{ } #else extern int pci_enable_msi(struct pci_dev *dev); extern void pci_disable_msi(struct pci_dev *dev); -extern int pci_enable_msix(struct pci_dev* dev, +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); @@ -703,7 +735,11 @@ extern void pci_unblock_user_cfg_access(struct pci_dev *dev); extern int pci_domains_supported; #else enum { pci_domains_supported = 0 }; -static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } +static inline int pci_domain_nr(struct pci_bus *bus) +{ + return 0; +} + static inline int pci_proc_domain(struct pci_bus *bus) { return 0; @@ -717,68 +753,161 @@ static inline int pci_proc_domain(struct pci_bus *bus) * these as simple inline functions to avoid hair in drivers. */ -#define _PCI_NOP(o,s,t) \ - static inline int pci_##o##_config_##s (struct pci_dev *dev, int where, t val) \ +#define _PCI_NOP(o, s, t) \ + static inline int pci_##o##_config_##s(struct pci_dev *dev, \ + int where, t val) \ { return PCIBIOS_FUNC_NOT_SUPPORTED; } -#define _PCI_NOP_ALL(o,x) _PCI_NOP(o,byte,u8 x) \ - _PCI_NOP(o,word,u16 x) \ - _PCI_NOP(o,dword,u32 x) + +#define _PCI_NOP_ALL(o, x) _PCI_NOP(o, byte, u8 x) \ + _PCI_NOP(o, word, u16 x) \ + _PCI_NOP(o, dword, u32 x) _PCI_NOP_ALL(read, *) _PCI_NOP_ALL(write,) -static inline struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *from) -{ return NULL; } +static inline struct pci_dev *pci_find_device(unsigned int vendor, + unsigned int device, + const struct pci_dev *from) +{ + return NULL; +} -static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn) -{ return NULL; } +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) -{ return NULL; } + 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; } + unsigned int device, + struct pci_dev *from) +{ + return NULL; +} -static inline struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device, -unsigned int ss_vendor, unsigned int ss_device, struct pci_dev *from) -{ return NULL; } +static inline struct pci_dev *pci_get_subsys(unsigned int vendor, + unsigned int device, + unsigned int ss_vendor, + unsigned int ss_device, + struct pci_dev *from) +{ + return NULL; +} -static inline struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from) -{ return NULL; } +static inline struct pci_dev *pci_get_class(unsigned int class, + struct pci_dev *from) +{ + return NULL; +} #define pci_dev_present(ids) (0) #define no_pci_devices() (1) #define pci_find_present(ids) (NULL) #define pci_dev_put(dev) do { } while (0) -static inline void pci_set_master(struct pci_dev *dev) { } -static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; } -static inline void pci_disable_device(struct pci_dev *dev) { } -static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; } -static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;} -static inline int __pci_register_driver(struct pci_driver *drv, struct module *owner) { return 0;} -static inline int pci_register_driver(struct pci_driver *drv) { return 0;} -static inline void pci_unregister_driver(struct pci_driver *drv) { } -static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; } -static inline int pci_find_next_capability (struct pci_dev *dev, u8 post, int cap) { return 0; } -static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; } -static inline void pcie_wait_pending_transaction(struct pci_dev *dev) {} +static inline void pci_set_master(struct pci_dev *dev) +{ } + +static inline int pci_enable_device(struct pci_dev *dev) +{ + return -EIO; +} + +static inline void pci_disable_device(struct pci_dev *dev) +{ } + +static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) +{ + return -EIO; +} + +static inline int pci_assign_resource(struct pci_dev *dev, int i) +{ + return -EBUSY; +} + +static inline int __pci_register_driver(struct pci_driver *drv, + struct module *owner) +{ + return 0; +} + +static inline int pci_register_driver(struct pci_driver *drv) +{ + return 0; +} + +static inline void pci_unregister_driver(struct pci_driver *drv) +{ } + +static inline int pci_find_capability(struct pci_dev *dev, int cap) +{ + return 0; +} + +static inline int pci_find_next_capability(struct pci_dev *dev, u8 post, + int cap) +{ + return 0; +} + +static inline int pci_find_ext_capability(struct pci_dev *dev, int cap) +{ + return 0; +} + +static inline void pcie_wait_pending_transaction(struct pci_dev *dev) +{ } /* Power management related routines */ -static inline int pci_save_state(struct pci_dev *dev) { return 0; } -static inline int pci_restore_state(struct pci_dev *dev) { return 0; } -static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state) { return 0; } -static inline pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) { return PCI_D0; } -static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) { return 0; } +static inline int pci_save_state(struct pci_dev *dev) +{ + return 0; +} + +static inline int pci_restore_state(struct pci_dev *dev) +{ + return 0; +} -static inline int pci_request_regions(struct pci_dev *dev, const char *res_name) { return -EIO; } -static inline void pci_release_regions(struct pci_dev *dev) { } +static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state) +{ + return 0; +} + +static inline pci_power_t pci_choose_state(struct pci_dev *dev, + pm_message_t state) +{ + return PCI_D0; +} + +static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, + int enable) +{ + return 0; +} + +static inline int pci_request_regions(struct pci_dev *dev, const char *res_name) +{ + return -EIO; +} + +static inline void pci_release_regions(struct pci_dev *dev) +{ } #define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0) -static inline void pci_block_user_cfg_access(struct pci_dev *dev) { } -static inline void pci_unblock_user_cfg_access(struct pci_dev *dev) { } +static inline void pci_block_user_cfg_access(struct pci_dev *dev) +{ } + +static inline void pci_unblock_user_cfg_access(struct pci_dev *dev) +{ } static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from) { return NULL; } @@ -799,27 +928,27 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus, /* these helpers provide future and backwards compatibility * for accessing popular PCI BAR info */ -#define pci_resource_start(dev,bar) ((dev)->resource[(bar)].start) -#define pci_resource_end(dev,bar) ((dev)->resource[(bar)].end) -#define pci_resource_flags(dev,bar) ((dev)->resource[(bar)].flags) +#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start) +#define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end) +#define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags) #define pci_resource_len(dev,bar) \ - ((pci_resource_start((dev),(bar)) == 0 && \ - pci_resource_end((dev),(bar)) == \ - pci_resource_start((dev),(bar))) ? 0 : \ - \ - (pci_resource_end((dev),(bar)) - \ - pci_resource_start((dev),(bar)) + 1)) + ((pci_resource_start((dev), (bar)) == 0 && \ + pci_resource_end((dev), (bar)) == \ + pci_resource_start((dev), (bar))) ? 0 : \ + \ + (pci_resource_end((dev), (bar)) - \ + pci_resource_start((dev), (bar)) + 1)) /* Similar to the helpers above, these manipulate per-pci_dev * driver-specific data. They are really just a wrapper around * the generic device structure functions of these calls. */ -static inline void *pci_get_drvdata (struct pci_dev *pdev) +static inline void *pci_get_drvdata(struct pci_dev *pdev) { return dev_get_drvdata(&pdev->dev); } -static inline void pci_set_drvdata (struct pci_dev *pdev, void *data) +static inline void pci_set_drvdata(struct pci_dev *pdev, void *data) { dev_set_drvdata(&pdev->dev, data); } @@ -838,7 +967,7 @@ static inline char *pci_name(struct pci_dev *pdev) */ #ifndef HAVE_ARCH_PCI_RESOURCE_TO_USER static inline void pci_resource_to_user(const struct pci_dev *dev, int bar, - const struct resource *rsrc, resource_size_t *start, + const struct resource *rsrc, resource_size_t *start, resource_size_t *end) { *start = rsrc->start; @@ -890,9 +1019,9 @@ enum pci_fixup_pass { void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); -void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); +void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); -void __iomem * const * pcim_iomap_table(struct pci_dev *pdev); +void __iomem * const *pcim_iomap_table(struct pci_dev *pdev); int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name); void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask); |