pci.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. /* Data associated with a PE, including IOMMU tracking etc.. */
  17. struct pnv_ioda_pe {
  18. /* A PE can be associated with a single device or an
  19. * entire bus (& children). In the former case, pdev
  20. * is populated, in the later case, pbus is.
  21. */
  22. struct pci_dev *pdev;
  23. struct pci_bus *pbus;
  24. /* Effective RID (device RID for a device PE and base bus
  25. * RID with devfn 0 for a bus PE)
  26. */
  27. unsigned int rid;
  28. /* PE number */
  29. unsigned int pe_number;
  30. /* "Weight" assigned to the PE for the sake of DMA resource
  31. * allocations
  32. */
  33. unsigned int dma_weight;
  34. /* This is a PCI-E -> PCI-X bridge, this points to the
  35. * corresponding bus PE
  36. */
  37. struct pnv_ioda_pe *bus_pe;
  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 link;
  50. };
  51. struct pnv_phb {
  52. struct pci_controller *hose;
  53. enum pnv_phb_type type;
  54. enum pnv_phb_model model;
  55. u64 opal_id;
  56. void __iomem *regs;
  57. spinlock_t lock;
  58. #ifdef CONFIG_PCI_MSI
  59. unsigned long *msi_map;
  60. unsigned int msi_base;
  61. unsigned int msi_count;
  62. unsigned int msi_next;
  63. unsigned int msi32_support;
  64. #endif
  65. int (*msi_setup)(struct pnv_phb *phb, struct pci_dev *dev,
  66. unsigned int hwirq, unsigned int is_64,
  67. struct msi_msg *msg);
  68. void (*dma_dev_setup)(struct pnv_phb *phb, struct pci_dev *pdev);
  69. void (*fixup_phb)(struct pci_controller *hose);
  70. u32 (*bdfn_to_pe)(struct pnv_phb *phb, struct pci_bus *bus, u32 devfn);
  71. union {
  72. struct {
  73. struct iommu_table iommu_table;
  74. } p5ioc2;
  75. struct {
  76. /* Global bridge info */
  77. unsigned int total_pe;
  78. unsigned int m32_size;
  79. unsigned int m32_segsize;
  80. unsigned int m32_pci_base;
  81. unsigned int io_size;
  82. unsigned int io_segsize;
  83. unsigned int io_pci_base;
  84. /* PE allocation bitmap */
  85. unsigned long *pe_alloc;
  86. /* M32 & IO segment maps */
  87. unsigned int *m32_segmap;
  88. unsigned int *io_segmap;
  89. struct pnv_ioda_pe *pe_array;
  90. /* Reverse map of PEs, will have to extend if
  91. * we are to support more than 256 PEs, indexed
  92. * bus { bus, devfn }
  93. */
  94. unsigned char pe_rmap[0x10000];
  95. /* 32-bit TCE tables allocation */
  96. unsigned long tce32_count;
  97. /* Total "weight" for the sake of DMA resources
  98. * allocation
  99. */
  100. unsigned int dma_weight;
  101. unsigned int dma_pe_count;
  102. /* Sorted list of used PE's, sorted at
  103. * boot for resource allocation purposes
  104. */
  105. struct list_head pe_list;
  106. } ioda;
  107. };
  108. /* PHB status structure */
  109. union {
  110. unsigned char blob[PNV_PCI_DIAG_BUF_SIZE];
  111. struct OpalIoP7IOCPhbErrorData p7ioc;
  112. } diag;
  113. };
  114. extern struct pci_ops pnv_pci_ops;
  115. extern void pnv_pci_setup_iommu_table(struct iommu_table *tbl,
  116. void *tce_mem, u64 tce_size,
  117. u64 dma_offset);
  118. extern void pnv_pci_init_p5ioc2_hub(struct device_node *np);
  119. extern void pnv_pci_init_ioda_hub(struct device_node *np);
  120. #endif /* __POWERNV_PCI_H */