aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pci.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r--include/linux/pci.h138
1 files changed, 100 insertions, 38 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index a16b1df3deff..e444f5b49118 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -299,7 +299,6 @@ struct pci_dev {
299 */ 299 */
300 unsigned int irq; 300 unsigned int irq;
301 struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ 301 struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
302 resource_size_t fw_addr[DEVICE_COUNT_RESOURCE]; /* FW-assigned addr */
303 302
304 /* These fields are used by common fixups */ 303 /* These fields are used by common fixups */
305 unsigned int transparent:1; /* Transparent PCI bridge */ 304 unsigned int transparent:1; /* Transparent PCI bridge */
@@ -369,24 +368,17 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
369 return (pdev->error_state != pci_channel_io_normal); 368 return (pdev->error_state != pci_channel_io_normal);
370} 369}
371 370
372static inline struct pci_cap_saved_state *pci_find_saved_cap( 371struct pci_host_bridge_window {
373 struct pci_dev *pci_dev, char cap) 372 struct list_head list;
374{ 373 struct resource *res; /* host bridge aperture (CPU address) */
375 struct pci_cap_saved_state *tmp; 374 resource_size_t offset; /* bus address + offset = CPU address */
376 struct hlist_node *pos; 375};
377
378 hlist_for_each_entry(tmp, pos, &pci_dev->saved_cap_space, next) {
379 if (tmp->cap.cap_nr == cap)
380 return tmp;
381 }
382 return NULL;
383}
384 376
385static inline void pci_add_saved_cap(struct pci_dev *pci_dev, 377struct pci_host_bridge {
386 struct pci_cap_saved_state *new_cap) 378 struct list_head list;
387{ 379 struct pci_bus *bus; /* root bus */
388 hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space); 380 struct list_head windows; /* pci_host_bridge_windows */
389} 381};
390 382
391/* 383/*
392 * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond 384 * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond
@@ -656,6 +648,10 @@ void pci_fixup_cardbus(struct pci_bus *);
656 648
657/* Generic PCI functions used internally */ 649/* Generic PCI functions used internally */
658 650
651void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
652 struct resource *res);
653void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
654 struct pci_bus_region *region);
659void pcibios_scan_specific_bus(int busn); 655void pcibios_scan_specific_bus(int busn);
660extern struct pci_bus *pci_find_bus(int domain, int busnr); 656extern struct pci_bus *pci_find_bus(int domain, int busnr);
661void pci_bus_add_devices(const struct pci_bus *bus); 657void pci_bus_add_devices(const struct pci_bus *bus);
@@ -690,7 +686,8 @@ u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp);
690extern struct pci_dev *pci_dev_get(struct pci_dev *dev); 686extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
691extern void pci_dev_put(struct pci_dev *dev); 687extern void pci_dev_put(struct pci_dev *dev);
692extern void pci_remove_bus(struct pci_bus *b); 688extern void pci_remove_bus(struct pci_bus *b);
693extern void pci_remove_bus_device(struct pci_dev *dev); 689extern void __pci_remove_bus_device(struct pci_dev *dev);
690extern void pci_stop_and_remove_bus_device(struct pci_dev *dev);
694extern void pci_stop_bus_device(struct pci_dev *dev); 691extern void pci_stop_bus_device(struct pci_dev *dev);
695void pci_setup_cardbus(struct pci_bus *bus); 692void pci_setup_cardbus(struct pci_bus *bus);
696extern void pci_sort_breadthfirst(void); 693extern void pci_sort_breadthfirst(void);
@@ -746,28 +743,28 @@ int pci_bus_write_config_dword(struct pci_bus *bus, unsigned int devfn,
746 int where, u32 val); 743 int where, u32 val);
747struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops); 744struct pci_ops *pci_bus_set_ops(struct pci_bus *bus, struct pci_ops *ops);
748 745
749static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val) 746static inline int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val)
750{ 747{
751 return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val); 748 return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val);
752} 749}
753static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val) 750static inline int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val)
754{ 751{
755 return pci_bus_read_config_word(dev->bus, dev->devfn, where, val); 752 return pci_bus_read_config_word(dev->bus, dev->devfn, where, val);
756} 753}
757static inline int pci_read_config_dword(struct pci_dev *dev, int where, 754static inline int pci_read_config_dword(const struct pci_dev *dev, int where,
758 u32 *val) 755 u32 *val)
759{ 756{
760 return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val); 757 return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val);
761} 758}
762static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val) 759static inline int pci_write_config_byte(const struct pci_dev *dev, int where, u8 val)
763{ 760{
764 return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val); 761 return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val);
765} 762}
766static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val) 763static inline int pci_write_config_word(const struct pci_dev *dev, int where, u16 val)
767{ 764{
768 return pci_bus_write_config_word(dev->bus, dev->devfn, where, val); 765 return pci_bus_write_config_word(dev->bus, dev->devfn, where, val);
769} 766}
770static inline int pci_write_config_dword(struct pci_dev *dev, int where, 767static inline int pci_write_config_dword(const struct pci_dev *dev, int where,
771 u32 val) 768 u32 val)
772{ 769{
773 return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val); 770 return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
@@ -817,6 +814,7 @@ int pcie_set_readrq(struct pci_dev *dev, int rq);
817int pcie_get_mps(struct pci_dev *dev); 814int pcie_get_mps(struct pci_dev *dev);
818int pcie_set_mps(struct pci_dev *dev, int mps); 815int pcie_set_mps(struct pci_dev *dev, int mps);
819int __pci_reset_function(struct pci_dev *dev); 816int __pci_reset_function(struct pci_dev *dev);
817int __pci_reset_function_locked(struct pci_dev *dev);
820int pci_reset_function(struct pci_dev *dev); 818int pci_reset_function(struct pci_dev *dev);
821void pci_update_resource(struct pci_dev *dev, int resno); 819void pci_update_resource(struct pci_dev *dev, int resno);
822int __must_check pci_assign_resource(struct pci_dev *dev, int i); 820int __must_check pci_assign_resource(struct pci_dev *dev, int i);
@@ -882,6 +880,7 @@ void set_pcie_hotplug_bridge(struct pci_dev *pdev);
882/* Functions for PCI Hotplug drivers to use */ 880/* Functions for PCI Hotplug drivers to use */
883int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); 881int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
884#ifdef CONFIG_HOTPLUG 882#ifdef CONFIG_HOTPLUG
883unsigned int pci_rescan_bus_bridge_resize(struct pci_dev *bridge);
885unsigned int pci_rescan_bus(struct pci_bus *bus); 884unsigned int pci_rescan_bus(struct pci_bus *bus);
886#endif 885#endif
887 886
@@ -891,13 +890,13 @@ ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void
891int pci_vpd_truncate(struct pci_dev *dev, size_t size); 890int pci_vpd_truncate(struct pci_dev *dev, size_t size);
892 891
893/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ 892/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
893resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx);
894void pci_bus_assign_resources(const struct pci_bus *bus); 894void pci_bus_assign_resources(const struct pci_bus *bus);
895void pci_bus_size_bridges(struct pci_bus *bus); 895void pci_bus_size_bridges(struct pci_bus *bus);
896int pci_claim_resource(struct pci_dev *, int); 896int pci_claim_resource(struct pci_dev *, int);
897void pci_assign_unassigned_resources(void); 897void pci_assign_unassigned_resources(void);
898void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge); 898void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge);
899void pdev_enable_device(struct pci_dev *); 899void pdev_enable_device(struct pci_dev *);
900void pdev_sort_resources(struct pci_dev *, struct resource_list *);
901int pci_enable_resources(struct pci_dev *, int mask); 900int pci_enable_resources(struct pci_dev *, int mask);
902void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), 901void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
903 int (*)(const struct pci_dev *, u8, u8)); 902 int (*)(const struct pci_dev *, u8, u8));
@@ -914,6 +913,8 @@ void pci_release_selected_regions(struct pci_dev *, int);
914 913
915/* drivers/pci/bus.c */ 914/* drivers/pci/bus.c */
916void pci_add_resource(struct list_head *resources, struct resource *res); 915void pci_add_resource(struct list_head *resources, struct resource *res);
916void pci_add_resource_offset(struct list_head *resources, struct resource *res,
917 resource_size_t offset);
917void pci_free_resource_list(struct list_head *resources); 918void pci_free_resource_list(struct list_head *resources);
918void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags); 919void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags);
919struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n); 920struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n);
@@ -946,7 +947,20 @@ int __must_check __pci_register_driver(struct pci_driver *, struct module *,
946 __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME) 947 __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
947 948
948void pci_unregister_driver(struct pci_driver *dev); 949void pci_unregister_driver(struct pci_driver *dev);
949void pci_remove_behind_bridge(struct pci_dev *dev); 950
951/**
952 * module_pci_driver() - Helper macro for registering a PCI driver
953 * @__pci_driver: pci_driver struct
954 *
955 * Helper macro for PCI drivers which do not do anything special in module
956 * init/exit. This eliminates a lot of boilerplate. Each module may only
957 * use this macro once, and calling it replaces module_init() and module_exit()
958 */
959#define module_pci_driver(__pci_driver) \
960 module_driver(__pci_driver, pci_register_driver, \
961 pci_unregister_driver)
962
963void pci_stop_and_remove_behind_bridge(struct pci_dev *dev);
950struct pci_driver *pci_dev_driver(const struct pci_dev *dev); 964struct pci_driver *pci_dev_driver(const struct pci_dev *dev);
951int pci_add_dynid(struct pci_driver *drv, 965int pci_add_dynid(struct pci_driver *drv,
952 unsigned int vendor, unsigned int device, 966 unsigned int vendor, unsigned int device,
@@ -1382,7 +1396,10 @@ static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
1382 */ 1396 */
1383 1397
1384struct pci_fixup { 1398struct pci_fixup {
1385 u16 vendor, device; /* You can use PCI_ANY_ID here of course */ 1399 u16 vendor; /* You can use PCI_ANY_ID here of course */
1400 u16 device; /* You can use PCI_ANY_ID here of course */
1401 u32 class; /* You can use PCI_ANY_ID here too */
1402 unsigned int class_shift; /* should be 0, 8, 16 */
1386 void (*hook)(struct pci_dev *dev); 1403 void (*hook)(struct pci_dev *dev);
1387}; 1404};
1388 1405
@@ -1397,30 +1414,68 @@ enum pci_fixup_pass {
1397}; 1414};
1398 1415
1399/* Anonymous variables would be nice... */ 1416/* Anonymous variables would be nice... */
1400#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \ 1417#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \
1401 static const struct pci_fixup __pci_fixup_##name __used \ 1418 class_shift, hook) \
1402 __attribute__((__section__(#section))) = { vendor, device, hook }; 1419 static const struct pci_fixup const __pci_fixup_##name __used \
1420 __attribute__((__section__(#section), aligned((sizeof(void *))))) \
1421 = { vendor, device, class, class_shift, hook };
1422
1423#define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, class, \
1424 class_shift, hook) \
1425 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
1426 vendor##device##hook, vendor, device, class, class_shift, hook)
1427#define DECLARE_PCI_FIXUP_CLASS_HEADER(vendor, device, class, \
1428 class_shift, hook) \
1429 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
1430 vendor##device##hook, vendor, device, class, class_shift, hook)
1431#define DECLARE_PCI_FIXUP_CLASS_FINAL(vendor, device, class, \
1432 class_shift, hook) \
1433 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
1434 vendor##device##hook, vendor, device, class, class_shift, hook)
1435#define DECLARE_PCI_FIXUP_CLASS_ENABLE(vendor, device, class, \
1436 class_shift, hook) \
1437 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
1438 vendor##device##hook, vendor, device, class, class_shift, hook)
1439#define DECLARE_PCI_FIXUP_CLASS_RESUME(vendor, device, class, \
1440 class_shift, hook) \
1441 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
1442 resume##vendor##device##hook, vendor, device, class, \
1443 class_shift, hook)
1444#define DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(vendor, device, class, \
1445 class_shift, hook) \
1446 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
1447 resume_early##vendor##device##hook, vendor, device, \
1448 class, class_shift, hook)
1449#define DECLARE_PCI_FIXUP_CLASS_SUSPEND(vendor, device, class, \
1450 class_shift, hook) \
1451 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
1452 suspend##vendor##device##hook, vendor, device, class, \
1453 class_shift, hook)
1454
1403#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \ 1455#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \
1404 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \ 1456 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
1405 vendor##device##hook, vendor, device, hook) 1457 vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
1406#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \ 1458#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \
1407 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \ 1459 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
1408 vendor##device##hook, vendor, device, hook) 1460 vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
1409#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \ 1461#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \
1410 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \ 1462 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
1411 vendor##device##hook, vendor, device, hook) 1463 vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
1412#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \ 1464#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \
1413 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \ 1465 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
1414 vendor##device##hook, vendor, device, hook) 1466 vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook)
1415#define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \ 1467#define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \
1416 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ 1468 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
1417 resume##vendor##device##hook, vendor, device, hook) 1469 resume##vendor##device##hook, vendor, device, \
1470 PCI_ANY_ID, 0, hook)
1418#define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \ 1471#define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \
1419 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \ 1472 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
1420 resume_early##vendor##device##hook, vendor, device, hook) 1473 resume_early##vendor##device##hook, vendor, device, \
1474 PCI_ANY_ID, 0, hook)
1421#define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \ 1475#define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \
1422 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ 1476 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
1423 suspend##vendor##device##hook, vendor, device, hook) 1477 suspend##vendor##device##hook, vendor, device, \
1478 PCI_ANY_ID, 0, hook)
1424 1479
1425#ifdef CONFIG_PCI_QUIRKS 1480#ifdef CONFIG_PCI_QUIRKS
1426void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); 1481void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
@@ -1647,6 +1702,13 @@ static inline void pci_set_bus_of_node(struct pci_bus *bus) { }
1647static inline void pci_release_bus_of_node(struct pci_bus *bus) { } 1702static inline void pci_release_bus_of_node(struct pci_bus *bus) { }
1648#endif /* CONFIG_OF */ 1703#endif /* CONFIG_OF */
1649 1704
1705#ifdef CONFIG_EEH
1706static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev)
1707{
1708 return pdev->dev.archdata.edev;
1709}
1710#endif
1711
1650/** 1712/**
1651 * pci_find_upstream_pcie_bridge - find upstream PCIe-to-PCI bridge of a device 1713 * pci_find_upstream_pcie_bridge - find upstream PCIe-to-PCI bridge of a device
1652 * @pdev: the PCI device 1714 * @pdev: the PCI device