Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** ----------------------------------------------------------------------------- |
| 3 | ** |
| 4 | ** Perle Specialix driver for Linux |
| 5 | ** Ported from existing RIO Driver for SCO sources. |
| 6 | * |
| 7 | * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 | ** |
| 23 | ** Module : rioinit.c |
| 24 | ** SID : 1.3 |
| 25 | ** Last Modified : 11/6/98 10:33:43 |
| 26 | ** Retrieved : 11/6/98 10:33:49 |
| 27 | ** |
| 28 | ** ident @(#)rioinit.c 1.3 |
| 29 | ** |
| 30 | ** ----------------------------------------------------------------------------- |
| 31 | */ |
| 32 | #ifdef SCCS_LABELS |
| 33 | static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3"; |
| 34 | #endif |
| 35 | |
| 36 | #include <linux/config.h> |
| 37 | #include <linux/module.h> |
| 38 | #include <linux/slab.h> |
| 39 | #include <linux/errno.h> |
Adrian Bunk | 97998d8 | 2005-06-25 14:59:35 -0700 | [diff] [blame] | 40 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #include <asm/io.h> |
| 42 | #include <asm/system.h> |
| 43 | #include <asm/string.h> |
| 44 | #include <asm/semaphore.h> |
| 45 | #include <asm/uaccess.h> |
| 46 | |
| 47 | #include <linux/termios.h> |
| 48 | #include <linux/serial.h> |
| 49 | |
| 50 | #include <linux/generic_serial.h> |
| 51 | |
| 52 | |
| 53 | #include "linux_compat.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | #include "pkt.h" |
| 55 | #include "daemon.h" |
| 56 | #include "rio.h" |
| 57 | #include "riospace.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | #include "cmdpkt.h" |
| 59 | #include "map.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | #include "rup.h" |
| 61 | #include "port.h" |
| 62 | #include "riodrvr.h" |
| 63 | #include "rioinfo.h" |
| 64 | #include "func.h" |
| 65 | #include "errors.h" |
| 66 | #include "pci.h" |
| 67 | |
| 68 | #include "parmmap.h" |
| 69 | #include "unixrup.h" |
| 70 | #include "board.h" |
| 71 | #include "host.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | #include "phb.h" |
| 73 | #include "link.h" |
| 74 | #include "cmdblk.h" |
| 75 | #include "route.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | #include "cirrus.h" |
| 77 | #include "rioioctl.h" |
| 78 | #include "rio_linux.h" |
| 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | int RIOPCIinit(struct rio_info *p, int Mode); |
| 81 | |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame^] | 82 | static int RIOScrub(int, u8 __iomem *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
| 85 | /** |
| 86 | ** RIOAssignAT : |
| 87 | ** |
| 88 | ** Fill out the fields in the p->RIOHosts structure now we know we know |
| 89 | ** we have a board present. |
| 90 | ** |
| 91 | ** bits < 0 indicates 8 bit operation requested, |
| 92 | ** bits > 0 indicates 16 bit operation. |
| 93 | */ |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 94 | |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame^] | 95 | int RIOAssignAT(struct rio_info *p, int Base, void __iomem *virtAddr, int mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | { |
| 97 | int bits; |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame^] | 98 | struct DpRam __iomem *cardp = (struct DpRam __iomem *)virtAddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
| 100 | if ((Base < ONE_MEG) || (mode & BYTE_ACCESS_MODE)) |
| 101 | bits = BYTE_OPERATION; |
| 102 | else |
| 103 | bits = WORD_OPERATION; |
| 104 | |
| 105 | /* |
| 106 | ** Board has passed its scrub test. Fill in all the |
| 107 | ** transient stuff. |
| 108 | */ |
| 109 | p->RIOHosts[p->RIONumHosts].Caddr = virtAddr; |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame^] | 110 | p->RIOHosts[p->RIONumHosts].CardP = virtAddr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
| 112 | /* |
| 113 | ** Revision 01 AT host cards don't support WORD operations, |
| 114 | */ |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 115 | if (readb(&cardp->DpRevision) == 01) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | bits = BYTE_OPERATION; |
| 117 | |
| 118 | p->RIOHosts[p->RIONumHosts].Type = RIO_AT; |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 119 | p->RIOHosts[p->RIONumHosts].Copy = rio_copy_to_card; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | /* set this later */ |
| 121 | p->RIOHosts[p->RIONumHosts].Slot = -1; |
| 122 | p->RIOHosts[p->RIONumHosts].Mode = SLOW_LINKS | SLOW_AT_BUS | bits; |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 123 | writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | p->RIOHosts[p->RIONumHosts].Mode | INTERRUPT_DISABLE , |
| 124 | &p->RIOHosts[p->RIONumHosts].Control); |
| 125 | writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt); |
| 126 | writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | p->RIOHosts[p->RIONumHosts].Mode | INTERRUPT_DISABLE, |
| 127 | &p->RIOHosts[p->RIONumHosts].Control); |
| 128 | writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | p->RIOHosts[p->RIONumHosts].UniqueNum = |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 130 | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0])&0xFF)<<0)| |
| 131 | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1])&0xFF)<<8)| |
| 132 | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2])&0xFF)<<16)| |
| 133 | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3])&0xFF)<<24); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Uniquenum 0x%x\n",p->RIOHosts[p->RIONumHosts].UniqueNum); |
| 135 | |
| 136 | p->RIONumHosts++; |
| 137 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Tests Passed at 0x%x\n", Base); |
| 138 | return(1); |
| 139 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 141 | static u8 val[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | #ifdef VERY_LONG_TEST |
| 143 | 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, |
| 144 | 0xa5, 0xff, 0x5a, 0x00, 0xff, 0xc9, 0x36, |
| 145 | #endif |
| 146 | 0xff, 0x00, 0x00 }; |
| 147 | |
| 148 | #define TEST_END sizeof(val) |
| 149 | |
| 150 | /* |
| 151 | ** RAM test a board. |
| 152 | ** Nothing too complicated, just enough to check it out. |
| 153 | */ |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame^] | 154 | int RIOBoardTest(unsigned long paddr, void __iomem *caddr, unsigned char type, int slot) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | { |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame^] | 156 | struct DpRam __iomem *DpRam = caddr; |
| 157 | void __iomem *ram[4]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | int size[4]; |
| 159 | int op, bank; |
| 160 | int nbanks; |
| 161 | |
Alan Cox | 554b7c8 | 2006-03-24 03:18:32 -0800 | [diff] [blame] | 162 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Reset host type=%d, DpRam=%p, slot=%d\n", |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 163 | type, DpRam, slot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
| 165 | RIOHostReset(type, DpRam, slot); |
| 166 | |
| 167 | /* |
| 168 | ** Scrub the memory. This comes in several banks: |
| 169 | ** DPsram1 - 7000h bytes |
| 170 | ** DPsram2 - 200h bytes |
| 171 | ** DPsram3 - 7000h bytes |
| 172 | ** scratch - 1000h bytes |
| 173 | */ |
| 174 | |
| 175 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Setup ram/size arrays\n"); |
| 176 | |
| 177 | size[0] = DP_SRAM1_SIZE; |
| 178 | size[1] = DP_SRAM2_SIZE; |
| 179 | size[2] = DP_SRAM3_SIZE; |
| 180 | size[3] = DP_SCRATCH_SIZE; |
| 181 | |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame^] | 182 | ram[0] = DpRam->DpSram1; |
| 183 | ram[1] = DpRam->DpSram2; |
| 184 | ram[2] = DpRam->DpSram3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | nbanks = (type == RIO_PCI) ? 3 : 4; |
| 186 | if (nbanks == 4) |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame^] | 187 | ram[3] = DpRam->DpScratch; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
| 189 | |
| 190 | if (nbanks == 3) { |
Alan Cox | 554b7c8 | 2006-03-24 03:18:32 -0800 | [diff] [blame] | 191 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Memory: %p(0x%x), %p(0x%x), %p(0x%x)\n", |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 192 | ram[0], size[0], ram[1], size[1], ram[2], size[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | } else { |
Alan Cox | 554b7c8 | 2006-03-24 03:18:32 -0800 | [diff] [blame] | 194 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: %p(0x%x), %p(0x%x), %p(0x%x), %p(0x%x)\n", |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 195 | ram[0], size[0], ram[1], size[1], ram[2], size[2], ram[3], size[3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | /* |
| 199 | ** This scrub operation will test for crosstalk between |
| 200 | ** banks. TEST_END is a magic number, and relates to the offset |
| 201 | ** within the 'val' array used by Scrub. |
| 202 | */ |
| 203 | for (op=0; op<TEST_END; op++) { |
| 204 | for (bank=0; bank<nbanks; bank++) { |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame^] | 205 | if (RIOScrub(op, ram[bank], size[bank]) == RIO_FAIL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: RIOScrub band %d, op %d failed\n", |
| 207 | bank, op); |
| 208 | return RIO_FAIL; |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | rio_dprintk (RIO_DEBUG_INIT, "Test completed\n"); |
Alan Cox | 554b7c8 | 2006-03-24 03:18:32 -0800 | [diff] [blame] | 214 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | |
| 218 | /* |
| 219 | ** Scrub an area of RAM. |
| 220 | ** Define PRETEST and POSTTEST for a more thorough checking of the |
| 221 | ** state of the memory. |
| 222 | ** Call with op set to an index into the above 'val' array to determine |
| 223 | ** which value will be written into memory. |
| 224 | ** Call with op set to zero means that the RAM will not be read and checked |
| 225 | ** before it is written. |
| 226 | ** Call with op not zero, and the RAM will be read and compated with val[op-1] |
| 227 | ** to check that the data from the previous phase was retained. |
| 228 | */ |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 229 | |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame^] | 230 | static int RIOScrub(int op, u8 __iomem *ram, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | { |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 232 | int off; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | unsigned char oldbyte; |
| 234 | unsigned char newbyte; |
| 235 | unsigned char invbyte; |
| 236 | unsigned short oldword; |
| 237 | unsigned short newword; |
| 238 | unsigned short invword; |
| 239 | unsigned short swapword; |
| 240 | |
| 241 | if (op) { |
| 242 | oldbyte = val[op-1]; |
| 243 | oldword = oldbyte | (oldbyte<<8); |
| 244 | } else |
| 245 | oldbyte = oldword = 0; /* Tell the compiler we've initilalized them. */ |
| 246 | newbyte = val[op]; |
| 247 | newword = newbyte | (newbyte<<8); |
| 248 | invbyte = ~newbyte; |
| 249 | invword = invbyte | (invbyte<<8); |
| 250 | |
| 251 | /* |
| 252 | ** Check that the RAM contains the value that should have been left there |
| 253 | ** by the previous test (not applicable for pass zero) |
| 254 | */ |
| 255 | if (op) { |
| 256 | for (off=0; off<size; off++) { |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 257 | if (readb(ram + off) != oldbyte) { |
| 258 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 1: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, readb(ram + off)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | return RIO_FAIL; |
| 260 | } |
| 261 | } |
| 262 | for (off=0; off<size; off+=2) { |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 263 | if (readw(ram + off) != oldword) { |
| 264 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: WORD at offset 0x%x should have been=%x, was=%x\n",off,oldword, readw(ram + off)); |
| 265 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram+off+1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | return RIO_FAIL; |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | /* |
| 272 | ** Now write the INVERSE of the test data into every location, using |
| 273 | ** BYTE write operations, first checking before each byte is written |
| 274 | ** that the location contains the old value still, and checking after |
| 275 | ** the write that the location contains the data specified - this is |
| 276 | ** the BYTE read/write test. |
| 277 | */ |
| 278 | for (off=0; off<size; off++) { |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 279 | if (op && (readb(ram + off) != oldbyte)) { |
| 280 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, readb(ram + off)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | return RIO_FAIL; |
| 282 | } |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 283 | writeb(invbyte, ram + off); |
| 284 | if (readb(ram + off) != invbyte) { |
| 285 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Inv Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, invbyte, readb(ram + off)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | return RIO_FAIL; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | /* |
| 291 | ** now, use WORD operations to write the test value into every location, |
| 292 | ** check as before that the location contains the previous test value |
| 293 | ** before overwriting, and that it contains the data value written |
| 294 | ** afterwards. |
| 295 | ** This is the WORD operation test. |
| 296 | */ |
| 297 | for (off=0; off<size; off+=2) { |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 298 | if (readw(ram + off) != invword) { |
| 299 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: WORD at offset 0x%x should have been=%x, was=%x\n", off, invword, readw(ram + off)); |
| 300 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram+off+1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | return RIO_FAIL; |
| 302 | } |
| 303 | |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 304 | writew(newword, ram + off); |
| 305 | if ( readw(ram + off) != newword ) { |
| 306 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, readw(ram + off)); |
| 307 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram + off + 1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | return RIO_FAIL; |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | /* |
| 313 | ** now run through the block of memory again, first in byte mode |
| 314 | ** then in word mode, and check that all the locations contain the |
| 315 | ** required test data. |
| 316 | */ |
| 317 | for (off=0; off<size; off++) { |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 318 | if (readb(ram + off) != newbyte) { |
| 319 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Byte Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, readb(ram + off)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | return RIO_FAIL; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | for (off=0; off<size; off+=2) { |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 325 | if (readw(ram + off) != newword ) { |
| 326 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, readw(ram + off)); |
| 327 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram + off + 1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | return RIO_FAIL; |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | /* |
| 333 | ** time to check out byte swapping errors |
| 334 | */ |
| 335 | swapword = invbyte | (newbyte << 8); |
| 336 | |
| 337 | for (off=0; off<size; off+=2) { |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 338 | writeb(invbyte, &ram[off]); |
| 339 | writeb(newbyte, &ram[off+1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | for ( off=0; off<size; off+=2 ) { |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 343 | if (readw(ram + off) != swapword) { |
| 344 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, swapword, readw(ram + off)); |
| 345 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram + off + 1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | return RIO_FAIL; |
| 347 | } |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 348 | writew(~swapword, ram + off); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | for (off=0; off<size; off+=2) { |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 352 | if (readb(ram + off) != newbyte) { |
| 353 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, readb(ram + off)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | return RIO_FAIL; |
| 355 | } |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 356 | if (readb(ram + off + 1) != invbyte) { |
| 357 | rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off+1, invbyte, readb(ram + off + 1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | return RIO_FAIL; |
| 359 | } |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 360 | writew(newword, ram + off); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | } |
Alan Cox | 554b7c8 | 2006-03-24 03:18:32 -0800 | [diff] [blame] | 362 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 366 | int RIODefaultName(struct rio_info *p, struct Host *HostP, unsigned int UnitId) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | { |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 368 | memcpy(HostP->Mapping[UnitId].Name, "UNKNOWN RTA X-XX", 17); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | HostP->Mapping[UnitId].Name[12]='1'+(HostP-p->RIOHosts); |
| 370 | if ((UnitId+1) > 9) { |
| 371 | HostP->Mapping[UnitId].Name[14]='0'+((UnitId+1)/10); |
| 372 | HostP->Mapping[UnitId].Name[15]='0'+((UnitId+1)%10); |
| 373 | } |
| 374 | else { |
| 375 | HostP->Mapping[UnitId].Name[14]='1'+UnitId; |
| 376 | HostP->Mapping[UnitId].Name[15]=0; |
| 377 | } |
| 378 | return 0; |
| 379 | } |
| 380 | |
| 381 | #define RIO_RELEASE "Linux" |
| 382 | #define RELEASE_ID "1.0" |
| 383 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | static struct rioVersion stVersion; |
| 385 | |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 386 | struct rioVersion *RIOVersid(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | { |
| 388 | strlcpy(stVersion.version, "RIO driver for linux V1.0", |
| 389 | sizeof(stVersion.version)); |
| 390 | strlcpy(stVersion.buildDate, __DATE__, |
| 391 | sizeof(stVersion.buildDate)); |
| 392 | |
| 393 | return &stVersion; |
| 394 | } |
| 395 | |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame^] | 396 | void RIOHostReset(unsigned int Type, struct DpRam __iomem *DpRamP, unsigned int Slot) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | { |
| 398 | /* |
| 399 | ** Reset the Tpu |
| 400 | */ |
| 401 | rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: type 0x%x", Type); |
| 402 | switch ( Type ) { |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 403 | case RIO_AT: |
| 404 | rio_dprintk (RIO_DEBUG_INIT, " (RIO_AT)\n"); |
| 405 | writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | INTERRUPT_DISABLE | BYTE_OPERATION | |
| 406 | SLOW_LINKS | SLOW_AT_BUS, &DpRamP->DpControl); |
| 407 | writeb(0xFF, &DpRamP->DpResetTpu); |
| 408 | udelay(3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: Don't know if it worked. Try reset again\n"); |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 410 | writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | INTERRUPT_DISABLE | |
| 411 | BYTE_OPERATION | SLOW_LINKS | SLOW_AT_BUS, &DpRamP->DpControl); |
| 412 | writeb(0xFF, &DpRamP->DpResetTpu); |
| 413 | udelay(3); |
| 414 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | case RIO_PCI: |
| 416 | rio_dprintk (RIO_DEBUG_INIT, " (RIO_PCI)\n"); |
Alan Cox | 00d83a5 | 2006-03-24 03:18:28 -0800 | [diff] [blame] | 417 | writeb(RIO_PCI_BOOT_FROM_RAM, &DpRamP->DpControl); |
| 418 | writeb(0xFF, &DpRamP->DpResetInt); |
| 419 | writeb(0xFF, &DpRamP->DpResetTpu); |
Adrian Bunk | 97998d8 | 2005-06-25 14:59:35 -0700 | [diff] [blame] | 420 | udelay(100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | default: |
| 423 | rio_dprintk (RIO_DEBUG_INIT, " (UNKNOWN)\n"); |
| 424 | break; |
| 425 | } |
| 426 | return; |
| 427 | } |