OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [uclinux/] [uClinux-2.0.x/] [drivers/] [scsi/] [t128.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
#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/07/02 17:58:27  simons
108
 * Initial revision
109
 *
110
 */
111
 
112
#include <asm/system.h>
113
#include <linux/signal.h>
114
#include <linux/sched.h>
115
#include <asm/io.h>
116
#include <linux/blk.h>
117
#include "scsi.h"
118
#include "hosts.h"
119
#include "t128.h"
120
#define AUTOPROBE_IRQ
121
#include "NCR5380.h"
122
#include "constants.h"
123
#include "sd.h"
124
#include<linux/stat.h>
125
 
126
struct proc_dir_entry proc_scsi_t128 = {
127
    PROC_SCSI_T128, 4, "t128",
128
    S_IFDIR | S_IRUGO | S_IXUGO, 2
129
};
130
 
131
 
132
static struct override {
133
    unsigned char *address;
134
    int irq;
135
} overrides
136
#ifdef T128_OVERRIDE
137
    [] = T128_OVERRIDE;
138
#else
139
    [4] = {{NULL,IRQ_AUTO}, {NULL,IRQ_AUTO}, {NULL,IRQ_AUTO},
140
        {NULL,IRQ_AUTO}};
141
#endif
142
 
143
#define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override))
144
 
145
static struct base {
146
    unsigned char *address;
147
    int noauto;
148
} bases[] = {{(unsigned char *) 0xcc000, 0}, {(unsigned char *) 0xc8000, 0},
149
    {(unsigned char *) 0xdc000, 0}, {(unsigned char *) 0xd8000, 0}};
150
 
151
#define NO_BASES (sizeof (bases) / sizeof (struct base))
152
 
153
static const struct signature {
154
    const char *string;
155
    int offset;
156
} signatures[] = {
157
{"TSROM: SCSI BIOS, Version 1.12", 0x36},
158
};
159
 
160
#define NO_SIGNATURES (sizeof (signatures) /  sizeof (struct signature))
161
 
162
/*
163
 * Function : t128_setup(char *str, int *ints)
164
 *
165
 * Purpose : LILO command line initialization of the overrides array,
166
 *
167
 * Inputs : str - unused, ints - array of integer parameters with ints[0]
168
 *      equal to the number of ints.
169
 *
170
 */
171
 
172
void t128_setup(char *str, int *ints) {
173
    static int commandline_current = 0;
174
    int i;
175
    if (ints[0] != 2)
176
        printk("t128_setup : usage t128=address,irq\n");
177
    else
178
        if (commandline_current < NO_OVERRIDES) {
179
            overrides[commandline_current].address = (unsigned char *) ints[1];
180
            overrides[commandline_current].irq = ints[2];
181
            for (i = 0; i < NO_BASES; ++i)
182
                if (bases[i].address == (unsigned char *) ints[1]) {
183
                    bases[i].noauto = 1;
184
                    break;
185
                }
186
            ++commandline_current;
187
        }
188
}
189
 
190
/*
191
 * Function : int t128_detect(Scsi_Host_Template * tpnt)
192
 *
193
 * Purpose : detects and initializes T128,T128F, or T228 controllers
194
 *      that were autoprobed, overridden on the LILO command line,
195
 *      or specified at compile time.
196
 *
197
 * Inputs : tpnt - template for this SCSI adapter.
198
 *
199
 * Returns : 1 if a host adapter was found, 0 if not.
200
 *
201
 */
202
 
203
int t128_detect(Scsi_Host_Template * tpnt) {
204
    static int current_override = 0, current_base = 0;
205
    struct Scsi_Host *instance;
206
    unsigned char *base;
207
    int sig, count;
208
 
209
    tpnt->proc_dir = &proc_scsi_t128;
210
    tpnt->proc_info = &t128_proc_info;
211
 
212
    for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
213
        base = NULL;
214
 
215
        if (overrides[current_override].address)
216
            base = overrides[current_override].address;
217
        else
218
            for (; !base && (current_base < NO_BASES); ++current_base) {
219
#if (TDEBUG & TDEBUG_INIT)
220
    printk("scsi : probing address %08x\n", (unsigned int) bases[current_base].address);
221
#endif
222
                for (sig = 0; sig < NO_SIGNATURES; ++sig)
223
                    if (!bases[current_base].noauto && !memcmp
224
                        (bases[current_base].address + signatures[sig].offset,
225
                        signatures[sig].string, strlen(signatures[sig].string))) {
226
                        base = bases[current_base].address;
227
#if (TDEBUG & TDEBUG_INIT)
228
                        printk("scsi-t128 : detected board.\n");
229
#endif
230
                        break;
231
                    }
232
            }
233
 
234
#if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT)
235
        printk("scsi-t128 : base = %08x\n", (unsigned int) base);
236
#endif
237
 
238
        if (!base)
239
            break;
240
 
241
        instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
242
        instance->base = base;
243
 
244
        NCR5380_init(instance, 0);
245
 
246
        if (overrides[current_override].irq != IRQ_AUTO)
247
            instance->irq = overrides[current_override].irq;
248
        else
249
            instance->irq = NCR5380_probe_irq(instance, T128_IRQS);
250
 
251
        if (instance->irq != IRQ_NONE)
252
            if (request_irq(instance->irq, t128_intr, SA_INTERRUPT, "t128", NULL)) {
253
                printk("scsi%d : IRQ%d not free, interrupts disabled\n",
254
                    instance->host_no, instance->irq);
255
                instance->irq = IRQ_NONE;
256
            }
257
 
258
        if (instance->irq == IRQ_NONE) {
259
            printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
260
            printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
261
        }
262
 
263
#if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT)
264
        printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
265
#endif
266
 
267
        printk("scsi%d : at 0x%08x", instance->host_no, (int)
268
            instance->base);
269
        if (instance->irq == IRQ_NONE)
270
            printk (" interrupts disabled");
271
        else
272
            printk (" irq %d", instance->irq);
273
        printk(" options CAN_QUEUE=%d  CMD_PER_LUN=%d release=%d",
274
            CAN_QUEUE, CMD_PER_LUN, T128_PUBLIC_RELEASE);
275
        NCR5380_print_options(instance);
276
        printk("\n");
277
 
278
        ++current_override;
279
        ++count;
280
    }
281
    return count;
282
}
283
 
