pci.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113
  1. /*
  2. * pci.h
  3. *
  4. * PCI defines and function prototypes
  5. * Copyright 1994, Drew Eckhardt
  6. * Copyright 1997--1999 Martin Mares <mj@ucw.cz>
  7. *
  8. * For more information, please consult the following manuals (look at
  9. * http://www.pcisig.com/ for how to get them):
  10. *
  11. * PCI BIOS Specification
  12. * PCI Local Bus Specification
  13. * PCI to PCI Bridge Specification
  14. * PCI System Design Guide
  15. */
  16. #ifndef LINUX_PCI_H
  17. #define LINUX_PCI_H
  18. #include <linux/pci_regs.h> /* The pci register defines */
  19. /*
  20. * The PCI interface treats multi-function devices as independent
  21. * devices. The slot/function address of each device is encoded
  22. * in a single byte as follows:
  23. *
  24. * 7:3 = slot
  25. * 2:0 = function
  26. */
  27. #define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
  28. #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f)
  29. #define PCI_FUNC(devfn) ((devfn) & 0x07)
  30. /* Ioctls for /proc/bus/pci/X/Y nodes. */
  31. #define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8)
  32. #define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00) /* Get controller for PCI device. */
  33. #define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01) /* Set mmap state to I/O space. */
  34. #define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02) /* Set mmap state to MEM space. */
  35. #define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03) /* Enable/disable write-combining. */
  36. #ifdef __KERNEL__
  37. #include <linux/mod_devicetable.h>
  38. #include <linux/types.h>
  39. #include <linux/init.h>
  40. #include <linux/ioport.h>
  41. #include <linux/list.h>
  42. #include <linux/compiler.h>
  43. #include <linux/errno.h>
  44. #include <linux/kobject.h>
  45. #include <asm/atomic.h>
  46. #include <linux/device.h>
  47. /* Include the ID list */
  48. #include <linux/pci_ids.h>
  49. /* pci_slot represents a physical slot */
  50. struct pci_slot {
  51. struct pci_bus *bus; /* The bus this slot is on */
  52. struct list_head list; /* node in list of slots on this bus */
  53. struct hotplug_slot *hotplug; /* Hotplug info (migrate over time) */
  54. unsigned char number; /* PCI_SLOT(pci_dev->devfn) */
  55. struct kobject kobj;
  56. };
  57. /* File state for mmap()s on /proc/bus/pci/X/Y */
  58. enum pci_mmap_state {
  59. pci_mmap_io,
  60. pci_mmap_mem
  61. };
  62. /* This defines the direction arg to the DMA mapping routines. */
  63. #define PCI_DMA_BIDIRECTIONAL 0
  64. #define PCI_DMA_TODEVICE 1
  65. #define PCI_DMA_FROMDEVICE 2
  66. #define PCI_DMA_NONE 3
  67. #define DEVICE_COUNT_RESOURCE 12
  68. typedef int __bitwise pci_power_t;
  69. #define PCI_D0 ((pci_power_t __force) 0)
  70. #define PCI_D1 ((pci_power_t __force) 1)
  71. #define PCI_D2 ((pci_power_t __force) 2)
  72. #define PCI_D3hot ((pci_power_t __force) 3)
  73. #define PCI_D3cold ((pci_power_t __force) 4)
  74. #define PCI_UNKNOWN ((pci_power_t __force) 5)
  75. #define PCI_POWER_ERROR ((pci_power_t __force) -1)
  76. /** The pci_channel state describes connectivity between the CPU and
  77. * the pci device. If some PCI bus between here and the pci device
  78. * has crashed or locked up, this info is reflected here.
  79. */
  80. typedef unsigned int __bitwise pci_channel_state_t;
  81. enum pci_channel_state {
  82. /* I/O channel is in normal state */
  83. pci_channel_io_normal = (__force pci_channel_state_t) 1,
  84. /* I/O to channel is blocked */
  85. pci_channel_io_frozen = (__force pci_channel_state_t) 2,
  86. /* PCI card is dead */
  87. pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
  88. };
  89. typedef unsigned int __bitwise pcie_reset_state_t;
  90. enum pcie_reset_state {
  91. /* Reset is NOT asserted (Use to deassert reset) */
  92. pcie_deassert_reset = (__force pcie_reset_state_t) 1,
  93. /* Use #PERST to reset PCI-E device */
  94. pcie_warm_reset = (__force pcie_reset_state_t) 2,
  95. /* Use PCI-E Hot Reset to reset device */
  96. pcie_hot_reset = (__force pcie_reset_state_t) 3
  97. };
  98. typedef unsigned short __bitwise pci_dev_flags_t;
  99. enum pci_dev_flags {
  100. /* INTX_DISABLE in PCI_COMMAND register disables MSI
  101. * generation too.
  102. */
  103. PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = (__force pci_dev_flags_t) 1,
  104. };
  105. typedef unsigned short __bitwise pci_bus_flags_t;
  106. enum pci_bus_flags {
  107. PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
  108. PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t) 2,
  109. };
  110. struct pci_cap_saved_state {
  111. struct hlist_node next;
  112. char cap_nr;
  113. u32 data[0];
  114. };
  115. struct pcie_link_state;
  116. struct pci_vpd;
  117. /*
  118. * The pci_dev structure is used to describe PCI devices.
  119. */
  120. struct pci_dev {
  121. struct list_head bus_list; /* node in per-bus list */
  122. struct pci_bus *bus; /* bus this device is on */
  123. struct pci_bus *subordinate; /* bus this device bridges to */
  124. void *sysdata; /* hook for sys-specific extension */
  125. struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */
  126. struct pci_slot *slot; /* Physical slot this device is in */
  127. unsigned int devfn; /* encoded device & function index */
  128. unsigned short vendor;
  129. unsigned short device;
  130. unsigned short subsystem_vendor;
  131. unsigned short subsystem_device;
  132. unsigned int class; /* 3 bytes: (base,sub,prog-if) */
  133. u8 revision; /* PCI revision, low byte of class word */
  134. u8 hdr_type; /* PCI header type (`multi' flag masked out) */
  135. u8 pcie_type; /* PCI-E device/port type */
  136. u8 rom_base_reg; /* which config register controls the ROM */
  137. u8 pin; /* which interrupt pin this device uses */
  138. struct pci_driver *driver; /* which driver has allocated this device */
  139. u64 dma_mask; /* Mask of the bits of bus address this
  140. device implements. Normally this is
  141. 0xffffffff. You only need to change
  142. this if your device has broken DMA
  143. or supports 64-bit transfers. */
  144. struct device_dma_parameters dma_parms;
  145. pci_power_t current_state; /* Current operating state. In ACPI-speak,
  146. this is D0-D3, D0 being fully functional,
  147. and D3 being off. */
  148. int pm_cap; /* PM capability offset in the
  149. configuration space */
  150. unsigned int pme_support:5; /* Bitmask of states from which PME#
  151. can be generated */
  152. unsigned int d1_support:1; /* Low power state D1 is supported */
  153. unsigned int d2_support:1; /* Low power state D2 is supported */
  154. unsigned int no_d1d2:1; /* Only allow D0 and D3 */
  155. #ifdef CONFIG_PCIEASPM
  156. struct pcie_link_state *link_state; /* ASPM link state. */
  157. #endif
  158. pci_channel_state_t error_state; /* current connectivity state */
  159. struct device dev; /* Generic device interface */
  160. int cfg_size; /* Size of configuration space */
  161. /*
  162. * Instead of touching interrupt line and base address registers
  163. * directly, use the values stored here. They might be different!
  164. */
  165. unsigned int irq;
  166. struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
  167. /* These fields are used by common fixups */
  168. unsigned int transparent:1; /* Transparent PCI bridge */
  169. unsigned int multifunction:1;/* Part of multi-function device */
  170. /* keep track of device state */
  171. unsigned int is_added:1;
  172. unsigned int is_busmaster:1; /* device is busmaster */
  173. unsigned int no_msi:1; /* device may not use msi */
  174. unsigned int block_ucfg_access:1; /* userspace config space access is blocked */
  175. unsigned int broken_parity_status:1; /* Device generates false positive parity */
  176. unsigned int msi_enabled:1;
  177. unsigned int msix_enabled:1;
  178. unsigned int is_managed:1;
  179. unsigned int is_pcie:1;
  180. pci_dev_flags_t dev_flags;
  181. atomic_t enable_cnt; /* pci_enable_device has been called */
  182. u32 saved_config_space[16]; /* config space saved at suspend time */
  183. struct hlist_head saved_cap_space;
  184. struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */
  185. int rom_attr_enabled; /* has display of the rom attribute been enabled? */
  186. struct bin_attribute *res_attr[DEVICE_COUNT_RESOURCE]; /* sysfs file for resources */
  187. struct bin_attribute *res_attr_wc[DEVICE_COUNT_RESOURCE]; /* sysfs file for WC mapping of resources */
  188. #ifdef CONFIG_PCI_MSI
  189. struct list_head msi_list;
  190. #endif
  191. struct pci_vpd *vpd;
  192. };
  193. extern struct pci_dev *alloc_pci_dev(void);
  194. #define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list)
  195. #define to_pci_dev(n) container_of(n, struct pci_dev, dev)
  196. #define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
  197. static inline int pci_channel_offline(struct pci_dev *pdev)
  198. {
  199. return (pdev->error_state != pci_channel_io_normal);
  200. }
  201. static inline struct pci_cap_saved_state *pci_find_saved_cap(
  202. struct pci_dev *pci_dev, char cap)
  203. {
  204. struct pci_cap_saved_state *tmp;
  205. struct hlist_node *pos;
  206. hlist_for_each_entry(tmp, pos, &pci_dev->saved_cap_space, next) {
  207. if (tmp->cap_nr == cap)
  208. return tmp;
  209. }
  210. return NULL;
  211. }
  212. static inline void pci_add_saved_cap(struct pci_dev *pci_dev,
  213. struct pci_cap_saved_state *new_cap)
  214. {
  215. hlist_add_head(&new_cap->next, &pci_dev->saved_cap_space);
  216. }
  217. /*
  218. * For PCI devices, the region numbers are assigned this way:
  219. *
  220. * 0-5 standard PCI regions
  221. * 6 expansion ROM
  222. * 7-10 bridges: address space assigned to buses behind the bridge
  223. */
  224. #define PCI_ROM_RESOURCE 6
  225. #define PCI_BRIDGE_RESOURCES 7
  226. #define PCI_NUM_RESOURCES 11
  227. #ifndef PCI_BUS_NUM_RESOURCES
  228. #define PCI_BUS_NUM_RESOURCES 16
  229. #endif
  230. #define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */
  231. struct pci_bus {
  232. struct list_head node; /* node in list of buses */
  233. struct pci_bus *parent; /* parent bus this bridge is on */
  234. struct list_head children; /* list of child buses */
  235. struct list_head devices; /* list of devices on this bus */
  236. struct pci_dev *self; /* bridge device as seen by parent */
  237. struct list_head slots; /* list of slots on this bus */
  238. struct resource *resource[PCI_BUS_NUM_RESOURCES];
  239. /* address space routed to this bus */
  240. struct pci_ops *ops; /* configuration access functions */
  241. void *sysdata; /* hook for sys-specific extension */
  242. struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */
  243. unsigned char number; /* bus number */
  244. unsigned char primary; /* number of primary bridge */
  245. unsigned char secondary; /* number of secondary bridge */
  246. unsigned char subordinate; /* max number of subordinate buses */
  247. char name[48];
  248. unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */
  249. pci_bus_flags_t bus_flags; /* Inherited by child busses */
  250. struct device *bridge;
  251. struct device dev;
  252. struct bin_attribute *legacy_io; /* legacy I/O for this bus */
  253. struct bin_attribute *legacy_mem; /* legacy mem */
  254. unsigned int is_added:1;
  255. };
  256. #define pci_bus_b(n) list_entry(n, struct pci_bus, node)
  257. #define to_pci_bus(n) container_of(n, struct pci_bus, dev)
  258. /*
  259. * Error values that may be returned by PCI functions.
  260. */
  261. #define PCIBIOS_SUCCESSFUL 0x00
  262. #define PCIBIOS_FUNC_NOT_SUPPORTED 0x81
  263. #define PCIBIOS_BAD_VENDOR_ID 0x83
  264. #define PCIBIOS_DEVICE_NOT_FOUND 0x86
  265. #define PCIBIOS_BAD_REGISTER_NUMBER 0x87
  266. #define PCIBIOS_SET_FAILED 0x88
  267. #define PCIBIOS_BUFFER_TOO_SMALL 0x89
  268. /* Low-level architecture-dependent routines */
  269. struct pci_ops {
  270. int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val);
  271. int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
  272. };
  273. /*
  274. * ACPI needs to be able to access PCI config space before we've done a
  275. * PCI bus scan and created pci_bus structures.
  276. */
  277. extern int raw_pci_read(unsigned int domain, unsigned int bus,
  278. unsigned int devfn, int reg, int len, u32 *val);
  279. extern int raw_pci_write(unsigned int domain, unsigned int bus,
  280. unsigned int devfn, int reg, int len, u32 val);
  281. struct pci_bus_region {
  282. resource_size_t start;
  283. resource_size_t end;
  284. };
  285. struct pci_dynids {
  286. spinlock_t lock; /* protects list, index */
  287. struct list_head list; /* for IDs added at runtime */
  288. unsigned int use_driver_data:1; /* pci_device_id->driver_data is used */
  289. };
  290. /* ---------------------------------------------------------------- */
  291. /** PCI Error Recovery System (PCI-ERS). If a PCI device driver provides
  292. * a set of callbacks in struct pci_error_handlers, then that device driver
  293. * will be notified of PCI bus errors, and will be driven to recovery
  294. * when an error occurs.
  295. */
  296. typedef unsigned int __bitwise pci_ers_result_t;
  297. enum pci_ers_result {
  298. /* no result/none/not supported in device driver */
  299. PCI_ERS_RESULT_NONE = (__force pci_ers_result_t) 1,
  300. /* Device driver can recover without slot reset */
  301. PCI_ERS_RESULT_CAN_RECOVER = (__force pci_ers_result_t) 2,
  302. /* Device driver wants slot to be reset. */
  303. PCI_ERS_RESULT_NEED_RESET = (__force pci_ers_result_t) 3,
  304. /* Device has completely failed, is unrecoverable */
  305. PCI_ERS_RESULT_DISCONNECT = (__force pci_ers_result_t) 4,
  306. /* Device driver is fully recovered and operational */
  307. PCI_ERS_RESULT_RECOVERED = (__force pci_ers_result_t) 5,
  308. };
  309. /* PCI bus error event callbacks */
  310. struct pci_error_handlers {
  311. /* PCI bus error detected on this device */
  312. pci_ers_result_t (*error_detected)(struct pci_dev *dev,
  313. enum pci_channel_state error);
  314. /* MMIO has been re-enabled, but not DMA */
  315. pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev);
  316. /* PCI Express link has been reset */
  317. pci_ers_result_t (*link_reset)(struct pci_dev *dev);
  318. /* PCI slot has been reset */
  319. pci_ers_result_t (*slot_reset)(struct pci_dev *dev);
  320. /* Device driver may resume normal operations */
  321. void (*resume)(struct pci_dev *dev);
  322. };
  323. /* ---------------------------------------------------------------- */
  324. struct module;
  325. struct pci_driver {
  326. struct list_head node;
  327. char *name;
  328. const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */
  329. int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
  330. void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
  331. int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */
  332. int (*suspend_late) (struct pci_dev *dev, pm_message_t state);
  333. int (*resume_early) (struct pci_dev *dev);
  334. int (*resume) (struct pci_dev *dev); /* Device woken up */
  335. void (*shutdown) (struct pci_dev *dev);
  336. struct pm_ext_ops *pm;
  337. struct pci_error_handlers *err_handler;
  338. struct device_driver driver;
  339. struct pci_dynids dynids;
  340. };
  341. #define to_pci_driver(drv) container_of(drv, struct pci_driver, driver)
  342. /**
  343. * DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table
  344. * @_table: device table name
  345. *
  346. * This macro is used to create a struct pci_device_id array (a device table)
  347. * in a generic manner.
  348. */
  349. #define DEFINE_PCI_DEVICE_TABLE(_table) \
  350. const struct pci_device_id _table[] __devinitconst
  351. /**
  352. * PCI_DEVICE - macro used to describe a specific pci device
  353. * @vend: the 16 bit PCI Vendor ID
  354. * @dev: the 16 bit PCI Device ID
  355. *
  356. * This macro is used to create a struct pci_device_id that matches a
  357. * specific device. The subvendor and subdevice fields will be set to
  358. * PCI_ANY_ID.
  359. */
  360. #define PCI_DEVICE(vend,dev) \
  361. .vendor = (vend), .device = (dev), \
  362. .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
  363. /**
  364. * PCI_DEVICE_CLASS - macro used to describe a specific pci device class
  365. * @dev_class: the class, subclass, prog-if triple for this device
  366. * @dev_class_mask: the class mask for this device
  367. *
  368. * This macro is used to create a struct pci_device_id that matches a
  369. * specific PCI class. The vendor, device, subvendor, and subdevice
  370. * fields will be set to PCI_ANY_ID.
  371. */
  372. #define PCI_DEVICE_CLASS(dev_class,dev_class_mask) \
  373. .class = (dev_class), .class_mask = (dev_class_mask), \
  374. .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
  375. .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
  376. /**
  377. * PCI_VDEVICE - macro used to describe a specific pci device in short form
  378. * @vend: the vendor name
  379. * @dev: the 16 bit PCI Device ID
  380. *
  381. * This macro is used to create a struct pci_device_id that matches a
  382. * specific PCI device. The subvendor, and subdevice fields will be set
  383. * to PCI_ANY_ID. The macro allows the next field to follow as the device
  384. * private data.
  385. */
  386. #define PCI_VDEVICE(vendor, device) \
  387. PCI_VENDOR_ID_##vendor, (device), \
  388. PCI_ANY_ID, PCI_ANY_ID, 0, 0
  389. /* these external functions are only available when PCI support is enabled */
  390. #ifdef CONFIG_PCI
  391. extern struct bus_type pci_bus_type;
  392. /* Do NOT directly access these two variables, unless you are arch specific pci
  393. * code, or pci core code. */
  394. extern struct list_head pci_root_buses; /* list of all known PCI buses */
  395. /* Some device drivers need know if pci is initiated */
  396. extern int no_pci_devices(void);
  397. void pcibios_fixup_bus(struct pci_bus *);
  398. int __must_check pcibios_enable_device(struct pci_dev *, int mask);
  399. char *pcibios_setup(char *str);
  400. /* Used only when drivers/pci/setup.c is used */
  401. void pcibios_align_resource(void *, struct resource *, resource_size_t,
  402. resource_size_t);
  403. void pcibios_update_irq(struct pci_dev *, int irq);
  404. /* Generic PCI functions used internally */
  405. extern struct pci_bus *pci_find_bus(int domain, int busnr);
  406. void pci_bus_add_devices(struct pci_bus *bus);
  407. struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
  408. struct pci_ops *ops, void *sysdata);
  409. static inline struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,
  410. void *sysdata)
  411. {
  412. struct pci_bus *root_bus;
  413. root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata);
  414. if (root_bus)
  415. pci_bus_add_devices(root_bus);
  416. return root_bus;
  417. }
  418. struct pci_bus *pci_create_bus(struct device *parent, int bus,
  419. struct pci_ops *ops, void *sysdata);
  420. struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
  421. int busnr);
  422. struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
  423. const char *name);
  424. void pci_destroy_slot(struct pci_slot *slot);
  425. void pci_update_slot_number(struct pci_slot *slot, int slot_nr);
  426. int pci_scan_slot(struct pci_bus *bus, int devfn);
  427. struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
  428. void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
  429. unsigned int pci_scan_child_bus(struct pci_bus *bus);
  430. int __must_check pci_bus_add_device(struct pci_dev *dev);
  431. void pci_read_bridge_bases(struct pci_bus *child);
  432. struct resource *pci_find_parent_resource(const struct pci_dev *dev,
  433. struct resource *res);
  434. int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
  435. extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
  436. extern void pci_dev_put(struct pci_dev *dev);
  437. extern void pci_remove_bus(struct pci_bus *b);
  438. extern void pci_remove_bus_device(struct pci_dev *dev);
  439. extern void pci_stop_bus_device(struct pci_dev *dev);
  440. void pci_setup_cardbus(struct pci_bus *bus);
  441. extern void pci_sort_breadthfirst(void);
  442. /* Generic PCI functions exported to card drivers */
  443. #ifdef CONFIG_PCI_LEGACY
  444. struct pci_dev __deprecated *pci_find_device(unsigned int vendor,
  445. unsigned int device,
  446. const struct pci_dev *from);
  447. struct pci_dev __deprecated *pci_find_slot(unsigned int bus,
  448. unsigned int devfn);
  449. #endif /* CONFIG_PCI_LEGACY */
  450. int pci_find_capability(struct pci_dev *dev, int cap);
  451. int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap);
  452. int pci_find_ext_capability(struct pci_dev *dev, int cap);
  453. int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
  454. int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
  455. struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
  456. struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
  457. struct pci_dev *from);
  458. struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
  459. unsigned int ss_vendor, unsigned int ss_device,
  460. const struct pci_dev *from);
  461. struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn);
  462. struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn);
  463. struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from);
  464. int pci_dev_present(const struct pci_device_id *ids);
  465. int pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn,
  466. int where, u8 *val);
  467. int pci_bus_read_config_word(struct pci_bus *bus, unsigned int devfn,
  468. int where, u16 *val);
  469. int pci_bus_read_config_dword(struct pci_bus *bus, unsigned int devfn,
  470. int where, u32 *val);
  471. int pci_bus_write_config_byte(struct pci_bus *bus, unsigned int devfn,
  472. int where, u8 val);
  473. int pci_bus_write_config_word(struct pci_bus *bus, unsigned int devfn,
  474. int where, u16 val);
  475. int pci_bus_write_config_dword(struct pci_bus *bus, unsigned int devfn,
  476. int where, u32 val);
  477. static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val)
  478. {
  479. return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val);
  480. }
  481. static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val)
  482. {
  483. return pci_bus_read_config_word(dev->bus, dev->devfn, where, val);
  484. }
  485. static inline int pci_read_config_dword(struct pci_dev *dev, int where,
  486. u32 *val)
  487. {
  488. return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val);
  489. }
  490. static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val)
  491. {
  492. return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val);
  493. }
  494. static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val)
  495. {
  496. return pci_bus_write_config_word(dev->bus, dev->devfn, where, val);
  497. }
  498. static inline int pci_write_config_dword(struct pci_dev *dev, int where,
  499. u32 val)
  500. {
  501. return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
  502. }
  503. int __must_check pci_enable_device(struct pci_dev *dev);
  504. int __must_check pci_enable_device_io(struct pci_dev *dev);
  505. int __must_check pci_enable_device_mem(struct pci_dev *dev);
  506. int __must_check pci_reenable_device(struct pci_dev *);
  507. int __must_check pcim_enable_device(struct pci_dev *pdev);
  508. void pcim_pin_device(struct pci_dev *pdev);
  509. static inline int pci_is_managed(struct pci_dev *pdev)
  510. {
  511. return pdev->is_managed;
  512. }
  513. void pci_disable_device(struct pci_dev *dev);
  514. void pci_set_master(struct pci_dev *dev);
  515. int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
  516. #define HAVE_PCI_SET_MWI
  517. int __must_check pci_set_mwi(struct pci_dev *dev);
  518. int pci_try_set_mwi(struct pci_dev *dev);
  519. void pci_clear_mwi(struct pci_dev *dev);
  520. void pci_intx(struct pci_dev *dev, int enable);
  521. void pci_msi_off(struct pci_dev *dev);
  522. int pci_set_dma_mask(struct pci_dev *dev, u64 mask);
  523. int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask);
  524. int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size);
  525. int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask);
  526. int pcix_get_max_mmrbc(struct pci_dev *dev);
  527. int pcix_get_mmrbc(struct pci_dev *dev);
  528. int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc);
  529. int pcie_get_readrq(struct pci_dev *dev);
  530. int pcie_set_readrq(struct pci_dev *dev, int rq);
  531. void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno);
  532. int __must_check pci_assign_resource(struct pci_dev *dev, int i);
  533. int pci_select_bars(struct pci_dev *dev, unsigned long flags);
  534. /* ROM control related routines */
  535. void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size);
  536. void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom);
  537. size_t pci_get_rom_size(void __iomem *rom, size_t size);
  538. /* Power management related routines */
  539. int pci_save_state(struct pci_dev *dev);
  540. int pci_restore_state(struct pci_dev *dev);
  541. int pci_set_power_state(struct pci_dev *dev, pci_power_t state);
  542. pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
  543. int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable);
  544. int pci_prepare_to_sleep(struct pci_dev *dev);
  545. int pci_back_from_sleep(struct pci_dev *dev);
  546. /* Functions for PCI Hotplug drivers to use */
  547. int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
  548. /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
  549. void pci_bus_assign_resources(struct pci_bus *bus);
  550. void pci_bus_size_bridges(struct pci_bus *bus);
  551. int pci_claim_resource(struct pci_dev *, int);
  552. void pci_assign_unassigned_resources(void);
  553. void pdev_enable_device(struct pci_dev *);
  554. void pdev_sort_resources(struct pci_dev *, struct resource_list *);
  555. int pci_enable_resources(struct pci_dev *, int mask);
  556. void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
  557. int (*)(struct pci_dev *, u8, u8));
  558. #define HAVE_PCI_REQ_REGIONS 2
  559. int __must_check pci_request_regions(struct pci_dev *, const char *);
  560. void pci_release_regions(struct pci_dev *);
  561. int __must_check pci_request_region(struct pci_dev *, int, const char *);
  562. void pci_release_region(struct pci_dev *, int);
  563. int pci_request_selected_regions(struct pci_dev *, int, const char *);
  564. void pci_release_selected_regions(struct pci_dev *, int);
  565. /* drivers/pci/bus.c */
  566. int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
  567. struct resource *res, resource_size_t size,
  568. resource_size_t align, resource_size_t min,
  569. unsigned int type_mask,
  570. void (*alignf)(void *, struct resource *,
  571. resource_size_t, resource_size_t),
  572. void *alignf_data);
  573. void pci_enable_bridges(struct pci_bus *bus);
  574. /* Proper probing supporting hot-pluggable devices */
  575. int __must_check __pci_register_driver(struct pci_driver *, struct module *,
  576. const char *mod_name);
  577. static inline int __must_check pci_register_driver(struct pci_driver *driver)
  578. {
  579. return __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME);
  580. }
  581. void pci_unregister_driver(struct pci_driver *dev);
  582. void pci_remove_behind_bridge(struct pci_dev *dev);
  583. struct pci_driver *pci_dev_driver(const struct pci_dev *dev);
  584. const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
  585. struct pci_dev *dev);
  586. int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
  587. int pass);
  588. void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *),
  589. void *userdata);
  590. int pci_cfg_space_size_ext(struct pci_dev *dev);
  591. int pci_cfg_space_size(struct pci_dev *dev);
  592. unsigned char pci_bus_max_busnr(struct pci_bus *bus);
  593. /* kmem_cache style wrapper around pci_alloc_consistent() */
  594. #include <linux/dmapool.h>
  595. #define pci_pool dma_pool
  596. #define pci_pool_create(name, pdev, size, align, allocation) \
  597. dma_pool_create(name, &pdev->dev, size, align, allocation)
  598. #define pci_pool_destroy(pool) dma_pool_destroy(pool)
  599. #define pci_pool_alloc(pool, flags, handle) dma_pool_alloc(pool, flags, handle)
  600. #define pci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, addr)
  601. enum pci_dma_burst_strategy {
  602. PCI_DMA_BURST_INFINITY, /* make bursts as large as possible,
  603. strategy_parameter is N/A */
  604. PCI_DMA_BURST_BOUNDARY, /* disconnect at every strategy_parameter
  605. byte boundaries */
  606. PCI_DMA_BURST_MULTIPLE, /* disconnect at some multiple of
  607. strategy_parameter byte boundaries */
  608. };
  609. struct msix_entry {
  610. u16 vector; /* kernel uses to write allocated vector */
  611. u16 entry; /* driver uses to specify entry, OS writes */
  612. };
  613. #ifndef CONFIG_PCI_MSI
  614. static inline int pci_enable_msi(struct pci_dev *dev)
  615. {
  616. return -1;
  617. }
  618. static inline void pci_msi_shutdown(struct pci_dev *dev)
  619. { }
  620. static inline void pci_disable_msi(struct pci_dev *dev)
  621. { }
  622. static inline int pci_enable_msix(struct pci_dev *dev,
  623. struct msix_entry *entries, int nvec)
  624. {
  625. return -1;
  626. }
  627. static inline void pci_msix_shutdown(struct pci_dev *dev)
  628. { }
  629. static inline void pci_disable_msix(struct pci_dev *dev)
  630. { }
  631. static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev)
  632. { }
  633. static inline void pci_restore_msi_state(struct pci_dev *dev)
  634. { }
  635. #else
  636. extern int pci_enable_msi(struct pci_dev *dev);
  637. extern void pci_msi_shutdown(struct pci_dev *dev);
  638. extern void pci_disable_msi(struct pci_dev *dev);
  639. extern int pci_enable_msix(struct pci_dev *dev,
  640. struct msix_entry *entries, int nvec);
  641. extern void pci_msix_shutdown(struct pci_dev *dev);
  642. extern void pci_disable_msix(struct pci_dev *dev);
  643. extern void msi_remove_pci_irq_vectors(struct pci_dev *dev);
  644. extern void pci_restore_msi_state(struct pci_dev *dev);
  645. #endif
  646. #ifdef CONFIG_HT_IRQ
  647. /* The functions a driver should call */
  648. int ht_create_irq(struct pci_dev *dev, int idx);
  649. void ht_destroy_irq(unsigned int irq);
  650. #endif /* CONFIG_HT_IRQ */
  651. extern void pci_block_user_cfg_access(struct pci_dev *dev);
  652. extern void pci_unblock_user_cfg_access(struct pci_dev *dev);
  653. /*
  654. * PCI domain support. Sometimes called PCI segment (eg by ACPI),
  655. * a PCI domain is defined to be a set of PCI busses which share
  656. * configuration space.
  657. */
  658. #ifdef CONFIG_PCI_DOMAINS
  659. extern int pci_domains_supported;
  660. #else
  661. enum { pci_domains_supported = 0 };
  662. static inline int pci_domain_nr(struct pci_bus *bus)
  663. {
  664. return 0;
  665. }
  666. static inline int pci_proc_domain(struct pci_bus *bus)
  667. {
  668. return 0;
  669. }
  670. #endif /* CONFIG_PCI_DOMAINS */
  671. #else /* CONFIG_PCI is not enabled */
  672. /*
  673. * If the system does not have PCI, clearly these return errors. Define
  674. * these as simple inline functions to avoid hair in drivers.
  675. */
  676. #define _PCI_NOP(o, s, t) \
  677. static inline int pci_##o##_config_##s(struct pci_dev *dev, \
  678. int where, t val) \
  679. { return PCIBIOS_FUNC_NOT_SUPPORTED; }
  680. #define _PCI_NOP_ALL(o, x) _PCI_NOP(o, byte, u8 x) \
  681. _PCI_NOP(o, word, u16 x) \
  682. _PCI_NOP(o, dword, u32 x)
  683. _PCI_NOP_ALL(read, *)
  684. _PCI_NOP_ALL(write,)
  685. static inline struct pci_dev *pci_find_device(unsigned int vendor,
  686. unsigned int device,
  687. const struct pci_dev *from)
  688. {
  689. return NULL;
  690. }
  691. static inline struct pci_dev *pci_find_slot(unsigned int bus,
  692. unsigned int devfn)
  693. {
  694. return NULL;
  695. }
  696. static inline struct pci_dev *pci_get_device(unsigned int vendor,
  697. unsigned int device,
  698. struct pci_dev *from)
  699. {
  700. return NULL;
  701. }
  702. static inline struct pci_dev *pci_get_subsys(unsigned int vendor,
  703. unsigned int device,
  704. unsigned int ss_vendor,
  705. unsigned int ss_device,
  706. const struct pci_dev *from)
  707. {
  708. return NULL;
  709. }
  710. static inline struct pci_dev *pci_get_class(unsigned int class,
  711. struct pci_dev *from)
  712. {
  713. return NULL;
  714. }
  715. #define pci_dev_present(ids) (0)
  716. #define no_pci_devices() (1)
  717. #define pci_dev_put(dev) do { } while (0)
  718. static inline void pci_set_master(struct pci_dev *dev)
  719. { }
  720. static inline int pci_enable_device(struct pci_dev *dev)
  721. {
  722. return -EIO;
  723. }
  724. static inline void pci_disable_device(struct pci_dev *dev)
  725. { }
  726. static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
  727. {
  728. return -EIO;
  729. }
  730. static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
  731. {
  732. return -EIO;
  733. }
  734. static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
  735. unsigned int size)
  736. {
  737. return -EIO;
  738. }
  739. static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
  740. unsigned long mask)
  741. {
  742. return -EIO;
  743. }
  744. static inline int pci_assign_resource(struct pci_dev *dev, int i)
  745. {
  746. return -EBUSY;
  747. }
  748. static inline int __pci_register_driver(struct pci_driver *drv,
  749. struct module *owner)
  750. {
  751. return 0;
  752. }
  753. static inline int pci_register_driver(struct pci_driver *drv)
  754. {
  755. return 0;
  756. }
  757. static inline void pci_unregister_driver(struct pci_driver *drv)
  758. { }
  759. static inline int pci_find_capability(struct pci_dev *dev, int cap)
  760. {
  761. return 0;
  762. }
  763. static inline int pci_find_next_capability(struct pci_dev *dev, u8 post,
  764. int cap)
  765. {
  766. return 0;
  767. }
  768. static inline int pci_find_ext_capability(struct pci_dev *dev, int cap)
  769. {
  770. return 0;
  771. }
  772. /* Power management related routines */
  773. static inline int pci_save_state(struct pci_dev *dev)
  774. {
  775. return 0;
  776. }
  777. static inline int pci_restore_state(struct pci_dev *dev)
  778. {
  779. return 0;
  780. }
  781. static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
  782. {
  783. return 0;
  784. }
  785. static inline pci_power_t pci_choose_state(struct pci_dev *dev,
  786. pm_message_t state)
  787. {
  788. return PCI_D0;
  789. }
  790. static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
  791. int enable)
  792. {
  793. return 0;
  794. }
  795. static inline int pci_request_regions(struct pci_dev *dev, const char *res_name)
  796. {
  797. return -EIO;
  798. }
  799. static inline void pci_release_regions(struct pci_dev *dev)
  800. { }
  801. #define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0)
  802. static inline void pci_block_user_cfg_access(struct pci_dev *dev)
  803. { }
  804. static inline void pci_unblock_user_cfg_access(struct pci_dev *dev)
  805. { }
  806. static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
  807. { return NULL; }
  808. static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
  809. unsigned int devfn)
  810. { return NULL; }
  811. static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
  812. unsigned int devfn)
  813. { return NULL; }
  814. #endif /* CONFIG_PCI */
  815. /* Include architecture-dependent settings and functions */
  816. #include <asm/pci.h>
  817. /* these helpers provide future and backwards compatibility
  818. * for accessing popular PCI BAR info */
  819. #define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
  820. #define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end)
  821. #define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags)
  822. #define pci_resource_len(dev,bar) \
  823. ((pci_resource_start((dev), (bar)) == 0 && \
  824. pci_resource_end((dev), (bar)) == \
  825. pci_resource_start((dev), (bar))) ? 0 : \
  826. \
  827. (pci_resource_end((dev), (bar)) - \
  828. pci_resource_start((dev), (bar)) + 1))
  829. /* Similar to the helpers above, these manipulate per-pci_dev
  830. * driver-specific data. They are really just a wrapper around
  831. * the generic device structure functions of these calls.
  832. */
  833. static inline void *pci_get_drvdata(struct pci_dev *pdev)
  834. {
  835. return dev_get_drvdata(&pdev->dev);
  836. }
  837. static inline void pci_set_drvdata(struct pci_dev *pdev, void *data)
  838. {
  839. dev_set_drvdata(&pdev->dev, data);
  840. }
  841. /* If you want to know what to call your pci_dev, ask this function.
  842. * Again, it's a wrapper around the generic device.
  843. */
  844. static inline const char *pci_name(struct pci_dev *pdev)
  845. {
  846. return dev_name(&pdev->dev);
  847. }
  848. /* Some archs don't want to expose struct resource to userland as-is
  849. * in sysfs and /proc
  850. */
  851. #ifndef HAVE_ARCH_PCI_RESOURCE_TO_USER
  852. static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
  853. const struct resource *rsrc, resource_size_t *start,
  854. resource_size_t *end)
  855. {
  856. *start = rsrc->start;
  857. *end = rsrc->end;
  858. }
  859. #endif /* HAVE_ARCH_PCI_RESOURCE_TO_USER */
  860. /*
  861. * The world is not perfect and supplies us with broken PCI devices.
  862. * For at least a part of these bugs we need a work-around, so both
  863. * generic (drivers/pci/quirks.c) and per-architecture code can define
  864. * fixup hooks to be called for particular buggy devices.
  865. */
  866. struct pci_fixup {
  867. u16 vendor, device; /* You can use PCI_ANY_ID here of course */
  868. void (*hook)(struct pci_dev *dev);
  869. };
  870. enum pci_fixup_pass {
  871. pci_fixup_early, /* Before probing BARs */
  872. pci_fixup_header, /* After reading configuration header */
  873. pci_fixup_final, /* Final phase of device fixups */
  874. pci_fixup_enable, /* pci_enable_device() time */
  875. pci_fixup_resume, /* pci_device_resume() */
  876. pci_fixup_suspend, /* pci_device_suspend */
  877. pci_fixup_resume_early, /* pci_device_resume_early() */
  878. };
  879. /* Anonymous variables would be nice... */
  880. #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \
  881. static const struct pci_fixup __pci_fixup_##name __used \
  882. __attribute__((__section__(#section))) = { vendor, device, hook };
  883. #define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \
  884. DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
  885. vendor##device##hook, vendor, device, hook)
  886. #define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \
  887. DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
  888. vendor##device##hook, vendor, device, hook)
  889. #define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \
  890. DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
  891. vendor##device##hook, vendor, device, hook)
  892. #define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \
  893. DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
  894. vendor##device##hook, vendor, device, hook)
  895. #define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \
  896. DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
  897. resume##vendor##device##hook, vendor, device, hook)
  898. #define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \
  899. DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
  900. resume_early##vendor##device##hook, vendor, device, hook)
  901. #define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \
  902. DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
  903. suspend##vendor##device##hook, vendor, device, hook)
  904. void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
  905. void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
  906. void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
  907. void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);
  908. int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name);
  909. int pcim_iomap_regions_request_all(struct pci_dev *pdev, u16 mask,
  910. const char *name);
  911. void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask);
  912. extern int pci_pci_problems;
  913. #define PCIPCI_FAIL 1 /* No PCI PCI DMA */
  914. #define PCIPCI_TRITON 2
  915. #define PCIPCI_NATOMA 4
  916. #define PCIPCI_VIAETBF 8
  917. #define PCIPCI_VSFX 16
  918. #define PCIPCI_ALIMAGIK 32 /* Need low latency setting */
  919. #define PCIAGP_FAIL 64 /* No PCI to AGP DMA */
  920. extern unsigned long pci_cardbus_io_size;
  921. extern unsigned long pci_cardbus_mem_size;
  922. int pcibios_add_platform_entries(struct pci_dev *dev);
  923. void pcibios_disable_device(struct pci_dev *dev);
  924. int pcibios_set_pcie_reset_state(struct pci_dev *dev,
  925. enum pcie_reset_state state);
  926. #ifdef CONFIG_PCI_MMCONFIG
  927. extern void __init pci_mmcfg_early_init(void);
  928. extern void __init pci_mmcfg_late_init(void);
  929. #else
  930. static inline void pci_mmcfg_early_init(void) { }
  931. static inline void pci_mmcfg_late_init(void) { }
  932. #endif
  933. #endif /* __KERNEL__ */
  934. #endif /* LINUX_PCI_H */