pci.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #ifndef __POWERNV_PCI_H
  2. #define __POWERNV_PCI_H
  3. struct pci_dn;
  4. enum pnv_phb_type {
  5. PNV_PHB_P5IOC2 = 0,
  6. PNV_PHB_IODA1 = 1,
  7. PNV_PHB_IODA2 = 2,
  8. };
  9. /* Precise PHB model for error management */
  10. enum pnv_phb_model {
  11. PNV_PHB_MODEL_UNKNOWN,
  12. PNV_PHB_MODEL_P5IOC2,
  13. PNV_PHB_MODEL_P7IOC,
  14. PNV_PHB_MODEL_PHB3,
  15. };
  16. #define PNV_PCI_DIAG_BUF_SIZE 4096
  17. #define PNV_IODA_PE_DEV (1 << 0) /* PE has single PCI device */
  18. #define PNV_IODA_PE_BUS (1 << 1) /* PE has primary PCI bus */
  19. #define PNV_IODA_PE_BUS_ALL (1 << 2) /* PE has subordinate buses */
  20. /* Data associated with a PE, including IOMMU tracking etc.. */
  21. struct pnv_phb;
  22. struct pnv_ioda_pe {
  23. unsigned long flags;
  24. struct pnv_phb *phb;
  25. /* A PE can be associated with a single device or an
  26. * entire bus (& children). In the former case, pdev
  27. * is populated, in the later case, pbus is.
  28. */
  29. struct pci_dev *pdev;
  30. struct pci_bus *pbus;
  31. /* Effective RID (device RID for a device PE and base bus
  32. * RID with devfn 0 for a bus PE)
  33. */
  34. unsigned int rid;
  35. /* PE number */
  36. unsigned int pe_number;
  37. /* "Weight" assigned to the PE for the sake of DMA resource
  38. * allocations
  39. */
  40. unsigned int dma_weight;
  41. /* "Base" iommu table, ie, 4K TCEs, 32-bit DMA */
  42. int tce32_seg;
  43. int tce32_segcount;
  44. struct iommu_table tce32_table;
  45. /* XXX TODO: Add support for additional 64-bit iommus */
  46. /* MSIs. MVE index is identical for for 32 and 64 bit MSI
  47. * and -1 if not supported. (It's actually identical to the
  48. * PE number)
  49. */
  50. int mve_number;
  51. /* Link in list of PE#s */
  52. struct list_head dma_link;
  53. struct list_head list;
  54. };
  55. struct pnv_phb {
  56. struct pci_controller *hose;
  57. enum pnv_phb_type type;
  58. enum pnv_phb_model model;
  59. u64 opal_id;
  60. void __iomem *regs;
  61. int initialized;
  62. spinlock_t lock;
  63. #ifdef CONFIG_PCI_MSI
  64. unsigned int msi_base;
  65. unsigned int msi32_support;
  66. struct msi_bitmap msi_bmp;
  67. #endif
  68. int (*msi_setup)(struct pnv_phb *phb, struct pci_dev *dev,
  69. unsigned int hwirq, unsigned int virq,
  70. unsigned int is_64, struct msi_msg *msg);
  71. void (*dma_dev_setup)(struct pnv_phb *phb, struct pci_dev *pdev);
  72. void (*fixup_phb)(struct pci_controller *hose);
  73. u32 (*bdfn_to_pe)(struct pnv_phb *phb, struct pci_bus *bus, u32 devfn);
  74. union {
  75. struct {
  76. struct iommu_table iommu_table;
  77. } p5ioc2;
  78. struct {
  79. /* Global bridge info */
  80. unsigned int total_pe;
  81. unsigned int m32_size;
  82. unsigned int m32_segsize;
  83. unsigned int m32_pci_base;
  84. unsigned int io_size;
  85. unsigned int io_segsize;
  86. unsigned int io_pci_base;
  87. /* PE allocation bitmap */
  88. unsigned long *pe_alloc;
  89. /* M32 & IO segment maps */
  90. unsigned int *m32_segmap;
  91. unsigned int *io_segmap;
  92. struct pnv_ioda_pe *pe_array;
  93. /* IRQ chip */
  94. int irq_chip_init;
  95. struct irq_chip irq_chip;
  96. /* Sorted list of used PE's based
  97. * on the sequence of creation
  98. */
  99. struct list_head pe_list;
  100. /* Reverse map of PEs, will have to extend if
  101. * we are to support more than 256 PEs, indexed
  102. * bus { bus, devfn }
  103. */
  104. unsigned char pe_rmap[0x10000];
  105. /* 32-bit TCE tables allocation */
  106. unsigned long tce32_count;
  107. /* Total "weight" for the sake of DMA resources
  108. * allocation
  109. */
  110. unsigned int dma_weight;
  111. unsigned int dma_pe_count;
  112. /* Sorted list of used PE's, sorted at
  113. * boot for resource allocation purposes
  114. */
  115. struct list_head pe_dma_list;
  116. } ioda;
  117. };
  118. /* PHB status structure */
  119. union {
  120. unsigned char blob[PNV_PCI_DIAG_BUF_SIZE];
  121. struct OpalIoP7IOCPhbErrorData p7ioc;
  122. } diag;
  123. };
  124. extern struct pci_ops pnv_pci_ops;
  125. extern void pnv_pci_setup_iommu_table(struct iommu_table *tbl,
  126. void *tce_mem, u64 tce_size,
  127. u64 dma_offset);
  128. extern void pnv_pci_init_p5ioc2_hub(struct device_node *np);
  129. extern void pnv_pci_init_ioda_hub(struct device_node *np);
  130. extern void pnv_pci_init_ioda2_phb(struct device_node *np);
  131. extern void pnv_pci_ioda_tce_invalidate(struct iommu_table *tbl,
  132. u64 *startp, u64 *endp);
  133. #endif /* __POWERNV_PCI_H */