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/] [hosts.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 *  hosts.c Copyright (C) 1992 Drew Eckhardt
3
 *          Copyright (C) 1993, 1994, 1995 Eric Youngdale
4
 *
5
 *  mid to lowlevel SCSI driver interface
6
 *      Initial versions: Drew Eckhardt
7
 *      Subsequent revisions: Eric Youngdale
8
 *
9
 *  <drew@colorado.edu>
10
 */
11
 
12
 
13
/*
14
 *  This file contains the medium level SCSI
15
 *  host interface initialization, as well as the scsi_hosts array of SCSI
16
 *  hosts currently present in the system.
17
 */
18
 
19
/*
20
 * Don't import our own symbols, as this would severely mess up our
21
 * symbol tables.
22
 */
23
#define _SCSI_SYMS_VER_
24
#define __NO_VERSION__
25
#include <linux/module.h>
26
 
27
#include <linux/config.h>
28
#include <linux/blk.h>
29
#include <linux/kernel.h>
30
#include <linux/string.h>
31
#include <linux/mm.h>
32
#include <linux/proc_fs.h>
33
 
34
#include "scsi.h"
35
 
36
#ifndef NULL
37
#define NULL 0L
38
#endif
39
 
40
#define HOSTS_C
41
 
42
#include "hosts.h"
43
 
44
#ifdef CONFIG_A3000_SCSI
45
#include "a3000.h"
46
#endif
47
 
48
#ifdef CONFIG_A2091_SCSI
49
#include "a2091.h"
50
#endif
51
 
52
#ifdef CONFIG_GVP11_SCSI
53
#include "gvp11.h"
54
#endif
55
 
56
#ifdef CONFIG_ATARI_SCSI
57
#include "atari_scsi.h"
58
#endif
59
 
60
#ifdef CONFIG_SCSI_ADVANSYS
61
#include "advansys.h"
62
#endif
63
 
64
#ifdef CONFIG_SCSI_AHA152X
65
#include "aha152x.h"
66
#endif
67
 
68
#ifdef CONFIG_SCSI_AHA1542
69
#include "aha1542.h"
70
#endif
71
 
72
#ifdef CONFIG_SCSI_AHA1740
73
#include "aha1740.h"
74
#endif
75
 
76
#ifdef CONFIG_SCSI_AIC7XXX
77
#include "aic7xxx.h"
78
#endif
79
 
80
#ifdef CONFIG_SCSI_BUSLOGIC
81
#include "BusLogic.h"
82
#endif
83
 
84
#ifdef CONFIG_SCSI_EATA_DMA
85
#include "eata_dma.h"
86
#endif
87
 
88
#ifdef CONFIG_SCSI_EATA_PIO
89
#include "eata_pio.h"
90
#endif
91
 
92
#ifdef CONFIG_SCSI_U14_34F
93
#include "u14-34f.h"
94
#endif
95
 
96
#ifdef CONFIG_SCSI_FUTURE_DOMAIN
97
#include "fdomain.h"
98
#endif
99
 
100
#ifdef CONFIG_SCSI_GENERIC_NCR5380
101
#include "g_NCR5380.h"
102
#endif
103
 
104
#ifdef CONFIG_SCSI_IN2000
105
#include "in2000.h"
106
#endif
107
 
108
#ifdef CONFIG_SCSI_PAS16
109
#include "pas16.h"
110
#endif
111
 
112
#ifdef CONFIG_SCSI_QLOGIC_FAS
113
#include "qlogicfas.h"
114
#endif
115
 
116
#ifdef CONFIG_SCSI_QLOGIC_ISP
117
#include "qlogicisp.h"
118
#endif
119
 
120
#ifdef CONFIG_SCSI_SEAGATE
121
#include "seagate.h"
122
#endif
123
 
124
#ifdef CONFIG_SCSI_T128
125
#include "t128.h"
126
#endif
127
 
128
#ifdef CONFIG_SCSI_DTC3280
129
#include "dtc.h"
130
#endif
131
 
132
#ifdef CONFIG_SCSI_NCR53C7xx
133
#include "53c7,8xx.h"
134
#endif
135
 
136
#ifdef CONFIG_SCSI_NCR53C8XX
137
#include "ncr53c8xx.h"
138
#endif
139
 
140
#ifdef CONFIG_SCSI_ULTRASTOR
141
#include "ultrastor.h"
142
#endif
143
 
144
#ifdef CONFIG_SCSI_7000FASST
145
#include "wd7000.h"
146
#endif
147
 
148
#ifdef CONFIG_SCSI_EATA
149
#include "eata.h"
150
#endif
151
 
152
#ifdef CONFIG_SCSI_NCR53C406A
153
#include "NCR53c406a.h"
154
#endif
155
 
156
#ifdef CONFIG_SCSI_SYM53C416 
157
#include "sym53c416.h" 
158
#endif
159
 
160
#ifdef CONFIG_SCSI_DC390T
161
#include "dc390.h"
162
#endif
163
 
164
#ifdef CONFIG_SCSI_AM53C974
165
#include "AM53C974.h"
166
#endif
167
 
168
#ifdef CONFIG_SCSI_MEGARAID
169
#include "megaraid.h"
170
#endif
171
 
172
#ifdef CONFIG_SCSI_PPA
173
#include "ppa.h"
174
#endif
175
 
176
#ifdef CONFIG_SCSI_ACARD
177
#include "atp870u.h"
178
#endif
179
 
180
#ifdef CONFIG_SCSI_SUNESP
181
#include "esp.h"
182
#endif
183
 
184
#ifdef CONFIG_BLK_DEV_IDESCSI
185
#include "ide-scsi.h"
186
#endif
187
 
188
#ifdef CONFIG_SCSI_GDTH
189
#include "gdth.h"
190
#endif
191
 
192
#ifdef CONFIG_SCSI_INITIO
193
#include "ini9100u.h"
194
#endif
195
 
196
#ifdef CONFIG_SCSI_TC2550
197
#include "tripace.h"
198
#endif
199
 
200
#ifdef CONFIG_SCSI_INIA100
201
#include "inia100.h"
202
#endif
203
 
204
#ifdef CONFIG_SCSI_PCI2000
205
#include "pci2000.h"
206
#endif
207
 
208
#ifdef CONFIG_SCSI_PCI2220I
209
#include "pci2220i.h"
210
#endif
211
 
212
#ifdef CONFIG_SCSI_PSI240I
213
#include "psi240i.h"
214
#endif
215
 
216
#ifdef CONFIG_SCSI_DEBUG
217
#include "scsi_debug.h"
218
#endif
219
 
220
 
221
/*
222
static const char RCSid[] = "$Header: /home/marcus/revision_ctrl_test/oc_cvs/cvs/or1k/uclinux/uClinux-2.0.x/drivers/scsi/hosts.c,v 1.1.1.1 2001-09-10 07:44:33 simons Exp $";
223
*/
224
 
225
/*
226
 *  The scsi host entries should be in the order you wish the
227
 *  cards to be detected.  A driver may appear more than once IFF
228
 *  it can deal with being detected (and therefore initialized)
229
 *  with more than one simultaneous host number, can handle being
230
 *  reentrant, etc.
231
 *
232
 *  They may appear in any order, as each SCSI host is told which host
233
 *  number it is during detection.
234
 */
235
 
236
/* This is a placeholder for controllers that are not configured into
237
 * the system - we do this to ensure that the controller numbering is
238
 * always consistent, no matter how the kernel is configured. */
239
 
240
#define NO_CONTROLLER {NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
241
                           NULL, NULL, 0, 0, 0, 0, 0, 0}
