pci.h 3.7 KB

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