pci.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. void (*shutdown)(struct pnv_phb *phb);
  75. union {
  76. struct {
  77. struct iommu_table iommu_table;
  78. } p5ioc2;
  79. struct {
  80. /* Global bridge info */
  81. unsigned int total_pe;
  82. unsigned int m32_size;
  83. unsigned int m32_segsize;
  84. unsigned int m32_pci_base;
  85. unsigned int io_size;
  86. unsigned int io_segsize;
  87. unsigned int io_pci_base;
  88. /* PE allocation bitmap */
  89. unsigned long *pe_alloc;
  90. /* M32 & IO segment maps */
  91. unsigned int *m32_segmap;
  92. unsigned int *io_segmap;
  93. struct pnv_ioda_pe *pe_array;
  94. /* IRQ chip */
  95. int irq_chip_init;
  96. struct irq_chip irq_chip;
  97. /* Sorted list of used PE's based
  98. * on the sequence of creation
  99. */
  100. struct list_head pe_list;
  101. /* Reverse map of PEs, will have to extend if
  102. * we are to support more than 256 PEs, indexed
  103. * bus { bus, devfn }
  104. */
  105. unsigned char pe_rmap[0x10000];
  106. /* 32-bit TCE tables allocation */
  107. unsigned long tce32_count;
  108. /* Total "weight" for the sake of DMA resources
  109. * allocation
  110. */
  111. unsigned int dma_weight;
  112. unsigned int dma_pe_count;
  113. /* Sorted list of used PE's, sorted at
  114. * boot for resource allocation purposes
  115. */
  116. struct list_head pe_dma_list;
  117. } ioda;
  118. };
  119. /* PHB status structure */
  120. union {
  121. unsigned char blob[PNV_PCI_DIAG_BUF_SIZE];
  122. struct OpalIoP7IOCPhbErrorData p7ioc;
  123. } diag;
  124. };
  125. extern struct pci_ops pnv_pci_ops;
  126. extern void pnv_pci_setup_iommu_table(struct iommu_table *tbl,
  127. void *tce_mem, u64 tce_size,
  128. u64 dma_offset);
  129. extern void pnv_pci_init_p5ioc2_hub(struct device_node *np);
  130. extern void pnv_pci_init_ioda_hub(struct device_node *np);
  131. extern void pnv_pci_init_ioda2_phb(struct device_node *np);
  132. extern void pnv_pci_ioda_tce_invalidate(struct iommu_table *tbl,
  133. u64 *startp, u64 *endp);
  134. #endif /* __POWERNV_PCI_H */