pci.h 5.0 KB

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