blob: 10d21df1453143c5c8d6c33c629a6267985f2385 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* -*- mode: c; c-basic-offset: 8 -*- */
2
3/* Copyright (C) 1999,2001
4 *
5 * Author: J.E.J.Bottomley@HansenPartnership.com
6 *
7 * linux/arch/i386/kernel/voyager_cat.c
8 *
9 * This file contains all the logic for manipulating the CAT bus
10 * in a level 5 machine.
11 *
12 * The CAT bus is a serial configuration and test bus. Its primary
13 * uses are to probe the initial configuration of the system and to
14 * diagnose error conditions when a system interrupt occurs. The low
15 * level interface is fairly primitive, so most of this file consists
16 * of bit shift manipulations to send and receive packets on the
17 * serial bus */
18
19#include <linux/config.h>
20#include <linux/types.h>
21#include <linux/completion.h>
22#include <linux/sched.h>
23#include <asm/voyager.h>
24#include <asm/vic.h>
25#include <linux/ioport.h>
26#include <linux/init.h>
27#include <linux/slab.h>
28#include <linux/delay.h>
29#include <asm/io.h>
30
31#ifdef VOYAGER_CAT_DEBUG
32#define CDEBUG(x) printk x
33#else
34#define CDEBUG(x)
35#endif
36
37/* the CAT command port */
38#define CAT_CMD (sspb + 0xe)
39/* the CAT data port */
40#define CAT_DATA (sspb + 0xd)
41
42/* the internal cat functions */
43static void cat_pack(__u8 *msg, __u16 start_bit, __u8 *data,
44 __u16 num_bits);
45static void cat_unpack(__u8 *msg, __u16 start_bit, __u8 *data,
46 __u16 num_bits);
47static void cat_build_header(__u8 *header, const __u16 len,
48 const __u16 smallest_reg_bits,
49 const __u16 longest_reg_bits);
50static int cat_sendinst(voyager_module_t *modp, voyager_asic_t *asicp,
51 __u8 reg, __u8 op);
52static int cat_getdata(voyager_module_t *modp, voyager_asic_t *asicp,
53 __u8 reg, __u8 *value);
54static int cat_shiftout(__u8 *data, __u16 data_bytes, __u16 header_bytes,
55 __u8 pad_bits);
56static int cat_write(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg,
57 __u8 value);
58static int cat_read(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg,
59 __u8 *value);
60static int cat_subread(voyager_module_t *modp, voyager_asic_t *asicp,
61 __u16 offset, __u16 len, void *buf);
62static int cat_senddata(voyager_module_t *modp, voyager_asic_t *asicp,
63 __u8 reg, __u8 value);
64static int cat_disconnect(voyager_module_t *modp, voyager_asic_t *asicp);
65static int cat_connect(voyager_module_t *modp, voyager_asic_t *asicp);
66
67static inline const char *
68cat_module_name(int module_id)
69{
70 switch(module_id) {
71 case 0x10:
72 return "Processor Slot 0";
73 case 0x11:
74 return "Processor Slot 1";
75 case 0x12:
76 return "Processor Slot 2";
77 case 0x13:
78 return "Processor Slot 4";
79 case 0x14:
80 return "Memory Slot 0";
81 case 0x15:
82 return "Memory Slot 1";
83 case 0x18:
84 return "Primary Microchannel";
85 case 0x19:
86 return "Secondary Microchannel";
87 case 0x1a:
88 return "Power Supply Interface";
89 case 0x1c:
90 return "Processor Slot 5";
91 case 0x1d:
92 return "Processor Slot 6";
93 case 0x1e:
94 return "Processor Slot 7";
95 case 0x1f:
96 return "Processor Slot 8";
97 default:
98 return "Unknown Module";
99 }
100}
101
102static int sspb = 0; /* stores the super port location */
103int voyager_8slot = 0; /* set to true if a 51xx monster */
104
105voyager_module_t *voyager_cat_list;
106
107/* the I/O port assignments for the VIC and QIC */
108static struct resource vic_res = {
Adrian Bunkdd7ba3b2006-04-10 22:52:49 -0700109 .name = "Voyager Interrupt Controller",
110 .start = 0xFC00,
111 .end = 0xFC6F
112};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113static struct resource qic_res = {
Adrian Bunkdd7ba3b2006-04-10 22:52:49 -0700114 .name = "Quad Interrupt Controller",
115 .start = 0xFC70,
116 .end = 0xFCFF
117};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119/* This function is used to pack a data bit stream inside a message.
120 * It writes num_bits of the data buffer in msg starting at start_bit.
121 * Note: This function assumes that any unused bit in the data stream
122 * is set to zero so that the ors will work correctly */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123static void
124cat_pack(__u8 *msg, const __u16 start_bit, __u8 *data, const __u16 num_bits)
125{
126 /* compute initial shift needed */
127 const __u16 offset = start_bit % BITS_PER_BYTE;
128 __u16 len = num_bits / BITS_PER_BYTE;
129 __u16 byte = start_bit / BITS_PER_BYTE;
130 __u16 residue = (num_bits % BITS_PER_BYTE) + offset;
131 int i;
132
133 /* adjust if we have more than a byte of residue */
134 if(residue >= BITS_PER_BYTE) {
135 residue -= BITS_PER_BYTE;
136 len++;
137 }
138
139 /* clear out the bits. We assume here that if len==0 then
140 * residue >= offset. This is always true for the catbus
141 * operations */
142 msg[byte] &= 0xff << (BITS_PER_BYTE - offset);
143 msg[byte++] |= data[0] >> offset;
144 if(len == 0)
145 return;
146 for(i = 1; i < len; i++)
147 msg[byte++] = (data[i-1] << (BITS_PER_BYTE - offset))
148 | (data[i] >> offset);
149 if(residue != 0) {
150 __u8 mask = 0xff >> residue;
151 __u8 last_byte = data[i-1] << (BITS_PER_BYTE - offset)
152 | (data[i] >> offset);
153
154 last_byte &= ~mask;
155 msg[byte] &= mask;
156 msg[byte] |= last_byte;
157 }
158 return;
159}
160/* unpack the data again (same arguments as cat_pack()). data buffer
161 * must be zero populated.
162 *
163 * Function: given a message string move to start_bit and copy num_bits into
164 * data (starting at bit 0 in data).
165 */
166static void
167cat_unpack(__u8 *msg, const __u16 start_bit, __u8 *data, const __u16 num_bits)
168{
169 /* compute initial shift needed */
170 const __u16 offset = start_bit % BITS_PER_BYTE;
171 __u16 len = num_bits / BITS_PER_BYTE;
172 const __u8 last_bits = num_bits % BITS_PER_BYTE;
173 __u16 byte = start_bit / BITS_PER_BYTE;
174 int i;
175
176 if(last_bits != 0)
177 len++;
178
179 /* special case: want < 8 bits from msg and we can get it from
180 * a single byte of the msg */
181 if(len == 0 && BITS_PER_BYTE - offset >= num_bits) {
182 data[0] = msg[byte] << offset;
183 data[0] &= 0xff >> (BITS_PER_BYTE - num_bits);
184 return;
185 }
186 for(i = 0; i < len; i++) {
187 /* this annoying if has to be done just in case a read of
188 * msg one beyond the array causes a panic */
189 if(offset != 0) {
190 data[i] = msg[byte++] << offset;
191 data[i] |= msg[byte] >> (BITS_PER_BYTE - offset);
192 }
193 else {
194 data[i] = msg[byte++];
195 }
196 }
197 /* do we need to truncate the final byte */
198 if(last_bits != 0) {
199 data[i-1] &= 0xff << (BITS_PER_BYTE - last_bits);
200 }
201 return;
202}
203
204static void
205cat_build_header(__u8 *header, const __u16 len, const __u16 smallest_reg_bits,
206 const __u16 longest_reg_bits)
207{
208 int i;
209 __u16 start_bit = (smallest_reg_bits - 1) % BITS_PER_BYTE;
210 __u8 *last_byte = &header[len - 1];
211
212 if(start_bit == 0)
213 start_bit = 1; /* must have at least one bit in the hdr */
214
215 for(i=0; i < len; i++)
216 header[i] = 0;
217
218 for(i = start_bit; i > 0; i--)
219 *last_byte = ((*last_byte) << 1) + 1;
220
221}
222
223static int
224cat_sendinst(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg, __u8 op)
225{
226 __u8 parity, inst, inst_buf[4] = { 0 };
227 __u8 iseq[VOYAGER_MAX_SCAN_PATH], hseq[VOYAGER_MAX_REG_SIZE];
228 __u16 ibytes, hbytes, padbits;
229 int i;
230
231 /*
232 * Parity is the parity of the register number + 1 (READ_REGISTER
233 * and WRITE_REGISTER always add '1' to the number of bits == 1)
234 */
235 parity = (__u8)(1 + (reg & 0x01) +
236 ((__u8)(reg & 0x02) >> 1) +
237 ((__u8)(reg & 0x04) >> 2) +
238 ((__u8)(reg & 0x08) >> 3)) % 2;
239
240 inst = ((parity << 7) | (reg << 2) | op);
241
242 outb(VOYAGER_CAT_IRCYC, CAT_CMD);
243 if(!modp->scan_path_connected) {
244 if(asicp->asic_id != VOYAGER_CAT_ID) {
245 printk("**WARNING***: cat_sendinst has disconnected scan path not to CAT asic\n");
246 return 1;
247 }
248 outb(VOYAGER_CAT_HEADER, CAT_DATA);
249 outb(inst, CAT_DATA);
250 if(inb(CAT_DATA) != VOYAGER_CAT_HEADER) {
251 CDEBUG(("VOYAGER CAT: cat_sendinst failed to get CAT_HEADER\n"));
252 return 1;
253 }
254 return 0;
255 }
256 ibytes = modp->inst_bits / BITS_PER_BYTE;
257 if((padbits = modp->inst_bits % BITS_PER_BYTE) != 0) {
258 padbits = BITS_PER_BYTE - padbits;
259 ibytes++;
260 }
261 hbytes = modp->largest_reg / BITS_PER_BYTE;
262 if(modp->largest_reg % BITS_PER_BYTE)
263 hbytes++;
264 CDEBUG(("cat_sendinst: ibytes=%d, hbytes=%d\n", ibytes, hbytes));
265 /* initialise the instruction sequence to 0xff */
266 for(i=0; i < ibytes + hbytes; i++)
267 iseq[i] = 0xff;
268 cat_build_header(hseq, hbytes, modp->smallest_reg, modp->largest_reg);
269 cat_pack(iseq, modp->inst_bits, hseq, hbytes * BITS_PER_BYTE);
270 inst_buf[0] = inst;
271 inst_buf[1] = 0xFF >> (modp->largest_reg % BITS_PER_BYTE);
272 cat_pack(iseq, asicp->bit_location, inst_buf, asicp->ireg_length);
273#ifdef VOYAGER_CAT_DEBUG
274 printk("ins = 0x%x, iseq: ", inst);
275 for(i=0; i< ibytes + hbytes; i++)
276 printk("0x%x ", iseq[i]);
277 printk("\n");
278#endif
279 if(cat_shiftout(iseq, ibytes, hbytes, padbits)) {
280 CDEBUG(("VOYAGER CAT: cat_sendinst: cat_shiftout failed\n"));
281 return 1;
282 }
283 CDEBUG(("CAT SHIFTOUT DONE\n"));
284 return 0;
285}
286
287static int
288cat_getdata(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg,
289 __u8 *value)
290{
291 if(!modp->scan_path_connected) {
292 if(asicp->asic_id != VOYAGER_CAT_ID) {
293 CDEBUG(("VOYAGER CAT: ERROR: cat_getdata to CAT asic with scan path connected\n"));
294 return 1;
295 }
296 if(reg > VOYAGER_SUBADDRHI)
297 outb(VOYAGER_CAT_RUN, CAT_CMD);
298 outb(VOYAGER_CAT_DRCYC, CAT_CMD);
299 outb(VOYAGER_CAT_HEADER, CAT_DATA);
300 *value = inb(CAT_DATA);
301 outb(0xAA, CAT_DATA);
302 if(inb(CAT_DATA) != VOYAGER_CAT_HEADER) {
303 CDEBUG(("cat_getdata: failed to get VOYAGER_CAT_HEADER\n"));
304 return 1;
305 }
306 return 0;
307 }
308 else {
309 __u16 sbits = modp->num_asics -1 + asicp->ireg_length;
310 __u16 sbytes = sbits / BITS_PER_BYTE;
311 __u16 tbytes;
312 __u8 string[VOYAGER_MAX_SCAN_PATH], trailer[VOYAGER_MAX_REG_SIZE];
313 __u8 padbits;
314 int i;
315
316 outb(VOYAGER_CAT_DRCYC, CAT_CMD);
317
318 if((padbits = sbits % BITS_PER_BYTE) != 0) {
319 padbits = BITS_PER_BYTE - padbits;
320 sbytes++;
321 }
322 tbytes = asicp->ireg_length / BITS_PER_BYTE;
323 if(asicp->ireg_length % BITS_PER_BYTE)
324 tbytes++;
325 CDEBUG(("cat_getdata: tbytes = %d, sbytes = %d, padbits = %d\n",
326 tbytes, sbytes, padbits));
327 cat_build_header(trailer, tbytes, 1, asicp->ireg_length);
328
329
330 for(i = tbytes - 1; i >= 0; i--) {
331 outb(trailer[i], CAT_DATA);
332 string[sbytes + i] = inb(CAT_DATA);
333 }
334
335 for(i = sbytes - 1; i >= 0; i--) {
336 outb(0xaa, CAT_DATA);
337 string[i] = inb(CAT_DATA);
338 }
339 *value = 0;
340 cat_unpack(string, padbits + (tbytes * BITS_PER_BYTE) + asicp->asic_location, value, asicp->ireg_length);
341#ifdef VOYAGER_CAT_DEBUG
342 printk("value=0x%x, string: ", *value);
343 for(i=0; i< tbytes+sbytes; i++)
344 printk("0x%x ", string[i]);
345 printk("\n");
346#endif
347
348 /* sanity check the rest of the return */
349 for(i=0; i < tbytes; i++) {
350 __u8 input = 0;
351
352 cat_unpack(string, padbits + (i * BITS_PER_BYTE), &input, BITS_PER_BYTE);
353 if(trailer[i] != input) {
354 CDEBUG(("cat_getdata: failed to sanity check rest of ret(%d) 0x%x != 0x%x\n", i, input, trailer[i]));
355 return 1;
356 }
357 }
358 CDEBUG(("cat_getdata DONE\n"));
359 return 0;
360 }
361}
362
363static int
364cat_shiftout(__u8 *data, __u16 data_bytes, __u16 header_bytes, __u8 pad_bits)
365{
366 int i;
367
368 for(i = data_bytes + header_bytes - 1; i >= header_bytes; i--)
369 outb(data[i], CAT_DATA);
370
371 for(i = header_bytes - 1; i >= 0; i--) {
372 __u8 header = 0;
373 __u8 input;
374
375 outb(data[i], CAT_DATA);
376 input = inb(CAT_DATA);
377 CDEBUG(("cat_shiftout: returned 0x%x\n", input));
378 cat_unpack(data, ((data_bytes + i) * BITS_PER_BYTE) - pad_bits,
379 &header, BITS_PER_BYTE);
380 if(input != header) {
381 CDEBUG(("VOYAGER CAT: cat_shiftout failed to return header 0x%x != 0x%x\n", input, header));
382 return 1;
383 }
384 }
385 return 0;
386}
387
388static int
389cat_senddata(voyager_module_t *modp, voyager_asic_t *asicp,
390 __u8 reg, __u8 value)
391{
392 outb(VOYAGER_CAT_DRCYC, CAT_CMD);
393 if(!modp->scan_path_connected) {
394 if(asicp->asic_id != VOYAGER_CAT_ID) {
395 CDEBUG(("VOYAGER CAT: ERROR: scan path disconnected when asic != CAT\n"));
396 return 1;
397 }
398 outb(VOYAGER_CAT_HEADER, CAT_DATA);
399 outb(value, CAT_DATA);
400 if(inb(CAT_DATA) != VOYAGER_CAT_HEADER) {
401 CDEBUG(("cat_senddata: failed to get correct header response to sent data\n"));
402 return 1;
403 }
404 if(reg > VOYAGER_SUBADDRHI) {
405 outb(VOYAGER_CAT_RUN, CAT_CMD);
406 outb(VOYAGER_CAT_END, CAT_CMD);
407 outb(VOYAGER_CAT_RUN, CAT_CMD);
408 }
409
410 return 0;
411 }
412 else {
413 __u16 hbytes = asicp->ireg_length / BITS_PER_BYTE;
414 __u16 dbytes = (modp->num_asics - 1 + asicp->ireg_length)/BITS_PER_BYTE;
415 __u8 padbits, dseq[VOYAGER_MAX_SCAN_PATH],
416 hseq[VOYAGER_MAX_REG_SIZE];
417 int i;
418
419 if((padbits = (modp->num_asics - 1
420 + asicp->ireg_length) % BITS_PER_BYTE) != 0) {
421 padbits = BITS_PER_BYTE - padbits;
422 dbytes++;
423 }
424 if(asicp->ireg_length % BITS_PER_BYTE)
425 hbytes++;
426
427 cat_build_header(hseq, hbytes, 1, asicp->ireg_length);
428
429 for(i = 0; i < dbytes + hbytes; i++)
430 dseq[i] = 0xff;
431 CDEBUG(("cat_senddata: dbytes=%d, hbytes=%d, padbits=%d\n",
432 dbytes, hbytes, padbits));
433 cat_pack(dseq, modp->num_asics - 1 + asicp->ireg_length,
434 hseq, hbytes * BITS_PER_BYTE);
435 cat_pack(dseq, asicp->asic_location, &value,
436 asicp->ireg_length);
437#ifdef VOYAGER_CAT_DEBUG
438 printk("dseq ");
439 for(i=0; i<hbytes+dbytes; i++) {
440 printk("0x%x ", dseq[i]);
441 }
442 printk("\n");
443#endif
444 return cat_shiftout(dseq, dbytes, hbytes, padbits);
445 }
446}
447
448static int
449cat_write(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg,
450 __u8 value)
451{
452 if(cat_sendinst(modp, asicp, reg, VOYAGER_WRITE_CONFIG))
453 return 1;
454 return cat_senddata(modp, asicp, reg, value);
455}
456
457static int
458cat_read(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg,
459 __u8 *value)
460{
461 if(cat_sendinst(modp, asicp, reg, VOYAGER_READ_CONFIG))
462 return 1;
463 return cat_getdata(modp, asicp, reg, value);
464}
465
466static int
467cat_subaddrsetup(voyager_module_t *modp, voyager_asic_t *asicp, __u16 offset,
468 __u16 len)
469{
470 __u8 val;
471
472 if(len > 1) {
473 /* set auto increment */
474 __u8 newval;
475
476 if(cat_read(modp, asicp, VOYAGER_AUTO_INC_REG, &val)) {
477 CDEBUG(("cat_subaddrsetup: read of VOYAGER_AUTO_INC_REG failed\n"));
478 return 1;
479 }
480 CDEBUG(("cat_subaddrsetup: VOYAGER_AUTO_INC_REG = 0x%x\n", val));
481 newval = val | VOYAGER_AUTO_INC;
482 if(newval != val) {
483 if(cat_write(modp, asicp, VOYAGER_AUTO_INC_REG, val)) {
484 CDEBUG(("cat_subaddrsetup: write to VOYAGER_AUTO_INC_REG failed\n"));
485 return 1;
486 }
487 }
488 }
489 if(cat_write(modp, asicp, VOYAGER_SUBADDRLO, (__u8)(offset &0xff))) {
490 CDEBUG(("cat_subaddrsetup: write to SUBADDRLO failed\n"));
491 return 1;
492 }
493 if(asicp->subaddr > VOYAGER_SUBADDR_LO) {
494 if(cat_write(modp, asicp, VOYAGER_SUBADDRHI, (__u8)(offset >> 8))) {
495 CDEBUG(("cat_subaddrsetup: write to SUBADDRHI failed\n"));
496 return 1;
497 }
498 cat_read(modp, asicp, VOYAGER_SUBADDRHI, &val);
499 CDEBUG(("cat_subaddrsetup: offset = %d, hi = %d\n", offset, val));
500 }
501 cat_read(modp, asicp, VOYAGER_SUBADDRLO, &val);
502 CDEBUG(("cat_subaddrsetup: offset = %d, lo = %d\n", offset, val));
503 return 0;
504}
505
506static int
507cat_subwrite(voyager_module_t *modp, voyager_asic_t *asicp, __u16 offset,
508 __u16 len, void *buf)
509{
510 int i, retval;
511
512 /* FIXME: need special actions for VOYAGER_CAT_ID here */
513 if(asicp->asic_id == VOYAGER_CAT_ID) {
514 CDEBUG(("cat_subwrite: ATTEMPT TO WRITE TO CAT ASIC\n"));
515 /* FIXME -- This is supposed to be handled better
516 * There is a problem writing to the cat asic in the
517 * PSI. The 30us delay seems to work, though */
518 udelay(30);
519 }
520
521 if((retval = cat_subaddrsetup(modp, asicp, offset, len)) != 0) {
522 printk("cat_subwrite: cat_subaddrsetup FAILED\n");
523 return retval;
524 }
525
526 if(cat_sendinst(modp, asicp, VOYAGER_SUBADDRDATA, VOYAGER_WRITE_CONFIG)) {
527 printk("cat_subwrite: cat_sendinst FAILED\n");
528 return 1;
529 }
530 for(i = 0; i < len; i++) {
531 if(cat_senddata(modp, asicp, 0xFF, ((__u8 *)buf)[i])) {
532 printk("cat_subwrite: cat_sendata element at %d FAILED\n", i);
533 return 1;
534 }
535 }
536 return 0;
537}
538static int
539cat_subread(voyager_module_t *modp, voyager_asic_t *asicp, __u16 offset,
540 __u16 len, void *buf)
541{
542 int i, retval;
543
544 if((retval = cat_subaddrsetup(modp, asicp, offset, len)) != 0) {
545 CDEBUG(("cat_subread: cat_subaddrsetup FAILED\n"));
546 return retval;
547 }
548
549 if(cat_sendinst(modp, asicp, VOYAGER_SUBADDRDATA, VOYAGER_READ_CONFIG)) {
550 CDEBUG(("cat_subread: cat_sendinst failed\n"));
551 return 1;
552 }
553 for(i = 0; i < len; i++) {
554 if(cat_getdata(modp, asicp, 0xFF,
555 &((__u8 *)buf)[i])) {
556 CDEBUG(("cat_subread: cat_getdata element %d failed\n", i));
557 return 1;
558 }
559 }
560 return 0;
561}
562
563
564/* buffer for storing EPROM data read in during initialisation */
565static __initdata __u8 eprom_buf[0xFFFF];
566static voyager_module_t *voyager_initial_module;
567
568/* Initialise the cat bus components. We assume this is called by the
569 * boot cpu *after* all memory initialisation has been done (so we can
570 * use kmalloc) but before smp initialisation, so we can probe the SMP
571 * configuration and pick up necessary information. */
572void
573voyager_cat_init(void)
574{
575 voyager_module_t **modpp = &voyager_initial_module;
576 voyager_asic_t **asicpp;
577 voyager_asic_t *qabc_asic = NULL;
578 int i, j;
579 unsigned long qic_addr = 0;
580 __u8 qabc_data[0x20];
581 __u8 num_submodules, val;
582 voyager_eprom_hdr_t *eprom_hdr = (voyager_eprom_hdr_t *)&eprom_buf[0];
583
584 __u8 cmos[4];
585 unsigned long addr;
586
587 /* initiallise the SUS mailbox */
588 for(i=0; i<sizeof(cmos); i++)
589 cmos[i] = voyager_extended_cmos_read(VOYAGER_DUMP_LOCATION + i);
590 addr = *(unsigned long *)cmos;
591 if((addr & 0xff000000) != 0xff000000) {
592 printk(KERN_ERR "Voyager failed to get SUS mailbox (addr = 0x%lx\n", addr);
593 } else {
594 static struct resource res;
595
596 res.name = "voyager SUS";
597 res.start = addr;
598 res.end = addr+0x3ff;
599
600 request_resource(&iomem_resource, &res);
601 voyager_SUS = (struct voyager_SUS *)
602 ioremap(addr, 0x400);
603 printk(KERN_NOTICE "Voyager SUS mailbox version 0x%x\n",
604 voyager_SUS->SUS_version);
605 voyager_SUS->kernel_version = VOYAGER_MAILBOX_VERSION;
606 voyager_SUS->kernel_flags = VOYAGER_OS_HAS_SYSINT;
607 }
608
609 /* clear the processor counts */
610 voyager_extended_vic_processors = 0;
611 voyager_quad_processors = 0;
612
613
614
615 printk("VOYAGER: beginning CAT bus probe\n");
616 /* set up the SuperSet Port Block which tells us where the
617 * CAT communication port is */
618 sspb = inb(VOYAGER_SSPB_RELOCATION_PORT) * 0x100;
619 VDEBUG(("VOYAGER DEBUG: sspb = 0x%x\n", sspb));
620
621 /* now find out if were 8 slot or normal */
622 if((inb(VIC_PROC_WHO_AM_I) & EIGHT_SLOT_IDENTIFIER)
623 == EIGHT_SLOT_IDENTIFIER) {
624 voyager_8slot = 1;
625 printk(KERN_NOTICE "Voyager: Eight slot 51xx configuration detected\n");
626 }
627
628 for(i = VOYAGER_MIN_MODULE;
629 i <= VOYAGER_MAX_MODULE; i++) {
630 __u8 input;
631 int asic;
632 __u16 eprom_size;
633 __u16 sp_offset;
634
635 outb(VOYAGER_CAT_DESELECT, VOYAGER_CAT_CONFIG_PORT);
636 outb(i, VOYAGER_CAT_CONFIG_PORT);
637
638 /* check the presence of the module */
639 outb(VOYAGER_CAT_RUN, CAT_CMD);
640 outb(VOYAGER_CAT_IRCYC, CAT_CMD);
641 outb(VOYAGER_CAT_HEADER, CAT_DATA);
642 /* stream series of alternating 1's and 0's to stimulate
643 * response */
644 outb(0xAA, CAT_DATA);
645 input = inb(CAT_DATA);
646 outb(VOYAGER_CAT_END, CAT_CMD);
647 if(input != VOYAGER_CAT_HEADER) {
648 continue;
649 }
650 CDEBUG(("VOYAGER DEBUG: found module id 0x%x, %s\n", i,
651 cat_module_name(i)));
652 *modpp = kmalloc(sizeof(voyager_module_t), GFP_KERNEL); /*&voyager_module_storage[cat_count++];*/
653 if(*modpp == NULL) {
654 printk("**WARNING** kmalloc failure in cat_init\n");
655 continue;
656 }
657 memset(*modpp, 0, sizeof(voyager_module_t));
658 /* need temporary asic for cat_subread. It will be
659 * filled in correctly later */
660 (*modpp)->asic = kmalloc(sizeof(voyager_asic_t), GFP_KERNEL); /*&voyager_asic_storage[asic_count];*/
661 if((*modpp)->asic == NULL) {
662 printk("**WARNING** kmalloc failure in cat_init\n");
663 continue;
664 }
665 memset((*modpp)->asic, 0, sizeof(voyager_asic_t));
666 (*modpp)->asic->asic_id = VOYAGER_CAT_ID;
667 (*modpp)->asic->subaddr = VOYAGER_SUBADDR_HI;
668 (*modpp)->module_addr = i;
669 (*modpp)->scan_path_connected = 0;
670 if(i == VOYAGER_PSI) {
671 /* Exception leg for modules with no EEPROM */
672 printk("Module \"%s\"\n", cat_module_name(i));
673 continue;
674 }
675
676 CDEBUG(("cat_init: Reading eeprom for module 0x%x at offset %d\n", i, VOYAGER_XSUM_END_OFFSET));
677 outb(VOYAGER_CAT_RUN, CAT_CMD);
678 cat_disconnect(*modpp, (*modpp)->asic);
679 if(cat_subread(*modpp, (*modpp)->asic,
680 VOYAGER_XSUM_END_OFFSET, sizeof(eprom_size),
681 &eprom_size)) {
682 printk("**WARNING**: Voyager couldn't read EPROM size for module 0x%x\n", i);
683 outb(VOYAGER_CAT_END, CAT_CMD);
684 continue;
685 }
686 if(eprom_size > sizeof(eprom_buf)) {
687 printk("**WARNING**: Voyager insufficient size to read EPROM data, module 0x%x. Need %d\n", i, eprom_size);
688 outb(VOYAGER_CAT_END, CAT_CMD);
689 continue;
690 }
691 outb(VOYAGER_CAT_END, CAT_CMD);
692 outb(VOYAGER_CAT_RUN, CAT_CMD);
693 CDEBUG(("cat_init: module 0x%x, eeprom_size %d\n", i, eprom_size));
694 if(cat_subread(*modpp, (*modpp)->asic, 0,
695 eprom_size, eprom_buf)) {
696 outb(VOYAGER_CAT_END, CAT_CMD);
697 continue;
698 }
699 outb(VOYAGER_CAT_END, CAT_CMD);
700 printk("Module \"%s\", version 0x%x, tracer 0x%x, asics %d\n",
701 cat_module_name(i), eprom_hdr->version_id,
702 *((__u32 *)eprom_hdr->tracer), eprom_hdr->num_asics);
703 (*modpp)->ee_size = eprom_hdr->ee_size;
704 (*modpp)->num_asics = eprom_hdr->num_asics;
705 asicpp = &((*modpp)->asic);
706 sp_offset = eprom_hdr->scan_path_offset;
707 /* All we really care about are the Quad cards. We
708 * identify them because they are in a processor slot
709 * and have only four asics */
710 if((i < 0x10 || (i>=0x14 && i < 0x1c) || i>0x1f)) {
711 modpp = &((*modpp)->next);
712 continue;
713 }
714 /* Now we know it's in a processor slot, does it have
715 * a quad baseboard submodule */
716 outb(VOYAGER_CAT_RUN, CAT_CMD);
717 cat_read(*modpp, (*modpp)->asic, VOYAGER_SUBMODPRESENT,
718 &num_submodules);
719 /* lowest two bits, active low */
720 num_submodules = ~(0xfc | num_submodules);
721 CDEBUG(("VOYAGER CAT: %d submodules present\n", num_submodules));
722 if(num_submodules == 0) {
723 /* fill in the dyadic extended processors */
724 __u8 cpu = i & 0x07;
725
726 printk("Module \"%s\": Dyadic Processor Card\n",
727 cat_module_name(i));
728 voyager_extended_vic_processors |= (1<<cpu);
729 cpu += 4;
730 voyager_extended_vic_processors |= (1<<cpu);
731 outb(VOYAGER_CAT_END, CAT_CMD);
732 continue;
733 }
734
735 /* now we want to read the asics on the first submodule,
736 * which should be the quad base board */
737
738 cat_read(*modpp, (*modpp)->asic, VOYAGER_SUBMODSELECT, &val);
739 CDEBUG(("cat_init: SUBMODSELECT value = 0x%x\n", val));
740 val = (val & 0x7c) | VOYAGER_QUAD_BASEBOARD;
741 cat_write(*modpp, (*modpp)->asic, VOYAGER_SUBMODSELECT, val);
742
743 outb(VOYAGER_CAT_END, CAT_CMD);
744
745
746 CDEBUG(("cat_init: Reading eeprom for module 0x%x at offset %d\n", i, VOYAGER_XSUM_END_OFFSET));
747 outb(VOYAGER_CAT_RUN, CAT_CMD);
748 cat_disconnect(*modpp, (*modpp)->asic);
749 if(cat_subread(*modpp, (*modpp)->asic,
750 VOYAGER_XSUM_END_OFFSET, sizeof(eprom_size),
751 &eprom_size)) {
752 printk("**WARNING**: Voyager couldn't read EPROM size for module 0x%x\n", i);
753 outb(VOYAGER_CAT_END, CAT_CMD);
754 continue;
755 }
756 if(eprom_size > sizeof(eprom_buf)) {
757 printk("**WARNING**: Voyager insufficient size to read EPROM data, module 0x%x. Need %d\n", i, eprom_size);
758 outb(VOYAGER_CAT_END, CAT_CMD);
759 continue;
760 }
761 outb(VOYAGER_CAT_END, CAT_CMD);
762 outb(VOYAGER_CAT_RUN, CAT_CMD);
763 CDEBUG(("cat_init: module 0x%x, eeprom_size %d\n", i, eprom_size));
764 if(cat_subread(*modpp, (*modpp)->asic, 0,
765 eprom_size, eprom_buf)) {
766 outb(VOYAGER_CAT_END, CAT_CMD);
767 continue;
768 }
769 outb(VOYAGER_CAT_END, CAT_CMD);
770 /* Now do everything for the QBB submodule 1 */
771 (*modpp)->ee_size = eprom_hdr->ee_size;
772 (*modpp)->num_asics = eprom_hdr->num_asics;
773 asicpp = &((*modpp)->asic);
774 sp_offset = eprom_hdr->scan_path_offset;
775 /* get rid of the dummy CAT asic and read the real one */
776 kfree((*modpp)->asic);
777 for(asic=0; asic < (*modpp)->num_asics; asic++) {
778 int j;
779 voyager_asic_t *asicp = *asicpp
780 = kmalloc(sizeof(voyager_asic_t), GFP_KERNEL); /*&voyager_asic_storage[asic_count++];*/
781 voyager_sp_table_t *sp_table;
782 voyager_at_t *asic_table;
783 voyager_jtt_t *jtag_table;
784
785 if(asicp == NULL) {
786 printk("**WARNING** kmalloc failure in cat_init\n");
787 continue;
788 }
789 memset(asicp, 0, sizeof(voyager_asic_t));
790 asicpp = &(asicp->next);
791 asicp->asic_location = asic;
792 sp_table = (voyager_sp_table_t *)(eprom_buf + sp_offset);
793 asicp->asic_id = sp_table->asic_id;
794 asic_table = (voyager_at_t *)(eprom_buf + sp_table->asic_data_offset);
795 for(j=0; j<4; j++)
796 asicp->jtag_id[j] = asic_table->jtag_id[j];
797 jtag_table = (voyager_jtt_t *)(eprom_buf + asic_table->jtag_offset);
798 asicp->ireg_length = jtag_table->ireg_len;
799 asicp->bit_location = (*modpp)->inst_bits;
800 (*modpp)->inst_bits += asicp->ireg_length;
801 if(asicp->ireg_length > (*modpp)->largest_reg)
802 (*modpp)->largest_reg = asicp->ireg_length;
803 if (asicp->ireg_length < (*modpp)->smallest_reg ||
804 (*modpp)->smallest_reg == 0)
805 (*modpp)->smallest_reg = asicp->ireg_length;
806 CDEBUG(("asic 0x%x, ireg_length=%d, bit_location=%d\n",
807 asicp->asic_id, asicp->ireg_length,
808 asicp->bit_location));
809 if(asicp->asic_id == VOYAGER_QUAD_QABC) {
810 CDEBUG(("VOYAGER CAT: QABC ASIC found\n"));
811 qabc_asic = asicp;
812 }
813 sp_offset += sizeof(voyager_sp_table_t);
814 }
815 CDEBUG(("Module inst_bits = %d, largest_reg = %d, smallest_reg=%d\n",
816 (*modpp)->inst_bits, (*modpp)->largest_reg,
817 (*modpp)->smallest_reg));
818 /* OK, now we have the QUAD ASICs set up, use them.
819 * we need to:
820 *
821 * 1. Find the Memory area for the Quad CPIs.
822 * 2. Find the Extended VIC processor
823 * 3. Configure a second extended VIC processor (This
824 * cannot be done for the 51xx.
825 * */
826 outb(VOYAGER_CAT_RUN, CAT_CMD);
827 cat_connect(*modpp, (*modpp)->asic);
828 CDEBUG(("CAT CONNECTED!!\n"));
829 cat_subread(*modpp, qabc_asic, 0, sizeof(qabc_data), qabc_data);
830 qic_addr = qabc_data[5] << 8;
831 qic_addr = (qic_addr | qabc_data[6]) << 8;
832 qic_addr = (qic_addr | qabc_data[7]) << 8;
833 printk("Module \"%s\": Quad Processor Card; CPI 0x%lx, SET=0x%x\n",
834 cat_module_name(i), qic_addr, qabc_data[8]);
835#if 0 /* plumbing fails---FIXME */
836 if((qabc_data[8] & 0xf0) == 0) {
837 /* FIXME: 32 way 8 CPU slot monster cannot be
838 * plumbed this way---need to check for it */
839
840 printk("Plumbing second Extended Quad Processor\n");
841 /* second VIC line hardwired to Quad CPU 1 */
842 qabc_data[8] |= 0x20;
843 cat_subwrite(*modpp, qabc_asic, 8, 1, &qabc_data[8]);
844#ifdef VOYAGER_CAT_DEBUG
845 /* verify plumbing */
846 cat_subread(*modpp, qabc_asic, 8, 1, &qabc_data[8]);
847 if((qabc_data[8] & 0xf0) == 0) {
848 CDEBUG(("PLUMBING FAILED: 0x%x\n", qabc_data[8]));
849 }
850#endif
851 }
852#endif
853
854 {
855 struct resource *res = kmalloc(sizeof(struct resource),GFP_KERNEL);
856 memset(res, 0, sizeof(struct resource));
857 res->name = kmalloc(128, GFP_KERNEL);
858 sprintf((char *)res->name, "Voyager %s Quad CPI", cat_module_name(i));
859 res->start = qic_addr;
860 res->end = qic_addr + 0x3ff;
861 request_resource(&iomem_resource, res);
862 }
863
864 qic_addr = (unsigned long)ioremap(qic_addr, 0x400);
865
866 for(j = 0; j < 4; j++) {
867 __u8 cpu;
868
869 if(voyager_8slot) {
870 /* 8 slot has a different mapping,
871 * each slot has only one vic line, so
872 * 1 cpu in each slot must be < 8 */
873 cpu = (i & 0x07) + j*8;
874 } else {
875 cpu = (i & 0x03) + j*4;
876 }
877 if( (qabc_data[8] & (1<<j))) {
878 voyager_extended_vic_processors |= (1<<cpu);
879 }
880 if(qabc_data[8] & (1<<(j+4)) ) {
881 /* Second SET register plumbed: Quad
882 * card has two VIC connected CPUs.
883 * Secondary cannot be booted as a VIC
884 * CPU */
885 voyager_extended_vic_processors |= (1<<cpu);
886 voyager_allowed_boot_processors &= (~(1<<cpu));
887 }
888
889 voyager_quad_processors |= (1<<cpu);
890 voyager_quad_cpi_addr[cpu] = (struct voyager_qic_cpi *)
891 (qic_addr+(j<<8));
892 CDEBUG(("CPU%d: CPI address 0x%lx\n", cpu,
893 (unsigned long)voyager_quad_cpi_addr[cpu]));
894 }
895 outb(VOYAGER_CAT_END, CAT_CMD);
896
897
898
899 *asicpp = NULL;
900 modpp = &((*modpp)->next);
901 }
902 *modpp = NULL;
903 printk("CAT Bus Initialisation finished: extended procs 0x%x, quad procs 0x%x, allowed vic boot = 0x%x\n", voyager_extended_vic_processors, voyager_quad_processors, voyager_allowed_boot_processors);
904 request_resource(&ioport_resource, &vic_res);
905 if(voyager_quad_processors)
906 request_resource(&ioport_resource, &qic_res);
907 /* set up the front power switch */
908}
909
910int
911voyager_cat_readb(__u8 module, __u8 asic, int reg)
912{
913 return 0;
914}
915
916static int
917cat_disconnect(voyager_module_t *modp, voyager_asic_t *asicp)
918{
919 __u8 val;
920 int err = 0;
921
922 if(!modp->scan_path_connected)
923 return 0;
924 if(asicp->asic_id != VOYAGER_CAT_ID) {
925 CDEBUG(("cat_disconnect: ASIC is not CAT\n"));
926 return 1;
927 }
928 err = cat_read(modp, asicp, VOYAGER_SCANPATH, &val);
929 if(err) {
930 CDEBUG(("cat_disconnect: failed to read SCANPATH\n"));
931 return err;
932 }
933 val &= VOYAGER_DISCONNECT_ASIC;
934 err = cat_write(modp, asicp, VOYAGER_SCANPATH, val);
935 if(err) {
936 CDEBUG(("cat_disconnect: failed to write SCANPATH\n"));
937 return err;
938 }
939 outb(VOYAGER_CAT_END, CAT_CMD);
940 outb(VOYAGER_CAT_RUN, CAT_CMD);
941 modp->scan_path_connected = 0;
942
943 return 0;
944}
945
946static int
947cat_connect(voyager_module_t *modp, voyager_asic_t *asicp)
948{
949 __u8 val;
950 int err = 0;
951
952 if(modp->scan_path_connected)
953 return 0;
954 if(asicp->asic_id != VOYAGER_CAT_ID) {
955 CDEBUG(("cat_connect: ASIC is not CAT\n"));
956 return 1;
957 }
958
959 err = cat_read(modp, asicp, VOYAGER_SCANPATH, &val);
960 if(err) {
961 CDEBUG(("cat_connect: failed to read SCANPATH\n"));
962 return err;
963 }
964 val |= VOYAGER_CONNECT_ASIC;
965 err = cat_write(modp, asicp, VOYAGER_SCANPATH, val);
966 if(err) {
967 CDEBUG(("cat_connect: failed to write SCANPATH\n"));
968 return err;
969 }
970 outb(VOYAGER_CAT_END, CAT_CMD);
971 outb(VOYAGER_CAT_RUN, CAT_CMD);
972 modp->scan_path_connected = 1;
973
974 return 0;
975}
976
977void
978voyager_cat_power_off(void)
979{
980 /* Power the machine off by writing to the PSI over the CAT
981 * bus */
982 __u8 data;
983 voyager_module_t psi = { 0 };
984 voyager_asic_t psi_asic = { 0 };
985
986 psi.asic = &psi_asic;
987 psi.asic->asic_id = VOYAGER_CAT_ID;
988 psi.asic->subaddr = VOYAGER_SUBADDR_HI;
989 psi.module_addr = VOYAGER_PSI;
990 psi.scan_path_connected = 0;
991
992 outb(VOYAGER_CAT_END, CAT_CMD);
993 /* Connect the PSI to the CAT Bus */
994 outb(VOYAGER_CAT_DESELECT, VOYAGER_CAT_CONFIG_PORT);
995 outb(VOYAGER_PSI, VOYAGER_CAT_CONFIG_PORT);
996 outb(VOYAGER_CAT_RUN, CAT_CMD);
997 cat_disconnect(&psi, &psi_asic);
998 /* Read the status */
999 cat_subread(&psi, &psi_asic, VOYAGER_PSI_GENERAL_REG, 1, &data);
1000 outb(VOYAGER_CAT_END, CAT_CMD);
1001 CDEBUG(("PSI STATUS 0x%x\n", data));
1002 /* These two writes are power off prep and perform */
1003 data = PSI_CLEAR;
1004 outb(VOYAGER_CAT_RUN, CAT_CMD);
1005 cat_subwrite(&psi, &psi_asic, VOYAGER_PSI_GENERAL_REG, 1, &data);
1006 outb(VOYAGER_CAT_END, CAT_CMD);
1007 data = PSI_POWER_DOWN;
1008 outb(VOYAGER_CAT_RUN, CAT_CMD);
1009 cat_subwrite(&psi, &psi_asic, VOYAGER_PSI_GENERAL_REG, 1, &data);
1010 outb(VOYAGER_CAT_END, CAT_CMD);
1011}
1012
1013struct voyager_status voyager_status = { 0 };
1014
1015void
1016voyager_cat_psi(__u8 cmd, __u16 reg, __u8 *data)
1017{
1018 voyager_module_t psi = { 0 };
1019 voyager_asic_t psi_asic = { 0 };
1020
1021 psi.asic = &psi_asic;
1022 psi.asic->asic_id = VOYAGER_CAT_ID;
1023 psi.asic->subaddr = VOYAGER_SUBADDR_HI;
1024 psi.module_addr = VOYAGER_PSI;
1025 psi.scan_path_connected = 0;
1026
1027 outb(VOYAGER_CAT_END, CAT_CMD);
1028 /* Connect the PSI to the CAT Bus */
1029 outb(VOYAGER_CAT_DESELECT, VOYAGER_CAT_CONFIG_PORT);
1030 outb(VOYAGER_PSI, VOYAGER_CAT_CONFIG_PORT);
1031 outb(VOYAGER_CAT_RUN, CAT_CMD);
1032 cat_disconnect(&psi, &psi_asic);
1033 switch(cmd) {
1034 case VOYAGER_PSI_READ:
1035 cat_read(&psi, &psi_asic, reg, data);
1036 break;
1037 case VOYAGER_PSI_WRITE:
1038 cat_write(&psi, &psi_asic, reg, *data);
1039 break;
1040 case VOYAGER_PSI_SUBREAD:
1041 cat_subread(&psi, &psi_asic, reg, 1, data);
1042 break;
1043 case VOYAGER_PSI_SUBWRITE:
1044 cat_subwrite(&psi, &psi_asic, reg, 1, data);
1045 break;
1046 default:
1047 printk(KERN_ERR "Voyager PSI, unrecognised command %d\n", cmd);
1048 break;
1049 }
1050 outb(VOYAGER_CAT_END, CAT_CMD);
1051}
1052
1053void
1054voyager_cat_do_common_interrupt(void)
1055{
1056 /* This is caused either by a memory parity error or something
1057 * in the PSI */
1058 __u8 data;
1059 voyager_module_t psi = { 0 };
1060 voyager_asic_t psi_asic = { 0 };
1061 struct voyager_psi psi_reg;
1062 int i;
1063 re_read:
1064 psi.asic = &psi_asic;
1065 psi.asic->asic_id = VOYAGER_CAT_ID;
1066 psi.asic->subaddr = VOYAGER_SUBADDR_HI;
1067 psi.module_addr = VOYAGER_PSI;
1068 psi.scan_path_connected = 0;
1069
1070 outb(VOYAGER_CAT_END, CAT_CMD);
1071 /* Connect the PSI to the CAT Bus */
1072 outb(VOYAGER_CAT_DESELECT, VOYAGER_CAT_CONFIG_PORT);
1073 outb(VOYAGER_PSI, VOYAGER_CAT_CONFIG_PORT);
1074 outb(VOYAGER_CAT_RUN, CAT_CMD);
1075 cat_disconnect(&psi, &psi_asic);
1076 /* Read the status. NOTE: Need to read *all* the PSI regs here
1077 * otherwise the cmn int will be reasserted */
1078 for(i = 0; i < sizeof(psi_reg.regs); i++) {
1079 cat_read(&psi, &psi_asic, i, &((__u8 *)&psi_reg.regs)[i]);
1080 }
1081 outb(VOYAGER_CAT_END, CAT_CMD);
1082 if((psi_reg.regs.checkbit & 0x02) == 0) {
1083 psi_reg.regs.checkbit |= 0x02;
1084 cat_write(&psi, &psi_asic, 5, psi_reg.regs.checkbit);
1085 printk("VOYAGER RE-READ PSI\n");
1086 goto re_read;
1087 }
1088 outb(VOYAGER_CAT_RUN, CAT_CMD);
1089 for(i = 0; i < sizeof(psi_reg.subregs); i++) {
1090 /* This looks strange, but the PSI doesn't do auto increment
1091 * correctly */
1092 cat_subread(&psi, &psi_asic, VOYAGER_PSI_SUPPLY_REG + i,
1093 1, &((__u8 *)&psi_reg.subregs)[i]);
1094 }
1095 outb(VOYAGER_CAT_END, CAT_CMD);
1096#ifdef VOYAGER_CAT_DEBUG
1097 printk("VOYAGER PSI: ");
1098 for(i=0; i<sizeof(psi_reg.regs); i++)
1099 printk("%02x ", ((__u8 *)&psi_reg.regs)[i]);
1100 printk("\n ");
1101 for(i=0; i<sizeof(psi_reg.subregs); i++)
1102 printk("%02x ", ((__u8 *)&psi_reg.subregs)[i]);
1103 printk("\n");
1104#endif
1105 if(psi_reg.regs.intstatus & PSI_MON) {
1106 /* switch off or power fail */
1107
1108 if(psi_reg.subregs.supply & PSI_SWITCH_OFF) {
1109 if(voyager_status.switch_off) {
1110 printk(KERN_ERR "Voyager front panel switch turned off again---Immediate power off!\n");
1111 voyager_cat_power_off();
1112 /* not reached */
1113 } else {
1114 printk(KERN_ERR "Voyager front panel switch turned off\n");
1115 voyager_status.switch_off = 1;
1116 voyager_status.request_from_kernel = 1;
1117 up(&kvoyagerd_sem);
1118 }
1119 /* Tell the hardware we're taking care of the
1120 * shutdown, otherwise it will power the box off
1121 * within 3 seconds of the switch being pressed and,
1122 * which is much more important to us, continue to
1123 * assert the common interrupt */
1124 data = PSI_CLR_SWITCH_OFF;
1125 outb(VOYAGER_CAT_RUN, CAT_CMD);
1126 cat_subwrite(&psi, &psi_asic, VOYAGER_PSI_SUPPLY_REG,
1127 1, &data);
1128 outb(VOYAGER_CAT_END, CAT_CMD);
1129 } else {
1130
1131 VDEBUG(("Voyager ac fail reg 0x%x\n",
1132 psi_reg.subregs.ACfail));
1133 if((psi_reg.subregs.ACfail & AC_FAIL_STAT_CHANGE) == 0) {
1134 /* No further update */
1135 return;
1136 }
1137#if 0
1138 /* Don't bother trying to find out who failed.
1139 * FIXME: This probably makes the code incorrect on
1140 * anything other than a 345x */
1141 for(i=0; i< 5; i++) {
1142 if( psi_reg.subregs.ACfail &(1<<i)) {
1143 break;
1144 }
1145 }
1146 printk(KERN_NOTICE "AC FAIL IN SUPPLY %d\n", i);
1147#endif
1148 /* DON'T do this: it shuts down the AC PSI
1149 outb(VOYAGER_CAT_RUN, CAT_CMD);
1150 data = PSI_MASK_MASK | i;
1151 cat_subwrite(&psi, &psi_asic, VOYAGER_PSI_MASK,
1152 1, &data);
1153 outb(VOYAGER_CAT_END, CAT_CMD);
1154 */
1155 printk(KERN_ERR "Voyager AC power failure\n");
1156 outb(VOYAGER_CAT_RUN, CAT_CMD);
1157 data = PSI_COLD_START;
1158 cat_subwrite(&psi, &psi_asic, VOYAGER_PSI_GENERAL_REG,
1159 1, &data);
1160 outb(VOYAGER_CAT_END, CAT_CMD);
1161 voyager_status.power_fail = 1;
1162 voyager_status.request_from_kernel = 1;
1163 up(&kvoyagerd_sem);
1164 }
1165
1166
1167 } else if(psi_reg.regs.intstatus & PSI_FAULT) {
1168 /* Major fault! */
1169 printk(KERN_ERR "Voyager PSI Detected major fault, immediate power off!\n");
1170 voyager_cat_power_off();
1171 /* not reached */
1172 } else if(psi_reg.regs.intstatus & (PSI_DC_FAIL | PSI_ALARM
1173 | PSI_CURRENT | PSI_DVM
1174 | PSI_PSCFAULT | PSI_STAT_CHG)) {
1175 /* other psi fault */
1176
1177 printk(KERN_WARNING "Voyager PSI status 0x%x\n", data);
1178 /* clear the PSI fault */
1179 outb(VOYAGER_CAT_RUN, CAT_CMD);
1180 cat_write(&psi, &psi_asic, VOYAGER_PSI_STATUS_REG, 0);
1181 outb(VOYAGER_CAT_END, CAT_CMD);
1182 }
1183}