1 #ifndef __POWERNV_PCI_H
2 #define __POWERNV_PCI_H
12 /* Precise PHB model for error management */
14 PNV_PHB_MODEL_UNKNOWN,
20 #define PNV_PCI_DIAG_BUF_SIZE 8192
21 #define PNV_IODA_PE_DEV (1 << 0) /* PE has single PCI device */
22 #define PNV_IODA_PE_BUS (1 << 1) /* PE has primary PCI bus */
23 #define PNV_IODA_PE_BUS_ALL (1 << 2) /* PE has subordinate buses */
24 #define PNV_IODA_PE_MASTER (1 << 3) /* Master PE in compound case */
25 #define PNV_IODA_PE_SLAVE (1 << 4) /* Slave PE in compound case */
27 /* Data associated with a PE, including IOMMU tracking etc.. */
33 /* A PE can be associated with a single device or an
34 * entire bus (& children). In the former case, pdev
35 * is populated, in the later case, pbus is.
40 /* Effective RID (device RID for a device PE and base bus
41 * RID with devfn 0 for a bus PE)
46 unsigned int pe_number;
48 /* "Weight" assigned to the PE for the sake of DMA resource
51 unsigned int dma_weight;
53 /* "Base" iommu table, ie, 4K TCEs, 32-bit DMA */
56 struct iommu_table tce32_table;
57 phys_addr_t tce_inval_reg_phys;
59 /* 64-bit TCE bypass region */
60 bool tce_bypass_enabled;
61 uint64_t tce_bypass_base;
63 /* MSIs. MVE index is identical for for 32 and 64 bit MSI
64 * and -1 if not supported. (It's actually identical to the
69 /* PEs in compound case */
70 struct pnv_ioda_pe *master;
71 struct list_head slaves;
73 /* Link in list of PE#s */
74 struct list_head dma_link;
75 struct list_head list;
78 /* IOC dependent EEH operations */
81 int (*post_init)(struct pci_controller *hose);
82 int (*set_option)(struct eeh_pe *pe, int option);
83 int (*get_state)(struct eeh_pe *pe);
84 int (*reset)(struct eeh_pe *pe, int option);
85 int (*get_log)(struct eeh_pe *pe, int severity,
86 char *drv_log, unsigned long len);
87 int (*configure_bridge)(struct eeh_pe *pe);
88 int (*err_inject)(struct eeh_pe *pe, int type, int func,
89 unsigned long addr, unsigned long mask);
90 int (*next_error)(struct eeh_pe **pe);
92 #endif /* CONFIG_EEH */
94 #define PNV_PHB_FLAG_EEH (1 << 0)
97 struct pci_controller *hose;
98 enum pnv_phb_type type;
99 enum pnv_phb_model model;
108 struct pnv_eeh_ops *eeh_ops;
111 #ifdef CONFIG_DEBUG_FS
113 struct dentry *dbgfs;
116 #ifdef CONFIG_PCI_MSI
117 unsigned int msi_base;
118 unsigned int msi32_support;
119 struct msi_bitmap msi_bmp;
121 int (*msi_setup)(struct pnv_phb *phb, struct pci_dev *dev,
122 unsigned int hwirq, unsigned int virq,
123 unsigned int is_64, struct msi_msg *msg);
124 void (*dma_dev_setup)(struct pnv_phb *phb, struct pci_dev *pdev);
125 int (*dma_set_mask)(struct pnv_phb *phb, struct pci_dev *pdev,
127 void (*fixup_phb)(struct pci_controller *hose);
128 u32 (*bdfn_to_pe)(struct pnv_phb *phb, struct pci_bus *bus, u32 devfn);
129 void (*shutdown)(struct pnv_phb *phb);
130 int (*init_m64)(struct pnv_phb *phb);
131 void (*alloc_m64_pe)(struct pnv_phb *phb);
132 int (*pick_m64_pe)(struct pnv_phb *phb, struct pci_bus *bus, int all);
133 int (*get_pe_state)(struct pnv_phb *phb, int pe_no);
134 void (*freeze_pe)(struct pnv_phb *phb, int pe_no);
135 int (*unfreeze_pe)(struct pnv_phb *phb, int pe_no, int opt);
139 struct iommu_table iommu_table;
143 /* Global bridge info */
144 unsigned int total_pe;
145 unsigned int reserved_pe;
147 /* 32-bit MMIO window */
148 unsigned int m32_size;
149 unsigned int m32_segsize;
150 unsigned int m32_pci_base;
152 /* 64-bit MMIO window */
153 unsigned int m64_bar_idx;
154 unsigned long m64_size;
155 unsigned long m64_segsize;
156 unsigned long m64_base;
157 unsigned long m64_bar_alloc;
160 unsigned int io_size;
161 unsigned int io_segsize;
162 unsigned int io_pci_base;
164 /* PE allocation bitmap */
165 unsigned long *pe_alloc;
167 /* M32 & IO segment maps */
168 unsigned int *m32_segmap;
169 unsigned int *io_segmap;
170 struct pnv_ioda_pe *pe_array;
174 struct irq_chip irq_chip;
176 /* Sorted list of used PE's based
177 * on the sequence of creation
179 struct list_head pe_list;
181 /* Reverse map of PEs, will have to extend if
182 * we are to support more than 256 PEs, indexed
185 unsigned char pe_rmap[0x10000];
187 /* 32-bit TCE tables allocation */
188 unsigned long tce32_count;
190 /* Total "weight" for the sake of DMA resources
193 unsigned int dma_weight;
194 unsigned int dma_pe_count;
196 /* Sorted list of used PE's, sorted at
197 * boot for resource allocation purposes
199 struct list_head pe_dma_list;
203 /* PHB and hub status structure */
205 unsigned char blob[PNV_PCI_DIAG_BUF_SIZE];
206 struct OpalIoP7IOCPhbErrorData p7ioc;
207 struct OpalIoPhb3ErrorData phb3;
208 struct OpalIoP7IOCErrorData hub_diag;
213 extern struct pci_ops pnv_pci_ops;
215 extern struct pnv_eeh_ops ioda_eeh_ops;
218 void pnv_pci_dump_phb_diag_data(struct pci_controller *hose,
219 unsigned char *log_buff);
220 int pnv_pci_cfg_read(struct device_node *dn,
221 int where, int size, u32 *val);
222 int pnv_pci_cfg_write(struct device_node *dn,
223 int where, int size, u32 val);
224 extern void pnv_pci_setup_iommu_table(struct iommu_table *tbl,
225 void *tce_mem, u64 tce_size,
226 u64 dma_offset, unsigned page_shift);
227 extern void pnv_pci_init_p5ioc2_hub(struct device_node *np);
228 extern void pnv_pci_init_ioda_hub(struct device_node *np);
229 extern void pnv_pci_init_ioda2_phb(struct device_node *np);
230 extern void pnv_pci_ioda_tce_invalidate(struct iommu_table *tbl,
231 __be64 *startp, __be64 *endp, bool rm);
232 extern void pnv_pci_reset_secondary_bus(struct pci_dev *dev);
233 extern int ioda_eeh_phb_reset(struct pci_controller *hose, int option);
235 #endif /* __POWERNV_PCI_H */