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

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