root/drivers/scsi/aha152x.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef _AHA152X_H
   2 #define _AHA152X_H
   3 
   4 /*
   5  * $Id: aha152x.h,v 1.0 1994/03/25 12:52:00 root Exp $
   6  */
   7 
   8 #include "../block/blk.h"
   9 #include "scsi.h"
  10 #if defined(__KERNEL__)
  11 #include <asm/io.h>
  12 
  13 int        aha152x_detect(int);
  14 const char *aha152x_info(void);
  15 int        aha152x_command(Scsi_Cmnd *);
  16 int        aha152x_queue(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
  17 int        aha152x_abort(Scsi_Cmnd *, int);
  18 int        aha152x_reset(Scsi_Cmnd *);
  19 int        aha152x_biosparam(int, int, int*);
  20 
  21 /* number of queueable commands
  22    (unless we support more than 1 cmd_per_lun this should do) */
  23 #define AHA152X_MAXQUEUE        7               
  24 
  25 #define AHA152X_REVID   "Adaptec 152x SCSI driver; $Revision: 1.0 $"
  26 
  27 /* Initial value of Scsi_Host entry */
  28 #define AHA152X       { /* name */              AHA152X_REVID, \
  29                         /* detect */            aha152x_detect,             \
  30                         /* info */              aha152x_info,               \
  31                         /* command */           aha152x_command,            \
  32                         /* queuecommand */      aha152x_queue,              \
  33                         /* abort */             aha152x_abort,              \
  34                         /* reset */             aha152x_reset,              \
  35                         /* slave_attach */      /* NULL */  0,              \
  36                         /* bios_param */        aha152x_biosparam,          \
  37                         /* can_queue */         1,                          \
  38                         /* this_id */           7,                          \
  39                         /* sg_tablesize */      SG_ALL,                     \
  40                         /* cmd_per_lun */       1,                          \
  41                         /* present */           0,                          \
  42                         /* unchecked_isa_dma */ 0 }
  43 #endif
  44 
  45 
  46 /* port addresses */
  47 #define SCSISEQ         (port_base+0x00)        /* SCSI sequence control */
  48 #define SXFRCTL0        (port_base+0x01)        /* SCSI transfer control 0 */
  49 #define SXFRCTL1        (port_base+0x02)        /* SCSI transfer control 1 */
  50 #define SCSISIG         (port_base+0x03)        /* SCSI signal in/out */
  51 #define SCSIRATE        (port_base+0x04)        /* SCSI rate control */
  52 #define SELID           (port_base+0x05)        /* selection/reselection ID */
  53 #define SCSIID          SELID                   /* SCSI ID */
  54 #define SCSIDAT         (port_base+0x06)        /* SCSI latched data */
  55 #define SCSIBUS         (port_base+0x07)        /* SCSI data bus */
  56 #define STCNT0          (port_base+0x08)        /* SCSI transfer count 0 */
  57 #define STCNT1          (port_base+0x09)        /* SCSI transfer count 1 */
  58 #define STCNT2          (port_base+0x0a)        /* SCSI transfer count 2 */
  59 #define SSTAT0          (port_base+0x0b)        /* SCSI interrupt status 0 */
  60 #define SSTAT1          (port_base+0x0c)        /* SCSI interrupt status 1 */
  61 #define SSTAT2          (port_base+0x0d)        /* SCSI interrupt status 2 */
  62 #define SCSITEST        (port_base+0x0e)        /* SCSI test control */
  63 #define SSTAT4          (port_base+0x0f)        /* SCSI status 4 */
  64 #define SIMODE0         (port_base+0x10)        /* SCSI interrupt mode 0 */
  65 #define SIMODE1         (port_base+0x11)        /* SCSI interrupt mode 1 */
  66 #define DMACNTRL0       (port_base+0x12)        /* DMA control 0 */
  67 #define DMACNTRL1       (port_base+0x13)        /* DMA control 1 */
  68 #define DMASTAT         (port_base+0x14)        /* DMA status */
  69 #define FIFOSTAT        (port_base+0x15)        /* FIFO status */
  70 #define DATAPORT        (port_base+0x16)        /* DATA port */
  71 #define BRSTCNTRL       (port_base+0x18)        /* burst control */
  72 #define PORTA           (port_base+0x1a)        /* PORT A */
  73 #define PORTB           (port_base+0x1b)        /* PORT B */
  74 #define REV             (port_base+0x1c)        /* revision */
  75 #define STACK           (port_base+0x1d)        /* stack */
  76 #define TEST            (port_base+0x1e)        /* test register */
  77 
  78 
  79 /* bits and bitmasks to ports */
  80 
  81 /* SCSI sequence control */
  82 #define TEMODEO         0x80
  83 #define ENSELO          0x40
  84 #define ENSELI          0x20
  85 #define ENRESELI        0x10
  86 #define ENAUTOATNO      0x08
  87 #define ENAUTOATNI      0x04
  88 #define ENAUTOATNP      0x02
  89 #define SCSIRSTO        0x01
  90 
  91 /* SCSI transfer control 0 */
  92 #define SCSIEN          0x80
  93 #define DMAEN           0x40
  94 #define CH1             0x20
  95 #define CLRSTCNT        0x10
  96 #define SPIOEN          0x08
  97 #define CLRCH1          0x02
  98 
  99 /* SCSI transfer control 1 */
 100 #define BITBUCKET       0x80
 101 #define SWRAPEN         0x40
 102 #define ENSPCHK         0x20
 103 #define STIMESEL        0x18    /* mask */
 104 #define STIMESEL_       3
 105 #define ENSTIMER        0x04
 106 #define BYTEALIGN       0x02
 107 
 108 /* SCSI signal IN */
 109 #define CDI             0x80
 110 #define IOI             0x40
 111 #define MSGI            0x20
 112 #define ATNI            0x10
 113 #define SELI            0x08
 114 #define BSYI            0x04
 115 #define REQI            0x02
 116 #define ACKI            0x01
 117 
 118 /* SCSI Phases */
 119 #define P_MASK          (MSGI|CDI|IOI)
 120 #define P_DATAO         (0)
 121 #define P_DATAI         (IOI)
 122 #define P_CMD           (CDI)
 123 #define P_STATUS        (CDI|IOI)
 124 #define P_MSGO          (MSGI|CDI)
 125 #define P_MSGI          (MSGI|CDI|IOI)
 126 
 127 /* SCSI signal OUT */
 128 #define CDO             0x80
 129 #define IOO             0x40
 130 #define MSGO            0x20
 131 #define ATNO            0x10
 132 #define SELO            0x08
 133 #define BSYO            0x04
 134 #define REQO            0x02
 135 #define ACKO            0x01
 136 
 137 /* SCSI rate control */
 138 #define SXFR            0x70    /* mask */
 139 #define SXFR_           4
 140 #define SOFS            0x0f    /* mask */
 141 
 142 /* SCSI ID */
 143 #define OID             0x70
 144 #define OID_            4
 145 #define TID             0x07
 146 
 147 /* SCSI transfer count */
 148 #define GETSTCNT()   ( (GETPORT(STCNT2)<<16) \
 149                      + (GETPORT(STCNT1)<< 8) \
 150                      + GETPORT(STCNT0) )
 151 
 152 #define SETSTCNT(X)  { SETPORT(STCNT2, ((X) & 0xFF0000) >> 16); \
 153                        SETPORT(STCNT1, ((X) & 0x00FF00) >>  8); \
 154                        SETPORT(STCNT0, ((X) & 0x0000FF) ); }
 155 
 156 /* SCSI interrupt status */
 157 #define TARGET          0x80
 158 #define SELDO           0x40
 159 #define SELDI           0x20
 160 #define SELINGO         0x10
 161 #define SWRAP           0x08
 162 #define SDONE           0x04
 163 #define SPIORDY         0x02
 164 #define DMADONE         0x01
 165 
 166 #define SETSDONE        0x80
 167 #define CLRSELDO        0x40
 168 #define CLRSELDI        0x20
 169 #define CLRSELINGO      0x10
 170 #define CLRSWRAP        0x08
 171 #define CLRSDONE        0x04
 172 #define CLRSPIORDY      0x02
 173 #define CLRDMADONE      0x01
 174 
 175 /* SCSI status 1 */
 176 #define SELTO           0x80
 177 #define ATNTARG         0x40
 178 #define SCSIRSTI        0x20
 179 #define PHASEMIS        0x10
 180 #define BUSFREE         0x08
 181 #define SCSIPERR        0x04
 182 #define PHASECHG        0x02
 183 #define REQINIT         0x01
 184 
 185 #define CLRSELTIMO      0x80
 186 #define CLRATNO         0x40
 187 #define CLRSCSIRSTI     0x20
 188 #define CLRBUSFREE      0x08
 189 #define CLRSCSIPERR     0x04
 190 #define CLRPHASECHG     0x02
 191 #define CLRREQINIT      0x01
 192 
 193 /* SCSI status 2 */
 194 #define SOFFSET         0x20
 195 #define SEMPTY          0x10
 196 #define SFULL           0x08
 197 #define SFCNT           0x07    /* mask */
 198 
 199 /* SCSI status 3 */
 200 #define SCSICNT         0xf0    /* mask */
 201 #define SCSICNT_        4
 202 #define OFFCNT          0x0f    /* mask */
 203 
 204 /* SCSI TEST control */
 205 #define SCTESTU         0x08
 206 #define SCTESTD         0x04
 207 #define STCTEST         0x01
 208 
 209 /* SCSI status 4 */
 210 #define SYNCERR         0x04
 211 #define FWERR           0x02
 212 #define FRERR           0x01
 213 
 214 #define CLRSYNCERR      0x04
 215 #define CLRFWERR        0x02
 216 #define CLRFRERR        0x01
 217 
 218 /* SCSI interrupt mode 0 */
 219 #define ENSELDO         0x40
 220 #define ENSELDI         0x20
 221 #define ENSELINGO       0x10
 222 #define ENSWRAP         0x08
 223 #define ENSDONE         0x04
 224 #define ENSPIORDY       0x02
 225 #define ENDMADONE       0x01
 226 
 227 /* SCSI interrupt mode 1 */
 228 #define ENSELTIMO       0x80
 229 #define ENATNTARG       0x40
 230 #define ENSCSIRST       0x20
 231 #define ENPHASEMIS      0x10
 232 #define ENBUSFREE       0x08
 233 #define ENSCSIPERR      0x04
 234 #define ENPHASECHG      0x02
 235 #define ENREQINIT       0x01
 236 
 237 /* DMA control 0 */
 238 #define ENDMA           0x80
 239 #define _8BIT           0x40
 240 #define DMA             0x20
 241 #define WRITE_READ      0x08
 242 #define INTEN           0x04
 243 #define RSTFIFO         0x02
 244 #define SWINT           0x01
 245 
 246 /* DMA control 1 */
 247 #define PWRDWN          0x80
 248 #define STK             0x07    /* mask */
 249 
 250 /* DMA status */
 251 #define ATDONE          0x80
 252 #define WORDRDY         0x40
 253 #define INTSTAT         0x20
 254 #define DFIFOFULL       0x10
 255 #define DFIFOEMP        0x08
 256 
 257 /* BURST control */
 258 #define BON             0xf0
 259 #define BOFF            0x0f
 260 
 261 /* TEST REGISTER */
 262 #define BOFFTMR         0x40
 263 #define BONTMR          0x20
 264 #define STCNTH          0x10
 265 #define STCNTM          0x08
 266 #define STCNTL          0x04
 267 #define SCSIBLK         0x02
 268 #define DMABLK          0x01
 269 
 270 /* On the AHA-152x board PORTA and PORTB contain
 271    some information about the board's configuration. */
 272 typedef union {
 273   struct {
 274     unsigned reserved:2;        /* reserved */
 275     unsigned tardisc:1;         /* Target disconnect: 0=disabled, 1=enabled */
 276     unsigned syncneg:1;         /* Initial sync neg: 0=disabled, 1=enabled */
 277     unsigned msgclasses:2;      /* Message classes
 278                                    0=#4
 279                                    1=#0, #1, #2, #3, #4
 280                                    2=#0, #3, #4
 281                                    3=#0, #4
 282                                 */
 283     unsigned boot:1;            /* boot: 0=disabled, 1=enabled */
 284     unsigned dma:1;             /* Transfer mode: 0=PIO; 1=DMA */
 285     unsigned id:3;              /* SCSI-id */
 286     unsigned irq:2;             /* IRQ-Channel: 0,3=12, 1=10, 2=11 */
 287     unsigned dmachan:2;         /* DMA-Channel: 0=0, 1=5, 2=6, 3=7 */
 288     unsigned parity:1;          /* SCSI-parity: 1=enabled 0=disabled */
 289   } fields;
 290   unsigned short port;
 291 } aha152x_config ;
 292 
 293 #define cf_parity       fields.parity
 294 #define cf_dmachan      fields.dmachan
 295 #define cf_irq          fields.irq
 296 #define cf_id           fields.id
 297 #define cf_dma          fields.dma
 298 #define cf_boot         fields.boot
 299 #define cf_msgclasses   fields.msgclasses
 300 #define cf_syncneg      fields.syncneg
 301 #define cf_tardisc      fields.tardisc
 302 #define cf_port         port
 303 
 304 /* Some macros to manipulate ports and their bits */
 305 
 306 #define SETPORT(PORT, VAL)      \
 307         outb( (VAL), (PORT) )
 308 
 309 #define SETPORTP(PORT, VAL)     \
 310         outb_p( (VAL), (PORT) )
 311 
 312 #define SETPORTW(PORT, VAL)     \
 313         outw( (VAL), (PORT) )
 314 
 315 #define GETPORT(PORT)   \
 316         inb( PORT )
 317 
 318 #define GETPORTW(PORT)  \
 319         inw( PORT )
 320 
 321 #define SETBITS(PORT, BITS)     \
 322         outb( (inb(PORT) | (BITS)), (PORT) )
 323 
 324 #define CLRBITS(PORT, BITS)     \
 325         outb( (inb(PORT) & ~(BITS)), (PORT) )
 326 
 327 #define CLRSETBITS(PORT, CLR, SET)      \
 328         outb( (inb(PORT) & ~(CLR)) | (SET) , (PORT) )
 329 
 330 #define TESTHI(PORT, BITS)      \
 331         ((inb(PORT) & (BITS)) == BITS)
 332 
 333 #define TESTLO(PORT, BITS)      \
 334         ((inb(PORT) & (BITS)) == 0)
 335 
 336 #endif /* _AHA152X_H */

/* [previous][next][first][last][top][bottom][index][help] */