powerpc/eeh: Cleanup EEH subsystem variables
[deliverable/linux.git] / arch / powerpc / platforms / powernv / pci.h
CommitLineData
61305a96
BH
1#ifndef __POWERNV_PCI_H
2#define __POWERNV_PCI_H
3
4struct pci_dn;
5
6enum pnv_phb_type {
aa0c033f
GS
7 PNV_PHB_P5IOC2 = 0,
8 PNV_PHB_IODA1 = 1,
9 PNV_PHB_IODA2 = 2,
61305a96
BH
10};
11
cee72d5b
BH
12/* Precise PHB model for error management */
13enum pnv_phb_model {
14 PNV_PHB_MODEL_UNKNOWN,
15 PNV_PHB_MODEL_P5IOC2,
16 PNV_PHB_MODEL_P7IOC,
aa0c033f 17 PNV_PHB_MODEL_PHB3,
cee72d5b
BH
18};
19
5c9d6d75 20#define PNV_PCI_DIAG_BUF_SIZE 8192
7ebdf956
GS
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 */
cee72d5b 24
184cd4a3 25/* Data associated with a PE, including IOMMU tracking etc.. */
4cce9550 26struct pnv_phb;
184cd4a3 27struct pnv_ioda_pe {
7ebdf956 28 unsigned long flags;
4cce9550 29 struct pnv_phb *phb;
7ebdf956 30
184cd4a3
BH
31 /* A PE can be associated with a single device or an
32 * entire bus (& children). In the former case, pdev
33 * is populated, in the later case, pbus is.
34 */
35 struct pci_dev *pdev;
36 struct pci_bus *pbus;
37
38 /* Effective RID (device RID for a device PE and base bus
39 * RID with devfn 0 for a bus PE)
40 */
41 unsigned int rid;
42
43 /* PE number */
44 unsigned int pe_number;
45
46 /* "Weight" assigned to the PE for the sake of DMA resource
47 * allocations
48 */
49 unsigned int dma_weight;
50
184cd4a3
BH
51 /* "Base" iommu table, ie, 4K TCEs, 32-bit DMA */
52 int tce32_seg;
53 int tce32_segcount;
54 struct iommu_table tce32_table;
8e0a1611 55 phys_addr_t tce_inval_reg_phys;
184cd4a3 56
cd15b048
BH
57 /* 64-bit TCE bypass region */
58 bool tce_bypass_enabled;
59 uint64_t tce_bypass_base;
184cd4a3
BH
60
61 /* MSIs. MVE index is identical for for 32 and 64 bit MSI
62 * and -1 if not supported. (It's actually identical to the
63 * PE number)
64 */
65 int mve_number;
66
67 /* Link in list of PE#s */
7ebdf956
GS
68 struct list_head dma_link;
69 struct list_head list;
184cd4a3
BH
70};
71
8747f363
GS
72/* IOC dependent EEH operations */
73#ifdef CONFIG_EEH
74struct pnv_eeh_ops {
75 int (*post_init)(struct pci_controller *hose);
76 int (*set_option)(struct eeh_pe *pe, int option);
77 int (*get_state)(struct eeh_pe *pe);
78 int (*reset)(struct eeh_pe *pe, int option);
79 int (*get_log)(struct eeh_pe *pe, int severity,
80 char *drv_log, unsigned long len);
81 int (*configure_bridge)(struct eeh_pe *pe);
82 int (*next_error)(struct eeh_pe **pe);
83};
84#endif /* CONFIG_EEH */
85
f5bc6b70
GS
86#define PNV_PHB_FLAG_EEH (1 << 0)
87
61305a96
BH
88struct pnv_phb {
89 struct pci_controller *hose;
90 enum pnv_phb_type type;
cee72d5b 91 enum pnv_phb_model model;
8747f363 92 u64 hub_id;
61305a96 93 u64 opal_id;
f5bc6b70 94 int flags;
61305a96 95 void __iomem *regs;
db1266c8 96 int initialized;
61305a96
BH
97 spinlock_t lock;
98
8747f363
GS
99#ifdef CONFIG_EEH
100 struct pnv_eeh_ops *eeh_ops;
8747f363
GS
101#endif
102
37c367f2
GS
103#ifdef CONFIG_DEBUG_FS
104 struct dentry *dbgfs;
105#endif
106
c1a2562a 107#ifdef CONFIG_PCI_MSI
c1a2562a 108 unsigned int msi_base;
c1a2562a 109 unsigned int msi32_support;
fb1b55d6 110 struct msi_bitmap msi_bmp;
c1a2562a
BH
111#endif
112 int (*msi_setup)(struct pnv_phb *phb, struct pci_dev *dev,
137436c9
GS
113 unsigned int hwirq, unsigned int virq,
114 unsigned int is_64, struct msi_msg *msg);
61305a96 115 void (*dma_dev_setup)(struct pnv_phb *phb, struct pci_dev *pdev);
cd15b048
BH
116 int (*dma_set_mask)(struct pnv_phb *phb, struct pci_dev *pdev,
117 u64 dma_mask);
61305a96
BH
118 void (*fixup_phb)(struct pci_controller *hose);
119 u32 (*bdfn_to_pe)(struct pnv_phb *phb, struct pci_bus *bus, u32 devfn);
73ed148a 120 void (*shutdown)(struct pnv_phb *phb);
61305a96
BH
121
122 union {
123 struct {
124 struct iommu_table iommu_table;
125 } p5ioc2;
184cd4a3
BH
126
127 struct {
128 /* Global bridge info */
129 unsigned int total_pe;
36954dc7 130 unsigned int reserved_pe;
184cd4a3
BH
131 unsigned int m32_size;
132 unsigned int m32_segsize;
133 unsigned int m32_pci_base;
134 unsigned int io_size;
135 unsigned int io_segsize;
136 unsigned int io_pci_base;
137
138 /* PE allocation bitmap */
139 unsigned long *pe_alloc;
140
141 /* M32 & IO segment maps */
142 unsigned int *m32_segmap;
143 unsigned int *io_segmap;
144 struct pnv_ioda_pe *pe_array;
145
137436c9
GS
146 /* IRQ chip */
147 int irq_chip_init;
148 struct irq_chip irq_chip;
149
7ebdf956
GS
150 /* Sorted list of used PE's based
151 * on the sequence of creation
152 */
153 struct list_head pe_list;
154
184cd4a3
BH
155 /* Reverse map of PEs, will have to extend if
156 * we are to support more than 256 PEs, indexed
157 * bus { bus, devfn }
158 */
159 unsigned char pe_rmap[0x10000];
160
161 /* 32-bit TCE tables allocation */
162 unsigned long tce32_count;
163
164 /* Total "weight" for the sake of DMA resources
165 * allocation
166 */
167 unsigned int dma_weight;
168 unsigned int dma_pe_count;
169
170 /* Sorted list of used PE's, sorted at
171 * boot for resource allocation purposes
172 */
7ebdf956 173 struct list_head pe_dma_list;
184cd4a3 174 } ioda;
61305a96 175 };
cee72d5b 176
ca1de5de 177 /* PHB and hub status structure */
cee72d5b
BH
178 union {
179 unsigned char blob[PNV_PCI_DIAG_BUF_SIZE];
180 struct OpalIoP7IOCPhbErrorData p7ioc;
93aef2a7 181 struct OpalIoPhb3ErrorData phb3;
ca1de5de 182 struct OpalIoP7IOCErrorData hub_diag;
cee72d5b 183 } diag;
ca1de5de 184
61305a96
BH
185};
186
187extern struct pci_ops pnv_pci_ops;
8747f363
GS
188#ifdef CONFIG_EEH
189extern struct pnv_eeh_ops ioda_eeh_ops;
190#endif
61305a96 191
93aef2a7
GS
192void pnv_pci_dump_phb_diag_data(struct pci_controller *hose,
193 unsigned char *log_buff);
9bf41be6
GS
194int pnv_pci_cfg_read(struct device_node *dn,
195 int where, int size, u32 *val);
196int pnv_pci_cfg_write(struct device_node *dn,
197 int where, int size, u32 val);
61305a96
BH
198extern void pnv_pci_setup_iommu_table(struct iommu_table *tbl,
199 void *tce_mem, u64 tce_size,
200 u64 dma_offset);
201extern void pnv_pci_init_p5ioc2_hub(struct device_node *np);
184cd4a3 202extern void pnv_pci_init_ioda_hub(struct device_node *np);
aa0c033f 203extern void pnv_pci_init_ioda2_phb(struct device_node *np);
4cce9550 204extern void pnv_pci_ioda_tce_invalidate(struct iommu_table *tbl,
3ad26e5c 205 __be64 *startp, __be64 *endp, bool rm);
73ed148a 206
61305a96 207#endif /* __POWERNV_PCI_H */
This page took 0.242891 seconds and 5 git commands to generate.