linux/drivers/scsi/qlogicfas.c
<<
>>
Prefs
   1/*
   2 * Qlogic FAS408 ISA card driver
   3 *
   4 * Copyright 1994, Tom Zerucha.   
   5 * tz@execpc.com
   6 * 
   7 * Redistributable under terms of the GNU General Public License
   8 *
   9 * For the avoidance of doubt the "preferred form" of this code is one which
  10 * is in an open non patent encumbered format. Where cryptographic key signing
  11 * forms part of the process of creating an executable the information
  12 * including keys needed to generate an equivalently functional executable
  13 * are deemed to be part of the source code.
  14 *
  15 * Check qlogicfas408.c for more credits and info.
  16 */
  17
  18#include <linux/module.h>
  19#include <linux/blkdev.h>               /* to get disk capacity */
  20#include <linux/kernel.h>
  21#include <linux/string.h>
  22#include <linux/init.h>
  23#include <linux/interrupt.h>
  24#include <linux/ioport.h>
  25#include <linux/proc_fs.h>
  26#include <linux/unistd.h>
  27#include <linux/spinlock.h>
  28#include <linux/stat.h>
  29
  30#include <asm/io.h>
  31#include <asm/irq.h>
  32#include <asm/dma.h>
  33
  34#include "scsi.h"
  35#include <scsi/scsi_host.h>
  36#include "qlogicfas408.h"
  37
  38/* Set the following to 2 to use normal interrupt (active high/totempole-
  39 * tristate), otherwise use 0 (REQUIRED FOR PCMCIA) for active low, open
  40 * drain
  41 */
  42#define INT_TYPE        2
  43
  44static char qlogicfas_name[] = "qlogicfas";
  45
  46/*
  47 *      Look for qlogic card and init if found 
  48 */
  49 
  50static struct Scsi_Host *__qlogicfas_detect(struct scsi_host_template *host,
  51                                                                int qbase,
  52                                                                int qlirq)
  53{
  54        int qltyp;              /* type of chip */
  55        int qinitid;
  56        struct Scsi_Host *hreg; /* registered host structure */
  57        struct qlogicfas408_priv *priv;
  58
  59        /*      Qlogic Cards only exist at 0x230 or 0x330 (the chip itself
  60         *      decodes the address - I check 230 first since MIDI cards are
  61         *      typically at 0x330
  62         *
  63         *      Theoretically, two Qlogic cards can coexist in the same system.
  64         *      This should work by simply using this as a loadable module for
  65         *      the second card, but I haven't tested this.
  66         */
  67
  68        if (!qbase || qlirq == -1)
  69                goto err;
  70
  71        if (!request_region(qbase, 0x10, qlogicfas_name)) {
  72                printk(KERN_INFO "%s: address %#x is busy\n", qlogicfas_name,
  73                                                              qbase);
  74                goto err;
  75        }
  76
  77        if (!qlogicfas408_detect(qbase, INT_TYPE)) {
  78                printk(KERN_WARNING "%s: probe failed for %#x\n",
  79                                                                qlogicfas_name,
  80                                                                qbase);
  81                goto err_release_mem;
  82        }
  83
  84        printk(KERN_INFO "%s: Using preset base address of %03x,"
  85                         " IRQ %d\n", qlogicfas_name, qbase, qlirq);
  86
  87        qltyp = qlogicfas408_get_chip_type(qbase, INT_TYPE);
  88        qinitid = host->this_id;
  89        if (qinitid < 0)
  90                qinitid = 7;    /* if no ID, use 7 */
  91
  92        qlogicfas408_setup(qbase, qinitid, INT_TYPE);
  93
  94        hreg = scsi_host_alloc(host, sizeof(struct qlogicfas408_priv));
  95        if (!hreg)
  96                goto err_release_mem;
  97        priv = get_priv_by_host(hreg);
  98        hreg->io_port = qbase;
  99        hreg->n_io_port = 16;
 100        hreg->dma_channel = -1;
 101        if (qlirq != -1)
 102                hreg->irq = qlirq;
 103        priv->qbase = qbase;
 104        priv->qlirq = qlirq;
 105        priv->qinitid = qinitid;
 106        priv->shost = hreg;
 107        priv->int_type = INT_TYPE;
 108
 109        sprintf(priv->qinfo,
 110                "Qlogicfas Driver version 0.46, chip %02X at %03X, IRQ %d, TPdma:%d",
 111                qltyp, qbase, qlirq, QL_TURBO_PDMA);
 112        host->name = qlogicfas_name;
 113
 114        if (request_irq(qlirq, qlogicfas408_ihandl, 0, qlogicfas_name, hreg))
 115                goto free_scsi_host;
 116
 117        if (scsi_add_host(hreg, NULL))
 118                goto free_interrupt;
 119
 120        scsi_scan_host(hreg);
 121
 122        return hreg;
 123
 124free_interrupt:
 125        free_irq(qlirq, hreg);
 126
 127free_scsi_host:
 128        scsi_host_put(hreg);
 129
 130err_release_mem:
 131        release_region(qbase, 0x10);
 132err:
 133        return NULL;
 134}
 135
 136#define MAX_QLOGICFAS   8
 137static struct qlogicfas408_priv *cards;
 138static int iobase[MAX_QLOGICFAS];
 139static int stati" name="L115">  goto  109        MAX_QLOGICFAS]n>
 109    rk by _param_arrayse_region" class="sr38"> 138static int hreg, qbase, 0x10)n>
 109    rk by _param_arrayse_region" class="sr39"> 139static int hreg, qbase, 0x10)n
 109     ODULE_PARM_DESCse_region" class="sr38"> 138static int  110     I/Otring">& at %03X,de=qbase" class="sref">qbase, 0x10)n
 109     ODULE_PARM_DESCse_region" class="sr39"> 139static int  110     IRQ at %03X,de=qbase" class="sref">qbase, 0x10)n>
