1 |
1622 |
jcastillo |
/*
|
2 |
|
|
* Code common to all PYXIS chips.
|
3 |
|
|
*
|
4 |
|
|
* Based on code written by David A Rusling (david.rusling@reo.mts.dec.com).
|
5 |
|
|
*
|
6 |
|
|
*/
|
7 |
|
|
#include <linux/kernel.h>
|
8 |
|
|
#include <linux/config.h>
|
9 |
|
|
#include <linux/types.h>
|
10 |
|
|
#include <linux/bios32.h>
|
11 |
|
|
#include <linux/pci.h>
|
12 |
|
|
#include <linux/sched.h>
|
13 |
|
|
|
14 |
|
|
#include <asm/system.h>
|
15 |
|
|
#include <asm/io.h>
|
16 |
|
|
#include <asm/hwrpb.h>
|
17 |
|
|
#include <asm/ptrace.h>
|
18 |
|
|
#include <asm/mmu_context.h>
|
19 |
|
|
|
20 |
|
|
extern struct hwrpb_struct *hwrpb;
|
21 |
|
|
extern asmlinkage void wrmces(unsigned long mces);
|
22 |
|
|
|
23 |
|
|
/*
|
24 |
|
|
* BIOS32-style PCI interface:
|
25 |
|
|
*/
|
26 |
|
|
|
27 |
|
|
#ifdef CONFIG_ALPHA_PYXIS
|
28 |
|
|
|
29 |
|
|
#ifdef DEBUG
|
30 |
|
|
# define DBG(args) printk args
|
31 |
|
|
#else
|
32 |
|
|
# define DBG(args)
|
33 |
|
|
#endif
|
34 |
|
|
|
35 |
|
|
#define DEBUG_MCHECK
|
36 |
|
|
#ifdef DEBUG_MCHECK
|
37 |
|
|
# define DBG_MCK(args) printk args
|
38 |
|
|
/* #define DEBUG_MCHECK_DUMP */
|
39 |
|
|
#else
|
40 |
|
|
# define DBG_MCK(args)
|
41 |
|
|
#endif
|
42 |
|
|
|
43 |
|
|
#define vuip volatile unsigned int *
|
44 |
|
|
#define vulp volatile unsigned long *
|
45 |
|
|
|
46 |
|
|
static volatile unsigned int PYXIS_mcheck_expected = 0;
|
47 |
|
|
static volatile unsigned int PYXIS_mcheck_taken = 0;
|
48 |
|
|
static unsigned int PYXIS_jd;
|
49 |
|
|
|
50 |
|
|
#ifdef CONFIG_ALPHA_SRM_SETUP
|
51 |
|
|
unsigned int PYXIS_DMA_WIN_BASE = PYXIS_DMA_WIN_BASE_DEFAULT;
|
52 |
|
|
unsigned int PYXIS_DMA_WIN_SIZE = PYXIS_DMA_WIN_SIZE_DEFAULT;
|
53 |
|
|
unsigned long pyxis_sm_base_r1, pyxis_sm_base_r2, pyxis_sm_base_r3;
|
54 |
|
|
#endif /* SRM_SETUP */
|
55 |
|
|
|
56 |
|
|
/*
|
57 |
|
|
* Given a bus, device, and function number, compute resulting
|
58 |
|
|
* configuration space address and setup the PYXIS_HAXR2 register
|
59 |
|
|
* accordingly. It is therefore not safe to have concurrent
|
60 |
|
|
* invocations to configuration space access routines, but there
|
61 |
|
|
* really shouldn't be any need for this.
|
62 |
|
|
*
|
63 |
|
|
* Type 0:
|
64 |
|
|
*
|
65 |
|
|
* 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
|
66 |
|
|
* 3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0
|
67 |
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
68 |
|
|
* | | |D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|0|
|
69 |
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
70 |
|
|
*
|
71 |
|
|
* 31:11 Device select bit.
|
72 |
|
|
* 10:8 Function number
|
73 |
|
|
* 7:2 Register number
|
74 |
|
|
*
|
75 |
|
|
* Type 1:
|
76 |
|
|
*
|
77 |
|
|
* 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
|
78 |
|
|
* 3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0
|
79 |
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
80 |
|
|
* | | | | | | | | | | |B|B|B|B|B|B|B|B|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|1|
|
81 |
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
82 |
|
|
*
|
83 |
|
|
* 31:24 reserved
|
84 |
|
|
* 23:16 bus number (8 bits = 128 possible buses)
|
85 |
|
|
* 15:11 Device number (5 bits)
|
86 |
|
|
* 10:8 function number
|
87 |
|
|
* 7:2 register number
|
88 |
|
|
*
|
89 |
|
|
* Notes:
|
90 |
|
|
* The function number selects which function of a multi-function device
|
91 |
|
|
* (e.g., scsi and ethernet).
|
92 |
|
|
*
|
93 |
|
|
* The register selects a DWORD (32 bit) register offset. Hence it
|
94 |
|
|
* doesn't get shifted by 2 bits as we want to "drop" the bottom two
|
95 |
|
|
* bits.
|
96 |
|
|
*/
|
97 |
|
|
static int mk_conf_addr(unsigned char bus, unsigned char device_fn,
|
98 |
|
|
unsigned char where, unsigned long *pci_addr,
|
99 |
|
|
unsigned char *type1)
|
100 |
|
|
{
|
101 |
|
|
unsigned long addr;
|
102 |
|
|
|
103 |
|
|
DBG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x, pci_addr=0x%p, type1=0x%p)\n",
|
104 |
|
|
bus, device_fn, where, pci_addr, type1));
|
105 |
|
|
|
106 |
|
|
if (bus == 0) {
|
107 |
|
|
int device;
|
108 |
|
|
|
109 |
|
|
device = device_fn >> 3;
|
110 |
|
|
/* type 0 configuration cycle: */
|
111 |
|
|
#if NOT_NOW
|
112 |
|
|
if (device > 20) {
|
113 |
|
|
DBG(("mk_conf_addr: device (%d) > 20, returning -1\n",
|
114 |
|
|
device));
|
115 |
|
|
return -1;
|
116 |
|
|
}
|
117 |
|
|
#endif
|
118 |
|
|
*type1 = 0;
|
119 |
|
|
addr = (device_fn << 8) | (where);
|
120 |
|
|
} else {
|
121 |
|
|
/* type 1 configuration cycle: */
|
122 |
|
|
*type1 = 1;
|
123 |
|
|
addr = (bus << 16) | (device_fn << 8) | (where);
|
124 |
|
|
}
|
125 |
|
|
*pci_addr = addr;
|
126 |
|
|
DBG(("mk_conf_addr: returning pci_addr 0x%lx\n", addr));
|
127 |
|
|
return 0;
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
static unsigned int conf_read(unsigned long addr, unsigned char type1)
|
132 |
|
|
{
|
133 |
|
|
unsigned long flags;
|
134 |
|
|
unsigned int stat0, value, temp;
|
135 |
|
|
unsigned int pyxis_cfg = 0; /* to keep gcc quiet */
|
136 |
|
|
|
137 |
|
|
save_flags(flags); /* avoid getting hit by machine check */
|
138 |
|
|
cli();
|
139 |
|
|
|
140 |
|
|
DBG(("conf_read(addr=0x%lx, type1=%d)\n", addr, type1));
|
141 |
|
|
|
142 |
|
|
/* reset status register to avoid losing errors: */
|
143 |
|
|
stat0 = *((vuip)PYXIS_ERR);
|
144 |
|
|
*((vuip)PYXIS_ERR) = stat0; mb();
|
145 |
|
|
temp = *((vuip)PYXIS_ERR);
|
146 |
|
|
DBG(("conf_read: PYXIS ERR was 0x%x\n", stat0));
|
147 |
|
|
/* if Type1 access, must set PYXIS CFG */
|
148 |
|
|
if (type1) {
|
149 |
|
|
pyxis_cfg = *((vuip)PYXIS_CFG);
|
150 |
|
|
*((vuip)PYXIS_CFG) = pyxis_cfg | 1; mb();
|
151 |
|
|
temp = *((vuip)PYXIS_CFG);
|
152 |
|
|
DBG(("conf_read: TYPE1 access\n"));
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
mb();
|
156 |
|
|
draina();
|
157 |
|
|
PYXIS_mcheck_expected = 1;
|
158 |
|
|
PYXIS_mcheck_taken = 0;
|
159 |
|
|
mb();
|
160 |
|
|
/* access configuration space: */
|
161 |
|
|
value = *((vuip)addr);
|
162 |
|
|
mb();
|
163 |
|
|
mb();
|
164 |
|
|
if (PYXIS_mcheck_taken) {
|
165 |
|
|
PYXIS_mcheck_taken = 0;
|
166 |
|
|
value = 0xffffffffU;
|
167 |
|
|
mb();
|
168 |
|
|
}
|
169 |
|
|
PYXIS_mcheck_expected = 0;
|
170 |
|
|
mb();
|
171 |
|
|
|
172 |
|
|
/* if Type1 access, must reset IOC CFG so normal IO space ops work */
|
173 |
|
|
if (type1) {
|
174 |
|
|
*((vuip)PYXIS_CFG) = pyxis_cfg & ~1; mb();
|
175 |
|
|
temp = *((vuip)PYXIS_CFG);
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
DBG(("conf_read(): finished\n"));
|
179 |
|
|
|
180 |
|
|
restore_flags(flags);
|
181 |
|
|
return value;
|
182 |
|
|
}
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
static void conf_write(unsigned long addr, unsigned int value, unsigned char type1)
|
186 |
|
|
{
|
187 |
|
|
unsigned long flags;
|
188 |
|
|
unsigned int stat0, temp;
|
189 |
|
|
unsigned int pyxis_cfg = 0; /* to keep gcc quiet */
|
190 |
|
|
|
191 |
|
|
save_flags(flags); /* avoid getting hit by machine check */
|
192 |
|
|
cli();
|
193 |
|
|
|
194 |
|
|
/* reset status register to avoid losing errors: */
|
195 |
|
|
stat0 = *((vuip)PYXIS_ERR);
|
196 |
|
|
*((vuip)PYXIS_ERR) = stat0; mb();
|
197 |
|
|
temp = *((vuip)PYXIS_ERR);
|
198 |
|
|
DBG(("conf_write: PYXIS ERR was 0x%x\n", stat0));
|
199 |
|
|
/* if Type1 access, must set PYXIS CFG */
|
200 |
|
|
if (type1) {
|
201 |
|
|
pyxis_cfg = *((vuip)PYXIS_CFG);
|
202 |
|
|
*((vuip)PYXIS_CFG) = pyxis_cfg | 1; mb();
|
203 |
|
|
temp = *((vuip)PYXIS_CFG);
|
204 |
|
|
DBG(("conf_read: TYPE1 access\n"));
|
205 |
|
|
}
|
206 |
|
|
|
207 |
|
|
draina();
|
208 |
|
|
PYXIS_mcheck_expected = 1;
|
209 |
|
|
mb();
|
210 |
|
|
/* access configuration space: */
|
211 |
|
|
*((vuip)addr) = value;
|
212 |
|
|
mb();
|
213 |
|
|
mb();
|
214 |
|
|
temp = *((vuip)PYXIS_ERR); /* do a PYXIS read to force the write */
|
215 |
|
|
PYXIS_mcheck_expected = 0;
|
216 |
|
|
mb();
|
217 |
|
|
|
218 |
|
|
/* if Type1 access, must reset IOC CFG so normal IO space ops work */
|
219 |
|
|
if (type1) {
|
220 |
|
|
*((vuip)PYXIS_CFG) = pyxis_cfg & ~1; mb();
|
221 |
|
|
temp = *((vuip)PYXIS_CFG);
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
DBG(("conf_write(): finished\n"));
|
225 |
|
|
restore_flags(flags);
|
226 |
|
|
}
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
int pcibios_read_config_byte (unsigned char bus, unsigned char device_fn,
|
230 |
|
|
unsigned char where, unsigned char *value)
|
231 |
|
|
{
|
232 |
|
|
unsigned long addr = PYXIS_CONF;
|
233 |
|
|
unsigned long pci_addr;
|
234 |
|
|
unsigned char type1;
|
235 |
|
|
|
236 |
|
|
*value = 0xff;
|
237 |
|
|
|
238 |
|
|
if (mk_conf_addr(bus, device_fn, where, &pci_addr, &type1) < 0) {
|
239 |
|
|
return PCIBIOS_SUCCESSFUL;
|
240 |
|
|
}
|
241 |
|
|
|
242 |
|
|
addr |= (pci_addr << 5) + 0x00;
|
243 |
|
|
|
244 |
|
|
*value = conf_read(addr, type1) >> ((where & 3) * 8);
|
245 |
|
|
|
246 |
|
|
return PCIBIOS_SUCCESSFUL;
|
247 |
|
|
}
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
int pcibios_read_config_word (unsigned char bus, unsigned char device_fn,
|
251 |
|
|
unsigned char where, unsigned short *value)
|
252 |
|
|
{
|
253 |
|
|
unsigned long addr = PYXIS_CONF;
|
254 |
|
|
unsigned long pci_addr;
|
255 |
|
|
unsigned char type1;
|
256 |
|
|
|
257 |
|
|
*value = 0xffff;
|
258 |
|
|
|
259 |
|
|
if (where & 0x1) {
|
260 |
|
|
return PCIBIOS_BAD_REGISTER_NUMBER;
|
261 |
|
|
}
|
262 |
|
|
|
263 |
|
|
if (mk_conf_addr(bus, device_fn, where, &pci_addr, &type1)) {
|
264 |
|
|
return PCIBIOS_SUCCESSFUL;
|
265 |
|
|
}
|
266 |
|
|
|
267 |
|
|
addr |= (pci_addr << 5) + 0x08;
|
268 |
|
|
|
269 |
|
|
*value = conf_read(addr, type1) >> ((where & 3) * 8);
|
270 |
|
|
return PCIBIOS_SUCCESSFUL;
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
int pcibios_read_config_dword (unsigned char bus, unsigned char device_fn,
|
275 |
|
|
unsigned char where, unsigned int *value)
|
276 |
|
|
{
|
277 |
|
|
unsigned long addr = PYXIS_CONF;
|
278 |
|
|
unsigned long pci_addr;
|
279 |
|
|
unsigned char type1;
|
280 |
|
|
|
281 |
|
|
*value = 0xffffffff;
|
282 |
|
|
if (where & 0x3) {
|
283 |
|
|
return PCIBIOS_BAD_REGISTER_NUMBER;
|
284 |
|
|
}
|
285 |
|
|
|
286 |
|
|
if (mk_conf_addr(bus, device_fn, where, &pci_addr, &type1)) {
|
287 |
|
|
return PCIBIOS_SUCCESSFUL;
|
288 |
|
|
}
|
289 |
|
|
addr |= (pci_addr << 5) + 0x18;
|
290 |
|
|
*value = conf_read(addr, type1);
|
291 |
|
|
return PCIBIOS_SUCCESSFUL;
|
292 |
|
|
}
|
293 |
|
|
|
294 |
|
|
|
295 |
|
|
int pcibios_write_config_byte (unsigned char bus, unsigned char device_fn,
|
296 |
|
|
unsigned char where, unsigned char value)
|
297 |
|
|
{
|
298 |
|
|
unsigned long addr = PYXIS_CONF;
|
299 |
|
|
unsigned long pci_addr;
|
300 |
|
|
unsigned char type1;
|
301 |
|
|
|
302 |
|
|
if (mk_conf_addr(bus, device_fn, where, &pci_addr, &type1) < 0) {
|
303 |
|
|
return PCIBIOS_SUCCESSFUL;
|
304 |
|
|
}
|
305 |
|
|
addr |= (pci_addr << 5) + 0x00;
|
306 |
|
|
conf_write(addr, value << ((where & 3) * 8), type1);
|
307 |
|
|
return PCIBIOS_SUCCESSFUL;
|
308 |
|
|
}
|
309 |
|
|
|
310 |
|
|
|
311 |
|
|
int pcibios_write_config_word (unsigned char bus, unsigned char device_fn,
|
312 |
|
|
unsigned char where, unsigned short value)
|
313 |
|
|
{
|
314 |
|
|
unsigned long addr = PYXIS_CONF;
|
315 |
|
|
unsigned long pci_addr;
|
316 |
|
|
unsigned char type1;
|
317 |
|
|
|
318 |
|
|
if (mk_conf_addr(bus, device_fn, where, &pci_addr, &type1) < 0) {
|
319 |
|
|
return PCIBIOS_SUCCESSFUL;
|
320 |
|
|
}
|
321 |
|
|
addr |= (pci_addr << 5) + 0x08;
|
322 |
|
|
conf_write(addr, value << ((where & 3) * 8), type1);
|
323 |
|
|
return PCIBIOS_SUCCESSFUL;
|
324 |
|
|
}
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
int pcibios_write_config_dword (unsigned char bus, unsigned char device_fn,
|
328 |
|
|
unsigned char where, unsigned int value)
|
329 |
|
|
{
|
330 |
|
|
unsigned long addr = PYXIS_CONF;
|
331 |
|
|
unsigned long pci_addr;
|
332 |
|
|
unsigned char type1;
|
333 |
|
|
|
334 |
|
|
if (mk_conf_addr(bus, device_fn, where, &pci_addr, &type1) < 0) {
|
335 |
|
|
return PCIBIOS_SUCCESSFUL;
|
336 |
|
|
}
|
337 |
|
|
addr |= (pci_addr << 5) + 0x18;
|
338 |
|
|
conf_write(addr, value << ((where & 3) * 8), type1);
|
339 |
|
|
return PCIBIOS_SUCCESSFUL;
|
340 |
|
|
}
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
unsigned long pyxis_init(unsigned long mem_start, unsigned long mem_end)
|
344 |
|
|
{
|
345 |
|
|
unsigned int pyxis_err;
|
346 |
|
|
|
347 |
|
|
#if 0
|
348 |
|
|
printk("pyxis_init: PYXIS_ERR_MASK 0x%x\n", *(vuip)PYXIS_ERR_MASK);
|
349 |
|
|
printk("pyxis_init: PYXIS_ERR 0x%x\n", *(vuip)PYXIS_ERR);
|
350 |
|
|
|
351 |
|
|
printk("pyxis_init: PYXIS_INT_REQ 0x%lx\n", *(vulp)PYXIS_INT_REQ);
|
352 |
|
|
printk("pyxis_init: PYXIS_INT_MASK 0x%lx\n", *(vulp)PYXIS_INT_MASK);
|
353 |
|
|
printk("pyxis_init: PYXIS_INT_ROUTE 0x%lx\n", *(vulp)PYXIS_INT_ROUTE);
|
354 |
|
|
printk("pyxis_init: PYXIS_INT_HILO 0x%lx\n", *(vulp)PYXIS_INT_HILO);
|
355 |
|
|
printk("pyxis_init: PYXIS_INT_CNFG 0x%x\n", *(vuip)PYXIS_INT_CNFG);
|
356 |
|
|
printk("pyxis_init: PYXIS_RT_COUNT 0x%lx\n", *(vulp)PYXIS_RT_COUNT);
|
357 |
|
|
#endif
|
358 |
|
|
|
359 |
|
|
#if 0
|
360 |
|
|
printk("pyxis_init: W0 BASE 0x%x MASK 0x%x TRANS 0x%x\n",
|
361 |
|
|
*(vuip)PYXIS_W0_BASE, *(vuip)PYXIS_W0_MASK, *(vuip)PYXIS_T0_BASE);
|
362 |
|
|
printk("pyxis_init: W1 BASE 0x%x MASK 0x%x TRANS 0x%x\n",
|
363 |
|
|
*(vuip)PYXIS_W1_BASE, *(vuip)PYXIS_W1_MASK, *(vuip)PYXIS_T1_BASE);
|
364 |
|
|
printk("pyxis_init: W2 BASE 0x%x MASK 0x%x TRANS 0x%x\n",
|
365 |
|
|
*(vuip)PYXIS_W2_BASE, *(vuip)PYXIS_W2_MASK, *(vuip)PYXIS_T2_BASE);
|
366 |
|
|
printk("pyxis_init: W3 BASE 0x%x MASK 0x%x TRANS 0x%x\n",
|
367 |
|
|
*(vuip)PYXIS_W3_BASE, *(vuip)PYXIS_W3_MASK, *(vuip)PYXIS_T3_BASE);
|
368 |
|
|
#endif
|
369 |
|
|
|
370 |
|
|
/*
|
371 |
|
|
* Set up error reporting. Make sure CPU_PE is OFF in the mask.
|
372 |
|
|
*/
|
373 |
|
|
pyxis_err = *(vuip)PYXIS_ERR_MASK;
|
374 |
|
|
pyxis_err &= ~4;
|
375 |
|
|
*(vuip)PYXIS_ERR_MASK = pyxis_err;
|
376 |
|
|
mb();
|
377 |
|
|
pyxis_err = *(vuip)PYXIS_ERR_MASK;
|
378 |
|
|
|
379 |
|
|
pyxis_err = *(vuip)PYXIS_ERR ;
|
380 |
|
|
pyxis_err |= 0x180; /* master/target abort */
|
381 |
|
|
*(vuip)PYXIS_ERR = pyxis_err ;
|
382 |
|
|
mb() ;
|
383 |
|
|
pyxis_err = *(vuip)PYXIS_ERR ;
|
384 |
|
|
|
385 |
|
|
#ifdef CONFIG_ALPHA_SRM_SETUP
|
386 |
|
|
/* check window 0 for enabled and mapped to 0 */
|
387 |
|
|
if (((*(vuip)PYXIS_W0_BASE & 3) == 1) &&
|
388 |
|
|
(*(vuip)PYXIS_T0_BASE == 0) &&
|
389 |
|
|
((*(vuip)PYXIS_W0_MASK & 0xfff00000U) > 0x0ff00000U))
|
390 |
|
|
{
|
391 |
|
|
PYXIS_DMA_WIN_BASE = *(vuip)PYXIS_W0_BASE & 0xfff00000U;
|
392 |
|
|
PYXIS_DMA_WIN_SIZE = *(vuip)PYXIS_W0_MASK & 0xfff00000U;
|
393 |
|
|
PYXIS_DMA_WIN_SIZE += 0x00100000U;
|
394 |
|
|
#if 1
|
395 |
|
|
printk("pyxis_init: using Window 0 settings\n");
|
396 |
|
|
printk("pyxis_init: BASE 0x%x MASK 0x%x TRANS 0x%x\n",
|
397 |
|
|
*(vuip)PYXIS_W0_BASE,
|
398 |
|
|
*(vuip)PYXIS_W0_MASK,
|
399 |
|
|
*(vuip)PYXIS_T0_BASE);
|
400 |
|
|
#endif
|
401 |
|
|
}
|
402 |
|
|
else /* check window 1 for enabled and mapped to 0 */
|
403 |
|
|
if (((*(vuip)PYXIS_W1_BASE & 3) == 1) &&
|
404 |
|
|
(*(vuip)PYXIS_T1_BASE == 0) &&
|
405 |
|
|
((*(vuip)PYXIS_W1_MASK & 0xfff00000U) > 0x0ff00000U))
|
406 |
|
|
{
|
407 |
|
|
PYXIS_DMA_WIN_BASE = *(vuip)PYXIS_W1_BASE & 0xfff00000U;
|
408 |
|
|
PYXIS_DMA_WIN_SIZE = *(vuip)PYXIS_W1_MASK & 0xfff00000U;
|
409 |
|
|
PYXIS_DMA_WIN_SIZE += 0x00100000U;
|
410 |
|
|
#if 1
|
411 |
|
|
printk("pyxis_init: using Window 1 settings\n");
|
412 |
|
|
printk("pyxis_init: BASE 0x%x MASK 0x%x TRANS 0x%x\n",
|
413 |
|
|
*(vuip)PYXIS_W1_BASE,
|
414 |
|
|
*(vuip)PYXIS_W1_MASK,
|
415 |
|
|
*(vuip)PYXIS_T1_BASE);
|
416 |
|
|
#endif
|
417 |
|
|
}
|
418 |
|
|
else /* check window 2 for enabled and mapped to 0 */
|
419 |
|
|
if (((*(vuip)PYXIS_W2_BASE & 3) == 1) &&
|
420 |
|
|
(*(vuip)PYXIS_T2_BASE == 0) &&
|
421 |
|
|
((*(vuip)PYXIS_W2_MASK & 0xfff00000U) > 0x0ff00000U))
|
422 |
|
|
{
|
423 |
|
|
PYXIS_DMA_WIN_BASE = *(vuip)PYXIS_W2_BASE & 0xfff00000U;
|
424 |
|
|
PYXIS_DMA_WIN_SIZE = *(vuip)PYXIS_W2_MASK & 0xfff00000U;
|
425 |
|
|
PYXIS_DMA_WIN_SIZE += 0x00100000U;
|
426 |
|
|
#if 1
|
427 |
|
|
printk("pyxis_init: using Window 2 settings\n");
|
428 |
|
|
printk("pyxis_init: BASE 0x%x MASK 0x%x TRANS 0x%x\n",
|
429 |
|
|
*(vuip)PYXIS_W2_BASE,
|
430 |
|
|
*(vuip)PYXIS_W2_MASK,
|
431 |
|
|
*(vuip)PYXIS_T2_BASE);
|
432 |
|
|
#endif
|
433 |
|
|
}
|
434 |
|
|
else /* check window 3 for enabled and mapped to 0 */
|
435 |
|
|
if (((*(vuip)PYXIS_W3_BASE & 3) == 1) &&
|
436 |
|
|
(*(vuip)PYXIS_T3_BASE == 0) &&
|
437 |
|
|
((*(vuip)PYXIS_W3_MASK & 0xfff00000U) > 0x0ff00000U))
|
438 |
|
|
{
|
439 |
|
|
PYXIS_DMA_WIN_BASE = *(vuip)PYXIS_W3_BASE & 0xfff00000U;
|
440 |
|
|
PYXIS_DMA_WIN_SIZE = *(vuip)PYXIS_W3_MASK & 0xfff00000U;
|
441 |
|
|
PYXIS_DMA_WIN_SIZE += 0x00100000U;
|
442 |
|
|
#if 1
|
443 |
|
|
printk("pyxis_init: using Window 3 settings\n");
|
444 |
|
|
printk("pyxis_init: BASE 0x%x MASK 0x%x TRANS 0x%x\n",
|
445 |
|
|
*(vuip)PYXIS_W3_BASE,
|
446 |
|
|
*(vuip)PYXIS_W3_MASK,
|
447 |
|
|
*(vuip)PYXIS_T3_BASE);
|
448 |
|
|
#endif
|
449 |
|
|
}
|
450 |
|
|
else /* we must use our defaults which were pre-initialized... */
|
451 |
|
|
#endif /* SRM_SETUP */
|
452 |
|
|
{
|
453 |
|
|
#if defined(CONFIG_ALPHA_RUFFIAN)
|
454 |
|
|
#if 1
|
455 |
|
|
printk("pyxis_init: skipping window register rewrites... "
|
456 |
|
|
"trust DeskStation firmware!\n");
|
457 |
|
|
#endif
|
458 |
|
|
#else /* RUFFIAN */
|
459 |
|
|
/*
|
460 |
|
|
* Set up the PCI->physical memory translation windows.
|
461 |
|
|
* For now, windows 1,2 and 3 are disabled. In the future, we may
|
462 |
|
|
* want to use them to do scatter/gather DMA. Window 0
|
463 |
|
|
* goes at 1 GB and is 1 GB large.
|
464 |
|
|
*/
|
465 |
|
|
|
466 |
|
|
*(vuip)PYXIS_W0_BASE = 1U | (PYXIS_DMA_WIN_BASE & 0xfff00000U);
|
467 |
|
|
*(vuip)PYXIS_W0_MASK = (PYXIS_DMA_WIN_SIZE - 1) & 0xfff00000U;
|
468 |
|
|
*(vuip)PYXIS_T0_BASE = 0;
|
469 |
|
|
|
470 |
|
|
*(vuip)PYXIS_W1_BASE = 0x0 ;
|
471 |
|
|
*(vuip)PYXIS_W2_BASE = 0x0 ;
|
472 |
|
|
*(vuip)PYXIS_W3_BASE = 0x0 ;
|
473 |
|
|
mb();
|
474 |
|
|
#endif /* RUFFIAN */
|
475 |
|
|
}
|
476 |
|
|
|
477 |
|
|
/*
|
478 |
|
|
* check ASN in HWRPB for validity, report if bad
|
479 |
|
|
*/
|
480 |
|
|
if (hwrpb->max_asn != MAX_ASN) {
|
481 |
|
|
printk("PYXIS_init: max ASN from HWRPB is bad (0x%lx)\n",
|
482 |
|
|
hwrpb->max_asn);
|
483 |
|
|
hwrpb->max_asn = MAX_ASN;
|
484 |
|
|
}
|
485 |
|
|
|
486 |
|
|
/*
|
487 |
|
|
* Next, clear the PYXIS_CFG register, which gets used
|
488 |
|
|
* for PCI Config Space accesses. That is the way
|
489 |
|
|
* we want to use it, and we do not want to depend on
|
490 |
|
|
* what ARC or SRM might have left behind...
|
491 |
|
|
*/
|
492 |
|
|
{
|
493 |
|
|
unsigned int pyxis_cfg, temp;
|
494 |
|
|
pyxis_cfg = *((vuip)PYXIS_CFG); mb();
|
495 |
|
|
if (pyxis_cfg != 0) {
|
496 |
|
|
#if 1
|
497 |
|
|
printk("PYXIS_init: CFG was 0x%x\n", pyxis_cfg);
|
498 |
|
|
#endif
|
499 |
|
|
*((vuip)PYXIS_CFG) = 0; mb();
|
500 |
|
|
temp = *((vuip)PYXIS_CFG);
|
501 |
|
|
}
|
502 |
|
|
}
|
503 |
|
|
|
504 |
|
|
{
|
505 |
|
|
unsigned int pyxis_hae_mem = *((vuip)PYXIS_HAE_MEM);
|
506 |
|
|
unsigned int pyxis_hae_io = *((vuip)PYXIS_HAE_IO);
|
507 |
|
|
#if 0
|
508 |
|
|
printk("PYXIS_init: HAE_MEM was 0x%x\n", pyxis_hae_mem);
|
509 |
|
|
printk("PYXIS_init: HAE_IO was 0x%x\n", pyxis_hae_io);
|
510 |
|
|
#endif
|
511 |
|
|
#ifdef CONFIG_ALPHA_SRM_SETUP
|
512 |
|
|
/*
|
513 |
|
|
sigh... For the SRM setup, unless we know apriori what the HAE
|
514 |
|
|
contents will be, we need to setup the arbitrary region bases
|
515 |
|
|
so we can test against the range of addresses and tailor the
|
516 |
|
|
region chosen for the SPARSE memory access.
|
517 |
|
|
|
518 |
|
|
see include/asm-alpha/pyxis.h for the SPARSE mem read/write
|
519 |
|
|
*/
|
520 |
|
|
pyxis_sm_base_r1 = (pyxis_hae_mem ) & 0xe0000000UL;/* region 1 */
|
521 |
|
|
pyxis_sm_base_r2 = (pyxis_hae_mem << 16) & 0xf8000000UL;/* region 2 */
|
522 |
|
|
pyxis_sm_base_r3 = (pyxis_hae_mem << 24) & 0xfc000000UL;/* region 3 */
|
523 |
|
|
#else /* SRM_SETUP */
|
524 |
|
|
*((vuip)PYXIS_HAE_MEM) = 0U; mb();
|
525 |
|
|
pyxis_hae_mem = *((vuip)PYXIS_HAE_MEM);
|
526 |
|
|
*((vuip)PYXIS_HAE_IO) = 0; mb();
|
527 |
|
|
pyxis_hae_io = *((vuip)PYXIS_HAE_IO);
|
528 |
|
|
#endif /* SRM_SETUP */
|
529 |
|
|
}
|
530 |
|
|
|
531 |
|
|
/*
|
532 |
|
|
* Finally, check that the PYXIS_CTRL1 has IOA_BEN set for
|
533 |
|
|
* enabling byte/word PCI bus space(s) access.
|
534 |
|
|
*/
|
535 |
|
|
{
|
536 |
|
|
unsigned int ctrl1;
|
537 |
|
|
ctrl1 = *((vuip) PYXIS_CTRL1);
|
538 |
|
|
if (!(ctrl1 & 1)) {
|
539 |
|
|
#if 0
|
540 |
|
|
printk("PYXIS_init: enabling byte/word PCI space\n");
|
541 |
|
|
#endif
|
542 |
|
|
*((vuip) PYXIS_CTRL1) = ctrl1 | 1; mb();
|
543 |
|
|
ctrl1 = *((vuip)PYXIS_CTRL1);
|
544 |
|
|
}
|
545 |
|
|
}
|
546 |
|
|
|
547 |
|
|
return mem_start;
|
548 |
|
|
}
|
549 |
|
|
|
550 |
|
|
int pyxis_pci_clr_err(void)
|
551 |
|
|
{
|
552 |
|
|
PYXIS_jd = *((vuip)PYXIS_ERR);
|
553 |
|
|
DBG(("PYXIS_pci_clr_err: PYXIS ERR after read 0x%x\n", PYXIS_jd));
|
554 |
|
|
*((vuip)PYXIS_ERR) = 0x0180; mb();
|
555 |
|
|
PYXIS_jd = *((vuip)PYXIS_ERR);
|
556 |
|
|
return 0;
|
557 |
|
|
}
|
558 |
|
|
|
559 |
|
|
void pyxis_machine_check(unsigned long vector, unsigned long la_ptr,
|
560 |
|
|
struct pt_regs * regs)
|
561 |
|
|
{
|
562 |
|
|
#if 0
|
563 |
|
|
printk("PYXIS machine check ignored\n") ;
|
564 |
|
|
#else
|
565 |
|
|
struct el_common *mchk_header;
|
566 |
|
|
struct el_PYXIS_sysdata_mcheck *mchk_sysdata;
|
567 |
|
|
|
568 |
|
|
mchk_header = (struct el_common *)la_ptr;
|
569 |
|
|
|
570 |
|
|
mchk_sysdata =
|
571 |
|
|
(struct el_PYXIS_sysdata_mcheck *)(la_ptr + mchk_header->sys_offset);
|
572 |
|
|
|
573 |
|
|
#if 0
|
574 |
|
|
DBG_MCK(("pyxis_machine_check: vector=0x%lx la_ptr=0x%lx\n",
|
575 |
|
|
vector, la_ptr));
|
576 |
|
|
DBG_MCK(("\t\t pc=0x%lx size=0x%x procoffset=0x%x sysoffset 0x%x\n",
|
577 |
|
|
regs->pc, mchk_header->size, mchk_header->proc_offset,
|
578 |
|
|
mchk_header->sys_offset));
|
579 |
|
|
DBG_MCK(("pyxis_machine_check: expected %d DCSR 0x%lx PEAR 0x%lx\n",
|
580 |
|
|
PYXIS_mcheck_expected, mchk_sysdata->epic_dcsr,
|
581 |
|
|
mchk_sysdata->epic_pear));
|
582 |
|
|
#endif
|
583 |
|
|
#ifdef DEBUG_MCHECK_DUMP
|
584 |
|
|
{
|
585 |
|
|
unsigned long *ptr;
|
586 |
|
|
int i;
|
587 |
|
|
|
588 |
|
|
ptr = (unsigned long *)la_ptr;
|
589 |
|
|
for (i = 0; i < mchk_header->size / sizeof(long); i += 2) {
|
590 |
|
|
printk(" +%lx %lx %lx\n", i*sizeof(long), ptr[i], ptr[i+1]);
|
591 |
|
|
}
|
592 |
|
|
}
|
593 |
|
|
#endif /* DEBUG_MCHECK_DUMP */
|
594 |
|
|
/*
|
595 |
|
|
* Check if machine check is due to a badaddr() and if so,
|
596 |
|
|
* ignore the machine check.
|
597 |
|
|
*/
|
598 |
|
|
mb();
|
599 |
|
|
mb();
|
600 |
|
|
if (PYXIS_mcheck_expected/* && (mchk_sysdata->epic_dcsr && 0x0c00UL)*/) {
|
601 |
|
|
DBG(("PYXIS machine check expected\n"));
|
602 |
|
|
PYXIS_mcheck_expected = 0;
|
603 |
|
|
PYXIS_mcheck_taken = 1;
|
604 |
|
|
mb();
|
605 |
|
|
mb();
|
606 |
|
|
draina();
|
607 |
|
|
pyxis_pci_clr_err();
|
608 |
|
|
wrmces(0x7);
|
609 |
|
|
mb();
|
610 |
|
|
}
|
611 |
|
|
#if 1
|
612 |
|
|
else {
|
613 |
|
|
printk("PYXIS machine check NOT expected\n") ;
|
614 |
|
|
DBG_MCK(("pyxis_machine_check: vector=0x%lx la_ptr=0x%lx\n",
|
615 |
|
|
vector, la_ptr));
|
616 |
|
|
DBG_MCK(("\t\t pc=0x%lx size=0x%x procoffset=0x%x sysoffset 0x%x\n",
|
617 |
|
|
regs->pc, mchk_header->size, mchk_header->proc_offset,
|
618 |
|
|
mchk_header->sys_offset));
|
619 |
|
|
PYXIS_mcheck_expected = 0;
|
620 |
|
|
PYXIS_mcheck_taken = 1;
|
621 |
|
|
mb();
|
622 |
|
|
mb();
|
623 |
|
|
draina();
|
624 |
|
|
pyxis_pci_clr_err();
|
625 |
|
|
wrmces(0x7);
|
626 |
|
|
mb();
|
627 |
|
|
}
|
628 |
|
|
#endif
|
629 |
|
|
#endif
|
630 |
|
|
}
|
631 |
|
|
|
632 |
|
|
#if defined(CONFIG_ALPHA_RUFFIAN)
|
633 |
|
|
/* NOTE: this is only used by MILO, AFAIK... */
|
634 |
|
|
/*
|
635 |
|
|
* The DeskStation Ruffian motherboard firmware does not place
|
636 |
|
|
* the memory size in the PALimpure area. Therefore, it uses
|
637 |
|
|
* the Bank Configuration Registers in PYXIS to obtain the size.
|
638 |
|
|
*/
|
639 |
|
|
unsigned long pyxis_get_bank_size(unsigned long offset)
|
640 |
|
|
{
|
641 |
|
|
unsigned long bank_addr;
|
642 |
|
|
|
643 |
|
|
/* valid offsets are: 0x800, 0x840 and 0x880
|
644 |
|
|
* since Ruffian only uses three banks
|
645 |
|
|
*/
|
646 |
|
|
bank_addr = (unsigned long)PYXIS_MCR + offset;
|
647 |
|
|
|
648 |
|
|
/* check BANK_ENABLE */
|
649 |
|
|
if (*((unsigned long *)bank_addr) && 0x01)
|
650 |
|
|
{
|
651 |
|
|
/* do case on BANK_SIZE bits */
|
652 |
|
|
switch (*((unsigned long *)bank_addr) & 0x01e)
|
653 |
|
|
{
|
654 |
|
|
case 0x00: return 0x40000000UL; break; /* 1G */
|
655 |
|
|
case 0x02: return 0x20000000UL; break; /* 512M */
|
656 |
|
|
case 0x04: return 0x10000000UL; break; /* 256M */
|
657 |
|
|
case 0x06: return 0x08000000UL; break; /* 128M */
|
658 |
|
|
case 0x08: return 0x04000000UL; break; /* 64M */
|
659 |
|
|
case 0x0a: return 0x02000000UL; break; /* 32M */
|
660 |
|
|
case 0x0c: return 0x01000000UL; break; /* 16M */
|
661 |
|
|
case 0x0e: return 0x00800000UL; break; /* 8M */
|
662 |
|
|
case 0x10: return 0x80000000UL; break; /* 2G */
|
663 |
|
|
default : return 0x00000000UL; break; /* ERROR*/
|
664 |
|
|
}
|
665 |
|
|
} else
|
666 |
|
|
return 0x00UL;
|
667 |
|
|
}
|
668 |
|
|
#endif /* CONFIG_ALPHA_RUFFIAN */
|
669 |
|
|
|
670 |
|
|
#endif /* CONFIG_ALPHA_PYXIS */
|