242
 
243
/*
244
 *  When figure is run, we don't want to link to any object code.  Since
245
 *  the macro for each host will contain function pointers, we cannot
246
 *  use it and instead must use a "blank" that does no such
247
 *  idiocy.
248
 */
249
 
250
Scsi_Host_Template * scsi_hosts = NULL;
251
 
252
static Scsi_Host_Template builtin_scsi_hosts[] =
253
{
254
#ifdef CONFIG_AMIGA
255
#ifdef CONFIG_A3000_SCSI
256
        A3000_SCSI,
257
#endif
258
#ifdef CONFIG_A2091_SCSI
259
        A2091_SCSI,
260
#endif
261
#ifdef CONFIG_GVP11_SCSI
262
        GVP11_SCSI,
263
#endif
264
#endif
265
 
266
#ifdef CONFIG_ATARI
267
#ifdef CONFIG_ATARI_SCSI
268
        ATARI_SCSI,
269
#endif
270
#endif
271
 
272
#ifdef CONFIG_SCSI_ADVANSYS
273
        ADVANSYS,
274
#endif
275
/* BusLogic must come before aha1542.c */
276
#ifdef CONFIG_SCSI_BUSLOGIC
277
    BUSLOGIC,
278
#endif
279
#ifdef CONFIG_SCSI_U14_34F
280
    ULTRASTOR_14_34F,
281
#endif
282
#ifdef CONFIG_SCSI_ULTRASTOR
283
    ULTRASTOR_14F,
284
#endif
285
#ifdef CONFIG_SCSI_AHA152X
286
    AHA152X,
287
#endif
288
#ifdef CONFIG_SCSI_AHA1542
289
    AHA1542,
290
#endif
291
#ifdef CONFIG_SCSI_AHA1740
292
    AHA1740,
293
#endif
294
#ifdef CONFIG_SCSI_AIC7XXX
295
    AIC7XXX,
296
#endif
297
#ifdef CONFIG_SCSI_FUTURE_DOMAIN
298
    FDOMAIN_16X0,
299
#endif
300
#ifdef CONFIG_SCSI_IN2000
301
    IN2000,
302
#endif
303
#ifdef CONFIG_SCSI_GENERIC_NCR5380
304
    GENERIC_NCR5380,
305
#endif
306
#ifdef CONFIG_SCSI_NCR53C406A   /* 53C406A should come before QLOGIC */
307
    NCR53c406a,
308
#endif
309
#ifdef CONFIG_SCSI_SYM53C416 
310
    SYM53C416,
311
#endif 
312
#ifdef CONFIG_SCSI_QLOGIC_FAS
313
    QLOGICFAS,
314
#endif
315
#ifdef CONFIG_SCSI_QLOGIC_ISP
316
    QLOGICISP,
317
#endif
318
#ifdef CONFIG_SCSI_PAS16
319
    MV_PAS16,
320
#endif
321
#ifdef CONFIG_SCSI_SEAGATE
322
    SEAGATE_ST0X,
323
#endif
324
#ifdef CONFIG_SCSI_T128
325
    TRANTOR_T128,
326
#endif
327
#ifdef CONFIG_SCSI_DTC3280
328
        DTC3x80,
329
#endif
330
#ifdef CONFIG_SCSI_DC390T
331
    DC390_T,
332
#endif
333
#ifdef CONFIG_SCSI_NCR53C7xx
334
    NCR53c7xx,
335
#endif
336
#ifdef CONFIG_SCSI_NCR53C8XX
337
    NCR53C8XX,
338
#endif
339
#ifdef CONFIG_SCSI_EATA_DMA
340
    EATA_DMA,
341
#endif
342
#ifdef CONFIG_SCSI_EATA_PIO
343
    EATA_PIO,
344
#endif
345
#ifdef CONFIG_SCSI_7000FASST
346
    WD7000,
347
#endif
348
#ifdef CONFIG_SCSI_EATA
349
    EATA,
350
#endif
351
#ifdef CONFIG_SCSI_AM53C974
352
    AM53C974,
353
#endif
354
#ifdef CONFIG_SCSI_MEGARAID
355
    MEGARAID,
356
#endif
357
#ifdef CONFIG_SCSI_INIA100
358
    INIA100,
359
#endif
360
#ifdef CONFIG_SCSI_PPA
361
    PPA,
362
#endif
363
#ifdef CONFIG_SCSI_ACARD
364
    ATP870U,
365
#endif
366
#ifdef CONFIG_SCSI_SUNESP
367
    SCSI_SPARC_ESP,
368
#endif
369
#ifdef CONFIG_SCSI_GDTH
370
    GDTH,
371
#endif
372
#ifdef CONFIG_SCSI_INITIO
373
    INI9100U,
374
#endif
375
#ifdef CONFIG_SCSI_PCI2000
376
    PCI2000,
377
#endif
378
#ifdef CONFIG_SCSI_PCI2220I
379
    PCI2220I,
380
#endif
381
#ifdef CONFIG_SCSI_PSI240I
382
    PSI240I,
383
#endif
384
#ifdef CONFIG_BLK_DEV_IDESCSI
385
    IDESCSI,
386
#endif
387
#ifdef CONFIG_SCSI_DEBUG
388
    SCSI_DEBUG,
389
#endif
390
};
391
 
