| 1 |
1626 |
jcastillo |
#define AUTOSENSE
|
| 2 |
|
|
#define PSEUDO_DMA
|
| 3 |
|
|
|
| 4 |
|
|
/*
|
| 5 |
|
|
* Trantor T128/T128F/T228 driver
|
| 6 |
|
|
* Note : architecturally, the T100 and T130 are different and won't
|
| 7 |
|
|
* work
|
| 8 |
|
|
*
|
| 9 |
|
|
* Copyright 1993, Drew Eckhardt
|
| 10 |
|
|
* Visionary Computing
|
| 11 |
|
|
* (Unix and Linux consulting and custom programming)
|
| 12 |
|
|
* drew@colorado.edu
|
| 13 |
|
|
* +1 (303) 440-4894
|
| 14 |
|
|
*
|
| 15 |
|
|
* DISTRIBUTION RELEASE 3.
|
| 16 |
|
|
*
|
| 17 |
|
|
* For more information, please consult
|
| 18 |
|
|
*
|
| 19 |
|
|
* Trantor Systems, Ltd.
|
| 20 |
|
|
* T128/T128F/T228 SCSI Host Adapter
|
| 21 |
|
|
* Hardware Specifications
|
| 22 |
|
|
*
|
| 23 |
|
|
* Trantor Systems, Ltd.
|
| 24 |
|
|
* 5415 Randall Place
|
| 25 |
|
|
* Fremont, CA 94538
|
| 26 |
|
|
* 1+ (415) 770-1400, FAX 1+ (415) 770-9910
|
| 27 |
|
|
*
|
| 28 |
|
|
* and
|
| 29 |
|
|
*
|
| 30 |
|
|
* NCR 5380 Family
|
| 31 |
|
|
* SCSI Protocol Controller
|
| 32 |
|
|
* Databook
|
| 33 |
|
|
*
|
| 34 |
|
|
* NCR Microelectronics
|
| 35 |
|
|
* 1635 Aeroplaza Drive
|
| 36 |
|
|
* Colorado Springs, CO 80916
|
| 37 |
|
|
* 1+ (719) 578-3400
|
| 38 |
|
|
* 1+ (800) 334-5454
|
| 39 |
|
|
*/
|
| 40 |
|
|
|
| 41 |
|
|
/*
|
| 42 |
|
|
* Options :
|
| 43 |
|
|
* AUTOSENSE - if defined, REQUEST SENSE will be performed automatically
|
| 44 |
|
|
* for commands that return with a CHECK CONDITION status.
|
| 45 |
|
|
*
|
| 46 |
|
|
* PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance
|
| 47 |
|
|
* increase compared to polled I/O.
|
| 48 |
|
|
*
|
| 49 |
|
|
* PARITY - enable parity checking. Not supported.
|
| 50 |
|
|
*
|
| 51 |
|
|
* SCSI2 - enable support for SCSI-II tagged queueing. Untested.
|
| 52 |
|
|
*
|
| 53 |
|
|
*
|
| 54 |
|
|
* UNSAFE - leave interrupts enabled during pseudo-DMA transfers. You
|
| 55 |
|
|
* only really want to use this if you're having a problem with
|
| 56 |
|
|
* dropped characters during high speed communications, and even
|
| 57 |
|
|
* then, you're going to be better off twiddling with transfersize.
|
| 58 |
|
|
*
|
| 59 |
|
|
* USLEEP - enable support for devices that don't disconnect. Untested.
|
| 60 |
|
|
*
|
| 61 |
|
|
* The card is detected and initialized in one of several ways :
|
| 62 |
|
|
* 1. Autoprobe (default) - since the board is memory mapped,
|
| 63 |
|
|
* a BIOS signature is scanned for to locate the registers.
|
| 64 |
|
|
* An interrupt is triggered to autoprobe for the interrupt
|
| 65 |
|
|
* line.
|
| 66 |
|
|
*
|
| 67 |
|
|
* 2. With command line overrides - t128=address,irq may be
|
| 68 |
|
|
* used on the LILO command line to override the defaults.
|
| 69 |
|
|
*
|
| 70 |
|
|
* 3. With the T128_OVERRIDE compile time define. This is
|
| 71 |
|
|
* specified as an array of address, irq tuples. Ie, for
|
| 72 |
|
|
* one board at the default 0xcc000 address, IRQ5, I could say
|
| 73 |
|
|
* -DT128_OVERRIDE={{0xcc000, 5}}
|
| 74 |
|
|
*
|
| 75 |
|
|
* Note that if the override methods are used, place holders must
|
| 76 |
|
|
* be specified for other boards in the system.
|
| 77 |
|
|
*
|
| 78 |
|
|
* T128/T128F jumper/dipswitch settings (note : on my sample, the switches
|
| 79 |
|
|
* were epoxy'd shut, meaning I couldn't change the 0xcc000 base address) :
|
| 80 |
|
|
*
|
| 81 |
|
|
* T128 Sw7 Sw8 Sw6 = 0ws Sw5 = boot
|
| 82 |
|
|
* T128F Sw6 Sw7 Sw5 = 0ws Sw4 = boot Sw8 = floppy disable
|
| 83 |
|
|
* cc000 off off
|
| 84 |
|
|
* c8000 off on
|
| 85 |
|
|
* dc000 on off
|
| 86 |
|
|
* d8000 on on
|
| 87 |
|
|
*
|
| 88 |
|
|
*
|
| 89 |
|
|
* Interrupts
|
| 90 |
|
|
* There is a 12 pin jumper block, jp1, numbered as follows :
|
| 91 |
|
|
* T128 (JP1) T128F (J5)
|
| 92 |
|
|
* 2 4 6 8 10 12 11 9 7 5 3 1
|
| 93 |
|
|
* 1 3 5 7 9 11 12 10 8 6 4 2
|
| 94 |
|
|
*
|
| 95 |
|
|
* 3 2-4
|
| 96 |
|
|
* 5 1-3
|
| 97 |
|
|
* 7 3-5
|
| 98 |
|
|
* T128F only
|
| 99 |
|
|
* 10 8-10
|
| 100 |
|
|
* 12 7-9
|
| 101 |
|
|
* 14 10-12
|
| 102 |
|
|
* 15 9-11
|
| 103 |
|
|
*/
|
| 104 |
|
|
|
| 105 |
|
|
/*
|
| 106 |
|
|
* $Log: not supported by cvs2svn $
|
| 107 |
|
|
* Revision 1.1.1.1 2001/09/10 07:44:35 simons
|
| 108 |
|
|
* Initial import
|
| 109 |
|
|
*
|
| 110 |
|
|
* Revision 1.1.1.1 2001/07/02 17:58:27 simons
|
| 111 |
|
|
* Initial revision
|
| 112 |
|
|
*
|
| 113 |
|
|
*/
|
| 114 |
|
|
|
| 115 |
|
|
#include <asm/system.h>
|
| 116 |
|
|
#include <linux/signal.h>
|
| 117 |
|
|
#include <linux/sched.h>
|
| 118 |
|
|
#include <asm/io.h>
|
| 119 |
|
|
#include <linux/blk.h>
|
| 120 |
|
|
#include "scsi.h"
|
| 121 |
|
|
#include "hosts.h"
|
| 122 |
|
|
#include "t128.h"
|
| 123 |
|
|
#define AUTOPROBE_IRQ
|
| 124 |
|
|
#include "NCR5380.h"
|
| 125 |
|
|
#include "constants.h"
|
| 126 |
|
|
#include "sd.h"
|
| 127 |
|
|
#include<linux/stat.h>
|
| 128 |
|
|
|
| 129 |
|
|
struct proc_dir_entry proc_scsi_t128 = {
|
| 130 |
|
|
PROC_SCSI_T128, 4, "t128",
|
| 131 |
|
|
S_IFDIR | S_IRUGO | S_IXUGO, 2
|
| 132 |
|
|
};
|
| 133 |
|
|
|
| 134 |
|
|
|
| 135 |
|
|
static struct override {
|
| 136 |
|
|
unsigned char *address;
|
| 137 |
|
|
int irq;
|
| 138 |
|
|
} overrides
|
| 139 |
|
|
#ifdef T128_OVERRIDE
|
| 140 |
|
|
[] = T128_OVERRIDE;
|
| 141 |
|
|
#else
|
| 142 |
|
|
[4] = {{NULL,IRQ_AUTO}, {NULL,IRQ_AUTO}, {NULL,IRQ_AUTO},
|
| 143 |
|
|
{NULL,IRQ_AUTO}};
|
| 144 |
|
|
#endif
|
| 145 |
|
|
|
| 146 |
|
|
#define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override))
|
| 147 |
|
|
|
| 148 |
|
|
static struct base {
|
| 149 |
|
|
unsigned char *address;
|
| 150 |
|
|
int noauto;
|
| 151 |
|
|
} bases[] = {{(unsigned char *) 0xcc000, 0}, {(unsigned char *) 0xc8000, 0},
|
| 152 |
|
|
{(unsigned char *) 0xdc000, 0}, {(unsigned char *) 0xd8000, 0}};
|
| 153 |
|
|
|
| 154 |
|
|
#define NO_BASES (sizeof (bases) / sizeof (struct base))
|
| 155 |
|
|
|
| 156 |
|
|
static const struct signature {
|
| 157 |
|
|
const char *string;
|
| 158 |
|
|
int offset;
|
| 159 |
|
|
} signatures[] = {
|
| 160 |
|
|
{"TSROM: SCSI BIOS, Version 1.12", 0x36},
|
| 161 |
|
|
};
|
| 162 |
|
|
|
| 163 |
|
|
#define NO_SIGNATURES (sizeof (signatures) / sizeof (struct signature))
|
| 164 |
|
|
|
| 165 |
|
|
/*
|
| 166 |
|
|
* Function : t128_setup(char *str, int *ints)
|
| 167 |
|
|
*
|
| 168 |
|
|
* Purpose : LILO command line initialization of the overrides array,
|
| 169 |
|
|
*
|
| 170 |
|
|
* Inputs : str - unused, ints - array of integer parameters with ints[0]
|
| 171 |
|
|
* equal to the number of ints.
|
| 172 |
|
|
*
|
| 173 |
|
|
*/
|
| 174 |
|
|
|
| 175 |
|
|
void t128_setup(char *str, int *ints) {
|
| 176 |
|
|
static int commandline_current = 0;
|
| 177 |
|
|
int i;
|
| 178 |
|
|
if (ints[0] != 2)
|
| 179 |
|
|
printk("t128_setup : usage t128=address,irq\n");
|
| 180 |
|
|
else
|
| 181 |
|
|
if (commandline_current < NO_OVERRIDES) {
|
| 182 |
|
|
overrides[commandline_current].address = (unsigned char *) ints[1];
|
| 183 |
|
|
overrides[commandline_current].irq = ints[2];
|
| 184 |
|
|
for (i = 0; i < NO_BASES; ++i)
|
| 185 |
|
|
if (bases[i].address == (unsigned char *) ints[1]) {
|
| 186 |
|
|
bases[i].noauto = 1;
|
| 187 |
|
|
break;
|
| 188 |
|
|
}
|
| 189 |
|
|
++commandline_current;
|
| 190 |
|
|
}
|
| 191 |
|
|
}
|
| 192 |
|
|
|
| 193 |
|
|
/*
|
| 194 |
|
|
* Function : int t128_detect(Scsi_Host_Template * tpnt)
|
| 195 |
|
|
*
|
| 196 |
|
|
* Purpose : detects and initializes T128,T128F, or T228 controllers
|
| 197 |
|
|
* that were autoprobed, overridden on the LILO command line,
|
| 198 |
|
|
* or specified at compile time.
|
| 199 |
|
|
*
|
| 200 |
|
|
* Inputs : tpnt - template for this SCSI adapter.
|
| 201 |
|
|
*
|
| 202 |
|
|
* Returns : 1 if a host adapter was found, 0 if not.
|
| 203 |
|
|
*
|
| 204 |
|
|
*/
|
| 205 |
|
|
|
| 206 |
|
|
int t128_detect(Scsi_Host_Template * tpnt) {
|
| 207 |
|
|
static int current_override = 0, current_base = 0;
|
| 208 |
|
|
struct Scsi_Host *instance;
|
| 209 |
|
|
unsigned char *base;
|
| 210 |
|
|
int sig, count;
|
| 211 |
|
|
|
| 212 |
|
|
tpnt->proc_dir = &proc_scsi_t128;
|
| 213 |
|
|
tpnt->proc_info = &t128_proc_info;
|
| 214 |
|
|
|
| 215 |
|
|
for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
|
| 216 |
|
|
base = NULL;
|
| 217 |
|
|
|
| 218 |
|
|
if (overrides[current_override].address)
|
| 219 |
|
|
base = overrides[current_override].address;
|
| 220 |
|
|
else
|
| 221 |
|
|
for (; !base && (current_base < NO_BASES); ++current_base) {
|
| 222 |
|
|
#if (TDEBUG & TDEBUG_INIT)
|
| 223 |
|
|
printk("scsi : probing address %08x\n", (unsigned int) bases[current_base].address);
|
| 224 |
|
|
#endif
|
| 225 |
|
|
for (sig = 0; sig < NO_SIGNATURES; ++sig)
|
| 226 |
|
|
if (!bases[current_base].noauto && !memcmp
|
| 227 |
|
|
(bases[current_base].address + signatures[sig].offset,
|
| 228 |
|
|
signatures[sig].string, strlen(signatures[sig].string))) {
|
| 229 |
|
|
base = bases[current_base].address;
|
| 230 |
|
|
#if (TDEBUG & TDEBUG_INIT)
|
| 231 |
|
|
printk("scsi-t128 : detected board.\n");
|
| 232 |
|
|
#endif
|
| 233 |
|
|
break;
|
| 234 |
|
|
}
|
| 235 |
|
|
}
|
| 236 |
|
|
|
| 237 |
|
|
#if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT)
|
| 238 |
|
|
printk("scsi-t128 : base = %08x\n", (unsigned int) base);
|
| 239 |
|
|
#endif
|
| 240 |
|
|
|
| 241 |
|
|
if (!base)
|
| 242 |
|
|
break;
|
| 243 |
|
|
|
| 244 |
|
|
instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
|
| 245 |
|
|
instance->base = base;
|
| 246 |
|
|
|
| 247 |
|
|
NCR5380_init(instance, 0);
|
| 248 |
|
|
|
| 249 |
|
|
if (overrides[current_override].irq != IRQ_AUTO)
|
| 250 |
|
|
instance->irq = overrides[current_override].irq;
|
| 251 |
|
|
else
|
| 252 |
|
|
instance->irq = NCR5380_probe_irq(instance, T128_IRQS);
|
| 253 |
|
|
|
| 254 |
|
|
if (instance->irq != IRQ_NONE)
|
| 255 |
|
|
if (request_irq(instance->irq, t128_intr, SA_INTERRUPT, "t128", NULL)) {
|
| 256 |
|
|
printk("scsi%d : IRQ%d not free, interrupts disabled\n",
|
| 257 |
|
|
instance->host_no, instance->irq);
|
| 258 |
|
|
instance->irq = IRQ_NONE;
|
| 259 |
|
|
}
|
| 260 |
|
|
|
| 261 |
|
|
if (instance->irq == IRQ_NONE) {
|
| 262 |
|
|
printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
|
| 263 |
|
|
printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
|
| 264 |
|
|
}
|
| 265 |
|
|
|
| 266 |
|
|
#if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT)
|
| 267 |
|
|
printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
|
| 268 |
|
|
#endif
|
| 269 |
|
|
|
| 270 |
|
|
printk("scsi%d : at 0x%08x", instance->host_no, (int)
|
| 271 |
|
|
instance->base);
|
| 272 |
|
|
if (instance->irq == IRQ_NONE)
|
| 273 |
|
|
printk (" interrupts disabled");
|
| 274 |
|
|
else
|
| 275 |
|
|
printk (" irq %d", instance->irq);
|
| 276 |
|
|
printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
|
| 277 |
|
|
CAN_QUEUE, CMD_PER_LUN, T128_PUBLIC_RELEASE);
|
| 278 |
|
|
NCR5380_print_options(instance);
|
| 279 |
|
|
printk("\n");
|
| 280 |
|
|
|
| 281 |
|
|
++current_override;
|
| 282 |
|
|
++count;
|
| 283 |
|
|
}
|
| 284 |
|
|
return count;
|
| 285 |
|
|
}
|
| 286 |
|
|
|
| 287 |
|
|
/*
|
| 288 |
|
|
* Function : int t128_biosparam(Disk * disk, kdev_t dev, int *ip)
|
| 289 |
|
|
*
|
| 290 |
|
|
* Purpose : Generates a BIOS / DOS compatible H-C-S mapping for
|
| 291 |
|
|
* the specified device / size.
|
| 292 |
|
|
*
|
| 293 |
|
|
* Inputs : size = size of device in sectors (512 bytes), dev = block device
|
| 294 |
|
|
* major / minor, ip[] = {heads, sectors, cylinders}
|
| 295 |
|
|
*
|
| 296 |
|
|
* Returns : always 0 (success), initializes ip
|
| 297 |
|
|
*
|
| 298 |
|
|
*/
|
| 299 |
|
|
|
| 300 |
|
|
/*
|
| 301 |
|
|
* XXX Most SCSI boards use this mapping, I could be incorrect. Some one
|
| 302 |
|
|
* using hard disks on a trantor should verify that this mapping corresponds
|
| 303 |
|
|
* to that used by the BIOS / ASPI driver by running the linux fdisk program
|
| 304 |
|
|
* and matching the H_C_S coordinates to what DOS uses.
|
| 305 |
|
|
*/
|
| 306 |
|
|
|
| 307 |
|
|
int t128_biosparam(Disk * disk, kdev_t dev, int * ip)
|
| 308 |
|
|
{
|
| 309 |
|
|
int size = disk->capacity;
|
| 310 |
|
|
ip[0] = 64;
|
| 311 |
|
|
ip[1] = 32;
|
| 312 |
|
|
ip[2] = size >> 11;
|
| 313 |
|
|
return 0;
|
| 314 |
|
|
}
|
| 315 |
|
|
|
| 316 |
|
|
/*
|
| 317 |
|
|
* Function : int NCR5380_pread (struct Scsi_Host *instance,
|
| 318 |
|
|
* unsigned char *dst, int len)
|
| 319 |
|
|
*
|
| 320 |
|
|
* Purpose : Fast 5380 pseudo-dma read function, transfers len bytes to
|
| 321 |
|
|
* dst
|
| 322 |
|
|
*
|
| 323 |
|
|
* Inputs : dst = destination, len = length in bytes
|
| 324 |
|
|
*
|
| 325 |
|
|
* Returns : 0 on success, non zero on a failure such as a watchdog
|
| 326 |
|
|
* timeout.
|
| 327 |
|
|
*/
|
| 328 |
|
|
|
| 329 |
|
|
static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst,
|
| 330 |
|
|
int len) {
|
| 331 |
|
|
register unsigned char *reg = (unsigned char *) (instance->base +
|
| 332 |
|
|
T_DATA_REG_OFFSET), *d = dst;
|
| 333 |
|
|
register int i = len;
|
| 334 |
|
|
|
| 335 |
|
|
|
| 336 |
|
|
#if 0
|
| 337 |
|
|
for (; i; --i) {
|
| 338 |
|
|
while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
|
| 339 |
|
|
#else
|
| 340 |
|
|
while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
|
| 341 |
|
|
for (; i; --i) {
|
| 342 |
|
|
#endif
|
| 343 |
|
|
*d++ = *reg;
|
| 344 |
|
|
}
|
| 345 |
|
|
|
| 346 |
|
|
if (*(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
|
| 347 |
|
|
unsigned char tmp;
|
| 348 |
|
|
volatile unsigned char *foo;
|
| 349 |
|
|
foo = instance->base + T_CONTROL_REG_OFFSET;
|
| 350 |
|
|
tmp = *foo;
|
| 351 |
|
|
*foo = tmp | T_CR_CT;
|
| 352 |
|
|
*foo = tmp;
|
| 353 |
|
|
printk("scsi%d : watchdog timer fired in NCR5380_pread()\n",
|
| 354 |
|
|
instance->host_no);
|
| 355 |
|
|
return -1;
|
| 356 |
|
|
} else
|
| 357 |
|
|
return 0;
|
| 358 |
|
|
}
|
| 359 |
|
|
|
| 360 |
|
|
/*
|
| 361 |
|
|
* Function : int NCR5380_pwrite (struct Scsi_Host *instance,
|
| 362 |
|
|
* unsigned char *src, int len)
|
| 363 |
|
|
*
|
| 364 |
|
|
* Purpose : Fast 5380 pseudo-dma write function, transfers len bytes from
|
| 365 |
|
|
* src
|
| 366 |
|
|
*
|
| 367 |
|
|
* Inputs : src = source, len = length in bytes
|
| 368 |
|
|
*
|
| 369 |
|
|
* Returns : 0 on success, non zero on a failure such as a watchdog
|
| 370 |
|
|
* timeout.
|
| 371 |
|
|
*/
|
| 372 |
|
|
|
| 373 |
|
|
static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src,
|
| 374 |
|
|
int len) {
|
| 375 |
|
|
register unsigned char *reg = (unsigned char *) (instance->base +
|
| 376 |
|
|
T_DATA_REG_OFFSET), *s = src;
|
| 377 |
|
|
register int i = len;
|
| 378 |
|
|
|
| 379 |
|
|
#if 0
|
| 380 |
|
|
for (; i; --i) {
|
| 381 |
|
|
while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
|
| 382 |
|
|
#else
|
| 383 |
|
|
while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
|
| 384 |
|
|
for (; i; --i) {
|
| 385 |
|
|
#endif
|
| 386 |
|
|
*reg = *s++;
|
| 387 |
|
|
}
|
| 388 |
|
|
|
| 389 |
|
|
if (*(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
|
| 390 |
|
|
unsigned char tmp;
|
| 391 |
|
|
volatile unsigned char *foo;
|
| 392 |
|
|
foo = instance->base + T_CONTROL_REG_OFFSET;
|
| 393 |
|
|
tmp = *foo;
|
| 394 |
|
|
*foo = tmp | T_CR_CT;
|
| 395 |
|
|
*foo = tmp;
|
| 396 |
|
|
printk("scsi%d : watchdog timer fired in NCR5380_pwrite()\n",
|
| 397 |
|
|
instance->host_no);
|
| 398 |
|
|
return -1;
|
| 399 |
|
|
} else
|
| 400 |
|
|
return 0;
|
| 401 |
|
|
}
|
| 402 |
|
|
|
| 403 |
|
|
#include "NCR5380.c"
|
| 404 |
|
|
|
| 405 |
|
|
#ifdef MODULE
|
| 406 |
|
|
/* Eventually this will go into an include file, but this will be later */
|
| 407 |
|
|
Scsi_Host_Template driver_template = TRANTOR_T128;
|
| 408 |
|
|
|
| 409 |
|
|
#include "scsi_module.c"
|
| 410 |
|
|
#endif
|