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

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