392
#define MAX_SCSI_HOSTS (sizeof(builtin_scsi_hosts) / sizeof(Scsi_Host_Template))
393
 
394
 
395
/*
396
 *  Our semaphores and timeout counters, where size depends on
397
 *      MAX_SCSI_HOSTS here.
398
 */
399
 
400
struct Scsi_Host * scsi_hostlist = NULL;
401
struct Scsi_Device_Template * scsi_devicelist = NULL;
402
 
403
int max_scsi_hosts = 0;
404
int next_scsi_host = 0;
405
 
406
void
407
scsi_unregister(struct Scsi_Host * sh){
408
    struct Scsi_Host * shpnt;
409
 
410
    if(scsi_hostlist == sh)
411
        scsi_hostlist = sh->next;
412
    else {
413
        shpnt = scsi_hostlist;
414
        while(shpnt->next != sh) shpnt = shpnt->next;
415
        shpnt->next = shpnt->next->next;
416
    }
417
 
418
    /* If we are removing the last host registered, it is safe to reuse
419
     * its host number (this avoids "holes" at boot time) (DB)
420
     * It is also safe to reuse those of numbers directly below which have
421
     * been released earlier (to avoid some holes in numbering).
422
     */
423
    if(sh->host_no == max_scsi_hosts - 1) {
424
        while(--max_scsi_hosts >= next_scsi_host) {
425
            shpnt = scsi_hostlist;
426
            while(shpnt && shpnt->host_no != max_scsi_hosts - 1)
427
                shpnt = shpnt->next;
428
            if(shpnt)
429
                break;
430
        }
431
    }
432
    next_scsi_host--;
433
    scsi_init_free((char *) sh, sizeof(struct Scsi_Host) + sh->extra_bytes);
434
}
435
 
