pci.h 3.1 KB

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