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