Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _AHA1740_H
0003 
0004 /* $Id$
0005  *
0006  * Header file for the adaptec 1740 driver for Linux
0007  *
0008  * With minor revisions 3/31/93
0009  * Written and (C) 1992,1993 Brad McLean.  See aha1740.c
0010  * for more info
0011  *
0012  */
0013 
0014 #include <linux/types.h>
0015 
0016 #define SLOTSIZE    0x5c
0017 
0018 /* EISA configuration registers & values */
0019 #define HID0(base)  (base + 0x0)
0020 #define HID1(base)  (base + 0x1)
0021 #define HID2(base)  (base + 0x2)
0022 #define HID3(base)  (base + 0x3)
0023 #define EBCNTRL(base)   (base + 0x4)
0024 #define PORTADR(base)   (base + 0x40)
0025 #define BIOSADR(base)   (base + 0x41)
0026 #define INTDEF(base)    (base + 0x42)
0027 #define SCSIDEF(base)   (base + 0x43)
0028 #define BUSDEF(base)    (base + 0x44)
0029 #define RESV0(base) (base + 0x45)
0030 #define RESV1(base) (base + 0x46)
0031 #define RESV2(base) (base + 0x47)
0032 
0033 #define HID_MFG "ADP"
0034 #define HID_PRD 0
0035 #define HID_REV 2
0036 #define EBCNTRL_VALUE 1
0037 #define PORTADDR_ENH 0x80
0038 /* READ */
0039 #define G2INTST(base)   (base + 0x56)
0040 #define G2STAT(base)    (base + 0x57)
0041 #define MBOXIN0(base)   (base + 0x58)
0042 #define MBOXIN1(base)   (base + 0x59)
0043 #define MBOXIN2(base)   (base + 0x5a)
0044 #define MBOXIN3(base)   (base + 0x5b)
0045 #define G2STAT2(base)   (base + 0x5c)
0046 
0047 #define G2INTST_MASK        0xf0    /* isolate the status */
0048 #define G2INTST_CCBGOOD     0x10    /* CCB Completed */
0049 #define G2INTST_CCBRETRY    0x50    /* CCB Completed with a retry */
0050 #define G2INTST_HARDFAIL    0x70    /* Adapter Hardware Failure */
0051 #define G2INTST_CMDGOOD     0xa0    /* Immediate command success */
0052 #define G2INTST_CCBERROR    0xc0    /* CCB Completed with error */
0053 #define G2INTST_ASNEVENT    0xd0    /* Asynchronous Event Notification */
0054 #define G2INTST_CMDERROR    0xe0    /* Immediate command error */
0055 
0056 #define G2STAT_MBXOUT   4   /* Mailbox Out Empty Bit */
0057 #define G2STAT_INTPEND  2   /* Interrupt Pending Bit */
0058 #define G2STAT_BUSY 1   /* Busy Bit (attention pending) */
0059 
0060 #define G2STAT2_READY   0   /* Host Ready Bit */
0061 
0062 /* WRITE (and ReadBack) */
0063 #define MBOXOUT0(base)  (base + 0x50)
0064 #define MBOXOUT1(base)  (base + 0x51)
0065 #define MBOXOUT2(base)  (base + 0x52)
0066 #define MBOXOUT3(base)  (base + 0x53)
0067 #define ATTN(base)  (base + 0x54)
0068 #define G2CNTRL(base)   (base + 0x55)
0069 
0070 #define ATTN_IMMED  0x10    /* Immediate Command */
0071 #define ATTN_START  0x40    /* Start CCB */
0072 #define ATTN_ABORT  0x50    /* Abort CCB */
0073 
0074 #define G2CNTRL_HRST    0x80    /* Hard Reset */
0075 #define G2CNTRL_IRST    0x40    /* Clear EISA Interrupt */
0076 #define G2CNTRL_HRDY    0x20    /* Sets HOST ready */
0077 
0078 /* This is used with scatter-gather */
0079 struct aha1740_chain {
0080     u32 dataptr;        /* Location of data */
0081     u32 datalen;        /* Size of this part of chain */
0082 };
0083 
0084 /* These belong in scsi.h */
0085 #define any2scsi(up, p)             \
0086 (up)[0] = (((unsigned long)(p)) >> 16)  ;   \
0087 (up)[1] = (((unsigned long)(p)) >> 8);      \
0088 (up)[2] = ((unsigned long)(p));
0089 
0090 #define scsi2int(up) ( (((long)*(up)) << 16) + (((long)(up)[1]) << 8) + ((long)(up)[2]) )
0091 
0092 #define xany2scsi(up, p)    \
0093 (up)[0] = ((long)(p)) >> 24;    \
0094 (up)[1] = ((long)(p)) >> 16;    \
0095 (up)[2] = ((long)(p)) >> 8; \
0096 (up)[3] = ((long)(p));
0097 
0098 #define xscsi2int(up) ( (((long)(up)[0]) << 24) + (((long)(up)[1]) << 16) \
0099               + (((long)(up)[2]) <<  8) +  ((long)(up)[3]) )
0100 
0101 #define MAX_CDB 12
0102 #define MAX_SENSE 14
0103 #define MAX_STATUS 32
0104 
0105 struct ecb {            /* Enhanced Control Block 6.1 */
0106     u16 cmdw;       /* Command Word */
0107     /* Flag Word 1 */
0108     u16 cne:1,      /* Control Block Chaining */
0109     :6, di:1,       /* Disable Interrupt */
0110     :2, ses:1,      /* Suppress Underrun error */
0111     :1, sg:1,       /* Scatter/Gather */
0112     :1, dsb:1,      /* Disable Status Block */
0113      ars:1;         /* Automatic Request Sense */
0114     /* Flag Word 2 */
0115     u16 lun:3,      /* Logical Unit */
0116      tag:1,         /* Tagged Queuing */
0117      tt:2,          /* Tag Type */
0118      nd:1,          /* No Disconnect */
0119     :1, dat:1,      /* Data transfer - check direction */
0120      dir:1,         /* Direction of transfer 1 = datain */
0121      st:1,          /* Suppress Transfer */
0122      chk:1,         /* Calculate Checksum */
0123     :2, rec:1,:1;       /* Error Recovery */
0124     u16 nil0;       /* nothing */
0125     u32 dataptr;        /* Data or Scatter List ptr */
0126     u32 datalen;        /* Data or Scatter List len */
0127     u32 statusptr;      /* Status Block ptr */
0128     u32 linkptr;        /* Chain Address */
0129     u32 nil1;       /* nothing */
0130     u32 senseptr;       /* Sense Info Pointer */
0131     u8 senselen;        /* Sense Length */
0132     u8 cdblen;      /* CDB Length */
0133     u16 datacheck;      /* Data checksum */
0134     u8 cdb[MAX_CDB];    /* CDB area */
0135 /* Hardware defined portion ends here, rest is driver defined */
0136     u8 sense[MAX_SENSE];    /* Sense area */
0137     u8 status[MAX_STATUS];  /* Status area */
0138     struct scsi_cmnd *SCpnt;    /* Link to the SCSI Command Block */
0139     void (*done) (struct scsi_cmnd *);  /* Completion Function */
0140 };
0141 
0142 #define AHA1740CMD_NOP   0x00   /* No OP */
0143 #define AHA1740CMD_INIT  0x01   /* Initiator SCSI Command */
0144 #define AHA1740CMD_DIAG  0x05   /* Run Diagnostic Command */
0145 #define AHA1740CMD_SCSI  0x06   /* Initialize SCSI */
0146 #define AHA1740CMD_SENSE 0x08   /* Read Sense Information */
0147 #define AHA1740CMD_DOWN  0x09   /* Download Firmware (yeah, I bet!) */
0148 #define AHA1740CMD_RINQ  0x0a   /* Read Host Adapter Inquiry Data */
0149 #define AHA1740CMD_TARG  0x10   /* Target SCSI Command */
0150 
0151 #define AHA1740_ECBS 32
0152 #define AHA1740_SCATTER 16
0153 
0154 #endif