Annotation of Gnu-Mach/linux/src/drivers/scsi/in2000.h, revision 1.1.1.2

1.1       root        1: /*
                      2:  *    in2000.h -  Linux device driver definitions for the
                      3:  *                Always IN2000 ISA SCSI card.
                      4:  *
                      5:  *    IMPORTANT: This file is for version 1.33 - 26/Aug/1998
                      6:  *
                      7:  * Copyright (c) 1996 John Shifflett, GeoLog Consulting
                      8:  *    [email protected]
                      9:  *    [email protected]
                     10:  *
                     11:  * This program is free software; you can redistribute it and/or modify
                     12:  * it under the terms of the GNU General Public License as published by
                     13:  * the Free Software Foundation; either version 2, or (at your option)
                     14:  * any later version.
                     15:  *
                     16:  * This program is distributed in the hope that it will be useful,
                     17:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
                     18:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     19:  * GNU General Public License for more details.
                     20:  *
                     21:  */
                     22: 
                     23: #ifndef IN2000_H
                     24: #define IN2000_H
                     25: 
                     26: #include <asm/io.h>
                     27: 
                     28: #define PROC_INTERFACE     /* add code for /proc/scsi/in2000/xxx interface */
                     29: #ifdef  PROC_INTERFACE
                     30: #define PROC_STATISTICS    /* add code for keeping various real time stats */
                     31: #endif
                     32: 
                     33: #define SYNC_DEBUG         /* extra info on sync negotiation printed */
                     34: #define DEBUGGING_ON       /* enable command-line debugging bitmask */
                     35: #define DEBUG_DEFAULTS 0   /* default bitmask - change from command-line */
                     36: 
                     37: #define FAST_READ_IO       /* No problems with these on my machine */
                     38: #define FAST_WRITE_IO
                     39: 
                     40: #ifdef DEBUGGING_ON
                     41: #define DB(f,a) if (hostdata->args & (f)) a;
                     42: #define CHECK_NULL(p,s) /* if (!(p)) {printk("\n"); while (1) printk("NP:%s\r",(s));} */
                     43: #else
                     44: #define DB(f,a)
                     45: #define CHECK_NULL(p,s)
                     46: #endif
                     47: 
                     48: #define uchar unsigned char
                     49: 
                     50: #define read1_io(a)     (inb(hostdata->io_base+(a)))
                     51: #define read2_io(a)     (inw(hostdata->io_base+(a)))
                     52: #define write1_io(b,a)  (outb((b),hostdata->io_base+(a)))
                     53: #define write2_io(w,a)  (outw((w),hostdata->io_base+(a)))
                     54: 
                     55: /* These inline assembly defines are derived from a patch
                     56:  * sent to me by Bill Earnest. He's done a lot of very
                     57:  * valuable thinking, testing, and coding during his effort
                     58:  * to squeeze more speed out of this driver. I really think
                     59:  * that we are doing IO at close to the maximum now with
                     60:  * the fifo. (And yes, insw uses 'edi' while outsw uses
                     61:  * 'esi'. Thanks Bill!)
                     62:  */
                     63: 
                     64: #define FAST_READ2_IO()    \
1.1.1.2 ! root       65: ({ \
        !            66: int __dummy_1,__dummy_2; \
1.1       root       67:    __asm__ __volatile__ ("\n \
                     68:    cld                    \n \
                     69:    orl %%ecx, %%ecx       \n \
                     70:    jz 1f                  \n \
                     71:    rep                    \n \
1.1.1.2 ! root       72:    insw (%%dx),%%es:(%%edi) \n \
1.1       root       73: 1: "                       \
1.1.1.2 ! root       74:    : "=D" (sp) ,"=c" (__dummy_1) ,"=d" (__dummy_2)  /* output */   \
        !            75:    : "2" (f), "0" (sp), "1" (i)  /* input */    \
        !            76:    );       /* trashed */ \
        !            77: })
1.1       root       78: 
                     79: #define FAST_WRITE2_IO()   \
