1 |
1275 |
phoenix |
/* $Id: pci_schizo.c,v 1.1.1.1 2004-04-15 01:34:30 phoenix Exp $
|
2 |
|
|
* pci_schizo.c: SCHIZO/TOMATILLO specific PCI controller support.
|
3 |
|
|
*
|
4 |
|
|
* Copyright (C) 2001, 2002, 2003 David S. Miller (davem@redhat.com)
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
#include <linux/kernel.h>
|
8 |
|
|
#include <linux/types.h>
|
9 |
|
|
#include <linux/pci.h>
|
10 |
|
|
#include <linux/init.h>
|
11 |
|
|
#include <linux/slab.h>
|
12 |
|
|
|
13 |
|
|
#include <asm/pbm.h>
|
14 |
|
|
#include <asm/iommu.h>
|
15 |
|
|
#include <asm/irq.h>
|
16 |
|
|
#include <asm/upa.h>
|
17 |
|
|
|
18 |
|
|
#include "pci_impl.h"
|
19 |
|
|
#include "iommu_common.h"
|
20 |
|
|
|
21 |
|
|
/* All SCHIZO registers are 64-bits. The following accessor
|
22 |
|
|
* routines are how they are accessed. The REG parameter
|
23 |
|
|
* is a physical address.
|
24 |
|
|
*/
|
25 |
|
|
#define schizo_read(__reg) \
|
26 |
|
|
({ u64 __ret; \
|
27 |
|
|
__asm__ __volatile__("ldxa [%1] %2, %0" \
|
28 |
|
|
: "=r" (__ret) \
|
29 |
|
|
: "r" (__reg), "i" (ASI_PHYS_BYPASS_EC_E) \
|
30 |
|
|
: "memory"); \
|
31 |
|
|
__ret; \
|
32 |
|
|
})
|
33 |
|
|
#define schizo_write(__reg, __val) \
|
34 |
|
|
__asm__ __volatile__("stxa %0, [%1] %2" \
|
35 |
|
|
: /* no outputs */ \
|
36 |
|
|
: "r" (__val), "r" (__reg), \
|
37 |
|
|
"i" (ASI_PHYS_BYPASS_EC_E) \
|
38 |
|
|
: "memory")
|
39 |
|
|
|
40 |
|
|
/* This is a convention that at least Excalibur and Merlin
|
41 |
|
|
* follow. I suppose the SCHIZO used in Starcat and friends
|
42 |
|
|
* will do similar.
|
43 |
|
|
*
|
44 |
|
|
* The only way I could see this changing is if the newlink
|
45 |
|
|
* block requires more space in Schizo's address space than
|
46 |
|
|
* they predicted, thus requiring an address space reorg when
|
47 |
|
|
* the newer Schizo is taped out.
|
48 |
|
|
*/
|
49 |
|
|
|
50 |
|
|
/* Streaming buffer control register. */
|
51 |
|
|
#define SCHIZO_STRBUF_CTRL_LPTR 0x00000000000000f0UL /* LRU Lock Pointer */
|
52 |
|
|
#define SCHIZO_STRBUF_CTRL_LENAB 0x0000000000000008UL /* LRU Lock Enable */
|
53 |
|
|
#define SCHIZO_STRBUF_CTRL_RRDIS 0x0000000000000004UL /* Rerun Disable */
|
54 |
|
|
#define SCHIZO_STRBUF_CTRL_DENAB 0x0000000000000002UL /* Diagnostic Mode Enable */
|
55 |
|
|
#define SCHIZO_STRBUF_CTRL_ENAB 0x0000000000000001UL /* Streaming Buffer Enable */
|
56 |
|
|
|
57 |
|
|
/* IOMMU control register. */
|
58 |
|
|
#define SCHIZO_IOMMU_CTRL_RESV 0xfffffffff9000000 /* Reserved */
|
59 |
|
|
#define SCHIZO_IOMMU_CTRL_XLTESTAT 0x0000000006000000 /* Translation Error Status */
|
60 |
|
|
#define SCHIZO_IOMMU_CTRL_XLTEERR 0x0000000001000000 /* Translation Error encountered */
|
61 |
|
|
#define SCHIZO_IOMMU_CTRL_LCKEN 0x0000000000800000 /* Enable translation locking */
|
62 |
|
|
#define SCHIZO_IOMMU_CTRL_LCKPTR 0x0000000000780000 /* Translation lock pointer */
|
63 |
|
|
#define SCHIZO_IOMMU_CTRL_TSBSZ 0x0000000000070000 /* TSB Size */
|
64 |
|
|
#define SCHIZO_IOMMU_TSBSZ_1K 0x0000000000000000 /* TSB Table 1024 8-byte entries */
|
65 |
|
|
#define SCHIZO_IOMMU_TSBSZ_2K 0x0000000000010000 /* TSB Table 2048 8-byte entries */
|
66 |
|
|
#define SCHIZO_IOMMU_TSBSZ_4K 0x0000000000020000 /* TSB Table 4096 8-byte entries */
|
67 |
|
|
#define SCHIZO_IOMMU_TSBSZ_8K 0x0000000000030000 /* TSB Table 8192 8-byte entries */
|
68 |
|
|
#define SCHIZO_IOMMU_TSBSZ_16K 0x0000000000040000 /* TSB Table 16k 8-byte entries */
|
69 |
|
|
#define SCHIZO_IOMMU_TSBSZ_32K 0x0000000000050000 /* TSB Table 32k 8-byte entries */
|
70 |
|
|
#define SCHIZO_IOMMU_TSBSZ_64K 0x0000000000060000 /* TSB Table 64k 8-byte entries */
|
71 |
|
|
#define SCHIZO_IOMMU_TSBSZ_128K 0x0000000000070000 /* TSB Table 128k 8-byte entries */
|
72 |
|
|
#define SCHIZO_IOMMU_CTRL_RESV2 0x000000000000fff8 /* Reserved */
|
73 |
|
|
#define SCHIZO_IOMMU_CTRL_TBWSZ 0x0000000000000004 /* Assumed page size, 0=8k 1=64k */
|
74 |
|
|
#define SCHIZO_IOMMU_CTRL_DENAB 0x0000000000000002 /* Diagnostic mode enable */
|
75 |
|
|
#define SCHIZO_IOMMU_CTRL_ENAB 0x0000000000000001 /* IOMMU Enable */
|
76 |
|
|
|
77 |
|
|
/* Schizo config space address format is nearly identical to
|
78 |
|
|
* that of PSYCHO:
|
79 |
|
|
*
|
80 |
|
|
* 32 24 23 16 15 11 10 8 7 2 1 0
|
81 |
|
|
* ---------------------------------------------------------
|
82 |
|
|
* |0 0 0 0 0 0 0 0 0| bus | device | function | reg | 0 0 |
|
83 |
|
|
* ---------------------------------------------------------
|
84 |
|
|
*/
|
85 |
|
|
#define SCHIZO_CONFIG_BASE(PBM) ((PBM)->config_space)
|
86 |
|
|
#define SCHIZO_CONFIG_ENCODE(BUS, DEVFN, REG) \
|
87 |
|
|
(((unsigned long)(BUS) << 16) | \
|
88 |
|
|
((unsigned long)(DEVFN) << 8) | \
|
89 |
|
|
((unsigned long)(REG)))
|
90 |
|
|
|
91 |
|
|
static void *schizo_pci_config_mkaddr(struct pci_pbm_info *pbm,
|
92 |
|
|
unsigned char bus,
|
93 |
|
|
unsigned int devfn,
|
94 |
|
|
int where)
|
95 |
|
|
{
|
96 |
|
|
if (!pbm)
|
97 |
|
|
return NULL;
|
98 |
|
|
bus -= pbm->pci_first_busno;
|
99 |
|
|
return (void *)
|
100 |
|
|
(SCHIZO_CONFIG_BASE(pbm) |
|
101 |
|
|
SCHIZO_CONFIG_ENCODE(bus, devfn, where));
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
/* Just make sure the bus number is in range. */
|
105 |
|
|
static int schizo_out_of_range(struct pci_pbm_info *pbm,
|
106 |
|
|
unsigned char bus,
|
107 |
|
|
unsigned char devfn)
|
108 |
|
|
{
|
109 |
|
|
if (bus < pbm->pci_first_busno ||
|
110 |
|
|
bus > pbm->pci_last_busno)
|
111 |
|
|
return 1;
|
112 |
|
|
return 0;
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
/* SCHIZO PCI configuration space accessors. */
|
116 |
|
|
|
117 |
|
|
static int schizo_read_byte(struct pci_dev *dev, int where, u8 *value)
|
118 |
|
|
{
|
119 |
|
|
struct pci_pbm_info *pbm = pci_bus2pbm[dev->bus->number];
|
120 |
|
|
unsigned char bus = dev->bus->number;
|
121 |
|
|
unsigned int devfn = dev->devfn;
|
122 |
|
|
u8 *addr;
|
123 |
|
|
|
124 |
|
|
*value = 0xff;
|
125 |
|
|
addr = schizo_pci_config_mkaddr(pbm, bus, devfn, where);
|
126 |
|
|
if (!addr)
|
127 |
|
|
return PCIBIOS_SUCCESSFUL;
|
128 |
|
|
|
129 |
|
|
if (schizo_out_of_range(pbm, bus, devfn))
|
130 |
|
|
return PCIBIOS_SUCCESSFUL;
|
131 |
|
|
pci_config_read8(addr, value);
|
132 |
|
|
return PCIBIOS_SUCCESSFUL;
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
static int schizo_read_word(struct pci_dev *dev, int where, u16 *value)
|
136 |
|
|
{
|
137 |
|
|
struct pci_pbm_info *pbm = pci_bus2pbm[dev->bus->number];
|
138 |
|
|
unsigned char bus = dev->bus->number;
|
139 |
|
|
unsigned int devfn = dev->devfn;
|
140 |
|
|
u16 *addr;
|
141 |
|
|
|
142 |
|
|
*value = 0xffff;
|
143 |
|
|
addr = schizo_pci_config_mkaddr(pbm, bus, devfn, where);
|
144 |
|
|
if (!addr)
|
145 |
|
|
return PCIBIOS_SUCCESSFUL;
|
146 |
|
|
|
147 |
|
|
if (schizo_out_of_range(pbm, bus, devfn))
|
148 |
|
|
return PCIBIOS_SUCCESSFUL;
|
149 |
|
|
|
150 |
|
|
if (where & 0x01) {
|
151 |
|
|
printk("pcibios_read_config_word: misaligned reg [%x]\n",
|
152 |
|
|
where);
|
153 |
|
|
return PCIBIOS_SUCCESSFUL;
|
154 |
|
|
}
|
155 |
|
|
pci_config_read16(addr, value);
|
156 |
|
|
return PCIBIOS_SUCCESSFUL;
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
static int schizo_read_dword(struct pci_dev *dev, int where, u32 *value)
|
160 |
|
|
{
|
161 |
|
|
struct pci_pbm_info *pbm = pci_bus2pbm[dev->bus->number];
|
162 |
|
|
unsigned char bus = dev->bus->number;
|
163 |
|
|
unsigned int devfn = dev->devfn;
|
164 |
|
|
u32 *addr;
|
165 |
|
|
|
166 |
|
|
*value = 0xffffffff;
|
167 |
|
|
addr = schizo_pci_config_mkaddr(pbm, bus, devfn, where);
|
168 |
|
|
if (!addr)
|
169 |
|
|
return PCIBIOS_SUCCESSFUL;
|
170 |
|
|
|
171 |
|
|
if (schizo_out_of_range(pbm, bus, devfn))
|
172 |
|
|
return PCIBIOS_SUCCESSFUL;
|
173 |
|
|
|
174 |
|
|
if (where & 0x03) {
|
175 |
|
|
printk("pcibios_read_config_dword: misaligned reg [%x]\n",
|
176 |
|
|
where);
|
177 |
|
|
return PCIBIOS_SUCCESSFUL;
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
pci_config_read32(addr, value);
|
181 |
|
|
if (where == PCI_PRIMARY_BUS &&
|
182 |
|
|
dev->hdr_type == PCI_HEADER_TYPE_BRIDGE &&
|
183 |
|
|
*value != 0xffffffff) {
|
184 |
|
|
u8 *busp = ((u8 *) value) + 1;
|
185 |
|
|
int i;
|
186 |
|
|
|
187 |
|
|
for (i = 0; i < 3; i++)
|
188 |
|
|
busp[i] += pbm->pci_first_busno;
|
189 |
|
|
}
|
190 |
|
|
return PCIBIOS_SUCCESSFUL;
|
191 |
|
|
}
|
192 |
|
|
|
193 |
|
|
static int schizo_write_byte(struct pci_dev *dev, int where, u8 value)
|
194 |
|
|
{
|
195 |
|
|
struct pci_pbm_info *pbm = pci_bus2pbm[dev->bus->number];
|
196 |
|
|
unsigned char bus = dev->bus->number;
|
197 |
|
|
unsigned int devfn = dev->devfn;
|
198 |
|
|
u8 *addr;
|
199 |
|
|
|
200 |
|
|
addr = schizo_pci_config_mkaddr(pbm, bus, devfn, where);
|
201 |
|
|
if (!addr)
|
202 |
|
|
return PCIBIOS_SUCCESSFUL;
|
203 |
|
|
|
204 |
|
|
if (schizo_out_of_range(pbm, bus, devfn))
|
205 |
|
|
return PCIBIOS_SUCCESSFUL;
|
206 |
|
|
|
207 |
|
|
pci_config_write8(addr, value);
|
208 |
|
|
return PCIBIOS_SUCCESSFUL;
|
209 |
|
|
}
|
210 |
|
|
|
211 |
|
|
static int schizo_write_word(struct pci_dev *dev, int where, u16 value)
|
212 |
|
|
{
|
213 |
|
|
struct pci_pbm_info *pbm = pci_bus2pbm[dev->bus->number];
|
214 |
|
|
unsigned char bus = dev->bus->number;
|
215 |
|
|
unsigned int devfn = dev->devfn;
|
216 |
|
|
u16 *addr;
|
217 |
|
|
|
218 |
|
|
addr = schizo_pci_config_mkaddr(pbm, bus, devfn, where);
|
219 |
|
|
if (!addr)
|
220 |
|
|
return PCIBIOS_SUCCESSFUL;
|
221 |
|
|
|
222 |
|
|
if (schizo_out_of_range(pbm, bus, devfn))
|
223 |
|
|
return PCIBIOS_SUCCESSFUL;
|
224 |
|
|
|
225 |
|
|
if (where & 0x01) {
|
226 |
|
|
printk("pcibios_write_config_word: misaligned reg [%x]\n",
|
227 |
|
|
where);
|
228 |
|
|
return PCIBIOS_SUCCESSFUL;
|
229 |
|
|
}
|
230 |
|
|
pci_config_write16(addr, value);
|
231 |
|
|
return PCIBIOS_SUCCESSFUL;
|
232 |
|
|
}
|
233 |
|
|
|
234 |
|
|
static int schizo_write_dword(struct pci_dev *dev, int where, u32 value)
|
235 |
|
|
{
|
236 |
|
|
struct pci_pbm_info *pbm = pci_bus2pbm[dev->bus->number];
|
237 |
|
|
unsigned char bus = dev->bus->number;
|
238 |
|
|
unsigned int devfn = dev->devfn;
|
239 |
|
|
u32 *addr;
|
240 |
|
|
|
241 |
|
|
addr = schizo_pci_config_mkaddr(pbm, bus, devfn, where);
|
242 |
|
|
if (!addr)
|
243 |
|
|
return PCIBIOS_SUCCESSFUL;
|
244 |
|
|
|
245 |
|
|
if (schizo_out_of_range(pbm, bus, devfn))
|
246 |
|
|
return PCIBIOS_SUCCESSFUL;
|
247 |
|
|
|
248 |
|
|
if (where & 0x03) {
|
249 |
|
|
printk("pcibios_write_config_dword: misaligned reg [%x]\n",
|
250 |
|
|
where);
|
251 |
|
|
return PCIBIOS_SUCCESSFUL;
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
if (where == PCI_PRIMARY_BUS &&
|
255 |
|
|
dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
|
256 |
|
|
u8 *busp = ((u8 *) &value) + 1;
|
257 |
|
|
int i;
|
258 |
|
|
|
259 |
|
|
for (i = 0; i < 3; i++) {
|
260 |
|
|
if (busp[i] >= pbm->pci_first_busno)
|
261 |
|
|
busp[i] += pbm->pci_first_busno;
|
262 |
|
|
else
|
263 |
|
|
busp[i] = 0;
|
264 |
|
|
}
|
265 |
|
|
}
|
266 |
|
|
|
267 |
|
|
pci_config_write32(addr, value);
|
268 |
|
|
return PCIBIOS_SUCCESSFUL;
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
static struct pci_ops schizo_ops = {
|
272 |
|
|
schizo_read_byte,
|
273 |
|
|
schizo_read_word,
|
274 |
|
|
schizo_read_dword,
|
275 |
|
|
schizo_write_byte,
|
276 |
|
|
schizo_write_word,
|
277 |
|
|
schizo_write_dword
|
278 |
|
|
};
|
279 |
|
|
|
280 |
|
|
/* SCHIZO interrupt mapping support. Unlike Psycho, for this controller the
|
281 |
|
|
* imap/iclr registers are per-PBM.
|
282 |
|
|
*/
|
283 |
|
|
#define SCHIZO_IMAP_BASE 0x1000UL
|
284 |
|
|
#define SCHIZO_ICLR_BASE 0x1400UL
|
285 |
|
|
|
286 |
|
|
static unsigned long schizo_imap_offset(unsigned long ino)
|
287 |
|
|
{
|
288 |
|
|
return SCHIZO_IMAP_BASE + (ino * 8UL);
|
289 |
|
|
}
|
290 |
|
|
|
291 |
|
|
static unsigned long schizo_iclr_offset(unsigned long ino)
|
292 |
|
|
{
|
293 |
|
|
return SCHIZO_ICLR_BASE + (ino * 8UL);
|
294 |
|
|
}
|
295 |
|
|
|
296 |
|
|
/* PCI SCHIZO INO number to Sparc PIL level. This table only matters for
|
297 |
|
|
* INOs which will not have an associated PCI device struct, ie. onboard
|
298 |
|
|
* EBUS devices and PCI controller internal error interrupts.
|
299 |
|
|
*/
|
300 |
|
|
static unsigned char schizo_pil_table[] = {
|
301 |
|
|
/*0x00*/0, 0, 0, 0, /* PCI slot 0 Int A, B, C, D */
|
302 |
|
|
/*0x04*/0, 0, 0, 0, /* PCI slot 1 Int A, B, C, D */
|
303 |
|
|
/*0x08*/0, 0, 0, 0, /* PCI slot 2 Int A, B, C, D */
|
304 |
|
|
/*0x0c*/0, 0, 0, 0, /* PCI slot 3 Int A, B, C, D */
|
305 |
|
|
/*0x10*/0, 0, 0, 0, /* PCI slot 4 Int A, B, C, D */
|
306 |
|
|
/*0x14*/0, 0, 0, 0, /* PCI slot 5 Int A, B, C, D */
|
307 |
|
|
/*0x18*/4, /* SCSI */
|
308 |
|
|
/*0x19*/4, /* second SCSI */
|
309 |
|
|
/*0x1a*/0, /* UNKNOWN */
|
310 |
|
|
/*0x1b*/0, /* UNKNOWN */
|
311 |
|
|
/*0x1c*/8, /* Parallel */
|
312 |
|
|
/*0x1d*/5, /* Ethernet */
|
313 |
|
|
/*0x1e*/8, /* Firewire-1394 */
|
314 |
|
|
/*0x1f*/9, /* USB */
|
315 |
|
|
/*0x20*/13, /* Audio Record */
|
316 |
|
|
/*0x21*/14, /* Audio Playback */
|
317 |
|
|
/*0x22*/12, /* Serial */
|
318 |
|
|
/*0x23*/4, /* EBUS I2C */
|
319 |
|
|
/*0x24*/10, /* RTC Clock */
|
320 |
|
|
/*0x25*/11, /* Floppy */
|
321 |
|
|
/*0x26*/0, /* UNKNOWN */
|
322 |
|
|
/*0x27*/0, /* UNKNOWN */
|
323 |
|
|
/*0x28*/0, /* UNKNOWN */
|
324 |
|
|
/*0x29*/0, /* UNKNOWN */
|
325 |
|
|
/*0x2a*/10, /* UPA 1 */
|
326 |
|
|
/*0x2b*/10, /* UPA 2 */
|
327 |
|
|
/*0x2c*/0, /* UNKNOWN */
|
328 |
|
|
/*0x2d*/0, /* UNKNOWN */
|
329 |
|
|
/*0x2e*/0, /* UNKNOWN */
|
330 |
|
|
/*0x2f*/0, /* UNKNOWN */
|
331 |
|
|
/*0x30*/15, /* Uncorrectable ECC */
|
332 |
|
|
/*0x31*/15, /* Correctable ECC */
|
333 |
|
|
/*0x32*/15, /* PCI Bus A Error */
|
334 |
|
|
/*0x33*/15, /* PCI Bus B Error */
|
335 |
|
|
/*0x34*/15, /* Safari Bus Error */
|
336 |
|
|
/*0x35*/0, /* Reserved */
|
337 |
|
|
/*0x36*/0, /* Reserved */
|
338 |
|
|
/*0x37*/0, /* Reserved */
|
339 |
|
|
/*0x38*/0, /* Reserved for NewLink */
|
340 |
|
|
/*0x39*/0, /* Reserved for NewLink */
|
341 |
|
|
/*0x3a*/0, /* Reserved for NewLink */
|
342 |
|
|
/*0x3b*/0, /* Reserved for NewLink */
|
343 |
|
|
/*0x3c*/0, /* Reserved for NewLink */
|
344 |
|
|
/*0x3d*/0, /* Reserved for NewLink */
|
345 |
|
|
/*0x3e*/0, /* Reserved for NewLink */
|
346 |
|
|
/*0x3f*/0, /* Reserved for NewLink */
|
347 |
|
|
};
|
348 |
|
|
|
349 |
|
|
static int __init schizo_ino_to_pil(struct pci_dev *pdev, unsigned int ino)
|
350 |
|
|
{
|
351 |
|
|
int ret;
|
352 |
|
|
|
353 |
|
|
if (pdev &&
|
354 |
|
|
pdev->vendor == PCI_VENDOR_ID_SUN &&
|
355 |
|
|
pdev->device == PCI_DEVICE_ID_SUN_RIO_USB)
|
356 |
|
|
return 9;
|
357 |
|
|
|
358 |
|
|
ret = schizo_pil_table[ino];
|
359 |
|
|
if (ret == 0 && pdev == NULL) {
|
360 |
|
|
ret = 4;
|
361 |
|
|
} else if (ret == 0) {
|
362 |
|
|
switch ((pdev->class >> 16) & 0xff) {
|
363 |
|
|
case PCI_BASE_CLASS_STORAGE:
|
364 |
|
|
ret = 4;
|
365 |
|
|
break;
|
366 |
|
|
|
367 |
|
|
case PCI_BASE_CLASS_NETWORK:
|
368 |
|
|
ret = 6;
|
369 |
|
|
break;
|
370 |
|
|
|
371 |
|
|
case PCI_BASE_CLASS_DISPLAY:
|
372 |
|
|
ret = 9;
|
373 |
|
|
break;
|
374 |
|
|
|
375 |
|
|
case PCI_BASE_CLASS_MULTIMEDIA:
|
376 |
|
|
case PCI_BASE_CLASS_MEMORY:
|
377 |
|
|
case PCI_BASE_CLASS_BRIDGE:
|
378 |
|
|
case PCI_BASE_CLASS_SERIAL:
|
379 |
|
|
ret = 10;
|
380 |
|
|
break;
|
381 |
|
|
|
382 |
|
|
default:
|
383 |
|
|
ret = 4;
|
384 |
|
|
break;
|
385 |
|
|
};
|
386 |
|
|
}
|
387 |
|
|
|
388 |
|
|
return ret;
|
389 |
|
|
}
|
390 |
|
|
|
391 |
|
|
static unsigned int __init schizo_irq_build(struct pci_pbm_info *pbm,
|
392 |
|
|
struct pci_dev *pdev,
|
393 |
|
|
unsigned int ino)
|
394 |
|
|
{
|
395 |
|
|
struct ino_bucket *bucket;
|
396 |
|
|
unsigned long imap, iclr;
|
397 |
|
|
unsigned long imap_off, iclr_off;
|
398 |
|
|
int pil, ign_fixup;
|
399 |
|
|
|
400 |
|
|
ino &= PCI_IRQ_INO;
|
401 |
|
|
imap_off = schizo_imap_offset(ino);
|
402 |
|
|
|
403 |
|
|
/* Now build the IRQ bucket. */
|
404 |
|
|
pil = schizo_ino_to_pil(pdev, ino);
|
405 |
|
|
|
406 |
|
|
if (PIL_RESERVED(pil))
|
407 |
|
|
BUG();
|
408 |
|
|
|
409 |
|
|
imap = pbm->pbm_regs + imap_off;
|
410 |
|
|
imap += 4;
|
411 |
|
|
|
412 |
|
|
iclr_off = schizo_iclr_offset(ino);
|
413 |
|
|
iclr = pbm->pbm_regs + iclr_off;
|
414 |
|
|
iclr += 4;
|
415 |
|
|
|
416 |
|
|
/* On Schizo, no inofixup occurs. This is because each
|
417 |
|
|
* INO has it's own IMAP register. On Psycho and Sabre
|
418 |
|
|
* there is only one IMAP register for each PCI slot even
|
419 |
|
|
* though four different INOs can be generated by each
|
420 |
|
|
* PCI slot.
|
421 |
|
|
*
|
422 |
|
|
* But, for JBUS variants (essentially, Tomatillo), we have
|
423 |
|
|
* to fixup the lowest bit of the interrupt group number.
|
424 |
|
|
*/
|
425 |
|
|
ign_fixup = 0;
|
426 |
|
|
if (pbm->chip_type == PBM_CHIP_TYPE_TOMATILLO) {
|
427 |
|
|
if (pbm->portid & 1)
|
428 |
|
|
ign_fixup = (1 << 6);
|
429 |
|
|
}
|
430 |
|
|
|
431 |
|
|
bucket = __bucket(build_irq(pil, ign_fixup, iclr, imap));
|
432 |
|
|
bucket->flags |= IBF_PCI;
|
433 |
|
|
|
434 |
|
|
return __irq(bucket);
|
435 |
|
|
}
|
436 |
|
|
|
437 |
|
|
/* SCHIZO error handling support. */
|
438 |
|
|
enum schizo_error_type {
|
439 |
|
|
UE_ERR, CE_ERR, PCI_ERR, SAFARI_ERR
|
440 |
|
|
};
|
441 |
|
|
|
442 |
|
|
static spinlock_t stc_buf_lock = SPIN_LOCK_UNLOCKED;
|
443 |
|
|
static unsigned long stc_error_buf[128];
|
444 |
|
|
static unsigned long stc_tag_buf[16];
|
445 |
|
|
static unsigned long stc_line_buf[16];
|
446 |
|
|
|
447 |
|
|
/* These offsets look weird because I keep in pbm->controller_regs
|
448 |
|
|
* the second PROM register property minus 0x10000 which is the
|
449 |
|
|
* base of the Safari and UPA64S registers of SCHIZO.
|
450 |
|
|
*/
|
451 |
|
|
#define SCHIZO_PBM_A_REGS_OFF (0x600000UL - 0x400000UL)
|
452 |
|
|
#define SCHIZO_PBM_B_REGS_OFF (0x700000UL - 0x400000UL)
|
453 |
|
|
|
454 |
|
|
static void schizo_clear_other_err_intr(int irq)
|
455 |
|
|
{
|
456 |
|
|
struct ino_bucket *bucket = __bucket(irq);
|
457 |
|
|
unsigned long iclr = bucket->iclr;
|
458 |
|
|
|
459 |
|
|
iclr += (SCHIZO_PBM_B_REGS_OFF - SCHIZO_PBM_A_REGS_OFF);
|
460 |
|
|
upa_writel(ICLR_IDLE, iclr);
|
461 |
|
|
}
|
462 |
|
|
|
463 |
|
|
#define SCHIZO_STC_ERR 0xb800UL /* --> 0xba00 */
|
464 |
|
|
#define SCHIZO_STC_TAG 0xba00UL /* --> 0xba80 */
|
465 |
|
|
#define SCHIZO_STC_LINE 0xbb00UL /* --> 0xbb80 */
|
466 |
|
|
|
467 |
|
|
#define SCHIZO_STCERR_WRITE 0x2UL
|
468 |
|
|
#define SCHIZO_STCERR_READ 0x1UL
|
469 |
|
|
|
470 |
|
|
#define SCHIZO_STCTAG_PPN 0x3fffffff00000000UL
|
471 |
|
|
#define SCHIZO_STCTAG_VPN 0x00000000ffffe000UL
|
472 |
|
|
#define SCHIZO_STCTAG_VALID 0x8000000000000000UL
|
473 |
|
|
#define SCHIZO_STCTAG_READ 0x4000000000000000UL
|
474 |
|
|
|
475 |
|
|
#define SCHIZO_STCLINE_LINDX 0x0000000007800000UL
|
476 |
|
|
#define SCHIZO_STCLINE_SPTR 0x000000000007e000UL
|
477 |
|
|
#define SCHIZO_STCLINE_LADDR 0x0000000000001fc0UL
|
478 |
|
|
#define SCHIZO_STCLINE_EPTR 0x000000000000003fUL
|
479 |
|
|
#define SCHIZO_STCLINE_VALID 0x0000000000600000UL
|
480 |
|
|
#define SCHIZO_STCLINE_FOFN 0x0000000000180000UL
|
481 |
|
|
|
482 |
|
|
static void __schizo_check_stc_error_pbm(struct pci_pbm_info *pbm,
|
483 |
|
|
enum schizo_error_type type)
|
484 |
|
|
{
|
485 |
|
|
struct pci_strbuf *strbuf = &pbm->stc;
|
486 |
|
|
unsigned long regbase = pbm->pbm_regs;
|
487 |
|
|
unsigned long err_base, tag_base, line_base;
|
488 |
|
|
u64 control;
|
489 |
|
|
int i;
|
490 |
|
|
|
491 |
|
|
err_base = regbase + SCHIZO_STC_ERR;
|
492 |
|
|
tag_base = regbase + SCHIZO_STC_TAG;
|
493 |
|
|
line_base = regbase + SCHIZO_STC_LINE;
|
494 |
|
|
|
495 |
|
|
spin_lock(&stc_buf_lock);
|
496 |
|
|
|
497 |
|
|
/* This is __REALLY__ dangerous. When we put the
|
498 |
|
|
* streaming buffer into diagnostic mode to probe
|
499 |
|
|
* it's tags and error status, we _must_ clear all
|
500 |
|
|
* of the line tag valid bits before re-enabling
|
501 |
|
|
* the streaming buffer. If any dirty data lives
|
502 |
|
|
* in the STC when we do this, we will end up
|
503 |
|
|
* invalidating it before it has a chance to reach
|
504 |
|
|
* main memory.
|
505 |
|
|
*/
|
506 |
|
|
control = schizo_read(strbuf->strbuf_control);
|
507 |
|
|
schizo_write(strbuf->strbuf_control,
|
508 |
|
|
(control | SCHIZO_STRBUF_CTRL_DENAB));
|
509 |
|
|
for (i = 0; i < 128; i++) {
|
510 |
|
|
unsigned long val;
|
511 |
|
|
|
512 |
|
|
val = schizo_read(err_base + (i * 8UL));
|
513 |
|
|
schizo_write(err_base + (i * 8UL), 0UL);
|
514 |
|
|
stc_error_buf[i] = val;
|
515 |
|
|
}
|
516 |
|
|
for (i = 0; i < 16; i++) {
|
517 |
|
|
stc_tag_buf[i] = schizo_read(tag_base + (i * 8UL));
|
518 |
|
|
stc_line_buf[i] = schizo_read(line_base + (i * 8UL));
|
519 |
|
|
schizo_write(tag_base + (i * 8UL), 0UL);
|
520 |
|
|
schizo_write(line_base + (i * 8UL), 0UL);
|
521 |
|
|
}
|
522 |
|
|
|
523 |
|
|
/* OK, state is logged, exit diagnostic mode. */
|
524 |
|
|
schizo_write(strbuf->strbuf_control, control);
|
525 |
|
|
|
526 |
|
|
for (i = 0; i < 16; i++) {
|
527 |
|
|
int j, saw_error, first, last;
|
528 |
|
|
|
529 |
|
|
saw_error = 0;
|
530 |
|
|
first = i * 8;
|
531 |
|
|
last = first + 8;
|
532 |
|
|
for (j = first; j < last; j++) {
|
533 |
|
|
unsigned long errval = stc_error_buf[j];
|
534 |
|
|
if (errval != 0) {
|
535 |
|
|
saw_error++;
|
536 |
|
|
printk("%s: STC_ERR(%d)[wr(%d)rd(%d)]\n",
|
537 |
|
|
pbm->name,
|
538 |
|
|
j,
|
539 |
|
|
(errval & SCHIZO_STCERR_WRITE) ? 1 : 0,
|
540 |
|
|
(errval & SCHIZO_STCERR_READ) ? 1 : 0);
|
541 |
|
|
}
|
542 |
|
|
}
|
543 |
|
|
if (saw_error != 0) {
|
544 |
|
|
unsigned long tagval = stc_tag_buf[i];
|
545 |
|
|
unsigned long lineval = stc_line_buf[i];
|
546 |
|
|
printk("%s: STC_TAG(%d)[PA(%016lx)VA(%08lx)V(%d)R(%d)]\n",
|
547 |
|
|
pbm->name,
|
548 |
|
|
i,
|
549 |
|
|
((tagval & SCHIZO_STCTAG_PPN) >> 19UL),
|
550 |
|
|
(tagval & SCHIZO_STCTAG_VPN),
|
551 |
|
|
((tagval & SCHIZO_STCTAG_VALID) ? 1 : 0),
|
552 |
|
|
((tagval & SCHIZO_STCTAG_READ) ? 1 : 0));
|
553 |
|
|
|
554 |
|
|
/* XXX Should spit out per-bank error information... -DaveM */
|
555 |
|
|
printk("%s: STC_LINE(%d)[LIDX(%lx)SP(%lx)LADDR(%lx)EP(%lx)"
|
556 |
|
|
"V(%d)FOFN(%d)]\n",
|
557 |
|
|
pbm->name,
|
558 |
|
|
i,
|
559 |
|
|
((lineval & SCHIZO_STCLINE_LINDX) >> 23UL),
|
560 |
|
|
((lineval & SCHIZO_STCLINE_SPTR) >> 13UL),
|
561 |
|
|
((lineval & SCHIZO_STCLINE_LADDR) >> 6UL),
|
562 |
|
|
((lineval & SCHIZO_STCLINE_EPTR) >> 0UL),
|
563 |
|
|
((lineval & SCHIZO_STCLINE_VALID) ? 1 : 0),
|
564 |
|
|
((lineval & SCHIZO_STCLINE_FOFN) ? 1 : 0));
|
565 |
|
|
}
|
566 |
|
|
}
|
567 |
|
|
|
568 |
|
|
spin_unlock(&stc_buf_lock);
|
569 |
|
|
}
|
570 |
|
|
|
571 |
|
|
/* IOMMU is per-PBM in Schizo, so interrogate both for anonymous
|
572 |
|
|
* controller level errors.
|
573 |
|
|
*/
|
574 |
|
|
|
575 |
|
|
#define SCHIZO_IOMMU_TAG 0xa580UL
|
576 |
|
|
#define SCHIZO_IOMMU_DATA 0xa600UL
|
577 |
|
|
|
578 |
|
|
#define SCHIZO_IOMMU_TAG_CTXT 0x0000001ffe000000UL
|
579 |
|
|
#define SCHIZO_IOMMU_TAG_ERRSTS 0x0000000001800000UL
|
580 |
|
|
#define SCHIZO_IOMMU_TAG_ERR 0x0000000000400000UL
|
581 |
|
|
#define SCHIZO_IOMMU_TAG_WRITE 0x0000000000200000UL
|
582 |
|
|
#define SCHIZO_IOMMU_TAG_STREAM 0x0000000000100000UL
|
583 |
|
|
#define SCHIZO_IOMMU_TAG_SIZE 0x0000000000080000UL
|
584 |
|
|
#define SCHIZO_IOMMU_TAG_VPAGE 0x000000000007ffffUL
|
585 |
|
|
|
586 |
|
|
#define SCHIZO_IOMMU_DATA_VALID 0x0000000100000000UL
|
587 |
|
|
#define SCHIZO_IOMMU_DATA_CACHE 0x0000000040000000UL
|
588 |
|
|
#define SCHIZO_IOMMU_DATA_PPAGE 0x000000003fffffffUL
|
589 |
|
|
|
590 |
|
|
static void schizo_check_iommu_error_pbm(struct pci_pbm_info *pbm,
|
591 |
|
|
enum schizo_error_type type)
|
592 |
|
|
{
|
593 |
|
|
struct pci_iommu *iommu = pbm->iommu;
|
594 |
|
|
unsigned long iommu_tag[16];
|
595 |
|
|
unsigned long iommu_data[16];
|
596 |
|
|
unsigned long flags;
|
597 |
|
|
u64 control;
|
598 |
|
|
int i;
|
599 |
|
|
|
600 |
|
|
spin_lock_irqsave(&iommu->lock, flags);
|
601 |
|
|
control = schizo_read(iommu->iommu_control);
|
602 |
|
|
if (control & SCHIZO_IOMMU_CTRL_XLTEERR) {
|
603 |
|
|
unsigned long base;
|
604 |
|
|
char *type_string;
|
605 |
|
|
|
606 |
|
|
/* Clear the error encountered bit. */
|
607 |
|
|
control &= ~SCHIZO_IOMMU_CTRL_XLTEERR;
|
608 |
|
|
schizo_write(iommu->iommu_control, control);
|
609 |
|
|
|
610 |
|
|
switch((control & SCHIZO_IOMMU_CTRL_XLTESTAT) >> 25UL) {
|
611 |
|
|
case 0:
|
612 |
|
|
type_string = "Protection Error";
|
613 |
|
|
break;
|
614 |
|
|
case 1:
|
615 |
|
|
type_string = "Invalid Error";
|
616 |
|
|
break;
|
617 |
|
|
case 2:
|
618 |
|
|
type_string = "TimeOut Error";
|
619 |
|
|
break;
|
620 |
|
|
case 3:
|
621 |
|
|
default:
|
622 |
|
|
type_string = "ECC Error";
|
623 |
|
|
break;
|
624 |
|
|
};
|
625 |
|
|
printk("%s: IOMMU Error, type[%s]\n",
|
626 |
|
|
pbm->name, type_string);
|
627 |
|
|
|
628 |
|
|
/* Put the IOMMU into diagnostic mode and probe
|
629 |
|
|
* it's TLB for entries with error status.
|
630 |
|
|
*
|
631 |
|
|
* It is very possible for another DVMA to occur
|
632 |
|
|
* while we do this probe, and corrupt the system
|
633 |
|
|
* further. But we are so screwed at this point
|
634 |
|
|
* that we are likely to crash hard anyways, so
|
635 |
|
|
* get as much diagnostic information to the
|
636 |
|
|
* console as we can.
|
637 |
|
|
*/
|
638 |
|
|
schizo_write(iommu->iommu_control,
|
639 |
|
|
control | SCHIZO_IOMMU_CTRL_DENAB);
|
640 |
|
|
|
641 |
|
|
base = pbm->pbm_regs;
|
642 |
|
|
|
643 |
|
|
for (i = 0; i < 16; i++) {
|
644 |
|
|
iommu_tag[i] =
|
645 |
|
|
schizo_read(base + SCHIZO_IOMMU_TAG + (i * 8UL));
|
646 |
|
|
iommu_data[i] =
|
647 |
|
|
schizo_read(base + SCHIZO_IOMMU_DATA + (i * 8UL));
|
648 |
|
|
|
649 |
|
|
/* Now clear out the entry. */
|
650 |
|
|
schizo_write(base + SCHIZO_IOMMU_TAG + (i * 8UL), 0);
|
651 |
|
|
schizo_write(base + SCHIZO_IOMMU_DATA + (i * 8UL), 0);
|
652 |
|
|
}
|
653 |
|
|
|
654 |
|
|
/* Leave diagnostic mode. */
|
655 |
|
|
schizo_write(iommu->iommu_control, control);
|
656 |
|
|
|
657 |
|
|
for (i = 0; i < 16; i++) {
|
658 |
|
|
unsigned long tag, data;
|
659 |
|
|
|
660 |
|
|
tag = iommu_tag[i];
|
661 |
|
|
if (!(tag & SCHIZO_IOMMU_TAG_ERR))
|
662 |
|
|
continue;
|
663 |
|
|
|
664 |
|
|
data = iommu_data[i];
|
665 |
|
|
switch((tag & SCHIZO_IOMMU_TAG_ERRSTS) >> 23UL) {
|
666 |
|
|
case 0:
|
667 |
|
|
type_string = "Protection Error";
|
668 |
|
|
break;
|
669 |
|
|
case 1:
|
670 |
|
|
type_string = "Invalid Error";
|
671 |
|
|
break;
|
672 |
|
|
case 2:
|
673 |
|
|
type_string = "TimeOut Error";
|
674 |
|
|
break;
|
675 |
|
|
case 3:
|
676 |
|
|
default:
|
677 |
|
|
type_string = "ECC Error";
|
678 |
|
|
break;
|
679 |
|
|
};
|
680 |
|
|
printk("%s: IOMMU TAG(%d)[error(%s) ctx(%x) wr(%d) str(%d) "
|
681 |
|
|
"sz(%dK) vpg(%08lx)]\n",
|
682 |
|
|
pbm->name, i, type_string,
|
683 |
|
|
(int)((tag & SCHIZO_IOMMU_TAG_CTXT) >> 25UL),
|
684 |
|
|
((tag & SCHIZO_IOMMU_TAG_WRITE) ? 1 : 0),
|
685 |
|
|
((tag & SCHIZO_IOMMU_TAG_STREAM) ? 1 : 0),
|
686 |
|
|
((tag & SCHIZO_IOMMU_TAG_SIZE) ? 64 : 8),
|
687 |
|
|
(tag & SCHIZO_IOMMU_TAG_VPAGE) << IOMMU_PAGE_SHIFT);
|
688 |
|
|
printk("%s: IOMMU DATA(%d)[valid(%d) cache(%d) ppg(%016lx)]\n",
|
689 |
|
|
pbm->name, i,
|
690 |
|
|
((data & SCHIZO_IOMMU_DATA_VALID) ? 1 : 0),
|
691 |
|
|
((data & SCHIZO_IOMMU_DATA_CACHE) ? 1 : 0),
|
692 |
|
|
(data & SCHIZO_IOMMU_DATA_PPAGE) << IOMMU_PAGE_SHIFT);
|
693 |
|
|
}
|
694 |
|
|
}
|
695 |
|
|
if (pbm->stc.strbuf_enabled)
|
696 |
|
|
__schizo_check_stc_error_pbm(pbm, type);
|
697 |
|
|
spin_unlock_irqrestore(&iommu->lock, flags);
|
698 |
|
|
}
|
699 |
|
|
|
700 |
|
|
static void schizo_check_iommu_error(struct pci_controller_info *p,
|
701 |
|
|
enum schizo_error_type type)
|
702 |
|
|
{
|
703 |
|
|
schizo_check_iommu_error_pbm(&p->pbm_A, type);
|
704 |
|
|
schizo_check_iommu_error_pbm(&p->pbm_B, type);
|
705 |
|
|
}
|
706 |
|
|
|
707 |
|
|
/* Uncorrectable ECC error status gathering. */
|
708 |
|
|
#define SCHIZO_UE_AFSR 0x10030UL
|
709 |
|
|
#define SCHIZO_UE_AFAR 0x10038UL
|
710 |
|
|
|
711 |
|
|
#define SCHIZO_UEAFSR_PPIO 0x8000000000000000UL /* Safari */
|
712 |
|
|
#define SCHIZO_UEAFSR_PDRD 0x4000000000000000UL /* Safari/Tomatillo */
|
713 |
|
|
#define SCHIZO_UEAFSR_PDWR 0x2000000000000000UL /* Safari */
|
714 |
|
|
#define SCHIZO_UEAFSR_SPIO 0x1000000000000000UL /* Safari */
|
715 |
|
|
#define SCHIZO_UEAFSR_SDMA 0x0800000000000000UL /* Safari/Tomatillo */
|
716 |
|
|
#define SCHIZO_UEAFSR_ERRPNDG 0x0300000000000000UL /* Safari */
|
717 |
|
|
#define SCHIZO_UEAFSR_BMSK 0x000003ff00000000UL /* Safari */
|
718 |
|
|
#define SCHIZO_UEAFSR_QOFF 0x00000000c0000000UL /* Safari/Tomatillo */
|
719 |
|
|
#define SCHIZO_UEAFSR_AID 0x000000001f000000UL /* Safari/Tomatillo */
|
720 |
|
|
#define SCHIZO_UEAFSR_PARTIAL 0x0000000000800000UL /* Safari */
|
721 |
|
|
#define SCHIZO_UEAFSR_OWNEDIN 0x0000000000400000UL /* Safari */
|
722 |
|
|
#define SCHIZO_UEAFSR_MTAGSYND 0x00000000000f0000UL /* Safari */
|
723 |
|
|
#define SCHIZO_UEAFSR_MTAG 0x000000000000e000UL /* Safari */
|
724 |
|
|
#define SCHIZO_UEAFSR_ECCSYND 0x00000000000001ffUL /* Safari */
|
725 |
|
|
|
726 |
|
|
static void schizo_ue_intr(int irq, void *dev_id, struct pt_regs *regs)
|
727 |
|
|
{
|
728 |
|
|
struct pci_controller_info *p = dev_id;
|
729 |
|
|
unsigned long afsr_reg = p->pbm_B.controller_regs + SCHIZO_UE_AFSR;
|
730 |
|
|
unsigned long afar_reg = p->pbm_B.controller_regs + SCHIZO_UE_AFAR;
|
731 |
|
|
unsigned long afsr, afar, error_bits;
|
732 |
|
|
int reported, limit;
|
733 |
|
|
|
734 |
|
|
/* Latch uncorrectable error status. */
|
735 |
|
|
afar = schizo_read(afar_reg);
|
736 |
|
|
|
737 |
|
|
/* If either of the error pending bits are set in the
|
738 |
|
|
* AFSR, the error status is being actively updated by
|
739 |
|
|
* the hardware and we must re-read to get a clean value.
|
740 |
|
|
*/
|
741 |
|
|
limit = 1000;
|
742 |
|
|
do {
|
743 |
|
|
afsr = schizo_read(afsr_reg);
|
744 |
|
|
} while ((afsr & SCHIZO_UEAFSR_ERRPNDG) != 0 && --limit);
|
745 |
|
|
|
746 |
|
|
/* Clear the primary/secondary error status bits. */
|
747 |
|
|
error_bits = afsr &
|
748 |
|
|
(SCHIZO_UEAFSR_PPIO | SCHIZO_UEAFSR_PDRD | SCHIZO_UEAFSR_PDWR |
|
749 |
|
|
SCHIZO_UEAFSR_SPIO | SCHIZO_UEAFSR_SDMA);
|
750 |
|
|
if (!error_bits)
|
751 |
|
|
return;
|
752 |
|
|
schizo_write(afsr_reg, error_bits);
|
753 |
|
|
|
754 |
|
|
/* Log the error. */
|
755 |
|
|
printk("PCI%d: Uncorrectable Error, primary error type[%s]\n",
|
756 |
|
|
p->index,
|
757 |
|
|
(((error_bits & SCHIZO_UEAFSR_PPIO) ?
|
758 |
|
|
"PIO" :
|
759 |
|
|
((error_bits & SCHIZO_UEAFSR_PDRD) ?
|
760 |
|
|
"DMA Read" :
|
761 |
|
|
((error_bits & SCHIZO_UEAFSR_PDWR) ?
|
762 |
|
|
"DMA Write" : "???")))));
|
763 |
|
|
printk("PCI%d: bytemask[%04lx] qword_offset[%lx] SAFARI_AID[%02lx]\n",
|
764 |
|
|
p->index,
|
765 |
|
|
(afsr & SCHIZO_UEAFSR_BMSK) >> 32UL,
|
766 |
|
|
(afsr & SCHIZO_UEAFSR_QOFF) >> 30UL,
|
767 |
|
|
(afsr & SCHIZO_UEAFSR_AID) >> 24UL);
|
768 |
|
|
printk("PCI%d: partial[%d] owned_in[%d] mtag[%lx] mtag_synd[%lx] ecc_sync[%lx]\n",
|
769 |
|
|
p->index,
|
770 |
|
|
(afsr & SCHIZO_UEAFSR_PARTIAL) ? 1 : 0,
|
771 |
|
|
(afsr & SCHIZO_UEAFSR_OWNEDIN) ? 1 : 0,
|
772 |
|
|
(afsr & SCHIZO_UEAFSR_MTAG) >> 13UL,
|
773 |
|
|
(afsr & SCHIZO_UEAFSR_MTAGSYND) >> 16UL,
|
774 |
|
|
(afsr & SCHIZO_UEAFSR_ECCSYND) >> 0UL);
|
775 |
|
|
printk("PCI%d: UE AFAR [%016lx]\n", p->index, afar);
|
776 |
|
|
printk("PCI%d: UE Secondary errors [", p->index);
|
777 |
|
|
reported = 0;
|
778 |
|
|
if (afsr & SCHIZO_UEAFSR_SPIO) {
|
779 |
|
|
reported++;
|
780 |
|
|
printk("(PIO)");
|
781 |
|
|
}
|
782 |
|
|
if (afsr & SCHIZO_UEAFSR_SDMA) {
|
783 |
|
|
reported++;
|
784 |
|
|
printk("(DMA)");
|
785 |
|
|
}
|
786 |
|
|
if (!reported)
|
787 |
|
|
printk("(none)");
|
788 |
|
|
printk("]\n");
|
789 |
|
|
|
790 |
|
|
/* Interrogate IOMMU for error status. */
|
791 |
|
|
schizo_check_iommu_error(p, UE_ERR);
|
792 |
|
|
|
793 |
|
|
schizo_clear_other_err_intr(irq);
|
794 |
|
|
}
|
795 |
|
|
|
796 |
|
|
#define SCHIZO_CE_AFSR 0x10040UL
|
797 |
|
|
#define SCHIZO_CE_AFAR 0x10048UL
|
798 |
|
|
|
799 |
|
|
#define SCHIZO_CEAFSR_PPIO 0x8000000000000000UL
|
800 |
|
|
#define SCHIZO_CEAFSR_PDRD 0x4000000000000000UL
|
801 |
|
|
#define SCHIZO_CEAFSR_PDWR 0x2000000000000000UL
|
802 |
|
|
#define SCHIZO_CEAFSR_SPIO 0x1000000000000000UL
|
803 |
|
|
#define SCHIZO_CEAFSR_SDMA 0x0800000000000000UL
|
804 |
|
|
#define SCHIZO_CEAFSR_ERRPNDG 0x0300000000000000UL
|
805 |
|
|
#define SCHIZO_CEAFSR_BMSK 0x000003ff00000000UL
|
806 |
|
|
#define SCHIZO_CEAFSR_QOFF 0x00000000c0000000UL
|
807 |
|
|
#define SCHIZO_CEAFSR_AID 0x000000001f000000UL
|
808 |
|
|
#define SCHIZO_CEAFSR_PARTIAL 0x0000000000800000UL
|
809 |
|
|
#define SCHIZO_CEAFSR_OWNEDIN 0x0000000000400000UL
|
810 |
|
|
#define SCHIZO_CEAFSR_MTAGSYND 0x00000000000f0000UL
|
811 |
|
|
#define SCHIZO_CEAFSR_MTAG 0x000000000000e000UL
|
812 |
|
|
#define SCHIZO_CEAFSR_ECCSYND 0x00000000000001ffUL
|
813 |
|
|
|
814 |
|
|
static void schizo_ce_intr(int irq, void *dev_id, struct pt_regs *regs)
|
815 |
|
|
{
|
816 |
|
|
struct pci_controller_info *p = dev_id;
|
817 |
|
|
unsigned long afsr_reg = p->pbm_B.controller_regs + SCHIZO_CE_AFSR;
|
818 |
|
|
unsigned long afar_reg = p->pbm_B.controller_regs + SCHIZO_CE_AFAR;
|
819 |
|
|
unsigned long afsr, afar, error_bits;
|
820 |
|
|
int reported, limit;
|
821 |
|
|
|
822 |
|
|
/* Latch error status. */
|
823 |
|
|
afar = schizo_read(afar_reg);
|
824 |
|
|
|
825 |
|
|
/* If either of the error pending bits are set in the
|
826 |
|
|
* AFSR, the error status is being actively updated by
|
827 |
|
|
* the hardware and we must re-read to get a clean value.
|
828 |
|
|
*/
|
829 |
|
|
limit = 1000;
|
830 |
|
|
do {
|
831 |
|
|
afsr = schizo_read(afsr_reg);
|
832 |
|
|
} while ((afsr & SCHIZO_UEAFSR_ERRPNDG) != 0 && --limit);
|
833 |
|
|
|
834 |
|
|
/* Clear primary/secondary error status bits. */
|
835 |
|
|
error_bits = afsr &
|
836 |
|
|
(SCHIZO_CEAFSR_PPIO | SCHIZO_CEAFSR_PDRD | SCHIZO_CEAFSR_PDWR |
|
837 |
|
|
SCHIZO_CEAFSR_SPIO | SCHIZO_CEAFSR_SDMA);
|
838 |
|
|
if (!error_bits)
|
839 |
|
|
return;
|
840 |
|
|
schizo_write(afsr_reg, error_bits);
|
841 |
|
|
|
842 |
|
|
/* Log the error. */
|
843 |
|
|
printk("PCI%d: Correctable Error, primary error type[%s]\n",
|
844 |
|
|
p->index,
|
845 |
|
|
(((error_bits & SCHIZO_CEAFSR_PPIO) ?
|
846 |
|
|
"PIO" :
|
847 |
|
|
((error_bits & SCHIZO_CEAFSR_PDRD) ?
|
848 |
|
|
"DMA Read" :
|
849 |
|
|
((error_bits & SCHIZO_CEAFSR_PDWR) ?
|
850 |
|
|
"DMA Write" : "???")))));
|
851 |
|
|
|
852 |
|
|
/* XXX Use syndrome and afar to print out module string just like
|
853 |
|
|
* XXX UDB CE trap handler does... -DaveM
|
854 |
|
|
*/
|
855 |
|
|
printk("PCI%d: bytemask[%04lx] qword_offset[%lx] SAFARI_AID[%02lx]\n",
|
856 |
|
|
p->index,
|
857 |
|
|
(afsr & SCHIZO_UEAFSR_BMSK) >> 32UL,
|
858 |
|
|
(afsr & SCHIZO_UEAFSR_QOFF) >> 30UL,
|
859 |
|
|
(afsr & SCHIZO_UEAFSR_AID) >> 24UL);
|
860 |
|
|
printk("PCI%d: partial[%d] owned_in[%d] mtag[%lx] mtag_synd[%lx] ecc_sync[%lx]\n",
|
861 |
|
|
p->index,
|
862 |
|
|
(afsr & SCHIZO_UEAFSR_PARTIAL) ? 1 : 0,
|
863 |
|
|
(afsr & SCHIZO_UEAFSR_OWNEDIN) ? 1 : 0,
|
864 |
|
|
(afsr & SCHIZO_UEAFSR_MTAG) >> 13UL,
|
865 |
|
|
(afsr & SCHIZO_UEAFSR_MTAGSYND) >> 16UL,
|
866 |
|
|
(afsr & SCHIZO_UEAFSR_ECCSYND) >> 0UL);
|
867 |
|
|
printk("PCI%d: CE AFAR [%016lx]\n", p->index, afar);
|
868 |
|
|
printk("PCI%d: CE Secondary errors [", p->index);
|
869 |
|
|
reported = 0;
|
870 |
|
|
if (afsr & SCHIZO_CEAFSR_SPIO) {
|
871 |
|
|
reported++;
|
872 |
|
|
printk("(PIO)");
|
873 |
|
|
}
|
874 |
|
|
if (afsr & SCHIZO_CEAFSR_SDMA) {
|
875 |
|
|
reported++;
|
876 |
|
|
printk("(DMA)");
|
877 |
|
|
}
|
878 |
|
|
if (!reported)
|
879 |
|
|
printk("(none)");
|
880 |
|
|
printk("]\n");
|
881 |
|
|
|
882 |
|
|
schizo_clear_other_err_intr(irq);
|
883 |
|
|
}
|
884 |
|
|
|
885 |
|
|
#define SCHIZO_PCI_AFSR 0x2010UL
|
886 |
|
|
#define SCHIZO_PCI_AFAR 0x2018UL
|
887 |
|
|
|
888 |
|
|
#define SCHIZO_PCIAFSR_PMA 0x8000000000000000UL /* Schizo/Tomatillo */
|
889 |
|
|
#define SCHIZO_PCIAFSR_PTA 0x4000000000000000UL /* Schizo/Tomatillo */
|
890 |
|
|
#define SCHIZO_PCIAFSR_PRTRY 0x2000000000000000UL /* Schizo/Tomatillo */
|
891 |
|
|
#define SCHIZO_PCIAFSR_PPERR 0x1000000000000000UL /* Schizo/Tomatillo */
|
892 |
|
|
#define SCHIZO_PCIAFSR_PTTO 0x0800000000000000UL /* Schizo/Tomatillo */
|
893 |
|
|
#define SCHIZO_PCIAFSR_PUNUS 0x0400000000000000UL /* Schizo */
|
894 |
|
|
#define SCHIZO_PCIAFSR_SMA 0x0200000000000000UL /* Schizo/Tomatillo */
|
895 |
|
|
#define SCHIZO_PCIAFSR_STA 0x0100000000000000UL /* Schizo/Tomatillo */
|
896 |
|
|
#define SCHIZO_PCIAFSR_SRTRY 0x0080000000000000UL /* Schizo/Tomatillo */
|
897 |
|
|
#define SCHIZO_PCIAFSR_SPERR 0x0040000000000000UL /* Schizo/Tomatillo */
|
898 |
|
|
#define SCHIZO_PCIAFSR_STTO 0x0020000000000000UL /* Schizo/Tomatillo */
|
899 |
|
|
#define SCHIZO_PCIAFSR_SUNUS 0x0010000000000000UL /* Schizo */
|
900 |
|
|
#define SCHIZO_PCIAFSR_BMSK 0x000003ff00000000UL /* Schizo/Tomatillo */
|
901 |
|
|
#define SCHIZO_PCIAFSR_BLK 0x0000000080000000UL /* Schizo/Tomatillo */
|
902 |
|
|
#define SCHIZO_PCIAFSR_CFG 0x0000000040000000UL /* Schizo/Tomatillo */
|
903 |
|
|
#define SCHIZO_PCIAFSR_MEM 0x0000000020000000UL /* Schizo/Tomatillo */
|
904 |
|
|
#define SCHIZO_PCIAFSR_IO 0x0000000010000000UL /* Schizo/Tomatillo */
|
905 |
|
|
|
906 |
|
|
#define SCHIZO_PCI_CTRL (0x2000UL)
|
907 |
|
|
#define SCHIZO_PCICTRL_BUS_UNUS (1UL << 63UL) /* Safari */
|
908 |
|
|
#define SCHIZO_PCICTRL_ARB_PRIO (0x1ff << 52UL) /* Tomatillo */
|
909 |
|
|
#define SCHIZO_PCICTRL_ESLCK (1UL << 51UL) /* Safari */
|
910 |
|
|
#define SCHIZO_PCICTRL_ERRSLOT (7UL << 48UL) /* Safari */
|
911 |
|
|
#define SCHIZO_PCICTRL_TTO_ERR (1UL << 38UL) /* Safari/Tomatillo */
|
912 |
|
|
#define SCHIZO_PCICTRL_RTRY_ERR (1UL << 37UL) /* Safari/Tomatillo */
|
913 |
|
|
#define SCHIZO_PCICTRL_DTO_ERR (1UL << 36UL) /* Safari/Tomatillo */
|
914 |
|
|
#define SCHIZO_PCICTRL_SBH_ERR (1UL << 35UL) /* Safari */
|
915 |
|
|
#define SCHIZO_PCICTRL_SERR (1UL << 34UL) /* Safari/Tomatillo */
|
916 |
|
|
#define SCHIZO_PCICTRL_PCISPD (1UL << 33UL) /* Safari */
|
917 |
|
|
#define SCHIZO_PCICTRL_MRM_PREF (1UL << 28UL) /* Tomatillo */
|
918 |
|
|
#define SCHIZO_PCICTRL_RDO_PREF (1UL << 27UL) /* Tomatillo */
|
919 |
|
|
#define SCHIZO_PCICTRL_RDL_PREF (1UL << 26UL) /* Tomatillo */
|
920 |
|
|
#define SCHIZO_PCICTRL_PTO (3UL << 24UL) /* Safari/Tomatillo */
|
921 |
|
|
#define SCHIZO_PCICTRL_PTO_SHIFT 24UL
|
922 |
|
|
#define SCHIZO_PCICTRL_TRWSW (7UL << 21UL) /* Tomatillo */
|
923 |
|
|
#define SCHIZO_PCICTRL_F_TGT_A (1UL << 20UL) /* Tomatillo */
|
924 |
|
|
#define SCHIZO_PCICTRL_S_DTO_INT (1UL << 19UL) /* Safari */
|
925 |
|
|
#define SCHIZO_PCICTRL_F_TGT_RT (1UL << 19UL) /* Tomatillo */
|
926 |
|
|
#define SCHIZO_PCICTRL_SBH_INT (1UL << 18UL) /* Safari */
|
927 |
|
|
#define SCHIZO_PCICTRL_T_DTO_INT (1UL << 18UL) /* Tomatillo */
|
928 |
|
|
#define SCHIZO_PCICTRL_EEN (1UL << 17UL) /* Safari/Tomatillo */
|
929 |
|
|
#define SCHIZO_PCICTRL_PARK (1UL << 16UL) /* Safari/Tomatillo */
|
930 |
|
|
#define SCHIZO_PCICTRL_PCIRST (1UL << 8UL) /* Safari */
|
931 |
|
|
#define SCHIZO_PCICTRL_ARB_S (0x3fUL << 0UL) /* Safari */
|
932 |
|
|
#define SCHIZO_PCICTRL_ARB_T (0xffUL << 0UL) /* Tomatillo */
|
933 |
|
|
|
934 |
|
|
static void schizo_pcierr_intr_other(struct pci_pbm_info *pbm)
|
935 |
|
|
{
|
936 |
|
|
unsigned long csr_reg, csr, csr_error_bits;
|
937 |
|
|
u16 stat;
|
938 |
|
|
|
939 |
|
|
csr_reg = pbm->pbm_regs + SCHIZO_PCI_CTRL;
|
940 |
|
|
csr = schizo_read(csr_reg);
|
941 |
|
|
csr_error_bits =
|
942 |
|
|
csr & (SCHIZO_PCICTRL_BUS_UNUS |
|
943 |
|
|
SCHIZO_PCICTRL_TTO_ERR |
|
944 |
|
|
SCHIZO_PCICTRL_RTRY_ERR |
|
945 |
|
|
SCHIZO_PCICTRL_DTO_ERR |
|
946 |
|
|
SCHIZO_PCICTRL_SBH_ERR |
|
947 |
|
|
SCHIZO_PCICTRL_SERR);
|
948 |
|
|
if (csr_error_bits) {
|
949 |
|
|
/* Clear the errors. */
|
950 |
|
|
schizo_write(csr_reg, csr);
|
951 |
|
|
|
952 |
|
|
/* Log 'em. */
|
953 |
|
|
if (csr_error_bits & SCHIZO_PCICTRL_BUS_UNUS)
|
954 |
|
|
printk("%s: Bus unusable error asserted.\n",
|
955 |
|
|
pbm->name);
|
956 |
|
|
if (csr_error_bits & SCHIZO_PCICTRL_TTO_ERR)
|
957 |
|
|
printk("%s: PCI TRDY# timeout error asserted.\n",
|
958 |
|
|
pbm->name);
|
959 |
|
|
if (csr_error_bits & SCHIZO_PCICTRL_RTRY_ERR)
|
960 |
|
|
printk("%s: PCI excessive retry error asserted.\n",
|
961 |
|
|
pbm->name);
|
962 |
|
|
if (csr_error_bits & SCHIZO_PCICTRL_DTO_ERR)
|
963 |
|
|
printk("%s: PCI discard timeout error asserted.\n",
|
964 |
|
|
pbm->name);
|
965 |
|
|
if (csr_error_bits & SCHIZO_PCICTRL_SBH_ERR)
|
966 |
|
|
printk("%s: PCI streaming byte hole error asserted.\n",
|
967 |
|
|
pbm->name);
|
968 |
|
|
if (csr_error_bits & SCHIZO_PCICTRL_SERR)
|
969 |
|
|
printk("%s: PCI SERR signal asserted.\n",
|
970 |
|
|
pbm->name);
|
971 |
|
|
}
|
972 |
|
|
pci_read_config_word(pbm->pci_bus->self, PCI_STATUS, &stat);
|
973 |
|
|
if (stat & (PCI_STATUS_PARITY |
|
974 |
|
|
PCI_STATUS_SIG_TARGET_ABORT |
|
975 |
|
|
PCI_STATUS_REC_TARGET_ABORT |
|
976 |
|
|
PCI_STATUS_REC_MASTER_ABORT |
|
977 |
|
|
PCI_STATUS_SIG_SYSTEM_ERROR)) {
|
978 |
|
|
printk("%s: PCI bus error, PCI_STATUS[%04x]\n",
|
979 |
|
|
pbm->name, stat);
|
980 |
|
|
pci_write_config_word(pbm->pci_bus->self, PCI_STATUS, 0xffff);
|
981 |
|
|
}
|
982 |
|
|
}
|
983 |
|
|
|
984 |
|
|
static void schizo_pcierr_intr(int irq, void *dev_id, struct pt_regs *regs)
|
985 |
|
|
{
|
986 |
|
|
struct pci_pbm_info *pbm = dev_id;
|
987 |
|
|
struct pci_controller_info *p = pbm->parent;
|
988 |
|
|
unsigned long afsr_reg, afar_reg, base;
|
989 |
|
|
unsigned long afsr, afar, error_bits;
|
990 |
|
|
int reported;
|
991 |
|
|
|
992 |
|
|
base = pbm->pbm_regs;
|
993 |
|
|
|
994 |
|
|
afsr_reg = base + SCHIZO_PCI_AFSR;
|
995 |
|
|
afar_reg = base + SCHIZO_PCI_AFAR;
|
996 |
|
|
|
997 |
|
|
/* Latch error status. */
|
998 |
|
|
afar = schizo_read(afar_reg);
|
999 |
|
|
afsr = schizo_read(afsr_reg);
|
1000 |
|
|
|
1001 |
|
|
/* Clear primary/secondary error status bits. */
|
1002 |
|
|
error_bits = afsr &
|
1003 |
|
|
(SCHIZO_PCIAFSR_PMA | SCHIZO_PCIAFSR_PTA |
|
1004 |
|
|
SCHIZO_PCIAFSR_PRTRY | SCHIZO_PCIAFSR_PPERR |
|
1005 |
|
|
SCHIZO_PCIAFSR_PTTO | SCHIZO_PCIAFSR_PUNUS |
|
1006 |
|
|
SCHIZO_PCIAFSR_SMA | SCHIZO_PCIAFSR_STA |
|
1007 |
|
|
SCHIZO_PCIAFSR_SRTRY | SCHIZO_PCIAFSR_SPERR |
|
1008 |
|
|
SCHIZO_PCIAFSR_STTO | SCHIZO_PCIAFSR_SUNUS);
|
1009 |
|
|
if (!error_bits)
|
1010 |
|
|
return schizo_pcierr_intr_other(pbm);
|
1011 |
|
|
schizo_write(afsr_reg, error_bits);
|
1012 |
|
|
|
1013 |
|
|
/* Log the error. */
|
1014 |
|
|
printk("%s: PCI Error, primary error type[%s]\n",
|
1015 |
|
|
pbm->name,
|
1016 |
|
|
(((error_bits & SCHIZO_PCIAFSR_PMA) ?
|
1017 |
|
|
"Master Abort" :
|
1018 |
|
|
((error_bits & SCHIZO_PCIAFSR_PTA) ?
|
1019 |
|
|
"Target Abort" :
|
1020 |
|
|
((error_bits & SCHIZO_PCIAFSR_PRTRY) ?
|
1021 |
|
|
"Excessive Retries" :
|
1022 |
|
|
((error_bits & SCHIZO_PCIAFSR_PPERR) ?
|
1023 |
|
|
"Parity Error" :
|
1024 |
|
|
((error_bits & SCHIZO_PCIAFSR_PTTO) ?
|
1025 |
|
|
"Timeout" :
|
1026 |
|
|
((error_bits & SCHIZO_PCIAFSR_PUNUS) ?
|
1027 |
|
|
"Bus Unusable" : "???"))))))));
|
1028 |
|
|
printk("%s: bytemask[%04lx] was_block(%d) space(%s)\n",
|
1029 |
|
|
pbm->name,
|
1030 |
|
|
(afsr & SCHIZO_PCIAFSR_BMSK) >> 32UL,
|
1031 |
|
|
(afsr & SCHIZO_PCIAFSR_BLK) ? 1 : 0,
|
1032 |
|
|
((afsr & SCHIZO_PCIAFSR_CFG) ?
|
1033 |
|
|
"Config" :
|
1034 |
|
|
((afsr & SCHIZO_PCIAFSR_MEM) ?
|
1035 |
|
|
"Memory" :
|
1036 |
|
|
((afsr & SCHIZO_PCIAFSR_IO) ?
|
1037 |
|
|
"I/O" : "???"))));
|
1038 |
|
|
printk("%s: PCI AFAR [%016lx]\n",
|
1039 |
|
|
pbm->name, afar);
|
1040 |
|
|
printk("%s: PCI Secondary errors [",
|
1041 |
|
|
pbm->name);
|
1042 |
|
|
reported = 0;
|
1043 |
|
|
if (afsr & SCHIZO_PCIAFSR_SMA) {
|
1044 |
|
|
reported++;
|
1045 |
|
|
printk("(Master Abort)");
|
1046 |
|
|
}
|
1047 |
|
|
if (afsr & SCHIZO_PCIAFSR_STA) {
|
1048 |
|
|
reported++;
|
1049 |
|
|
printk("(Target Abort)");
|
1050 |
|
|
}
|
1051 |
|
|
if (afsr & SCHIZO_PCIAFSR_SRTRY) {
|
1052 |
|
|
reported++;
|
1053 |
|
|
printk("(Excessive Retries)");
|
1054 |
|
|
}
|
1055 |
|
|
if (afsr & SCHIZO_PCIAFSR_SPERR) {
|
1056 |
|
|
reported++;
|
1057 |
|
|
printk("(Parity Error)");
|
1058 |
|
|
}
|
1059 |
|
|
if (afsr & SCHIZO_PCIAFSR_STTO) {
|
1060 |
|
|
reported++;
|
1061 |
|
|
printk("(Timeout)");
|
1062 |
|
|
}
|
1063 |
|
|
if (afsr & SCHIZO_PCIAFSR_SUNUS) {
|
1064 |
|
|
reported++;
|
1065 |
|
|
printk("(Bus Unusable)");
|
1066 |
|
|
}
|
1067 |
|
|
if (!reported)
|
1068 |
|
|
printk("(none)");
|
1069 |
|
|
printk("]\n");
|
1070 |
|
|
|
1071 |
|
|
/* For the error types shown, scan PBM's PCI bus for devices
|
1072 |
|
|
* which have logged that error type.
|
1073 |
|
|
*/
|
1074 |
|
|
|
1075 |
|
|
/* If we see a Target Abort, this could be the result of an
|
1076 |
|
|
* IOMMU translation error of some sort. It is extremely
|
1077 |
|
|
* useful to log this information as usually it indicates
|
1078 |
|
|
* a bug in the IOMMU support code or a PCI device driver.
|
1079 |
|
|
*/
|
1080 |
|
|
if (error_bits & (SCHIZO_PCIAFSR_PTA | SCHIZO_PCIAFSR_STA)) {
|
1081 |
|
|
schizo_check_iommu_error(p, PCI_ERR);
|
1082 |
|
|
pci_scan_for_target_abort(p, pbm, pbm->pci_bus);
|
1083 |
|
|
}
|
1084 |
|
|
if (error_bits & (SCHIZO_PCIAFSR_PMA | SCHIZO_PCIAFSR_SMA))
|
1085 |
|
|
pci_scan_for_master_abort(p, pbm, pbm->pci_bus);
|
1086 |
|
|
|
1087 |
|
|
/* For excessive retries, PSYCHO/PBM will abort the device
|
1088 |
|
|
* and there is no way to specifically check for excessive
|
1089 |
|
|
* retries in the config space status registers. So what
|
1090 |
|
|
* we hope is that we'll catch it via the master/target
|
1091 |
|
|
* abort events.
|
1092 |
|
|
*/
|
1093 |
|
|
|
1094 |
|
|
if (error_bits & (SCHIZO_PCIAFSR_PPERR | SCHIZO_PCIAFSR_SPERR))
|
1095 |
|
|
pci_scan_for_parity_error(p, pbm, pbm->pci_bus);
|
1096 |
|
|
|
1097 |
|
|
schizo_clear_other_err_intr(irq);
|
1098 |
|
|
}
|
1099 |
|
|
|
1100 |
|
|
#define SCHIZO_SAFARI_ERRLOG 0x10018UL
|
1101 |
|
|
|
1102 |
|
|
#define SAFARI_ERRLOG_ERROUT 0x8000000000000000UL
|
1103 |
|
|
|
1104 |
|
|
#define BUS_ERROR_BADCMD 0x4000000000000000UL /* Schizo/Tomatillo */
|
1105 |
|
|
#define BUS_ERROR_SSMDIS 0x2000000000000000UL /* Safari */
|
1106 |
|
|
#define BUS_ERROR_BADMA 0x1000000000000000UL /* Safari */
|
1107 |
|
|
#define BUS_ERROR_BADMB 0x0800000000000000UL /* Safari */
|
1108 |
|
|
#define BUS_ERROR_BADMC 0x0400000000000000UL /* Safari */
|
1109 |
|
|
#define BUS_ERROR_SNOOP_GR 0x0000000000200000UL /* Tomatillo */
|
1110 |
|
|
#define BUS_ERROR_SNOOP_PCI 0x0000000000100000UL /* Tomatillo */
|
1111 |
|
|
#define BUS_ERROR_SNOOP_RD 0x0000000000080000UL /* Tomatillo */
|
1112 |
|
|
#define BUS_ERROR_SNOOP_RDS 0x0000000000020000UL /* Tomatillo */
|
1113 |
|
|
#define BUS_ERROR_SNOOP_RDSA 0x0000000000010000UL /* Tomatillo */
|
1114 |
|
|
#define BUS_ERROR_SNOOP_OWN 0x0000000000008000UL /* Tomatillo */
|
1115 |
|
|
#define BUS_ERROR_SNOOP_RDO 0x0000000000004000UL /* Tomatillo */
|
1116 |
|
|
#define BUS_ERROR_CPU1PS 0x0000000000002000UL /* Safari */
|
1117 |
|
|
#define BUS_ERROR_WDATA_PERR 0x0000000000002000UL /* Tomatillo */
|
1118 |
|
|
#define BUS_ERROR_CPU1PB 0x0000000000001000UL /* Safari */
|
1119 |
|
|
#define BUS_ERROR_CTRL_PERR 0x0000000000001000UL /* Tomatillo */
|
1120 |
|
|
#define BUS_ERROR_CPU0PS 0x0000000000000800UL /* Safari */
|
1121 |
|
|
#define BUS_ERROR_SNOOP_ERR 0x0000000000000800UL /* Tomatillo */
|
1122 |
|
|
#define BUS_ERROR_CPU0PB 0x0000000000000400UL /* Safari */
|
1123 |
|
|
#define BUS_ERROR_JBUS_ILL_B 0x0000000000000400UL /* Tomatillo */
|
1124 |
|
|
#define BUS_ERROR_CIQTO 0x0000000000000200UL /* Safari */
|
1125 |
|
|
#define BUS_ERROR_LPQTO 0x0000000000000100UL /* Safari */
|
1126 |
|
|
#define BUS_ERROR_JBUS_ILL_C 0x0000000000000100UL /* Tomatillo */
|
1127 |
|
|
#define BUS_ERROR_SFPQTO 0x0000000000000080UL /* Safari */
|
1128 |
|
|
#define BUS_ERROR_UFPQTO 0x0000000000000040UL /* Safari */
|
1129 |
|
|
#define BUS_ERROR_RD_PERR 0x0000000000000040UL /* Tomatillo */
|
1130 |
|
|
#define BUS_ERROR_APERR 0x0000000000000020UL /* Safari/Tomatillo */
|
1131 |
|
|
#define BUS_ERROR_UNMAP 0x0000000000000010UL /* Safari/Tomatillo */
|
1132 |
|
|
#define BUS_ERROR_BUSERR 0x0000000000000004UL /* Safari/Tomatillo */
|
1133 |
|
|
#define BUS_ERROR_TIMEOUT 0x0000000000000002UL /* Safari/Tomatillo */
|
1134 |
|
|
#define BUS_ERROR_ILL 0x0000000000000001UL /* Safari */
|
1135 |
|
|
|
1136 |
|
|
/* We only expect UNMAP errors here. The rest of the Safari errors
|
1137 |
|
|
* are marked fatal and thus cause a system reset.
|
1138 |
|
|
*/
|
1139 |
|
|
static void schizo_safarierr_intr(int irq, void *dev_id, struct pt_regs *regs)
|
1140 |
|
|
{
|
1141 |
|
|
struct pci_controller_info *p = dev_id;
|
1142 |
|
|
u64 errlog;
|
1143 |
|
|
|
1144 |
|
|
errlog = schizo_read(p->pbm_B.controller_regs + SCHIZO_SAFARI_ERRLOG);
|
1145 |
|
|
schizo_write(p->pbm_B.controller_regs + SCHIZO_SAFARI_ERRLOG,
|
1146 |
|
|
errlog & ~(SAFARI_ERRLOG_ERROUT));
|
1147 |
|
|
|
1148 |
|
|
if (!(errlog & BUS_ERROR_UNMAP)) {
|
1149 |
|
|
printk("PCI%d: Unexpected Safari/JBUS error interrupt, errlog[%016lx]\n",
|
1150 |
|
|
p->index, errlog);
|
1151 |
|
|
|
1152 |
|
|
schizo_clear_other_err_intr(irq);
|
1153 |
|
|
return;
|
1154 |
|
|
}
|
1155 |
|
|
|
1156 |
|
|
printk("PCI%d: Safari/JBUS interrupt, UNMAPPED error, interrogating IOMMUs.\n",
|
1157 |
|
|
p->index);
|
1158 |
|
|
schizo_check_iommu_error(p, SAFARI_ERR);
|
1159 |
|
|
|
1160 |
|
|
schizo_clear_other_err_intr(irq);
|
1161 |
|
|
}
|
1162 |
|
|
|
1163 |
|
|
/* Nearly identical to PSYCHO equivalents... */
|
1164 |
|
|
#define SCHIZO_ECC_CTRL 0x10020UL
|
1165 |
|
|
#define SCHIZO_ECCCTRL_EE 0x8000000000000000 /* Enable ECC Checking */
|
1166 |
|
|
#define SCHIZO_ECCCTRL_UE 0x4000000000000000 /* Enable UE Interrupts */
|
1167 |
|
|
#define SCHIZO_ECCCTRL_CE 0x2000000000000000 /* Enable CE INterrupts */
|
1168 |
|
|
|
1169 |
|
|
#define SCHIZO_SAFARI_ERRCTRL 0x10008UL
|
1170 |
|
|
#define SCHIZO_SAFERRCTRL_EN 0x8000000000000000UL
|
1171 |
|
|
#define SCHIZO_SAFARI_IRQCTRL 0x10010UL
|
1172 |
|
|
#define SCHIZO_SAFIRQCTRL_EN 0x8000000000000000UL
|
1173 |
|
|
|
1174 |
|
|
#define SCHIZO_UE_INO 0x30 /* Uncorrectable ECC error */
|
1175 |
|
|
#define SCHIZO_CE_INO 0x31 /* Correctable ECC error */
|
1176 |
|
|
#define SCHIZO_PCIERR_A_INO 0x32 /* PBM A PCI bus error */
|
1177 |
|
|
#define SCHIZO_PCIERR_B_INO 0x33 /* PBM B PCI bus error */
|
1178 |
|
|
#define SCHIZO_SERR_INO 0x34 /* Safari interface error */
|
1179 |
|
|
|
1180 |
|
|
struct pci_pbm_info *pbm_for_ino(struct pci_controller_info *p, u32 ino)
|
1181 |
|
|
{
|
1182 |
|
|
ino &= IMAP_INO;
|
1183 |
|
|
if (p->pbm_A.ino_bitmap & (1UL << ino))
|
1184 |
|
|
return &p->pbm_A;
|
1185 |
|
|
if (p->pbm_B.ino_bitmap & (1UL << ino))
|
1186 |
|
|
return &p->pbm_B;
|
1187 |
|
|
prom_printf("TOMATILLO%d: No entry in ino bitmap for %d\n",
|
1188 |
|
|
p->index, ino);
|
1189 |
|
|
prom_halt();
|
1190 |
|
|
/* NOTREACHED */
|
1191 |
|
|
return NULL;
|
1192 |
|
|
}
|
1193 |
|
|
|
1194 |
|
|
/* How the Tomatillo IRQs are routed around is pure guesswork here.
|
1195 |
|
|
*
|
1196 |
|
|
* All the Tomatillo devices I see in prtconf dumps seem to have only
|
1197 |
|
|
* a single PCI bus unit attached to it. It would seem they are seperate
|
1198 |
|
|
* devices because their PortID (ie. JBUS ID) values are all different
|
1199 |
|
|
* and thus the registers are mapped to totally different locations.
|
1200 |
|
|
*
|
1201 |
|
|
* However, two Tomatillo's look "similar" in that the only difference
|
1202 |
|
|
* in their PortID is the lowest bit.
|
1203 |
|
|
*
|
1204 |
|
|
* So if we were to ignore this lower bit, it certainly looks like two
|
1205 |
|
|
* PCI bus units of the same Tomatillo. I still have not really
|
1206 |
|
|
* figured this out...
|
1207 |
|
|
*/
|
1208 |
|
|
static void __init tomatillo_register_error_handlers(struct pci_controller_info *p)
|
1209 |
|
|
{
|
1210 |
|
|
struct pci_pbm_info *pbm;
|
1211 |
|
|
unsigned int irq;
|
1212 |
|
|
struct ino_bucket *bucket;
|
1213 |
|
|
u64 tmp, err_mask, err_no_mask;
|
1214 |
|
|
|
1215 |
|
|
/* Build IRQs and register handlers. */
|
1216 |
|
|
pbm = pbm_for_ino(p, SCHIZO_UE_INO);
|
1217 |
|
|
irq = schizo_irq_build(pbm, NULL, (pbm->portid << 6) | SCHIZO_UE_INO);
|
1218 |
|
|
if (request_irq(irq, schizo_ue_intr,
|
1219 |
|
|
SA_SHIRQ, "TOMATILLO UE", p) < 0) {
|
1220 |
|
|
prom_printf("%s: Cannot register UE interrupt.\n",
|
1221 |
|
|
pbm->name);
|
1222 |
|
|
prom_halt();
|
1223 |
|
|
}
|
1224 |
|
|
bucket = __bucket(irq);
|
1225 |
|
|
tmp = readl(bucket->imap);
|
1226 |
|
|
upa_writel(tmp, (pbm->pbm_regs +
|
1227 |
|
|
schizo_imap_offset(SCHIZO_UE_INO) + 4));
|
1228 |
|
|
|
1229 |
|
|
pbm = pbm_for_ino(p, SCHIZO_CE_INO);
|
1230 |
|
|
irq = schizo_irq_build(pbm, NULL, (pbm->portid << 6) | SCHIZO_CE_INO);
|
1231 |
|
|
if (request_irq(irq, schizo_ce_intr,
|
1232 |
|
|
SA_SHIRQ, "TOMATILLO CE", p) < 0) {
|
1233 |
|
|
prom_printf("%s: Cannot register CE interrupt.\n",
|
1234 |
|
|
pbm->name);
|
1235 |
|
|
prom_halt();
|
1236 |
|
|
}
|
1237 |
|
|
bucket = __bucket(irq);
|
1238 |
|
|
tmp = upa_readl(bucket->imap);
|
1239 |
|
|
upa_writel(tmp, (pbm->pbm_regs +
|
1240 |
|
|
schizo_imap_offset(SCHIZO_CE_INO) + 4));
|
1241 |
|
|
|
1242 |
|
|
pbm = pbm_for_ino(p, SCHIZO_PCIERR_A_INO);
|
1243 |
|
|
irq = schizo_irq_build(pbm, NULL, ((pbm->portid << 6) |
|
1244 |
|
|
SCHIZO_PCIERR_A_INO));
|
1245 |
|
|
if (request_irq(irq, schizo_pcierr_intr,
|
1246 |
|
|
SA_SHIRQ, "TOMATILLO PCIERR", pbm) < 0) {
|
1247 |
|
|
prom_printf("%s: Cannot register PBM A PciERR interrupt.\n",
|
1248 |
|
|
pbm->name);
|
1249 |
|
|
prom_halt();
|
1250 |
|
|
}
|
1251 |
|
|
bucket = __bucket(irq);
|
1252 |
|
|
tmp = upa_readl(bucket->imap);
|
1253 |
|
|
upa_writel(tmp, (pbm->pbm_regs +
|
1254 |
|
|
schizo_imap_offset(SCHIZO_PCIERR_A_INO) + 4));
|
1255 |
|
|
|
1256 |
|
|
pbm = pbm_for_ino(p, SCHIZO_PCIERR_B_INO);
|
1257 |
|
|
irq = schizo_irq_build(pbm, NULL, ((pbm->portid << 6) |
|
1258 |
|
|
SCHIZO_PCIERR_B_INO));
|
1259 |
|
|
if (request_irq(irq, schizo_pcierr_intr,
|
1260 |
|
|
SA_SHIRQ, "TOMATILLO PCIERR", pbm) < 0) {
|
1261 |
|
|
prom_printf("%s: Cannot register PBM B PciERR interrupt.\n",
|
1262 |
|
|
pbm->name);
|
1263 |
|
|
prom_halt();
|
1264 |
|
|
}
|
1265 |
|
|
bucket = __bucket(irq);
|
1266 |
|
|
tmp = upa_readl(bucket->imap);
|
1267 |
|
|
upa_writel(tmp, (pbm->pbm_regs +
|
1268 |
|
|
schizo_imap_offset(SCHIZO_PCIERR_B_INO) + 4));
|
1269 |
|
|
|
1270 |
|
|
pbm = pbm_for_ino(p, SCHIZO_SERR_INO);
|
1271 |
|
|
irq = schizo_irq_build(pbm, NULL, (pbm->portid << 6) | SCHIZO_SERR_INO);
|
1272 |
|
|
if (request_irq(irq, schizo_safarierr_intr,
|
1273 |
|
|
SA_SHIRQ, "TOMATILLO SERR", p) < 0) {
|
1274 |
|
|
prom_printf("%s: Cannot register SafariERR interrupt.\n",
|
1275 |
|
|
pbm->name);
|
1276 |
|
|
prom_halt();
|
1277 |
|
|
}
|
1278 |
|
|
bucket = __bucket(irq);
|
1279 |
|
|
tmp = upa_readl(bucket->imap);
|
1280 |
|
|
upa_writel(tmp, (pbm->pbm_regs +
|
1281 |
|
|
schizo_imap_offset(SCHIZO_SERR_INO) + 4));
|
1282 |
|
|
|
1283 |
|
|
/* Enable UE and CE interrupts for controller. */
|
1284 |
|
|
schizo_write(p->pbm_A.controller_regs + SCHIZO_ECC_CTRL,
|
1285 |
|
|
(SCHIZO_ECCCTRL_EE |
|
1286 |
|
|
SCHIZO_ECCCTRL_UE |
|
1287 |
|
|
SCHIZO_ECCCTRL_CE));
|
1288 |
|
|
|
1289 |
|
|
schizo_write(p->pbm_B.controller_regs + SCHIZO_ECC_CTRL,
|
1290 |
|
|
(SCHIZO_ECCCTRL_EE |
|
1291 |
|
|
SCHIZO_ECCCTRL_UE |
|
1292 |
|
|
SCHIZO_ECCCTRL_CE));
|
1293 |
|
|
|
1294 |
|
|
/* Enable PCI Error interrupts and clear error
|
1295 |
|
|
* bits.
|
1296 |
|
|
*/
|
1297 |
|
|
err_mask = (SCHIZO_PCICTRL_BUS_UNUS |
|
1298 |
|
|
SCHIZO_PCICTRL_TTO_ERR |
|
1299 |
|
|
SCHIZO_PCICTRL_RTRY_ERR |
|
1300 |
|
|
SCHIZO_PCICTRL_SERR |
|
1301 |
|
|
SCHIZO_PCICTRL_EEN);
|
1302 |
|
|
|
1303 |
|
|
err_no_mask = SCHIZO_PCICTRL_DTO_ERR;
|
1304 |
|
|
|
1305 |
|
|
tmp = schizo_read(p->pbm_A.pbm_regs + SCHIZO_PCI_CTRL);
|
1306 |
|
|
tmp |= err_mask;
|
1307 |
|
|
tmp &= ~err_no_mask;
|
1308 |
|
|
schizo_write(p->pbm_A.pbm_regs + SCHIZO_PCI_CTRL, tmp);
|
1309 |
|
|
|
1310 |
|
|
tmp = schizo_read(p->pbm_B.pbm_regs + SCHIZO_PCI_CTRL);
|
1311 |
|
|
tmp |= err_mask;
|
1312 |
|
|
tmp &= ~err_no_mask;
|
1313 |
|
|
schizo_write(p->pbm_B.pbm_regs + SCHIZO_PCI_CTRL, tmp);
|
1314 |
|
|
|
1315 |
|
|
err_mask = (SCHIZO_PCIAFSR_PMA | SCHIZO_PCIAFSR_PTA |
|
1316 |
|
|
SCHIZO_PCIAFSR_PRTRY | SCHIZO_PCIAFSR_PPERR |
|
1317 |
|
|
SCHIZO_PCIAFSR_PTTO |
|
1318 |
|
|
SCHIZO_PCIAFSR_SMA | SCHIZO_PCIAFSR_STA |
|
1319 |
|
|
SCHIZO_PCIAFSR_SRTRY | SCHIZO_PCIAFSR_SPERR |
|
1320 |
|
|
SCHIZO_PCIAFSR_STTO);
|
1321 |
|
|
|
1322 |
|
|
schizo_write(p->pbm_A.pbm_regs + SCHIZO_PCI_AFSR, err_mask);
|
1323 |
|
|
schizo_write(p->pbm_B.pbm_regs + SCHIZO_PCI_AFSR, err_mask);
|
1324 |
|
|
|
1325 |
|
|
err_mask = (BUS_ERROR_BADCMD | BUS_ERROR_SNOOP_GR |
|
1326 |
|
|
BUS_ERROR_SNOOP_PCI | BUS_ERROR_SNOOP_RD |
|
1327 |
|
|
BUS_ERROR_SNOOP_RDS | BUS_ERROR_SNOOP_RDSA |
|
1328 |
|
|
BUS_ERROR_SNOOP_OWN | BUS_ERROR_SNOOP_RDO |
|
1329 |
|
|
BUS_ERROR_WDATA_PERR | BUS_ERROR_CTRL_PERR |
|
1330 |
|
|
BUS_ERROR_SNOOP_ERR | BUS_ERROR_JBUS_ILL_B |
|
1331 |
|
|
BUS_ERROR_JBUS_ILL_C | BUS_ERROR_RD_PERR |
|
1332 |
|
|
BUS_ERROR_APERR | BUS_ERROR_UNMAP |
|
1333 |
|
|
BUS_ERROR_BUSERR | BUS_ERROR_TIMEOUT);
|
1334 |
|
|
|
1335 |
|
|
schizo_write(p->pbm_A.controller_regs + SCHIZO_SAFARI_ERRCTRL,
|
1336 |
|
|
(SCHIZO_SAFERRCTRL_EN | err_mask));
|
1337 |
|
|
schizo_write(p->pbm_B.controller_regs + SCHIZO_SAFARI_ERRCTRL,
|
1338 |
|
|
(SCHIZO_SAFERRCTRL_EN | err_mask));
|
1339 |
|
|
|
1340 |
|
|
schizo_write(p->pbm_A.controller_regs + SCHIZO_SAFARI_IRQCTRL,
|
1341 |
|
|
(SCHIZO_SAFIRQCTRL_EN | (BUS_ERROR_UNMAP)));
|
1342 |
|
|
schizo_write(p->pbm_B.controller_regs + SCHIZO_SAFARI_IRQCTRL,
|
1343 |
|
|
(SCHIZO_SAFIRQCTRL_EN | (BUS_ERROR_UNMAP)));
|
1344 |
|
|
}
|
1345 |
|
|
|
1346 |
|
|
static void __init schizo_register_error_handlers(struct pci_controller_info *p)
|
1347 |
|
|
{
|
1348 |
|
|
struct pci_pbm_info *pbm;
|
1349 |
|
|
unsigned int irq;
|
1350 |
|
|
struct ino_bucket *bucket;
|
1351 |
|
|
u64 tmp, err_mask, err_no_mask;
|
1352 |
|
|
|
1353 |
|
|
/* Build IRQs and register handlers. */
|
1354 |
|
|
pbm = pbm_for_ino(p, SCHIZO_UE_INO);
|
1355 |
|
|
irq = schizo_irq_build(pbm, NULL, (pbm->portid << 6) | SCHIZO_UE_INO);
|
1356 |
|
|
if (request_irq(irq, schizo_ue_intr,
|
1357 |
|
|
SA_SHIRQ, "SCHIZO UE", p) < 0) {
|
1358 |
|
|
prom_printf("%s: Cannot register UE interrupt.\n",
|
1359 |
|
|
pbm->name);
|
1360 |
|
|
prom_halt();
|
1361 |
|
|
}
|
1362 |
|
|
bucket = __bucket(irq);
|
1363 |
|
|
tmp = readl(bucket->imap);
|
1364 |
|
|
upa_writel(tmp, (pbm->pbm_regs + schizo_imap_offset(SCHIZO_UE_INO) + 4));
|
1365 |
|
|
|
1366 |
|
|
pbm = pbm_for_ino(p, SCHIZO_CE_INO);
|
1367 |
|
|
irq = schizo_irq_build(pbm, NULL, (pbm->portid << 6) | SCHIZO_CE_INO);
|
1368 |
|
|
if (request_irq(irq, schizo_ce_intr,
|
1369 |
|
|
SA_SHIRQ, "SCHIZO CE", p) < 0) {
|
1370 |
|
|
prom_printf("%s: Cannot register CE interrupt.\n",
|
1371 |
|
|
pbm->name);
|
1372 |
|
|
prom_halt();
|
1373 |
|
|
}
|
1374 |
|
|
bucket = __bucket(irq);
|
1375 |
|
|
tmp = upa_readl(bucket->imap);
|
1376 |
|
|
upa_writel(tmp, (pbm->pbm_regs + schizo_imap_offset(SCHIZO_CE_INO) + 4));
|
1377 |
|
|
|
1378 |
|
|
pbm = pbm_for_ino(p, SCHIZO_PCIERR_A_INO);
|
1379 |
|
|
irq = schizo_irq_build(pbm, NULL, (pbm->portid << 6) | SCHIZO_PCIERR_A_INO);
|
1380 |
|
|
if (request_irq(irq, schizo_pcierr_intr,
|
1381 |
|
|
SA_SHIRQ, "SCHIZO PCIERR", pbm) < 0) {
|
1382 |
|
|
prom_printf("%s: Cannot register PBM A PciERR interrupt.\n",
|
1383 |
|
|
pbm->name);
|
1384 |
|
|
prom_halt();
|
1385 |
|
|
}
|
1386 |
|
|
bucket = __bucket(irq);
|
1387 |
|
|
tmp = upa_readl(bucket->imap);
|
1388 |
|
|
upa_writel(tmp, (pbm->pbm_regs + schizo_imap_offset(SCHIZO_PCIERR_A_INO) + 4));
|
1389 |
|
|
|
1390 |
|
|
pbm = pbm_for_ino(p, SCHIZO_PCIERR_B_INO);
|
1391 |
|
|
irq = schizo_irq_build(pbm, NULL, (pbm->portid << 6) | SCHIZO_PCIERR_B_INO);
|
1392 |
|
|
if (request_irq(irq, schizo_pcierr_intr,
|
1393 |
|
|
SA_SHIRQ, "SCHIZO PCIERR", &p->pbm_B) < 0) {
|
1394 |
|
|
prom_printf("%s: Cannot register PBM B PciERR interrupt.\n",
|
1395 |
|
|
pbm->name);
|
1396 |
|
|
prom_halt();
|
1397 |
|
|
}
|
1398 |
|
|
bucket = __bucket(irq);
|
1399 |
|
|
tmp = upa_readl(bucket->imap);
|
1400 |
|
|
upa_writel(tmp, (pbm->pbm_regs + schizo_imap_offset(SCHIZO_PCIERR_B_INO) + 4));
|
1401 |
|
|
|
1402 |
|
|
pbm = pbm_for_ino(p, SCHIZO_SERR_INO);
|
1403 |
|
|
irq = schizo_irq_build(pbm, NULL, (pbm->portid << 6) | SCHIZO_SERR_INO);
|
1404 |
|
|
if (request_irq(irq, schizo_safarierr_intr,
|
1405 |
|
|
SA_SHIRQ, "SCHIZO SERR", p) < 0) {
|
1406 |
|
|
prom_printf("%s: Cannot register SafariERR interrupt.\n",
|
1407 |
|
|
pbm->name);
|
1408 |
|
|
prom_halt();
|
1409 |
|
|
}
|
1410 |
|
|
bucket = __bucket(irq);
|
1411 |
|
|
tmp = upa_readl(bucket->imap);
|
1412 |
|
|
upa_writel(tmp, (pbm->pbm_regs + schizo_imap_offset(SCHIZO_SERR_INO) + 4));
|
1413 |
|
|
|
1414 |
|
|
/* Enable UE and CE interrupts for controller. */
|
1415 |
|
|
schizo_write(p->pbm_A.controller_regs + SCHIZO_ECC_CTRL,
|
1416 |
|
|
(SCHIZO_ECCCTRL_EE |
|
1417 |
|
|
SCHIZO_ECCCTRL_UE |
|
1418 |
|
|
SCHIZO_ECCCTRL_CE));
|
1419 |
|
|
|
1420 |
|
|
err_mask = (SCHIZO_PCICTRL_BUS_UNUS |
|
1421 |
|
|
SCHIZO_PCICTRL_ESLCK |
|
1422 |
|
|
SCHIZO_PCICTRL_TTO_ERR |
|
1423 |
|
|
SCHIZO_PCICTRL_RTRY_ERR |
|
1424 |
|
|
SCHIZO_PCICTRL_SBH_ERR |
|
1425 |
|
|
SCHIZO_PCICTRL_SERR |
|
1426 |
|
|
SCHIZO_PCICTRL_SBH_INT |
|
1427 |
|
|
SCHIZO_PCICTRL_EEN);
|
1428 |
|
|
|
1429 |
|
|
err_no_mask = SCHIZO_PCICTRL_DTO_ERR;
|
1430 |
|
|
|
1431 |
|
|
/* Enable PCI Error interrupts and clear error
|
1432 |
|
|
* bits for each PBM.
|
1433 |
|
|
*/
|
1434 |
|
|
tmp = schizo_read(p->pbm_A.pbm_regs + SCHIZO_PCI_CTRL);
|
1435 |
|
|
tmp |= err_mask;
|
1436 |
|
|
tmp &= ~err_no_mask;
|
1437 |
|
|
schizo_write(p->pbm_A.pbm_regs + SCHIZO_PCI_CTRL, tmp);
|
1438 |
|
|
|
1439 |
|
|
schizo_write(p->pbm_A.pbm_regs + SCHIZO_PCI_AFSR,
|
1440 |
|
|
(SCHIZO_PCIAFSR_PMA | SCHIZO_PCIAFSR_PTA |
|
1441 |
|
|
SCHIZO_PCIAFSR_PRTRY | SCHIZO_PCIAFSR_PPERR |
|
1442 |
|
|
SCHIZO_PCIAFSR_PTTO | SCHIZO_PCIAFSR_PUNUS |
|
1443 |
|
|
SCHIZO_PCIAFSR_SMA | SCHIZO_PCIAFSR_STA |
|
1444 |
|
|
SCHIZO_PCIAFSR_SRTRY | SCHIZO_PCIAFSR_SPERR |
|
1445 |
|
|
SCHIZO_PCIAFSR_STTO | SCHIZO_PCIAFSR_SUNUS));
|
1446 |
|
|
|
1447 |
|
|
tmp = schizo_read(p->pbm_B.pbm_regs + SCHIZO_PCI_CTRL);
|
1448 |
|
|
tmp |= err_mask;
|
1449 |
|
|
tmp &= ~err_no_mask;
|
1450 |
|
|
schizo_write(p->pbm_B.pbm_regs + SCHIZO_PCI_CTRL, tmp);
|
1451 |
|
|
|
1452 |
|
|
schizo_write(p->pbm_B.pbm_regs + SCHIZO_PCI_AFSR,
|
1453 |
|
|
(SCHIZO_PCIAFSR_PMA | SCHIZO_PCIAFSR_PTA |
|
1454 |
|
|
SCHIZO_PCIAFSR_PRTRY | SCHIZO_PCIAFSR_PPERR |
|
1455 |
|
|
SCHIZO_PCIAFSR_PTTO | SCHIZO_PCIAFSR_PUNUS |
|
1456 |
|
|
SCHIZO_PCIAFSR_SMA | SCHIZO_PCIAFSR_STA |
|
1457 |
|
|
SCHIZO_PCIAFSR_SRTRY | SCHIZO_PCIAFSR_SPERR |
|
1458 |
|
|
SCHIZO_PCIAFSR_STTO | SCHIZO_PCIAFSR_SUNUS));
|
1459 |
|
|
|
1460 |
|
|
/* Make all Safari error conditions fatal except unmapped
|
1461 |
|
|
* errors which we make generate interrupts.
|
1462 |
|
|
*/
|
1463 |
|
|
err_mask = (BUS_ERROR_BADCMD | BUS_ERROR_SSMDIS |
|
1464 |
|
|
BUS_ERROR_BADMA | BUS_ERROR_BADMB |
|
1465 |
|
|
BUS_ERROR_BADMC |
|
1466 |
|
|
BUS_ERROR_CPU1PS | BUS_ERROR_CPU1PB |
|
1467 |
|
|
BUS_ERROR_CPU0PS | BUS_ERROR_CPU0PB |
|
1468 |
|
|
BUS_ERROR_CIQTO |
|
1469 |
|
|
BUS_ERROR_LPQTO | BUS_ERROR_SFPQTO |
|
1470 |
|
|
BUS_ERROR_UFPQTO | BUS_ERROR_APERR |
|
1471 |
|
|
BUS_ERROR_BUSERR | BUS_ERROR_TIMEOUT |
|
1472 |
|
|
BUS_ERROR_ILL);
|
1473 |
|
|
#if 1
|
1474 |
|
|
/* XXX Something wrong with some Excalibur systems
|
1475 |
|
|
* XXX Sun is shipping. The behavior on a 2-cpu
|
1476 |
|
|
* XXX machine is that both CPU1 parity error bits
|
1477 |
|
|
* XXX are set and are immediately set again when
|
1478 |
|
|
* XXX their error status bits are cleared. Just
|
1479 |
|
|
* XXX ignore them for now. -DaveM
|
1480 |
|
|
*/
|
1481 |
|
|
err_mask &= ~(BUS_ERROR_CPU1PS | BUS_ERROR_CPU1PB |
|
1482 |
|
|
BUS_ERROR_CPU0PS | BUS_ERROR_CPU0PB);
|
1483 |
|
|
#endif
|
1484 |
|
|
|
1485 |
|
|
schizo_write(p->pbm_A.controller_regs + SCHIZO_SAFARI_ERRCTRL,
|
1486 |
|
|
(SCHIZO_SAFERRCTRL_EN | err_mask));
|
1487 |
|
|
|
1488 |
|
|
schizo_write(p->pbm_A.controller_regs + SCHIZO_SAFARI_IRQCTRL,
|
1489 |
|
|
(SCHIZO_SAFIRQCTRL_EN | (BUS_ERROR_UNMAP)));
|
1490 |
|
|
}
|
1491 |
|
|
|
1492 |
|
|
/* We have to do the config space accesses by hand, thus... */
|
1493 |
|
|
static void __init pbm_renumber(struct pci_pbm_info *pbm, u8 orig_busno)
|
1494 |
|
|
{
|
1495 |
|
|
u8 busno;
|
1496 |
|
|
int nbus;
|
1497 |
|
|
|
1498 |
|
|
busno = pci_highest_busnum;
|
1499 |
|
|
nbus = pbm->pci_last_busno - pbm->pci_first_busno;
|
1500 |
|
|
|
1501 |
|
|
pbm->pci_first_busno = busno;
|
1502 |
|
|
pbm->pci_last_busno = busno + nbus;
|
1503 |
|
|
pci_highest_busnum = busno + nbus + 1;
|
1504 |
|
|
|
1505 |
|
|
do {
|
1506 |
|
|
pci_bus2pbm[busno++] = pbm;
|
1507 |
|
|
} while (nbus--);
|
1508 |
|
|
}
|
1509 |
|
|
|
1510 |
|
|
static void __init pbm_bridge_reconfigure(struct pci_controller_info *p)
|
1511 |
|
|
{
|
1512 |
|
|
/* Now we can safely renumber both PBMs. */
|
1513 |
|
|
pbm_renumber(&p->pbm_B, p->pbm_B.pci_first_busno);
|
1514 |
|
|
pbm_renumber(&p->pbm_A, 0xff);
|
1515 |
|
|
}
|
1516 |
|
|
|
1517 |
|
|
static void __init pbm_config_busmastering(struct pci_pbm_info *pbm)
|
1518 |
|
|
{
|
1519 |
|
|
u8 *addr;
|
1520 |
|
|
|
1521 |
|
|
/* Set cache-line size to 64 bytes, this is actually
|
1522 |
|
|
* a nop but I do it for completeness.
|
1523 |
|
|
*/
|
1524 |
|
|
addr = schizo_pci_config_mkaddr(pbm, pbm->pci_first_busno,
|
1525 |
|
|
0, PCI_CACHE_LINE_SIZE);
|
1526 |
|
|
pci_config_write8(addr, 64 / sizeof(u32));
|
1527 |
|
|
|
1528 |
|
|
/* Set PBM latency timer to 64 PCI clocks. */
|
1529 |
|
|
addr = schizo_pci_config_mkaddr(pbm, pbm->pci_first_busno,
|
1530 |
|
|
0, PCI_LATENCY_TIMER);
|
1531 |
|
|
pci_config_write8(addr, 64);
|
1532 |
|
|
}
|
1533 |
|
|
|
1534 |
|
|
static void __init pbm_scan_bus(struct pci_controller_info *p,
|
1535 |
|
|
struct pci_pbm_info *pbm)
|
1536 |
|
|
{
|
1537 |
|
|
struct pcidev_cookie *cookie = kmalloc(sizeof(*cookie), GFP_KERNEL);
|
1538 |
|
|
|
1539 |
|
|
if (!cookie) {
|
1540 |
|
|
prom_printf("%s: Critical allocation failure.\n", pbm->name);
|
1541 |
|
|
prom_halt();
|
1542 |
|
|
}
|
1543 |
|
|
|
1544 |
|
|
/* All we care about is the PBM. */
|
1545 |
|
|
memset(cookie, 0, sizeof(*cookie));
|
1546 |
|
|
cookie->pbm = pbm;
|
1547 |
|
|
|
1548 |
|
|
pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno,
|
1549 |
|
|
p->pci_ops,
|
1550 |
|
|
pbm);
|
1551 |
|
|
pci_fixup_host_bridge_self(pbm->pci_bus);
|
1552 |
|
|
pbm->pci_bus->self->sysdata = cookie;
|
1553 |
|
|
|
1554 |
|
|
pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node);
|
1555 |
|
|
pci_record_assignments(pbm, pbm->pci_bus);
|
1556 |
|
|
pci_assign_unassigned(pbm, pbm->pci_bus);
|
1557 |
|
|
pci_fixup_irq(pbm, pbm->pci_bus);
|
1558 |
|
|
pci_determine_66mhz_disposition(pbm, pbm->pci_bus);
|
1559 |
|
|
pci_setup_busmastering(pbm, pbm->pci_bus);
|
1560 |
|
|
}
|
1561 |
|
|
|
1562 |
|
|
static void __init __schizo_scan_bus(struct pci_controller_info *p,
|
1563 |
|
|
int chip_type)
|
1564 |
|
|
{
|
1565 |
|
|
if (!p->pbm_B.prom_node || !p->pbm_A.prom_node) {
|
1566 |
|
|
printk("PCI: Only one PCI bus module of controller found.\n");
|
1567 |
|
|
printk("PCI: Ignoring entire controller.\n");
|
1568 |
|
|
return;
|
1569 |
|
|
}
|
1570 |
|
|
|
1571 |
|
|
pbm_bridge_reconfigure(p);
|
1572 |
|
|
pbm_config_busmastering(&p->pbm_B);
|
1573 |
|
|
p->pbm_B.is_66mhz_capable =
|
1574 |
|
|
prom_getbool(p->pbm_B.prom_node, "66mhz-capable");
|
1575 |
|
|
pbm_config_busmastering(&p->pbm_A);
|
1576 |
|
|
p->pbm_A.is_66mhz_capable =
|
1577 |
|
|
prom_getbool(p->pbm_A.prom_node, "66mhz-capable");
|
1578 |
|
|
pbm_scan_bus(p, &p->pbm_B);
|
1579 |
|
|
pbm_scan_bus(p, &p->pbm_A);
|
1580 |
|
|
|
1581 |
|
|
/* After the PCI bus scan is complete, we can register
|
1582 |
|
|
* the error interrupt handlers.
|
1583 |
|
|
*/
|
1584 |
|
|
if (chip_type == PBM_CHIP_TYPE_TOMATILLO)
|
1585 |
|
|
tomatillo_register_error_handlers(p);
|
1586 |
|
|
else
|
1587 |
|
|
schizo_register_error_handlers(p);
|
1588 |
|
|
}
|
1589 |
|
|
|
1590 |
|
|
static void __init schizo_scan_bus(struct pci_controller_info *p)
|
1591 |
|
|
{
|
1592 |
|
|
__schizo_scan_bus(p, PBM_CHIP_TYPE_SCHIZO);
|
1593 |
|
|
}
|
1594 |
|
|
|
1595 |
|
|
static void __init tomatillo_scan_bus(struct pci_controller_info *p)
|
1596 |
|
|
{
|
1597 |
|
|
__schizo_scan_bus(p, PBM_CHIP_TYPE_TOMATILLO);
|
1598 |
|
|
}
|
1599 |
|
|
|
1600 |
|
|
static void __init schizo_base_address_update(struct pci_dev *pdev, int resource)
|
1601 |
|
|
{
|
1602 |
|
|
struct pcidev_cookie *pcp = pdev->sysdata;
|
1603 |
|
|
struct pci_pbm_info *pbm = pcp->pbm;
|
1604 |
|
|
struct resource *res, *root;
|
1605 |
|
|
u32 reg;
|
1606 |
|
|
int where, size, is_64bit;
|
1607 |
|
|
|
1608 |
|
|
res = &pdev->resource[resource];
|
1609 |
|
|
if (resource < 6) {
|
1610 |
|
|
where = PCI_BASE_ADDRESS_0 + (resource * 4);
|
1611 |
|
|
} else if (resource == PCI_ROM_RESOURCE) {
|
1612 |
|
|
where = pdev->rom_base_reg;
|
1613 |
|
|
} else {
|
1614 |
|
|
/* Somebody might have asked allocation of a non-standard resource */
|
1615 |
|
|
return;
|
1616 |
|
|
}
|
1617 |
|
|
|
1618 |
|
|
is_64bit = 0;
|
1619 |
|
|
if (res->flags & IORESOURCE_IO)
|
1620 |
|
|
root = &pbm->io_space;
|
1621 |
|
|
else {
|
1622 |
|
|
root = &pbm->mem_space;
|
1623 |
|
|
if ((res->flags & PCI_BASE_ADDRESS_MEM_TYPE_MASK)
|
1624 |
|
|
== PCI_BASE_ADDRESS_MEM_TYPE_64)
|
1625 |
|
|
is_64bit = 1;
|
1626 |
|
|
}
|
1627 |
|
|
|
1628 |
|
|
size = res->end - res->start;
|
1629 |
|
|
pci_read_config_dword(pdev, where, ®);
|
1630 |
|
|
reg = ((reg & size) |
|
1631 |
|
|
(((u32)(res->start - root->start)) & ~size));
|
1632 |
|
|
if (resource == PCI_ROM_RESOURCE) {
|
1633 |
|
|
reg |= PCI_ROM_ADDRESS_ENABLE;
|
1634 |
|
|
res->flags |= PCI_ROM_ADDRESS_ENABLE;
|
1635 |
|
|
}
|
1636 |
|
|
pci_write_config_dword(pdev, where, reg);
|
1637 |
|
|
|
1638 |
|
|
/* This knows that the upper 32-bits of the address
|
1639 |
|
|
* must be zero. Our PCI common layer enforces this.
|
1640 |
|
|
*/
|
1641 |
|
|
if (is_64bit)
|
1642 |
|
|
pci_write_config_dword(pdev, where + 4, 0);
|
1643 |
|
|
}
|
1644 |
|
|
|
1645 |
|
|
static void __init schizo_resource_adjust(struct pci_dev *pdev,
|
1646 |
|
|
struct resource *res,
|
1647 |
|
|
struct resource *root)
|
1648 |
|
|
{
|
1649 |
|
|
res->start += root->start;
|
1650 |
|
|
res->end += root->start;
|
1651 |
|
|
}
|
1652 |
|
|
|
1653 |
|
|
/* Use ranges property to determine where PCI MEM, I/O, and Config
|
1654 |
|
|
* space are for this PCI bus module.
|
1655 |
|
|
*/
|
1656 |
|
|
static void schizo_determine_mem_io_space(struct pci_pbm_info *pbm)
|
1657 |
|
|
{
|
1658 |
|
|
int i, saw_cfg, saw_mem, saw_io;
|
1659 |
|
|
|
1660 |
|
|
saw_cfg = saw_mem = saw_io = 0;
|
1661 |
|
|
for (i = 0; i < pbm->num_pbm_ranges; i++) {
|
1662 |
|
|
struct linux_prom_pci_ranges *pr = &pbm->pbm_ranges[i];
|
1663 |
|
|
unsigned long a;
|
1664 |
|
|
int type;
|
1665 |
|
|
|
1666 |
|
|
type = (pr->child_phys_hi >> 24) & 0x3;
|
1667 |
|
|
a = (((unsigned long)pr->parent_phys_hi << 32UL) |
|
1668 |
|
|
((unsigned long)pr->parent_phys_lo << 0UL));
|
1669 |
|
|
|
1670 |
|
|
switch (type) {
|
1671 |
|
|
case 0:
|
1672 |
|
|
/* PCI config space, 16MB */
|
1673 |
|
|
pbm->config_space = a;
|
1674 |
|
|
saw_cfg = 1;
|
1675 |
|
|
break;
|
1676 |
|
|
|
1677 |
|
|
case 1:
|
1678 |
|
|
/* 16-bit IO space, 16MB */
|
1679 |
|
|
pbm->io_space.start = a;
|
1680 |
|
|
pbm->io_space.end = a + ((16UL*1024UL*1024UL) - 1UL);
|
1681 |
|
|
pbm->io_space.flags = IORESOURCE_IO;
|
1682 |
|
|
saw_io = 1;
|
1683 |
|
|
break;
|
1684 |
|
|
|
1685 |
|
|
case 2:
|
1686 |
|
|
/* 32-bit MEM space, 2GB */
|
1687 |
|
|
pbm->mem_space.start = a;
|
1688 |
|
|
pbm->mem_space.end = a + (0x80000000UL - 1UL);
|
1689 |
|
|
pbm->mem_space.flags = IORESOURCE_MEM;
|
1690 |
|
|
saw_mem = 1;
|
1691 |
|
|
break;
|
1692 |
|
|
|
1693 |
|
|
default:
|
1694 |
|
|
break;
|
1695 |
|
|
};
|
1696 |
|
|
}
|
1697 |
|
|
|
1698 |
|
|
if (!saw_cfg || !saw_io || !saw_mem) {
|
1699 |
|
|
prom_printf("%s: Fatal error, missing %s PBM range.\n",
|
1700 |
|
|
pbm->name,
|
1701 |
|
|
((!saw_cfg ?
|
1702 |
|
|
"CFG" :
|
1703 |
|
|
(!saw_io ?
|
1704 |
|
|
"IO" : "MEM"))));
|
1705 |
|
|
prom_halt();
|
1706 |
|
|
}
|
1707 |
|
|
|
1708 |
|
|
printk("%s: PCI CFG[%lx] IO[%lx] MEM[%lx]\n",
|
1709 |
|
|
pbm->name,
|
1710 |
|
|
pbm->config_space,
|
1711 |
|
|
pbm->io_space.start,
|
1712 |
|
|
pbm->mem_space.start);
|
1713 |
|
|
}
|
1714 |
|
|
|
1715 |
|
|
static void __init pbm_register_toplevel_resources(struct pci_controller_info *p,
|
1716 |
|
|
struct pci_pbm_info *pbm)
|
1717 |
|
|
{
|
1718 |
|
|
pbm->io_space.name = pbm->mem_space.name = pbm->name;
|
1719 |
|
|
|
1720 |
|
|
request_resource(&ioport_resource, &pbm->io_space);
|
1721 |
|
|
request_resource(&iomem_resource, &pbm->mem_space);
|
1722 |
|
|
pci_register_legacy_regions(&pbm->io_space,
|
1723 |
|
|
&pbm->mem_space);
|
1724 |
|
|
}
|
1725 |
|
|
|
1726 |
|
|
#define SCHIZO_STRBUF_CONTROL (0x02800UL)
|
1727 |
|
|
#define SCHIZO_STRBUF_FLUSH (0x02808UL)
|
1728 |
|
|
#define SCHIZO_STRBUF_FSYNC (0x02810UL)
|
1729 |
|
|
#define SCHIZO_STRBUF_CTXFLUSH (0x02818UL)
|
1730 |
|
|
#define SCHIZO_STRBUF_CTXMATCH (0x10000UL)
|
1731 |
|
|
|
1732 |
|
|
static void schizo_pbm_strbuf_init(struct pci_pbm_info *pbm)
|
1733 |
|
|
{
|
1734 |
|
|
unsigned long base = pbm->pbm_regs;
|
1735 |
|
|
u64 control;
|
1736 |
|
|
|
1737 |
|
|
if (pbm->chip_type == PBM_CHIP_TYPE_TOMATILLO) {
|
1738 |
|
|
/* TOMATILLO lacks streaming cache. */
|
1739 |
|
|
return;
|
1740 |
|
|
}
|
1741 |
|
|
|
1742 |
|
|
/* SCHIZO has context flushing. */
|
1743 |
|
|
pbm->stc.strbuf_control = base + SCHIZO_STRBUF_CONTROL;
|
1744 |
|
|
pbm->stc.strbuf_pflush = base + SCHIZO_STRBUF_FLUSH;
|
1745 |
|
|
pbm->stc.strbuf_fsync = base + SCHIZO_STRBUF_FSYNC;
|
1746 |
|
|
pbm->stc.strbuf_ctxflush = base + SCHIZO_STRBUF_CTXFLUSH;
|
1747 |
|
|
pbm->stc.strbuf_ctxmatch_base = base + SCHIZO_STRBUF_CTXMATCH;
|
1748 |
|
|
|
1749 |
|
|
pbm->stc.strbuf_flushflag = (volatile unsigned long *)
|
1750 |
|
|
((((unsigned long)&pbm->stc.__flushflag_buf[0])
|
1751 |
|
|
+ 63UL)
|
1752 |
|
|
& ~63UL);
|
1753 |
|
|
pbm->stc.strbuf_flushflag_pa = (unsigned long)
|
1754 |
|
|
__pa(pbm->stc.strbuf_flushflag);
|
1755 |
|
|
|
1756 |
|
|
/* Turn off LRU locking and diag mode, enable the
|
1757 |
|
|
* streaming buffer and leave the rerun-disable
|
1758 |
|
|
* setting however OBP set it.
|
1759 |
|
|
*/
|
1760 |
|
|
control = schizo_read(pbm->stc.strbuf_control);
|
1761 |
|
|
control &= ~(SCHIZO_STRBUF_CTRL_LPTR |
|
1762 |
|
|
SCHIZO_STRBUF_CTRL_LENAB |
|
1763 |
|
|
SCHIZO_STRBUF_CTRL_DENAB);
|
1764 |
|
|
control |= SCHIZO_STRBUF_CTRL_ENAB;
|
1765 |
|
|
schizo_write(pbm->stc.strbuf_control, control);
|
1766 |
|
|
|
1767 |
|
|
pbm->stc.strbuf_enabled = 1;
|
1768 |
|
|
}
|
1769 |
|
|
|
1770 |
|
|
#define SCHIZO_IOMMU_CONTROL (0x00200UL)
|
1771 |
|
|
#define SCHIZO_IOMMU_TSBBASE (0x00208UL)
|
1772 |
|
|
#define SCHIZO_IOMMU_FLUSH (0x00210UL)
|
1773 |
|
|
#define SCHIZO_IOMMU_CTXFLUSH (0x00218UL)
|
1774 |
|
|
|
1775 |
|
|
static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
|
1776 |
|
|
{
|
1777 |
|
|
struct pci_iommu *iommu = pbm->iommu;
|
1778 |
|
|
unsigned long tsbbase, i, tagbase, database, order;
|
1779 |
|
|
u32 vdma[2], dma_mask;
|
1780 |
|
|
u64 control;
|
1781 |
|
|
int err, tsbsize;
|
1782 |
|
|
|
1783 |
|
|
err = prom_getproperty(pbm->prom_node, "virtual-dma",
|
1784 |
|
|
(char *)&vdma[0], sizeof(vdma));
|
1785 |
|
|
if (err == 0 || err == -1) {
|
1786 |
|
|
/* No property, use default values. */
|
1787 |
|
|
vdma[0] = 0xc0000000;
|
1788 |
|
|
vdma[1] = 0x40000000;
|
1789 |
|
|
}
|
1790 |
|
|
|
1791 |
|
|
dma_mask = vdma[0];
|
1792 |
|
|
switch (vdma[1]) {
|
1793 |
|
|
case 0x20000000:
|
1794 |
|
|
dma_mask |= 0x1fffffff;
|
1795 |
|
|
tsbsize = 64;
|
1796 |
|
|
break;
|
1797 |
|
|
|
1798 |
|
|
case 0x40000000:
|
1799 |
|
|
dma_mask |= 0x3fffffff;
|
1800 |
|
|
tsbsize = 128;
|
1801 |
|
|
break;
|
1802 |
|
|
|
1803 |
|
|
case 0x80000000:
|
1804 |
|
|
dma_mask |= 0x7fffffff;
|
1805 |
|
|
tsbsize = 128;
|
1806 |
|
|
break;
|
1807 |
|
|
|
1808 |
|
|
default:
|
1809 |
|
|
prom_printf("SCHIZO: strange virtual-dma size.\n");
|
1810 |
|
|
prom_halt();
|
1811 |
|
|
};
|
1812 |
|
|
|
1813 |
|
|
/* Setup initial software IOMMU state. */
|
1814 |
|
|
spin_lock_init(&iommu->lock);
|
1815 |
|
|
iommu->iommu_cur_ctx = 0;
|
1816 |
|
|
|
1817 |
|
|
/* Register addresses, SCHIZO has iommu ctx flushing. */
|
1818 |
|
|
iommu->iommu_control = pbm->pbm_regs + SCHIZO_IOMMU_CONTROL;
|
1819 |
|
|
iommu->iommu_tsbbase = pbm->pbm_regs + SCHIZO_IOMMU_TSBBASE;
|
1820 |
|
|
iommu->iommu_flush = pbm->pbm_regs + SCHIZO_IOMMU_FLUSH;
|
1821 |
|
|
iommu->iommu_ctxflush = pbm->pbm_regs + SCHIZO_IOMMU_CTXFLUSH;
|
1822 |
|
|
|
1823 |
|
|
/* We use the main control/status register of SCHIZO as the write
|
1824 |
|
|
* completion register.
|
1825 |
|
|
*/
|
1826 |
|
|
iommu->write_complete_reg = pbm->controller_regs + 0x10000UL;
|
1827 |
|
|
|
1828 |
|
|
/*
|
1829 |
|
|
* Invalidate TLB Entries.
|
1830 |
|
|
*/
|
1831 |
|
|
control = schizo_read(iommu->iommu_control);
|
1832 |
|
|
control |= SCHIZO_IOMMU_CTRL_DENAB;
|
1833 |
|
|
schizo_write(iommu->iommu_control, control);
|
1834 |
|
|
|
1835 |
|
|
tagbase = SCHIZO_IOMMU_TAG, database = SCHIZO_IOMMU_DATA;
|
1836 |
|
|
|
1837 |
|
|
for(i = 0; i < 16; i++) {
|
1838 |
|
|
schizo_write(pbm->pbm_regs + tagbase + (i * 8UL), 0);
|
1839 |
|
|
schizo_write(pbm->pbm_regs + database + (i * 8UL), 0);
|
1840 |
|
|
}
|
1841 |
|
|
|
1842 |
|
|
/* Leave diag mode enabled for full-flushing done
|
1843 |
|
|
* in pci_iommu.c
|
1844 |
|
|
*/
|
1845 |
|
|
|
1846 |
|
|
/* Using assumed page size 8K with 128K entries we need 1MB iommu page
|
1847 |
|
|
* table (128K ioptes * 8 bytes per iopte). This is
|
1848 |
|
|
* page order 7 on UltraSparc.
|
1849 |
|
|
*/
|
1850 |
|
|
order = get_order(tsbsize * 8 * 1024);
|
1851 |
|
|
tsbbase = __get_free_pages(GFP_KERNEL, order);
|
1852 |
|
|
if (!tsbbase) {
|
1853 |
|
|
prom_printf("%s: Error, gfp(tsb) failed.\n", pbm->name);
|
1854 |
|
|
prom_halt();
|
1855 |
|
|
}
|
1856 |
|
|
|
1857 |
|
|
iommu->page_table = (iopte_t *)tsbbase;
|
1858 |
|
|
iommu->page_table_map_base = vdma[0];
|
1859 |
|
|
iommu->dma_addr_mask = dma_mask;
|
1860 |
|
|
memset((char *)tsbbase, 0, PAGE_SIZE << order);
|
1861 |
|
|
|
1862 |
|
|
switch (tsbsize) {
|
1863 |
|
|
case 64:
|
1864 |
|
|
iommu->page_table_sz_bits = 16;
|
1865 |
|
|
break;
|
1866 |
|
|
|
1867 |
|
|
case 128:
|
1868 |
|
|
iommu->page_table_sz_bits = 17;
|
1869 |
|
|
break;
|
1870 |
|
|
|
1871 |
|
|
default:
|
1872 |
|
|
prom_printf("iommu_init: Illegal TSB size %d\n", tsbsize);
|
1873 |
|
|
prom_halt();
|
1874 |
|
|
break;
|
1875 |
|
|
};
|
1876 |
|
|
|
1877 |
|
|
/* We start with no consistent mappings. */
|
1878 |
|
|
iommu->lowest_consistent_map =
|
1879 |
|
|
1 << (iommu->page_table_sz_bits - PBM_LOGCLUSTERS);
|
1880 |
|
|
|
1881 |
|
|
for (i = 0; i < PBM_NCLUSTERS; i++) {
|
1882 |
|
|
iommu->alloc_info[i].flush = 0;
|
1883 |
|
|
iommu->alloc_info[i].next = 0;
|
1884 |
|
|
}
|
1885 |
|
|
|
1886 |
|
|
schizo_write(iommu->iommu_tsbbase, __pa(tsbbase));
|
1887 |
|
|
|
1888 |
|
|
control = schizo_read(iommu->iommu_control);
|
1889 |
|
|
control &= ~(SCHIZO_IOMMU_CTRL_TSBSZ | SCHIZO_IOMMU_CTRL_TBWSZ);
|
1890 |
|
|
switch (tsbsize) {
|
1891 |
|
|
case 64:
|
1892 |
|
|
control |= SCHIZO_IOMMU_TSBSZ_64K;
|
1893 |
|
|
break;
|
1894 |
|
|
case 128:
|
1895 |
|
|
control |= SCHIZO_IOMMU_TSBSZ_128K;
|
1896 |
|
|
break;
|
1897 |
|
|
};
|
1898 |
|
|
|
1899 |
|
|
control |= SCHIZO_IOMMU_CTRL_ENAB;
|
1900 |
|
|
schizo_write(iommu->iommu_control, control);
|
1901 |
|
|
}
|
1902 |
|
|
|
1903 |
|
|
#define SCHIZO_PCI_IRQ_RETRY (0x1a00UL)
|
1904 |
|
|
#define SCHIZO_IRQ_RETRY_INF 0xffUL
|
1905 |
|
|
|
1906 |
|
|
#define SCHIZO_PCI_DIAG (0x2020UL)
|
1907 |
|
|
#define SCHIZO_PCIDIAG_D_BADECC (1UL << 10UL) /* Disable BAD ECC errors (Schizo) */
|
1908 |
|
|
#define SCHIZO_PCIDIAG_D_BYPASS (1UL << 9UL) /* Disable MMU bypass mode (Schizo/Tomatillo) */
|
1909 |
|
|
#define SCHIZO_PCIDIAG_D_TTO (1UL << 8UL) /* Disable TTO errors (Schizo/Tomatillo) */
|
1910 |
|
|
#define SCHIZO_PCIDIAG_D_RTRYARB (1UL << 7UL) /* Disable retry arbitration (Schizo) */
|
1911 |
|
|
#define SCHIZO_PCIDIAG_D_RETRY (1UL << 6UL) /* Disable retry limit (Schizo/Tomatillo) */
|
1912 |
|
|
#define SCHIZO_PCIDIAG_D_INTSYNC (1UL << 5UL) /* Disable interrupt/DMA synch (Schizo/Tomatillo) */
|
1913 |
|
|
#define SCHIZO_PCIDIAG_I_DMA_PARITY (1UL << 3UL) /* Invert DMA parity (Schizo/Tomatillo) */
|
1914 |
|
|
#define SCHIZO_PCIDIAG_I_PIOD_PARITY (1UL << 2UL) /* Invert PIO data parity (Schizo/Tomatillo) */
|
1915 |
|
|
#define SCHIZO_PCIDIAG_I_PIOA_PARITY (1UL << 1UL) /* Invert PIO address parity (Schizo/Tomatillo) */
|
1916 |
|
|
|
1917 |
|
|
#define TOMATILLO_PCI_IOC_CSR (0x2248UL)
|
1918 |
|
|
#define TOMATILLO_IOC_PART_WPENAB 0x0000000000080000UL
|
1919 |
|
|
#define TOMATILLO_IOC_RDMULT_PENAB 0x0000000000040000UL
|
1920 |
|
|
#define TOMATILLO_IOC_RDONE_PENAB 0x0000000000020000UL
|
1921 |
|
|
#define TOMATILLO_IOC_RDLINE_PENAB 0x0000000000010000UL
|
1922 |
|
|
#define TOMATILLO_IOC_RDMULT_PLEN 0x000000000000c000UL
|
1923 |
|
|
#define TOMATILLO_IOC_RDMULT_PLEN_SHIFT 14UL
|
1924 |
|
|
#define TOMATILLO_IOC_RDONE_PLEN 0x0000000000003000UL
|
1925 |
|
|
#define TOMATILLO_IOC_RDONE_PLEN_SHIFT 12UL
|
1926 |
|
|
#define TOMATILLO_IOC_RDLINE_PLEN 0x0000000000000c00UL
|
1927 |
|
|
#define TOMATILLO_IOC_RDLINE_PLEN_SHIFT 10UL
|
1928 |
|
|
#define TOMATILLO_IOC_PREF_OFF 0x00000000000003f8UL
|
1929 |
|
|
#define TOMATILLO_IOC_PREF_OFF_SHIFT 3UL
|
1930 |
|
|
#define TOMATILLO_IOC_RDMULT_CPENAB 0x0000000000000004UL
|
1931 |
|
|
#define TOMATILLO_IOC_RDONE_CPENAB 0x0000000000000002UL
|
1932 |
|
|
#define TOMATILLO_IOC_RDLINE_CPENAB 0x0000000000000001UL
|
1933 |
|
|
|
1934 |
|
|
#define TOMATILLO_PCI_IOC_TDIAG (0x2250UL)
|
1935 |
|
|
#define TOMATILLO_PCI_IOC_DDIAG (0x2290UL)
|
1936 |
|
|
|
1937 |
|
|
static void __init schizo_pbm_hw_init(struct pci_pbm_info *pbm)
|
1938 |
|
|
{
|
1939 |
|
|
u64 tmp;
|
1940 |
|
|
|
1941 |
|
|
/* Set IRQ retry to infinity. */
|
1942 |
|
|
schizo_write(pbm->pbm_regs + SCHIZO_PCI_IRQ_RETRY,
|
1943 |
|
|
SCHIZO_IRQ_RETRY_INF);
|
1944 |
|
|
|
1945 |
|
|
/* Enable arbiter for all PCI slots. Also, disable PCI interval
|
1946 |
|
|
* timer so that DTO (Discard TimeOuts) are not reported because
|
1947 |
|
|
* some Schizo revisions report them erroneously.
|
1948 |
|
|
*/
|
1949 |
|
|
tmp = schizo_read(pbm->pbm_regs + SCHIZO_PCI_CTRL);
|
1950 |
|
|
if (pbm->chip_type == PBM_CHIP_TYPE_SCHIZO_PLUS &&
|
1951 |
|
|
pbm->chip_version == 0x5 &&
|
1952 |
|
|
pbm->chip_revision == 0x1)
|
1953 |
|
|
tmp |= 0x0f;
|
1954 |
|
|
else
|
1955 |
|
|
tmp |= 0xff;
|
1956 |
|
|
|
1957 |
|
|
tmp &= ~SCHIZO_PCICTRL_PTO;
|
1958 |
|
|
if (pbm->chip_type == PBM_CHIP_TYPE_TOMATILLO &&
|
1959 |
|
|
pbm->chip_version == 0x2)
|
1960 |
|
|
tmp |= 0x3UL << SCHIZO_PCICTRL_PTO_SHIFT;
|
1961 |
|
|
else
|
1962 |
|
|
tmp |= 0x1UL << SCHIZO_PCICTRL_PTO_SHIFT;
|
1963 |
|
|
|
1964 |
|
|
if (!prom_getbool(pbm->prom_node, "no-bus-parking"))
|
1965 |
|
|
tmp |= SCHIZO_PCICTRL_PARK;
|
1966 |
|
|
|
1967 |
|
|
if (pbm->chip_type == PBM_CHIP_TYPE_TOMATILLO)
|
1968 |
|
|
tmp |= SCHIZO_PCICTRL_MRM_PREF;
|
1969 |
|
|
|
1970 |
|
|
schizo_write(pbm->pbm_regs + SCHIZO_PCI_CTRL, tmp);
|
1971 |
|
|
|
1972 |
|
|
tmp = schizo_read(pbm->pbm_regs + SCHIZO_PCI_DIAG);
|
1973 |
|
|
tmp &= ~(SCHIZO_PCIDIAG_D_RTRYARB |
|
1974 |
|
|
SCHIZO_PCIDIAG_D_RETRY |
|
1975 |
|
|
SCHIZO_PCIDIAG_D_INTSYNC);
|
1976 |
|
|
schizo_write(pbm->pbm_regs + SCHIZO_PCI_DIAG, tmp);
|
1977 |
|
|
|
1978 |
|
|
if (pbm->chip_type == PBM_CHIP_TYPE_TOMATILLO) {
|
1979 |
|
|
/* Clear prefetch lengths to workaround a bug in
|
1980 |
|
|
* Jalapeno...
|
1981 |
|
|
*/
|
1982 |
|
|
tmp = (TOMATILLO_IOC_PART_WPENAB |
|
1983 |
|
|
(1 << TOMATILLO_IOC_PREF_OFF_SHIFT) |
|
1984 |
|
|
TOMATILLO_IOC_RDMULT_CPENAB |
|
1985 |
|
|
TOMATILLO_IOC_RDONE_CPENAB |
|
1986 |
|
|
TOMATILLO_IOC_RDLINE_CPENAB);
|
1987 |
|
|
|
1988 |
|
|
schizo_write(pbm->pbm_regs + TOMATILLO_PCI_IOC_CSR,
|
1989 |
|
|
tmp);
|
1990 |
|
|
}
|
1991 |
|
|
}
|
1992 |
|
|
|
1993 |
|
|
static void __init schizo_pbm_init(struct pci_controller_info *p,
|
1994 |
|
|
int prom_node, u32 portid,
|
1995 |
|
|
int chip_type)
|
1996 |
|
|
{
|
1997 |
|
|
struct linux_prom64_registers pr_regs[4];
|
1998 |
|
|
unsigned int busrange[2];
|
1999 |
|
|
struct pci_pbm_info *pbm;
|
2000 |
|
|
const char *chipset_name;
|
2001 |
|
|
u32 ino_bitmap[2];
|
2002 |
|
|
int is_pbm_a;
|
2003 |
|
|
int err;
|
2004 |
|
|
|
2005 |
|
|
switch (chip_type) {
|
2006 |
|
|
case PBM_CHIP_TYPE_TOMATILLO:
|
2007 |
|
|
chipset_name = "TOMATILLO";
|
2008 |
|
|
break;
|
2009 |
|
|
|
2010 |
|
|
case PBM_CHIP_TYPE_SCHIZO_PLUS:
|
2011 |
|
|
chipset_name = "SCHIZO+";
|
2012 |
|
|
break;
|
2013 |
|
|
|
2014 |
|
|
case PBM_CHIP_TYPE_SCHIZO:
|
2015 |
|
|
default:
|
2016 |
|
|
chipset_name = "SCHIZO";
|
2017 |
|
|
break;
|
2018 |
|
|
};
|
2019 |
|
|
|
2020 |
|
|
/* For SCHIZO, three OBP regs:
|
2021 |
|
|
* 1) PBM controller regs
|
2022 |
|
|
* 2) Schizo front-end controller regs (same for both PBMs)
|
2023 |
|
|
* 3) PBM PCI config space
|
2024 |
|
|
*
|
2025 |
|
|
* For TOMATILLO, four OBP regs:
|
2026 |
|
|
* 1) PBM controller regs
|
2027 |
|
|
* 2) Tomatillo front-end controller regs
|
2028 |
|
|
* 3) PBM PCI config space
|
2029 |
|
|
* 4) Ichip regs
|
2030 |
|
|
*/
|
2031 |
|
|
err = prom_getproperty(prom_node, "reg",
|
2032 |
|
|
(char *)&pr_regs[0],
|
2033 |
|
|
sizeof(pr_regs));
|
2034 |
|
|
if (err == 0 || err == -1) {
|
2035 |
|
|
prom_printf("%s: Fatal error, no reg property.\n",
|
2036 |
|
|
chipset_name);
|
2037 |
|
|
prom_halt();
|
2038 |
|
|
}
|
2039 |
|
|
|
2040 |
|
|
is_pbm_a = ((pr_regs[0].phys_addr & 0x00700000) == 0x00600000);
|
2041 |
|
|
|
2042 |
|
|
if (is_pbm_a)
|
2043 |
|
|
pbm = &p->pbm_A;
|
2044 |
|
|
else
|
2045 |
|
|
pbm = &p->pbm_B;
|
2046 |
|
|
|
2047 |
|
|
pbm->portid = portid;
|
2048 |
|
|
pbm->parent = p;
|
2049 |
|
|
pbm->prom_node = prom_node;
|
2050 |
|
|
pbm->pci_first_slot = 1;
|
2051 |
|
|
|
2052 |
|
|
pbm->chip_type = chip_type;
|
2053 |
|
|
pbm->chip_version =
|
2054 |
|
|
prom_getintdefault(prom_node, "version#", 0);
|
2055 |
|
|
pbm->chip_revision =
|
2056 |
|
|
prom_getintdefault(prom_node, "module-revision#", 0);
|
2057 |
|
|
|
2058 |
|
|
pbm->pbm_regs = pr_regs[0].phys_addr;
|
2059 |
|
|
pbm->controller_regs = pr_regs[1].phys_addr - 0x10000UL;
|
2060 |
|
|
|
2061 |
|
|
sprintf(pbm->name,
|
2062 |
|
|
(chip_type == PBM_CHIP_TYPE_TOMATILLO ?
|
2063 |
|
|
"TOMATILLO%d PBM%c" :
|
2064 |
|
|
"SCHIZO%d PBM%c"),
|
2065 |
|
|
p->index,
|
2066 |
|
|
(pbm == &p->pbm_A ? 'A' : 'B'));
|
2067 |
|
|
|
2068 |
|
|
printk("%s: ver[%x:%x], portid %x, "
|
2069 |
|
|
"cregs[%lx] pregs[%lx]\n",
|
2070 |
|
|
pbm->name,
|
2071 |
|
|
pbm->chip_version, pbm->chip_revision,
|
2072 |
|
|
pbm->portid,
|
2073 |
|
|
pbm->controller_regs,
|
2074 |
|
|
pbm->pbm_regs);
|
2075 |
|
|
|
2076 |
|
|
schizo_pbm_hw_init(pbm);
|
2077 |
|
|
|
2078 |
|
|
prom_getstring(prom_node, "name",
|
2079 |
|
|
pbm->prom_name,
|
2080 |
|
|
sizeof(pbm->prom_name));
|
2081 |
|
|
|
2082 |
|
|
err = prom_getproperty(prom_node, "ranges",
|
2083 |
|
|
(char *) pbm->pbm_ranges,
|
2084 |
|
|
sizeof(pbm->pbm_ranges));
|
2085 |
|
|
if (err == 0 || err == -1) {
|
2086 |
|
|
prom_printf("%s: Fatal error, no ranges property.\n",
|
2087 |
|
|
pbm->name);
|
2088 |
|
|
prom_halt();
|
2089 |
|
|
}
|
2090 |
|
|
|
2091 |
|
|
pbm->num_pbm_ranges =
|
2092 |
|
|
(err / sizeof(struct linux_prom_pci_ranges));
|
2093 |
|
|
|
2094 |
|
|
schizo_determine_mem_io_space(pbm);
|
2095 |
|
|
pbm_register_toplevel_resources(p, pbm);
|
2096 |
|
|
|
2097 |
|
|
err = prom_getproperty(prom_node, "interrupt-map",
|
2098 |
|
|
(char *)pbm->pbm_intmap,
|
2099 |
|
|
sizeof(pbm->pbm_intmap));
|
2100 |
|
|
if (err != -1) {
|
2101 |
|
|
pbm->num_pbm_intmap = (err / sizeof(struct linux_prom_pci_intmap));
|
2102 |
|
|
err = prom_getproperty(prom_node, "interrupt-map-mask",
|
2103 |
|
|
(char *)&pbm->pbm_intmask,
|
2104 |
|
|
sizeof(pbm->pbm_intmask));
|
2105 |
|
|
if (err == -1) {
|
2106 |
|
|
prom_printf("%s: Fatal error, no "
|
2107 |
|
|
"interrupt-map-mask.\n", pbm->name);
|
2108 |
|
|
prom_halt();
|
2109 |
|
|
}
|
2110 |
|
|
} else {
|
2111 |
|
|
pbm->num_pbm_intmap = 0;
|
2112 |
|
|
memset(&pbm->pbm_intmask, 0, sizeof(pbm->pbm_intmask));
|
2113 |
|
|
}
|
2114 |
|
|
|
2115 |
|
|
err = prom_getproperty(prom_node, "ino-bitmap",
|
2116 |
|
|
(char *) &ino_bitmap[0],
|
2117 |
|
|
sizeof(ino_bitmap));
|
2118 |
|
|
if (err == 0 || err == -1) {
|
2119 |
|
|
prom_printf("%s: Fatal error, no ino-bitmap.\n", pbm->name);
|
2120 |
|
|
prom_halt();
|
2121 |
|
|
}
|
2122 |
|
|
pbm->ino_bitmap = (((u64)ino_bitmap[1] << 32UL) |
|
2123 |
|
|
((u64)ino_bitmap[0] << 0UL));
|
2124 |
|
|
|
2125 |
|
|
err = prom_getproperty(prom_node, "bus-range",
|
2126 |
|
|
(char *)&busrange[0],
|
2127 |
|
|
sizeof(busrange));
|
2128 |
|
|
if (err == 0 || err == -1) {
|
2129 |
|
|
prom_printf("%s: Fatal error, no bus-range.\n", pbm->name);
|
2130 |
|
|
prom_halt();
|
2131 |
|
|
}
|
2132 |
|
|
pbm->pci_first_busno = busrange[0];
|
2133 |
|
|
pbm->pci_last_busno = busrange[1];
|
2134 |
|
|
|
2135 |
|
|
schizo_pbm_iommu_init(pbm);
|
2136 |
|
|
schizo_pbm_strbuf_init(pbm);
|
2137 |
|
|
}
|
2138 |
|
|
|
2139 |
|
|
static inline int portid_compare(u32 x, u32 y, int chip_type)
|
2140 |
|
|
{
|
2141 |
|
|
if (chip_type == PBM_CHIP_TYPE_TOMATILLO) {
|
2142 |
|
|
if (x == (y ^ 1))
|
2143 |
|
|
return 1;
|
2144 |
|
|
return 0;
|
2145 |
|
|
}
|
2146 |
|
|
return (x == y);
|
2147 |
|
|
}
|
2148 |
|
|
|
2149 |
|
|
static void __init __schizo_init(int node, char *model_name, int chip_type)
|
2150 |
|
|
{
|
2151 |
|
|
struct pci_controller_info *p;
|
2152 |
|
|
struct pci_iommu *iommu;
|
2153 |
|
|
unsigned long flags;
|
2154 |
|
|
int is_pbm_a;
|
2155 |
|
|
u32 portid;
|
2156 |
|
|
|
2157 |
|
|
portid = prom_getintdefault(node, "portid", 0xff);
|
2158 |
|
|
|
2159 |
|
|
spin_lock_irqsave(&pci_controller_lock, flags);
|
2160 |
|
|
for(p = pci_controller_root; p; p = p->next) {
|
2161 |
|
|
struct pci_pbm_info *pbm;
|
2162 |
|
|
|
2163 |
|
|
if (p->pbm_A.prom_node && p->pbm_B.prom_node)
|
2164 |
|
|
continue;
|
2165 |
|
|
|
2166 |
|
|
pbm = (p->pbm_A.prom_node ?
|
2167 |
|
|
&p->pbm_A :
|
2168 |
|
|
&p->pbm_B);
|
2169 |
|
|
|
2170 |
|
|
if (portid_compare(pbm->portid, portid, chip_type)) {
|
2171 |
|
|
spin_unlock_irqrestore(&pci_controller_lock, flags);
|
2172 |
|
|
is_pbm_a = (p->pbm_A.prom_node == 0);
|
2173 |
|
|
schizo_pbm_init(p, node, portid, chip_type);
|
2174 |
|
|
return;
|
2175 |
|
|
}
|
2176 |
|
|
}
|
2177 |
|
|
spin_unlock_irqrestore(&pci_controller_lock, flags);
|
2178 |
|
|
|
2179 |
|
|
p = kmalloc(sizeof(struct pci_controller_info), GFP_ATOMIC);
|
2180 |
|
|
if (!p) {
|
2181 |
|
|
prom_printf("SCHIZO: Fatal memory allocation error.\n");
|
2182 |
|
|
prom_halt();
|
2183 |
|
|
}
|
2184 |
|
|
memset(p, 0, sizeof(*p));
|
2185 |
|
|
|
2186 |
|
|
iommu = kmalloc(sizeof(struct pci_iommu), GFP_ATOMIC);
|
2187 |
|
|
if (!iommu) {
|
2188 |
|
|
prom_printf("SCHIZO: Fatal memory allocation error.\n");
|
2189 |
|
|
prom_halt();
|
2190 |
|
|
}
|
2191 |
|
|
memset(iommu, 0, sizeof(*iommu));
|
2192 |
|
|
p->pbm_A.iommu = iommu;
|
2193 |
|
|
|
2194 |
|
|
iommu = kmalloc(sizeof(struct pci_iommu), GFP_ATOMIC);
|
2195 |
|
|
if (!iommu) {
|
2196 |
|
|
prom_printf("SCHIZO: Fatal memory allocation error.\n");
|
2197 |
|
|
prom_halt();
|
2198 |
|
|
}
|
2199 |
|
|
memset(iommu, 0, sizeof(*iommu));
|
2200 |
|
|
p->pbm_B.iommu = iommu;
|
2201 |
|
|
|
2202 |
|
|
spin_lock_irqsave(&pci_controller_lock, flags);
|
2203 |
|
|
p->next = pci_controller_root;
|
2204 |
|
|
pci_controller_root = p;
|
2205 |
|
|
spin_unlock_irqrestore(&pci_controller_lock, flags);
|
2206 |
|
|
|
2207 |
|
|
p->index = pci_num_controllers++;
|
2208 |
|
|
p->pbms_same_domain = 0;
|
2209 |
|
|
p->scan_bus = (chip_type == PBM_CHIP_TYPE_TOMATILLO ?
|
2210 |
|
|
tomatillo_scan_bus :
|
2211 |
|
|
schizo_scan_bus);
|
2212 |
|
|
p->irq_build = schizo_irq_build;
|
2213 |
|
|
p->base_address_update = schizo_base_address_update;
|
2214 |
|
|
p->resource_adjust = schizo_resource_adjust;
|
2215 |
|
|
p->pci_ops = &schizo_ops;
|
2216 |
|
|
|
2217 |
|
|
/* Like PSYCHO we have a 2GB aligned area for memory space. */
|
2218 |
|
|
pci_memspace_mask = 0x7fffffffUL;
|
2219 |
|
|
|
2220 |
|
|
schizo_pbm_init(p, node, portid, chip_type);
|
2221 |
|
|
}
|
2222 |
|
|
|
2223 |
|
|
void __init schizo_init(int node, char *model_name)
|
2224 |
|
|
{
|
2225 |
|
|
__schizo_init(node, model_name, PBM_CHIP_TYPE_SCHIZO);
|
2226 |
|
|
}
|
2227 |
|
|
|
2228 |
|
|
void __init schizo_plus_init(int node, char *model_name)
|
2229 |
|
|
{
|
2230 |
|
|
__schizo_init(node, model_name, PBM_CHIP_TYPE_SCHIZO_PLUS);
|
2231 |
|
|
}
|
2232 |
|
|
|
2233 |
|
|
void __init tomatillo_init(int node, char *model_name)
|
2234 |
|
|
{
|
2235 |
|
|
__schizo_init(node, model_name, PBM_CHIP_TYPE_TOMATILLO);
|
2236 |
|
|
}
|