pci.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. /* IOC dependent EEH operations */
  56. #ifdef CONFIG_EEH
  57. struct pnv_eeh_ops {
  58. int (*post_init)(struct pci_controller *hose);
  59. int (*set_option)(struct eeh_pe *pe, int option);
  60. int (*get_state)(struct eeh_pe *pe);
  61. int (*reset)(struct eeh_pe *pe, int option);
  62. int (*get_log)(struct eeh_pe *pe, int severity,
  63. char *drv_log, unsigned long len);
  64. int (*configure_bridge)(struct eeh_pe *pe);
  65. int (*next_error)(struct eeh_pe **pe);
  66. };
  67. #endif /* CONFIG_EEH */
  68. struct pnv_phb {
  69. struct pci_controller *hose;
  70. enum pnv_phb_type type;
  71. enum pnv_phb_model model;
  72. u64 hub_id;
  73. u64 opal_id;
  74. void __iomem *regs;
  75. int initialized;
  76. spinlock_t lock;
  77. #ifdef CONFIG_EEH
  78. struct pnv_eeh_ops *eeh_ops;
  79. int eeh_enabled;
  80. int removed;
  81. #endif
  82. #ifdef CONFIG_DEBUG_FS
  83. struct dentry *dbgfs;
  84. #endif
  85. #ifdef CONFIG_PCI_MSI
  86. unsigned int msi_base;
  87. unsigned int msi32_support;
  88. struct msi_bitmap msi_bmp;
  89. #endif
  90. int (*msi_setup)(struct pnv_phb *phb, struct pci_dev *dev,
  91. unsigned int hwirq, unsigned int virq,
  92. unsigned int is_64, struct msi_msg *msg);
  93. void (*dma_dev_setup)(struct pnv_phb *phb, struct pci_dev *pdev);
  94. void (*fixup_phb)(struct pci_controller *hose);
  95. u32 (*bdfn_to_pe)(struct pnv_phb *phb, struct pci_bus *bus, u32 devfn);
  96. void (*shutdown)(struct pnv_phb *phb);
  97. union {
  98. struct {
  99. struct iommu_table iommu_table;
  100. } p5ioc2;
  101. struct {
  102. /* Global bridge info */
  103. unsigned int total_pe;
  104. unsigned int m32_size;
  105. unsigned int m32_segsize;
  106. unsigned int m32_pci_base;
  107. unsigned int io_size;
  108. unsigned int io_segsize;
  109. unsigned int io_pci_base;
  110. /* PE allocation bitmap */
  111. unsigned long *pe_alloc;
  112. /* M32 & IO segment maps */
  113. unsigned int *m32_segmap;
  114. unsigned int *io_segmap;
  115. struct pnv_ioda_pe *pe_array;
  116. /* IRQ chip */
  117. int irq_chip_init;
  118. struct irq_chip irq_chip;
  119. /* Sorted list of used PE's based
  120. * on the sequence of creation
  121. */
  122. struct list_head pe_list;
  123. /* Reverse map of PEs, will have to extend if
  124. * we are to support more than 256 PEs, indexed
  125. * bus { bus, devfn }
  126. */
  127. unsigned char pe_rmap[0x10000];
  128. /* 32-bit TCE tables allocation */
  129. unsigned long tce32_count;
  130. /* Total "weight" for the sake of DMA resources
  131. * allocation
  132. */
  133. unsigned int dma_weight;
  134. unsigned int dma_pe_count;
  135. /* Sorted list of used PE's, sorted at
  136. * boot for resource allocation purposes
  137. */
  138. struct list_head pe_dma_list;
  139. } ioda;
  140. };
  141. /* PHB status structure */
  142. union {
  143. unsigned char blob[PNV_PCI_DIAG_BUF_SIZE];
  144. struct OpalIoP7IOCPhbErrorData p7ioc;
  145. } diag;
  146. };
  147. extern struct pci_ops pnv_pci_ops;
  148. #ifdef CONFIG_EEH
  149. extern struct pnv_eeh_ops ioda_eeh_ops;
  150. #endif
  151. extern void pnv_pci_setup_iommu_table(struct iommu_table *tbl,
  152. void *tce_mem, u64 tce_size,
  153. u64 dma_offset);
  154. extern void pnv_pci_init_p5ioc2_hub(struct device_node *np);
  155. extern void pnv_pci_init_ioda_hub(struct device_node *np);
  156. extern void pnv_pci_init_ioda2_phb(struct device_node *np);
  157. extern void pnv_pci_ioda_tce_invalidate(struct iommu_table *tbl,
  158. u64 *startp, u64 *endp);
  159. #endif /* __POWERNV_PCI_H */