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