1 diff --git a/arch/mips/pci/ops-bridge.c b/arch/mips/pci/ops-bridge.c
2 index 57e1463fcd02..6793a72edec2 100644
3 --- a/arch/mips/pci/ops-bridge.c
4 +++ b/arch/mips/pci/ops-bridge.c
8 #include <asm/paccess.h>
10 +#if defined(CONFIG_SGI_IP27)
11 #include <asm/pci/bridge.h>
12 #include <asm/sn/arch.h>
13 #include <asm/sn/intr.h>
14 #include <asm/sn/sn0/hub.h>
18 * Most of the IOC3 PCI config register aren't present
19 * we emulate what is needed for a normal PCI enumeration
21 -static u32 emulate_ioc3_cfg(int where, int size)
23 +emulate_ioc3_cfg(int where, int size)
25 if (size == 1 && where == 0x3d)
27 @@ -40,29 +44,29 @@ static u32 emulate_ioc3_cfg(int where, int size)
28 * accesses and does only decode parts of it's address space.
31 -static int pci_conf0_read_config(struct pci_bus *bus, unsigned int devfn,
32 - int where, int size, u32 * value)
34 +pci_conf0_read_config(struct pci_bus *bus, u32 devfn, int where, int size,
37 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
38 - bridge_t *bridge = bc->base;
39 int slot = PCI_SLOT(devfn);
40 int fn = PCI_FUNC(devfn);
45 - addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[PCI_VENDOR_ID];
46 + addr = &bc->bridge->pci_t0[slot].func[fn].b[PCI_VENDOR_ID];
47 if (get_dbe(cf, (u32 *) addr))
48 return PCIBIOS_DEVICE_NOT_FOUND;
51 - * IOC3 is fucking fucked beyond belief ... Don't even give the
52 - * generic PCI code a chance to look at it for real ...
53 + * IOC3 is fucking fucked beyond belief. Don't even give the
54 + * generic PCI code a chance to look at it for real.
56 if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
59 - addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[where ^ (4 - size)];
60 + addr = &bc->bridge->pci_t0[slot].func[fn].b[where ^ (4 - size)];
63 res = get_dbe(*value, (u8 *) addr);
64 @@ -74,9 +78,8 @@ static int pci_conf0_read_config(struct pci_bus *bus, unsigned int devfn,
65 return res ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
70 - * IOC3 is fucking fucked beyond belief ... Don't even give the
71 + * IOC3 is fucking fucked beyond belief. Don't even give the
72 * generic PCI code a chance to look at the wrong register.
74 if ((where >= 0x14 && where < 0x40) || (where >= 0x48)) {
75 @@ -85,10 +88,10 @@ static int pci_conf0_read_config(struct pci_bus *bus, unsigned int devfn,
79 - * IOC3 is fucking fucked beyond belief ... Don't try to access
80 - * anything but 32-bit words ...
81 + * IOC3 is fucking fucked beyond belief. Don't try to access
82 + * anything but 32-bit words.
84 - addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2];
85 + addr = &bc->bridge->pci_t0[slot].func[fn].l[where >> 2];
87 if (get_dbe(cf, (u32 *) addr))
88 return PCIBIOS_DEVICE_NOT_FOUND;
89 @@ -100,11 +103,11 @@ static int pci_conf0_read_config(struct pci_bus *bus, unsigned int devfn,
90 return PCIBIOS_SUCCESSFUL;
93 -static int pci_conf1_read_config(struct pci_bus *bus, unsigned int devfn,
94 - int where, int size, u32 * value)
96 +pci_conf1_read_config(struct pci_bus *bus, u32 devfn, int where, int size,
99 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
100 - bridge_t *bridge = bc->base;
101 int busno = bus->number;
102 int slot = PCI_SLOT(devfn);
103 int fn = PCI_FUNC(devfn);
104 @@ -112,20 +115,20 @@ static int pci_conf1_read_config(struct pci_bus *bus, unsigned int devfn,
108 - bridge->b_pci_cfg = (busno << 16) | (slot << 11);
109 - addr = &bridge->b_type1_cfg.c[(fn << 8) | PCI_VENDOR_ID];
110 + bridge_write_reg(((busno << 16) | (slot << 11)), bc, b_pci_type1_cfg);
111 + addr = &bc->bridge->pci_t1.b[(fn << 8) | PCI_VENDOR_ID];
112 if (get_dbe(cf, (u32 *) addr))
113 return PCIBIOS_DEVICE_NOT_FOUND;
116 - * IOC3 is fucking fucked beyond belief ... Don't even give the
117 - * generic PCI code a chance to look at it for real ...
118 + * IOC3 is fucking fucked beyond belief. Don't even give the
119 + * generic PCI code a chance to look at it for real.
121 if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
124 - bridge->b_pci_cfg = (busno << 16) | (slot << 11);
125 - addr = &bridge->b_type1_cfg.c[(fn << 8) | (where ^ (4 - size))];
126 + bridge_write_reg(((busno << 16) | (slot << 11)), bc, b_pci_type1_cfg);
127 + addr = &bc->bridge->pci_t1.b[(fn << 8) | (where ^ (4 - size))];
130 res = get_dbe(*value, (u8 *) addr);
131 @@ -137,9 +140,8 @@ static int pci_conf1_read_config(struct pci_bus *bus, unsigned int devfn,
132 return res ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
137 - * IOC3 is fucking fucked beyond belief ... Don't even give the
138 + * IOC3 is fucking fucked beyond belief. Don't even give the
139 * generic PCI code a chance to look at the wrong register.
141 if ((where >= 0x14 && where < 0x40) || (where >= 0x48)) {
142 @@ -148,11 +150,11 @@ static int pci_conf1_read_config(struct pci_bus *bus, unsigned int devfn,
146 - * IOC3 is fucking fucked beyond belief ... Don't try to access
147 - * anything but 32-bit words ...
148 + * IOC3 is fucking fucked beyond belief. Don't try to access
149 + * anything but 32-bit words.
151 - bridge->b_pci_cfg = (busno << 16) | (slot << 11);
152 - addr = &bridge->b_type1_cfg.c[(fn << 8) | where];
153 + bridge_write_reg(((busno << 16) | (slot << 11)), bc, b_pci_type1_cfg);
154 + addr = &bc->bridge->pci_t1.b[(fn << 8) | where];
156 if (get_dbe(cf, (u32 *) addr))
157 return PCIBIOS_DEVICE_NOT_FOUND;
158 @@ -164,8 +166,9 @@ static int pci_conf1_read_config(struct pci_bus *bus, unsigned int devfn,
159 return PCIBIOS_SUCCESSFUL;
162 -static int pci_read_config(struct pci_bus *bus, unsigned int devfn,
163 - int where, int size, u32 * value)
165 +pci_read_config(struct pci_bus *bus, u32 devfn, int where, int size,
169 return pci_conf1_read_config(bus, devfn, where, size, value);
170 @@ -173,29 +176,29 @@ static int pci_read_config(struct pci_bus *bus, unsigned int devfn,
171 return pci_conf0_read_config(bus, devfn, where, size, value);
174 -static int pci_conf0_write_config(struct pci_bus *bus, unsigned int devfn,
175 - int where, int size, u32 value)
177 +pci_conf0_write_config(struct pci_bus *bus, u32 devfn, int where, int size,
180 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
181 - bridge_t *bridge = bc->base;
182 int slot = PCI_SLOT(devfn);
183 int fn = PCI_FUNC(devfn);
185 u32 cf, shift, mask, smask;
188 - addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[PCI_VENDOR_ID];
189 + addr = &bc->bridge->pci_t0[slot].func[fn].b[PCI_VENDOR_ID];
190 if (get_dbe(cf, (u32 *) addr))
191 return PCIBIOS_DEVICE_NOT_FOUND;
194 - * IOC3 is fucking fucked beyond belief ... Don't even give the
195 - * generic PCI code a chance to look at it for real ...
196 + * IOC3 is fucking fucked beyond belief. Don't even give the
197 + * generic PCI code a chance to look at it for real.
199 if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
202 - addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[where ^ (4 - size)];
203 + addr = &bc->bridge->pci_t0[slot].func[fn].b[where ^ (4 - size)];
206 res = put_dbe(value, (u8 *) addr);
207 @@ -211,19 +214,18 @@ static int pci_conf0_write_config(struct pci_bus *bus, unsigned int devfn,
208 return PCIBIOS_SUCCESSFUL;
213 - * IOC3 is fucking fucked beyond belief ... Don't even give the
214 - * generic PCI code a chance to touch the wrong register.
215 + * IOC3 is fucking fucked beyond belief. Don't even give the
216 + * generic PCI code a chance to look at the wrong register.
218 if ((where >= 0x14 && where < 0x40) || (where >= 0x48))
219 return PCIBIOS_SUCCESSFUL;
222 - * IOC3 is fucking fucked beyond belief ... Don't try to access
223 - * anything but 32-bit words ...
224 + * IOC3 is fucking fucked beyond belief. Don't try to access
225 + * anything but 32-bit words.
227 - addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2];
228 + addr = &bc->bridge->pci_t0[slot].func[fn].l[where >> 2];
230 if (get_dbe(cf, (u32 *) addr))
231 return PCIBIOS_DEVICE_NOT_FOUND;
232 @@ -239,11 +241,11 @@ static int pci_conf0_write_config(struct pci_bus *bus, unsigned int devfn,
233 return PCIBIOS_SUCCESSFUL;
236 -static int pci_conf1_write_config(struct pci_bus *bus, unsigned int devfn,
237 - int where, int size, u32 value)
239 +pci_conf1_write_config(struct pci_bus *bus, u32 devfn, int where, int size,
242 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
243 - bridge_t *bridge = bc->base;
244 int slot = PCI_SLOT(devfn);
245 int fn = PCI_FUNC(devfn);
246 int busno = bus->number;
247 @@ -251,19 +253,20 @@ static int pci_conf1_write_config(struct pci_bus *bus, unsigned int devfn,
248 u32 cf, shift, mask, smask;
251 - bridge->b_pci_cfg = (busno << 16) | (slot << 11);
252 - addr = &bridge->b_type1_cfg.c[(fn << 8) | PCI_VENDOR_ID];
253 + bridge_write_reg(((busno << 16) | (slot << 11)), bc, b_pci_type1_cfg);
254 + addr = &bc->bridge->pci_t1.b[(fn << 8) | PCI_VENDOR_ID];
255 if (get_dbe(cf, (u32 *) addr))
256 return PCIBIOS_DEVICE_NOT_FOUND;
259 - * IOC3 is fucking fucked beyond belief ... Don't even give the
260 - * generic PCI code a chance to look at it for real ...
261 + * IOC3 is fucking fucked beyond belief. Don't even give the
262 + * generic PCI code a chance to look at it for real.
264 if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
267 - addr = &bridge->b_type1_cfg.c[(fn << 8) | (where ^ (4 - size))];
268 + bridge_write_reg(((busno << 16) | (slot << 11)), bc, b_pci_type1_cfg);
269 + addr = &bc->bridge->pci_t1.b[(fn << 8) | (where ^ (4 - size))];
272 res = put_dbe(value, (u8 *) addr);
273 @@ -279,19 +282,19 @@ static int pci_conf1_write_config(struct pci_bus *bus, unsigned int devfn,
274 return PCIBIOS_SUCCESSFUL;
279 - * IOC3 is fucking fucked beyond belief ... Don't even give the
280 - * generic PCI code a chance to touch the wrong register.
281 + * IOC3 is fucking fucked beyond belief. Don't even give the
282 + * generic PCI code a chance to look at the wrong register.
284 if ((where >= 0x14 && where < 0x40) || (where >= 0x48))
285 return PCIBIOS_SUCCESSFUL;
288 - * IOC3 is fucking fucked beyond belief ... Don't try to access
289 - * anything but 32-bit words ...
290 + * IOC3 is fucking fucked beyond belief. Don't try to access
291 + * anything but 32-bit words.
293 - addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2];
294 + bridge_write_reg(((busno << 16) | (slot << 11)), bc, b_pci_type1_cfg);
295 + addr = &bc->bridge->pci_t1.b[(fn << 8) | where];
297 if (get_dbe(cf, (u32 *) addr))
298 return PCIBIOS_DEVICE_NOT_FOUND;
299 @@ -307,8 +310,9 @@ static int pci_conf1_write_config(struct pci_bus *bus, unsigned int devfn,
300 return PCIBIOS_SUCCESSFUL;
303 -static int pci_write_config(struct pci_bus *bus, unsigned int devfn,
304 - int where, int size, u32 value)
306 +pci_write_config(struct pci_bus *bus, u32 devfn, int where, int size,
310 return pci_conf1_write_config(bus, devfn, where, size, value);
311 @@ -316,7 +320,8 @@ static int pci_write_config(struct pci_bus *bus, unsigned int devfn,
312 return pci_conf0_write_config(bus, devfn, where, size, value);
315 -struct pci_ops bridge_pci_ops = {
316 +struct pci_ops __read_mostly
318 .read = pci_read_config,
319 .write = pci_write_config,