pci_impl.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* pci_impl.h: Helper definitions for PCI controller support.
  2. *
  3. * Copyright (C) 1999, 2007 David S. Miller (davem@davemloft.net)
  4. */
  5. #ifndef PCI_IMPL_H
  6. #define PCI_IMPL_H
  7. #include <linux/types.h>
  8. #include <linux/spinlock.h>
  9. #include <linux/pci.h>
  10. #include <linux/msi.h>
  11. #include <asm/io.h>
  12. #include <asm/prom.h>
  13. #include <asm/iommu.h>
  14. /* The abstraction used here is that there are PCI controllers,
  15. * each with one (Sabre) or two (PSYCHO/SCHIZO) PCI bus modules
  16. * underneath. Each PCI bus module uses an IOMMU (shared by both
  17. * PBMs of a controller, or per-PBM), and if a streaming buffer
  18. * is present, each PCI bus module has it's own. (ie. the IOMMU
  19. * might be shared between PBMs, the STC is never shared)
  20. * Furthermore, each PCI bus module controls it's own autonomous
  21. * PCI bus.
  22. */
  23. #define PCI_STC_FLUSHFLAG_INIT(STC) \
  24. (*((STC)->strbuf_flushflag) = 0UL)
  25. #define PCI_STC_FLUSHFLAG_SET(STC) \
  26. (*((STC)->strbuf_flushflag) != 0UL)
  27. struct pci_controller_info;
  28. struct pci_pbm_info {
  29. struct pci_pbm_info *next;
  30. int index;
  31. /* PCI controller we sit under. */
  32. struct pci_controller_info *parent;
  33. /* Physical address base of controller registers. */
  34. unsigned long controller_regs;
  35. /* Physical address base of PBM registers. */
  36. unsigned long pbm_regs;
  37. /* Physical address of DMA sync register, if any. */
  38. unsigned long sync_reg;
  39. /* Opaque 32-bit system bus Port ID. */
  40. u32 portid;
  41. /* Opaque 32-bit handle used for hypervisor calls. */
  42. u32 devhandle;
  43. /* Chipset version information. */
  44. int chip_type;
  45. #define PBM_CHIP_TYPE_SABRE 1
  46. #define PBM_CHIP_TYPE_PSYCHO 2
  47. #define PBM_CHIP_TYPE_SCHIZO 3
  48. #define PBM_CHIP_TYPE_SCHIZO_PLUS 4
  49. #define PBM_CHIP_TYPE_TOMATILLO 5
  50. int chip_version;
  51. int chip_revision;
  52. /* Name used for top-level resources. */
  53. char *name;
  54. /* OBP specific information. */
  55. struct device_node *prom_node;
  56. u64 ino_bitmap;
  57. /* PBM I/O and Memory space resources. */
  58. struct resource io_space;
  59. struct resource mem_space;
  60. /* Base of PCI Config space, can be per-PBM or shared. */
  61. unsigned long config_space;
  62. /* State of 66MHz capabilities on this PBM. */
  63. int is_66mhz_capable;
  64. int all_devs_66mhz;
  65. #ifdef CONFIG_PCI_MSI
  66. /* MSI info. */
  67. u32 msiq_num;
  68. u32 msiq_ent_count;
  69. u32 msiq_first;
  70. u32 msiq_first_devino;
  71. u32 msi_num;
  72. u32 msi_first;
  73. u32 msi_data_mask;
  74. u32 msix_data_width;
  75. u64 msi32_start;
  76. u64 msi64_start;
  77. u32 msi32_len;
  78. u32 msi64_len;
  79. void *msi_queues;
  80. unsigned long *msi_bitmap;
  81. int (*setup_msi_irq)(unsigned int *virt_irq_p, struct pci_dev *pdev,
  82. struct msi_desc *entry);
  83. void (*teardown_msi_irq)(unsigned int virt_irq, struct pci_dev *pdev);
  84. #endif /* !(CONFIG_PCI_MSI) */
  85. /* This PBM's streaming buffer. */
  86. struct strbuf stc;
  87. /* IOMMU state, potentially shared by both PBM segments. */
  88. struct iommu *iommu;
  89. /* Now things for the actual PCI bus probes. */
  90. unsigned int pci_first_busno;
  91. unsigned int pci_last_busno;
  92. struct pci_bus *pci_bus;
  93. void (*scan_bus)(struct pci_pbm_info *);
  94. struct pci_ops *pci_ops;
  95. };
  96. struct pci_controller_info {
  97. /* The PCI bus modules controlled by us. */
  98. struct pci_pbm_info pbm_A;
  99. struct pci_pbm_info pbm_B;
  100. };
  101. extern struct pci_pbm_info *pci_pbm_root;
  102. extern unsigned long pci_memspace_mask;
  103. extern int pci_num_pbms;
  104. /* PCI bus scanning and fixup support. */
  105. extern void pci_iommu_table_init(struct iommu *iommu, int tsbsize,
  106. u32 dma_offset, u32 dma_addr_mask);
  107. extern void pci_get_pbm_props(struct pci_pbm_info *pbm);
  108. extern struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm);
  109. extern void pci_determine_mem_io_space(struct pci_pbm_info *pbm);
  110. extern int pci_host_bridge_read_pci_cfg(struct pci_bus *bus_dev,
  111. unsigned int devfn,
  112. int where, int size,
  113. u32 *value);
  114. extern int pci_host_bridge_write_pci_cfg(struct pci_bus *bus_dev,
  115. unsigned int devfn,
  116. int where, int size,
  117. u32 value);
  118. /* Error reporting support. */
  119. extern void pci_scan_for_target_abort(struct pci_pbm_info *, struct pci_bus *);
  120. extern void pci_scan_for_master_abort(struct pci_pbm_info *, struct pci_bus *);
  121. extern void pci_scan_for_parity_error(struct pci_pbm_info *, struct pci_bus *);
  122. /* Configuration space access. */
  123. extern void pci_config_read8(u8 *addr, u8 *ret);
  124. extern void pci_config_read16(u16 *addr, u16 *ret);
  125. extern void pci_config_read32(u32 *addr, u32 *ret);
  126. extern void pci_config_write8(u8 *addr, u8 val);
  127. extern void pci_config_write16(u16 *addr, u16 val);
  128. extern void pci_config_write32(u32 *addr, u32 val);
  129. #endif /* !(PCI_IMPL_H) */