qbase, 0x10)n
qlogicfas408_ih     if (!__qlogicfas_detect(struct sshsref">priv->detecef="+code=NULL" class="sref">NULL)a>
INT_TYPE))1n>
  56        struct priv->qbase, 0x10)n
  57        struct qlogicfas408_priv *priv
priv 
  70,
 109        INT_TYPE))1>,
priv->Scsi_Host *sshsref">priv->detecref="+code=hreg" 38"> 138static int  130 139static int qbase, 0x10)>)
priv->hreg, INT_TYPE))1>>
qinitidno="commdev  16 */
qbase, 0x10)>>
 134n>
  97        priv = priv->qbase, 0x10)>
  78="sref">sprintf( *cardsa>
 * *priv
 134n>
 121
nu> 130priv
 134n>
qbase, 0x10)n>
__qlogi  56        struct priv->NULL)n>
INT_TYPE))1n>
  57        struct qlogicfas408_priv *priv = priv->qbase, 0x10)a>
 108priv->qbase, 0x10)>;
priv->hreg->INT_TYPE))1a>
 11e=qlogicfas4isld wcodeicfas408_privINT_TYPE))1a>
 "L125"> 125        priv->hreg->priv->qbase, 0x10)>>
 134);
priv->hreg->NULL)>;
 "L125hre125        priv->hreg->qbase, 0x10)>>
priv->hreg->priv->hreg->NULL)>>
 131        priv->hreg->priv->hreg->qbase, 0x10)>>
 128        priv->qbase, 0x10)>)
 129,
qbase, 0x10));
 134>;
 134>>
  46/*
  46/*  16 */(struct qlogicfas408_ih  clasct(struct INT_TYPE))1a>
 109    rk by  id="L85" class="lineef="+code=priv" cTHIS_ ODULE9"> 109    THIS_ ODULEf="+rNT_TYPE" class="sref">INT_TYPE))1a>
host->name = INT_TYPE))1a)
name = naname = INT_TYPE))10)
priv-&t;priv-&gass="srecfas4="scfasrNT_TYPE" class="sref">INT_TYPE))10;
qinitid = ueuelineanf hrerrrrrrrrrrref="+code=name" class="srecfasqueuelineanf">qinitid = ass="srecfasqueuelineanfcfasrNT_TYPE" class="sref">INT_TYPE))10;
 132h_ab="+_08_ihe  id="L92" cef="+code=name" class="srecfasab="+">qinitid = ass="srecfasab="+cfasrNT_TYPE" class="sref">INT_TYPE))10>
 132h_bui_f=se+_08_ihe  id="L9ef="+code=name" class="srecfasbui_f=se+">qinitid = ass="srecfasbui_f=se+cfasrNT_TYPE" class="sref">INT_TYPE))10>
qinitid =bios_param hrerrrrrrrrrrrrref="+code=name" class="srecfasbiosparam">qinitid =lass="srecfasbiosparamcfasrNT_TYPE" class="sref">INT_TYPE))10;
INT_TYPE))10;
host->INT_TYPE))10>
hregINT_TYPE))10>
INT_TYPE))10)
printk(cfasrNT_TYPE" class="sref">INT_TYPE))2;
MAX_QLOGICFAS2;
 121 139static__NULL2;
  53  77qlogicfas408_ih  clasct(struct INT_TYPE))2;
qinitidno=     *     L="L16">  16 */  84        printk(KERN_INFO 110     I/Otring">&"commsion    * t  110     optionspan class="string">" IRQ %d\n", qbase, 0x102>
" IRQ ENODEV, priv 134 121qbase, 0x102;
 134
qbase, 0x102)
" IRQ %d\n&qex h> 139static%d\n&qex hi_hosvoidef="+code=NULL" class="sref">NULL2;
INT_TYPE))2>
  57        struct qlogicfas408_priv *qbase, 0x102;8 108 * *  97        hreg,   97         *NULL2>
  e=__qlogif="+codf (! *priv->qbase, 0x102;
 134
 134priv-&MODULE_AUTHORetect= name="L110"> 110     Tom Zes="ha, Mi"hael Griffith at %03X,de=qbase" class="sref">qbase, 0x102>
priv-&MODULE_DESCRIPTIONetect= name="L110"> 110      qbase, 0x102>
 109    MODULE_LICENSEetect= name="L110"> 110     GPL at %03X,de=qbase" class="sref">qbase, 0x102>
 139staticde=__qlogiqbase, 0x102>
 139static%d\n&qex hi_hode=qbase" class="sref">qbase, 0x102>8 108


The original LXR software*bysLXR ref"ua hyf="+re experi">qial class="sbys08" classmailto:lxr@si/ux.no">lxr@si/ux.nof="+.
lxr.si/ux.no kindly>; Redpill Li/pro ="ZQLO,/a> vidan of Li/ux rensult * commoperations serv