1.1.1.2 ! root       80: ({ \
        !            81: int __dummy_1,__dummy_2; \
1.1       root       82:    __asm__ __volatile__ ("\n \
                     83:    cld                    \n \
                     84:    orl %%ecx, %%ecx       \n \
                     85:    jz 1f                  \n \
                     86:    rep                    \n \
1.1.1.2 ! root       87:    outsw %%ds:(%%esi),(%%dx) \n \
1.1       root       88: 1: "                       \
1.1.1.2 ! root       89:    : "=S" (sp) ,"=c" (__dummy_1) ,"=d" (__dummy_2)/* output */   \
        !            90:    : "2" (f), "0" (sp), "1" (i)  /* input */    \
        !            91:    );       /* trashed */ \
        !            92: })
1.1       root       93: 
                     94: /* IN2000 io_port offsets */
                     95: #define IO_WD_ASR       0x00     /* R - 3393 auxstat reg */
                     96: #define     ASR_INT        0x80
                     97: #define     ASR_LCI        0x40
                     98: #define     ASR_BSY        0x20
                     99: #define     ASR_CIP        0x10
                    100: #define     ASR_PE         0x02
                    101: #define     ASR_DBR        0x01
                    102: #define IO_WD_ADDR      0x00     /* W - 3393 address reg */
                    103: #define IO_WD_DATA      0x01     /* R/W - rest of 3393 regs */
                    104: #define IO_FIFO         0x02     /* R/W - in2000 dual-port fifo (16 bits) */
                    105: #define IN2000_FIFO_SIZE   2048  /*    fifo capacity in bytes */
                    106: #define IO_CARD_RESET   0x03     /* W - in2000 start master reset */
                    107: #define IO_FIFO_COUNT   0x04     /* R - in2000 fifo counter */
                    108: #define IO_FIFO_WRITE   0x05     /* W - clear fifo counter, start write */
                    109: #define IO_FIFO_READ    0x07     /* W - start fifo read */
                    110: #define IO_LED_OFF      0x08     /* W - turn off in2000 activity LED */
                    111: #define IO_SWITCHES     0x08     /* R - read in2000 dip switch */
                    112: #define     SW_ADDR0       0x01  /*    bit 0 = bit 0 of index to io addr */
                    113: #define     SW_ADDR1       0x02  /*    bit 1 = bit 1 of index io addr */
                    114: #define     SW_DISINT      0x04  /*    bit 2 true if ints disabled */
                    115: #define     SW_INT0        0x08  /*    bit 3 = bit 0 of index to interrupt */
                    116: #define     SW_INT1        0x10  /*    bit 4 = bit 1 of index to interrupt */
                    117: #define     SW_INT_SHIFT   3     /*    shift right this amount to right justify int bits */
                    118: #define     SW_SYNC_DOS5   0x20  /*    bit 5 used by Always BIOS */
                    119: #define     SW_FLOPPY      0x40  /*    bit 6 true if floppy enabled */
                    120: #define     SW_BIT7        0x80  /*    bit 7 hardwired true (ground) */
                    121: #define IO_LED_ON       0x09     /* W - turn on in2000 activity LED */
                    122: #define IO_HARDWARE     0x0a     /* R - read in2000 hardware rev, stop reset */
                    123: #define IO_INTR_MASK    0x0c     /* W - in2000 interrupt mask reg */
                    124: #define     IMASK_WD       0x01  /*    WD33c93 interrupt mask */
                    125: #define     IMASK_FIFO     0x02  /*    FIFO interrupt mask */
                    126: 
                    127: /* wd register names */
                    128: #define WD_OWN_ID    0x00
                    129: #define WD_CONTROL   0x01
                    130: #define WD_TIMEOUT_PERIOD  0x02
                    131: #define WD_CDB_1     0x03
                    132: #define WD_CDB_2     0x04
                    133: #define WD_CDB_3     0x05
                    134: #define WD_CDB_4     0x06
                    135: #define WD_CDB_5     0x07
                    136: #define WD_CDB_6     0x08
                    137: #define WD_CDB_7     0x09
                    138: #define WD_CDB_8     0x0a
                    139: #define WD_CDB_9     0x0b
                    140: #define WD_CDB_10    0x0c
                    141: #define WD_CDB_11    0x0d
                    142: #define WD_CDB_12    0x0e
                    143: #define WD_TARGET_LUN      0x0f
                    144: #define WD_COMMAND_PHASE   0x10
                    145: #define WD_SYNCHRONOUS_TRANSFER  0x11
                    146: #define WD_TRANSFER_COUNT_MSB 0x12
                    147: #define WD_TRANSFER_COUNT  0x13
                    148: #define WD_TRANSFER_COUNT_LSB 0x14
                    149: #define WD_DESTINATION_ID  0x15
                    150: #define WD_SOURCE_ID    0x16
                    151: #define WD_SCSI_STATUS     0x17
                    152: #define WD_COMMAND      0x18
                    153: #define WD_DATA      0x19
                    154: #define WD_QUEUE_TAG    0x1a
                    155: #define WD_AUXILIARY_STATUS   0x1f
                    156: 
                    157: /* WD commands */
                    158: #define WD_CMD_RESET    0x00
                    159: #define WD_CMD_ABORT    0x01
                    160: #define WD_CMD_ASSERT_ATN  0x02
                    161: #define WD_CMD_NEGATE_ACK  0x03
                    162: #define WD_CMD_DISCONNECT  0x04
                    163: #define WD_CMD_RESELECT    0x05
                    164: #define WD_CMD_SEL_ATN     0x06
                    165: #define WD_CMD_SEL      0x07
                    166: #define WD_CMD_SEL_ATN_XFER   0x08
                    167: #define WD_CMD_SEL_XFER    0x09
                    168: #define WD_CMD_RESEL_RECEIVE  0x0a
                    169: #define WD_CMD_RESEL_SEND  0x0b
                    170: #define WD_CMD_WAIT_SEL_RECEIVE 0x0c
                    171: #define WD_CMD_TRANS_ADDR  0x18
                    172: #define WD_CMD_TRANS_INFO  0x20
                    173: #define WD_CMD_TRANSFER_PAD   0x21
                    174: #define WD_CMD_SBT_MODE    0x80
                    175: 
                    176: /* SCSI Bus Phases */
                    177: #define PHS_DATA_OUT    0x00
                    178: #define PHS_DATA_IN     0x01
                    179: #define PHS_COMMAND     0x02
                    180: #define PHS_STATUS      0x03
                    181: #define PHS_MESS_OUT    0x06
                    182: #define PHS_MESS_IN     0x07
                    183: 
                    184: /* Command Status Register definitions */
                    185: 
                    186:   /* reset state interrupts */
                    187: #define CSR_RESET    0x00
                    188: #define CSR_RESET_AF    0x01
                    189: 
                    190:   /* successful completion interrupts */
                    191: #define CSR_RESELECT    0x10
                    192: #define CSR_SELECT      0x11
                    193: #define CSR_SEL_XFER_DONE  0x16
                    194: #define CSR_XFER_DONE      0x18
                    195: 
                    196:   /* paused or aborted interrupts */
                    197: #define CSR_MSGIN    0x20
                    198: #define CSR_SDP         0x21
                    199: #define CSR_SEL_ABORT      0x22
                    200: #define CSR_RESEL_ABORT    0x25
                    201: #define CSR_RESEL_ABORT_AM 0x27
                    202: #define CSR_ABORT    0x28
                    203: 
                    204:   /* terminated interrupts */
                    205: #define CSR_INVALID     0x40
                    206: #define CSR_UNEXP_DISC     0x41
                    207: #define CSR_TIMEOUT     0x42
                    208: #define CSR_PARITY      0x43
                    209: #define CSR_PARITY_ATN     0x44
                    210: #define CSR_BAD_STATUS     0x45
                    211: #define CSR_UNEXP    0x48
                    212: 
                    213:   /* service required interrupts */
                    214: #define CSR_RESEL    0x80
                    215: #define CSR_RESEL_AM    0x81
                    216: #define CSR_DISC     0x85
                    217: #define CSR_SRV_REQ     0x88
                    218: 
                    219:    /* Own ID/CDB Size register */
                    220: #define OWNID_EAF    0x08
                    221: #define OWNID_EHP    0x10
                    222: #define OWNID_RAF    0x20
                    223: #define OWNID_FS_8   0x00
                    224: #define OWNID_FS_12  0x40
                    225: #define OWNID_FS_16  0x80
                    226: 
                    227:    /* Control register */
                    228: #define CTRL_HSP     0x01
                    229: #define CTRL_HA      0x02
                    230: #define CTRL_IDI     0x04
                    231: #define CTRL_EDI     0x08
                    232: #define CTRL_HHP     0x10
                    233: #define CTRL_POLLED  0x00
                    234: #define CTRL_BURST   0x20
                    235: #define CTRL_BUS     0x40
                    236: #define CTRL_DMA     0x80
                    237: 
                    238:    /* Timeout Period register */
                    239: #define TIMEOUT_PERIOD_VALUE  20    /* results in 200 ms. */
                    240: 
                    241:    /* Synchronous Transfer Register */
                    242: #define STR_FSS      0x80
                    243: 
                    244:    /* Destination ID register */
                    245: #define DSTID_DPD    0x40
                    246: #define DATA_OUT_DIR 0
                    247: #define DATA_IN_DIR  1
                    248: #define DSTID_SCC    0x80
                    249: 
                    250:    /* Source ID register */
                    251: #define SRCID_MASK   0x07
                    252: #define SRCID_SIV    0x08
                    253: #define SRCID_DSP    0x20
                    254: #define SRCID_ES     0x40
                    255: #define SRCID_ER     0x80
                    256: 
                    257: 
                    258: 
                    259: #define ILLEGAL_STATUS_BYTE   0xff
                    260: 
                    261: 
                    262: #define DEFAULT_SX_PER     500   /* (ns) fairly safe */
                    263: #define DEFAULT_SX_OFF     0     /* aka async */
                    264: 
                    265: #define OPTIMUM_SX_PER     252   /* (ns) best we can do (mult-of-4) */
                    266: #define OPTIMUM_SX_OFF     12    /* size of in2000 fifo */
                    267: 
                    268: struct sx_period {
                    269:    unsigned int   period_ns;
                    270:    uchar          reg_value;
                    271:    };
                    272: 
                    273: 
                    274: struct IN2000_hostdata {
                    275:     struct Scsi_Host *next;
                    276:     uchar            chip;             /* what kind of wd33c93 chip? */
                    277:     uchar            microcode;        /* microcode rev if 'B' */
                    278:     unsigned short   io_base;          /* IO port base */
                    279:     unsigned int     dip_switch;       /* dip switch settings */
                    280:     unsigned int     hrev;             /* hardware revision of card */
                    281:     volatile uchar   busy[8];          /* index = target, bit = lun */
                    282:     volatile Scsi_Cmnd *input_Q;       /* commands waiting to be started */
                    283:     volatile Scsi_Cmnd *selecting;     /* trying to select this command */
                    284:     volatile Scsi_Cmnd *connected;     /* currently connected command */
                    285:     volatile Scsi_Cmnd *disconnected_Q;/* commands waiting for reconnect */
                    286:     uchar            state;            /* what we are currently doing */
                    287:     uchar            fifo;             /* what the FIFO is up to */
                    288:     uchar            level2;           /* extent to which Level-2 commands are used */
                    289:     uchar            disconnect;       /* disconnect/reselect policy */
                    290:     unsigned int     args;             /* set from command-line argument */
                    291:     uchar            incoming_msg[8];  /* filled during message_in phase */
                    292:     int              incoming_ptr;     /* mainly used with EXTENDED messages */
                    293:     uchar            outgoing_msg[8];  /* send this during next message_out */
                    294:     int              outgoing_len;     /* length of outgoing message */
                    295:     unsigned int     default_sx_per;   /* default transfer period for SCSI bus */
                    296:     uchar            sync_xfer[8];     /* sync_xfer reg settings per target */
                    297:     uchar            sync_stat[8];     /* status of sync negotiation per target */
                    298:     uchar            sync_off;         /* bit mask: don't use sync with these targets */
                    299: #ifdef PROC_INTERFACE
                    300:     uchar            proc;             /* bit mask: what's in proc output */
                    301: #ifdef PROC_STATISTICS
                    302:     unsigned long    cmd_cnt[8];       /* # of commands issued per target */
                    303:     unsigned long    int_cnt;          /* # of interrupts serviced */
                    304:     unsigned long    disc_allowed_cnt[8]; /* # of disconnects allowed per target */
                    305:     unsigned long    disc_done_cnt[8]; /* # of disconnects done per target*/
                    306: #endif
                    307: #endif
                    308:     };
                    309: 
                    310: 
                    311: /* defines for hostdata->chip */
                    312: 
                    313: #define C_WD33C93       0
                    314: #define C_WD33C93A      1
                    315: #define C_WD33C93B      2
                    316: #define C_UNKNOWN_CHIP  100
                    317: 
                    318: /* defines for hostdata->state */
                    319: 
                    320: #define S_UNCONNECTED         0
                    321: #define S_SELECTING           1
                    322: #define S_RUNNING_LEVEL2      2
                    323: #define S_CONNECTED           3
                    324: #define S_PRE_TMP_DISC        4
                    325: #define S_PRE_CMP_DISC        5
                    326: 
                    327: /* defines for hostdata->fifo */
                    328: 
                    329: #define FI_FIFO_UNUSED        0
                    330: #define FI_FIFO_READING       1
                    331: #define FI_FIFO_WRITING       2
                    332: 
                    333: /* defines for hostdata->level2 */
                    334: /* NOTE: only the first 3 are trustworthy at this point -
                    335:  * having trouble when more than 1 device is reading/writing
                    336:  * at the same time...
                    337:  */
                    338: 
                    339: #define L2_NONE      0  /* no combination commands - we get lots of ints */
                    340: #define L2_SELECT    1  /* start with SEL_ATN_XFER, but never resume it */
                    341: #define L2_BASIC     2  /* resume after STATUS ints & RDP messages */
                    342: #define L2_DATA      3  /* resume after DATA_IN/OUT ints */
                    343: #define L2_MOST      4  /* resume after anything except a RESELECT int */
                    344: #define L2_RESELECT  5  /* resume after everything, including RESELECT ints */
                    345: #define L2_ALL       6  /* always resume */
                    346: 
                    347: /* defines for hostdata->disconnect */
                    348: 
                    349: #define DIS_NEVER    0
                    350: #define DIS_ADAPTIVE 1
                    351: #define DIS_ALWAYS   2
                    352: 
                    353: /* defines for hostdata->args */
                    354: 
                    355: #define DB_TEST               1<<0
                    356: #define DB_FIFO               1<<1
                    357: #define DB_QUEUE_COMMAND      1<<2
                    358: #define DB_EXECUTE            1<<3
                    359: #define DB_INTR               1<<4
                    360: #define DB_TRANSFER           1<<5
                    361: #define DB_MASK               0x3f
                    362: 
                    363: #define A_NO_SCSI_RESET       1<<15
                    364: 
                    365: 
                    366: /* defines for hostdata->sync_xfer[] */
                    367: 
                    368: #define SS_UNSET     0
                    369: #define SS_FIRST     1
                    370: #define SS_WAITING   2
                    371: #define SS_SET       3
                    372: 
                    373: /* defines for hostdata->proc */
                    374: 
                    375: #define PR_VERSION   1<<0
                    376: #define PR_INFO      1<<1
                    377: #define PR_STATISTICS 1<<2
                    378: #define PR_CONNECTED 1<<3
                    379: #define PR_INPUTQ    1<<4
                    380: #define PR_DISCQ     1<<5
                    381: #define PR_TEST      1<<6
                    382: #define PR_STOP      1<<7
                    383: 
                    384: 
                    385: #include <linux/version.h>
                    386: 
                    387: #if LINUX_VERSION_CODE < 0x020100   /* 2.0.xx */
                    388: # define in2000__INITFUNC(function) function
                    389: # define in2000__INIT
                    390: # define in2000__INITDATA
                    391: # define CLISPIN_LOCK(flags)   do { save_flags(flags); cli(); } while(0)
                    392: # define CLISPIN_UNLOCK(flags) restore_flags(flags)
                    393: #else                               /* 2.1.xxx */
                    394: # include <linux/init.h>
                    395: # include <asm/spinlock.h>
                    396: # define in2000__INITFUNC(function) __initfunc(function)
                    397: # define in2000__INIT __init
                    398: # define in2000__INITDATA __initdata
                    399: # define CLISPIN_LOCK(flags)   spin_lock_irqsave(&io_request_lock, flags)
                    400: # define CLISPIN_UNLOCK(flags) spin_unlock_irqrestore(&io_request_lock, flags)
                    401: #endif
                    402: 
                    403: 
                    404: int in2000_detect(Scsi_Host_Template *) in2000__INIT;
                    405: int in2000_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
                    406: int in2000_abort(Scsi_Cmnd *);
                    407: void in2000_setup(char *, int *) in2000__INIT;
                    408: int in2000_proc_info(char *, char **, off_t, int, int, int);
                    409: struct proc_dir_entry proc_scsi_in2000;
                    410: int in2000_biosparam(struct scsi_disk *, kdev_t, int *);
                    411: int in2000_reset(Scsi_Cmnd *, unsigned int);
                    412: 
                    413: 
                    414: #define IN2000_CAN_Q    16
                    415: #define IN2000_SG       SG_ALL
                    416: #define IN2000_CPL      2
                    417: #define IN2000_HOST_ID  7
                    418: 
                    419: #if LINUX_VERSION_CODE < 0x020100   /* 2.0.xx */
                    420: 
                    421: #define IN2000 {  NULL,                /* link pointer for modules */ \
                    422:                   NULL,                /* usage_count for modules */ \
                    423:                   &proc_scsi_in2000,   /* pointer to /proc/scsi directory entry */ \
                    424:                   in2000_proc_info,    /* pointer to proc info function */ \
                    425:                   "Always IN2000",     /* device name */ \
                    426:                   in2000_detect,       /* returns number of in2000's found */ \
                    427:                   NULL,                /* optional unload function for modules */ \
                    428:                   NULL,                /* optional misc info function */ \
                    429:                   NULL,                /* send scsi command, wait for completion */ \
                    430:                   in2000_queuecommand, /* queue scsi command, don't wait */ \
                    431:                   in2000_abort,        /* abort current command */ \
                    432:                   in2000_reset,        /* reset scsi bus */ \
                    433:                   NULL,                /* slave_attach - unused */ \
                    434:                   in2000_biosparam,    /* figures out BIOS parameters for lilo, etc */ \
                    435:                   IN2000_CAN_Q,        /* max commands we can queue up */ \
                    436:                   IN2000_HOST_ID,      /* host-adapter scsi id */ \
                    437:                   IN2000_SG,           /* scatter-gather table size */ \
                    438:                   IN2000_CPL,          /* commands per lun */ \
                    439:                   0,                   /* board counter */ \
                    440:                   0,                   /* unchecked dma */ \
                    441:                   DISABLE_CLUSTERING \
                    442:                }
                    443: 
                    444: #else       /* 2.1.xxx */
                    445: 
                    446: #define IN2000 {  proc_dir:        &proc_scsi_in2000,   /* pointer to /proc/scsi directory entry */ \
                    447:                   proc_info:       in2000_proc_info,    /* pointer to proc info function */ \
                    448:                   name:            "Always IN2000",     /* device name */ \
                    449:                   detect:          in2000_detect,       /* returns number of in2000's found */ \
                    450:                   queuecommand:    in2000_queuecommand, /* queue scsi command, don't wait */ \
                    451:                   abort:           in2000_abort,        /* abort current command */ \
                    452:                   reset:           in2000_reset,        /* reset scsi bus */ \
                    453:                   bios_param:      in2000_biosparam,    /* figures out BIOS parameters for lilo, etc */ \
                    454:                   can_queue:       IN2000_CAN_Q,        /* max commands we can queue up */ \
                    455:                   this_id:         IN2000_HOST_ID,      /* host-adapter scsi id */ \
                    456:                   sg_tablesize:    IN2000_SG,           /* scatter-gather table size */ \
                    457:                   cmd_per_lun:     IN2000_CPL,          /* commands per lun */ \
                    458:                   use_clustering:  DISABLE_CLUSTERING,  /* ENABLE_CLUSTERING may speed things up */ \
                    459:                   use_new_eh_code: 0                    /* new error code - not using it yet */ \
                    460:                 }
                    461: 
                    462: #endif
                    463: 
                    464: 
                    465: #endif /* IN2000_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.