284
/*
285
 * Function : int t128_biosparam(Disk * disk, kdev_t dev, int *ip)
286
 *
287
 * Purpose : Generates a BIOS / DOS compatible H-C-S mapping for
288
 *      the specified device / size.
289
 *
290
 * Inputs : size = size of device in sectors (512 bytes), dev = block device
291
 *      major / minor, ip[] = {heads, sectors, cylinders}
292
 *
293
 * Returns : always 0 (success), initializes ip
294
 *
295
 */
296
 
297
/*
298
 * XXX Most SCSI boards use this mapping, I could be incorrect.  Some one
299
 * using hard disks on a trantor should verify that this mapping corresponds
300
 * to that used by the BIOS / ASPI driver by running the linux fdisk program
301
 * and matching the H_C_S coordinates to what DOS uses.
302
 */
303
 
304
int t128_biosparam(Disk * disk, kdev_t dev, int * ip)
305
{
306
  int size = disk->capacity;
307
  ip[0] = 64;
308
  ip[1] = 32;
309
  ip[2] = size >> 11;
310
  return 0;
311
}
312
 
313
/*
314
 * Function : int NCR5380_pread (struct Scsi_Host *instance,
315
 *      unsigned char *dst, int len)
316
 *
317
 * Purpose : Fast 5380 pseudo-dma read function, transfers len bytes to
318
 *      dst
319
 *
320
 * Inputs : dst = destination, len = length in bytes
321
 *
322
 * Returns : 0 on success, non zero on a failure such as a watchdog
323
 *      timeout.
324
 */
325
 
326
static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst,
327
    int len) {
328
    register unsigned char *reg = (unsigned char *) (instance->base +
329
        T_DATA_REG_OFFSET), *d = dst;
330
    register int i = len;
331
 
332
 
333
#if 0
334
    for (; i; --i) {
335
        while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
336
#else
337
    while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
338
    for (; i; --i) {
339
#endif
340
        *d++ = *reg;
341
    }
342
 
343
    if (*(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
344
        unsigned char tmp;
345
        volatile unsigned char *foo;
346
        foo = instance->base + T_CONTROL_REG_OFFSET;
347
        tmp = *foo;
348
        *foo = tmp | T_CR_CT;
349
        *foo = tmp;
350
        printk("scsi%d : watchdog timer fired in NCR5380_pread()\n",
351
            instance->host_no);
352
        return -1;
353
    } else
354
        return 0;
355
}
356
 
357
/*
358
 * Function : int NCR5380_pwrite (struct Scsi_Host *instance,
359
 *      unsigned char *src, int len)
360
 *
361
 * Purpose : Fast 5380 pseudo-dma write function, transfers len bytes from
362
 *      src
363
 *
364
 * Inputs : src = source, len = length in bytes
365
 *
366
 * Returns : 0 on success, non zero on a failure such as a watchdog
367
 *      timeout.
368
 */
369
 
370
static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src,
371
    int len) {
372
    register unsigned char *reg = (unsigned char *) (instance->base +
373
        T_DATA_REG_OFFSET), *s = src;
374
    register int i = len;
375
 
376
#if 0
377
    for (; i; --i) {
378
        while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
379
#else
380
    while (!(instance->base[T_STATUS_REG_OFFSET]) & T_ST_RDY) barrier();
381
    for (; i; --i) {
382
#endif
383
        *reg = *s++;
384
    }
385
 
386
    if (*(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
387
        unsigned char tmp;
388
        volatile unsigned char *foo;
389
        foo = instance->base + T_CONTROL_REG_OFFSET;
390
        tmp = *foo;
391
        *foo = tmp | T_CR_CT;
392
        *foo = tmp;
393
        printk("scsi%d : watchdog timer fired in NCR5380_pwrite()\n",
394
            instance->host_no);
395
        return -1;
396
    } else
397
        return 0;
398
}
399
 
400
#include "NCR5380.c"
401
 
402
#ifdef MODULE
403
/* Eventually this will go into an include file, but this will be later */
404
Scsi_Host_Template driver_template = TRANTOR_T128;
405
 
406
#include "scsi_module.c"
407
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.