436
/* We call this when we come across a new host adapter. We only do this
437
 * once we are 100% sure that we want to use this host adapter -  it is a
438
 * pain to reverse this, so we try to avoid it
439
 */
440
 
441
struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){
442
    struct Scsi_Host * retval, *shpnt;
443
    retval = (struct Scsi_Host *)scsi_init_malloc(sizeof(struct Scsi_Host) + j,
444
                                                  (tpnt->unchecked_isa_dma && j ? GFP_DMA : 0) | GFP_ATOMIC);
445
    retval->host_busy = 0;
446
    retval->block = NULL;
447
    retval->wish_block = 0;
448
    if(j > 0xffff) panic("Too many extra bytes requested\n");
449
    retval->extra_bytes = j;
450
    retval->loaded_as_module = scsi_loadable_module_flag;
451
    retval->host_no = max_scsi_hosts++; /* never reuse host_no (DB) */
452
    next_scsi_host++;
453
    retval->host_queue = NULL;
454
    retval->host_wait = NULL;
455
    retval->last_reset = 0;
456
    retval->irq = 0;
457
    retval->dma_channel = 0xff;
458
 
459
    /* These three are default values which can be overridden */
460
    retval->max_channel = 0;
461
    retval->max_id = 8;
462
    retval->max_lun = 8;
463
 
464
    retval->unique_id = 0;
465
    retval->io_port = 0;
466
    retval->hostt = tpnt;
467
    retval->next = NULL;
468
#ifdef DEBUG
469
    printk("Register %x %x: %d\n", (int)retval, (int)retval->hostt, j);
470
#endif
471
 
472
    /* The next six are the default values which can be overridden
473
     * if need be */
474
    retval->this_id = tpnt->this_id;
475
    retval->can_queue = tpnt->can_queue;
476
    retval->sg_tablesize = tpnt->sg_tablesize;
477
    retval->cmd_per_lun = tpnt->cmd_per_lun;
478
    retval->unchecked_isa_dma = tpnt->unchecked_isa_dma;
479
    retval->use_clustering = tpnt->use_clustering;
480
 
481
    retval->select_queue_depths = NULL;
482
 
483
    if(!scsi_hostlist)
484
        scsi_hostlist = retval;
485
    else
486
    {
487
        shpnt = scsi_hostlist;
488
        while(shpnt->next) shpnt = shpnt->next;
489
        shpnt->next = retval;
490
    }
491
 
492
    return retval;
493
}
494
 
495
int
496
scsi_register_device(struct Scsi_Device_Template * sdpnt)
497
{
498
    if(sdpnt->next) panic("Device already registered");
499
    sdpnt->next = scsi_devicelist;
500
    scsi_devicelist = sdpnt;
501
    return 0;
502
}
503
 
504
unsigned int scsi_init()
505
{
506
    static int called = 0;
507
    int i, pcount;
508
    Scsi_Host_Template * tpnt;
509
    struct Scsi_Host * shpnt;
510
    const char * name;
511
 
512
    if(called) return 0;
513
 
514
    called = 1;
515
    for (tpnt = &builtin_scsi_hosts[0], i = 0; i < MAX_SCSI_HOSTS; ++i, tpnt++)
516
    {
517
        /*
518
         * Initialize our semaphores.  -1 is interpreted to mean
519
         * "inactive" - where as 0 will indicate a time out condition.
520
         */
521
 
522
        pcount = next_scsi_host;
523
        if ((tpnt->detect) &&
524
            (tpnt->present =
525
             tpnt->detect(tpnt)))
526
        {
527
            /* The only time this should come up is when people use
528
             * some kind of patched driver of some kind or another. */
529
            if(pcount == next_scsi_host) {
530
                if(tpnt->present > 1)
531
                    panic("Failure to register low-level scsi driver");
532
                /* The low-level driver failed to register a driver.  We
533
                 * can do this now. */
534
                scsi_register(tpnt,0);
535
            }
536
            tpnt->next = scsi_hosts;
537
            scsi_hosts = tpnt;
538
 
539
            /* Add the driver to /proc/scsi */
540
#if CONFIG_PROC_FS 
541
            build_proc_dir_entries(tpnt);
542
#endif
543
        }
544
    }
545
 
546
    for(shpnt=scsi_hostlist; shpnt; shpnt = shpnt->next)
547
    {
548
        if(shpnt->hostt->info)
549
            name = shpnt->hostt->info(shpnt);
550
        else
551
            name = shpnt->hostt->name;
552
        printk ("scsi%d : %s\n", /* And print a little message */
553
                shpnt->host_no, name);
554
    }
555
 
556
    printk ("scsi : %d host%s.\n", next_scsi_host,
557
            (next_scsi_host == 1) ? "" : "s");
558
 
559
    scsi_make_blocked_list();
560
 
561
    /* Now attach the high level drivers */
562
#ifdef CONFIG_BLK_DEV_SD
563
    scsi_register_device(&sd_template);
564
#endif
565
#ifdef CONFIG_BLK_DEV_SR
566
    scsi_register_device(&sr_template);
567
#endif
568
#ifdef CONFIG_CHR_DEV_ST
569
    scsi_register_device(&st_template);
570
#endif
571
#ifdef CONFIG_CHR_DEV_SG
572
    scsi_register_device(&sg_template);
573
#endif
574
 
575
#if 0      
576
    max_scsi_hosts = next_scsi_host;
577
#endif
578
    return 0;
579
}
580
 
581
/*
582
 * Overrides for Emacs so that we follow Linus's tabbing style.
583
 * Emacs will notice this stuff at the end of the file and automatically
584
 * adjust the settings for this buffer only.  This must remain at the end
585
 * of the file.
586
 * ---------------------------------------------------------------------------
587
 * Local variables:
588
 * c-indent-level: 4
589
 * c-brace-imaginary-offset: 0
590
 * c-brace-offset: -4
591
 * c-argdecl-indent: 4
592
 * c-label-offset: -4
593
 * c-continued-statement-offset: 4
594
 * c-continued-brace-offset: 0
595
 * indent-tabs-mode: nil
596
 * tab-width: 8
597
 * End:
598
 */

powered by: WebSVN 2.1.0

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