root/drivers/scsi/eata_dma.h

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

INCLUDED FROM


   1 /********************************************************
   2 * Header file for eata_dma.c Linux EATA-DMA SCSI driver *
   3 * (c) 1993,94,95 Michael Neuffer                        *
   4 *********************************************************
   5 * last change: 95/01/15                                 *
   6 ********************************************************/
   7 
   8 
   9 #ifndef _EATA_DMA_H
  10 #define _EATA_DMA_H
  11 
  12 #include "../block/blk.h"
  13 #include "scsi.h"
  14 #include "hosts.h"
  15 #include <linux/scsicam.h>
  16 
  17 #define VER_MAJOR 2
  18 #define VER_MINOR 1
  19 #define VER_SUB   "0g"
  20 
  21 /************************************************************************
  22  * Here you can configure your drives that are using a non-standard     *
  23  * geometry.                                                            *
  24  * To enable this set HARDCODED to 1                                    *
  25  * If you have only one drive that need reconfiguration, set ID1 to -1  *
  26  ************************************************************************/
  27 #define HARDCODED     0          /* Here are drives running in emu. mode   */
  28 
  29 #define ID0           0          /* SCSI ID of "IDE" drive mapped to C:    
  30                                   * If you're not sure check your config
  31                                   * utility that came with your controller
  32                                   */
  33 #define HEADS0       13          /* Number of emulated heads of this drive */  
  34 #define SECTORS0     38          /* Number of emulated sectors             */ 
  35 #define CYLINDER0   719          /* Number of emulated cylinders           */
  36    
  37 #define ID1           1          /* SCSI ID of "IDE" drive mapped to D:    */
  38 #define HEADS1       16          /* Number of emulated heads of this drive */ 
  39 #define SECTORS1     62          /* Number of emulated sectors             */
  40 #define CYLINDER1  1024          /* Number of emulated cylinders           */
  41 
  42 /************************************************************************
  43  * Here you can switch parts of the code on and of                      *
  44  ************************************************************************/
  45 
  46 #define CHECKPAL        0        /* EISA pal checking on/off            */
  47 
  48 /************************************************************************
  49  * Debug options.                                                       * 
  50  * Enable DEBUG and whichever options you require.                      *
  51  ************************************************************************/
  52 #define DEBUG           1       /* Enable debug code.                   */
  53 #define DPT_DEBUG       0       /* Bobs special                         */
  54 #define DBG_DELAY       0       /* Build in delays so debug messages can be
  55                                  * be read before they vanish of the top of
  56                                  * the screen!
  57                                  */
  58 #define DBG_PROBE       0       /* Debug probe routines.                */
  59 #define DBG_PCI         0       /* Trace PCI routines                   */
  60 #define DBG_EISA        0       /* Trace EISA routines                  */
  61 #define DBG_ISA         0       /* Trace ISA routines                   */ 
  62 #define DBG_BLINK       0       /* Trace Blink check                    */
  63 #define DBG_PIO         0       /* Trace get_config_PIO                 */
  64 #define DBG_COM         0       /* Trace command call                   */
  65 #define DBG_QUEUE       0       /* Trace command queueing.              */
  66 #define DBG_INTR        0       /* Trace interrupt service routine.     */
  67 #define DBG_REGISTER    0       /* */
  68 #define DBG_ABNORM      1       /* Debug abnormal actions (reset, abort)*/
  69 
  70 #if DEBUG 
  71 #define DBG(x, y)       if ((x)) {y;} 
  72 #else
  73 #define DBG(x, y)
  74 #endif
  75 
  76 
  77 #define EATA_DMA {                   \
  78         NULL, NULL,                  \
  79         "EATA (Extended Attachment) driver", \
  80         eata_detect,                 \
  81         NULL,                        \
  82         eata_info,                   \
  83         eata_command,                \
  84         eata_queue,                  \
  85         eata_abort,                  \
  86         eata_reset,                  \
  87         NULL, /* Slave attach */     \
  88         scsicam_bios_param,          \
  89         0,      /* Canqueue     */   \
  90         0,      /* this_id      */   \
  91         0,      /* sg_tablesize */   \
  92         0,      /* cmd_per_lun  */   \
  93         0,      /* present      */   \
  94         0,      /* True if ISA  */   \
  95         ENABLE_CLUSTERING }
  96 
  97 int eata_detect(Scsi_Host_Template *);
  98 const char *eata_info(struct Scsi_Host *);
  99 int eata_command(Scsi_Cmnd *);
 100 int eata_queue(Scsi_Cmnd *, void *(done)(Scsi_Cmnd *));
 101 int eata_abort(Scsi_Cmnd *);
 102 int eata_reset(Scsi_Cmnd *);
 103 
 104 
 105 /*********************************************
 106  * Misc. definitions                         *
 107  *********************************************/
 108 
 109 #ifndef TRUE
 110 # define TRUE 1
 111 #endif
 112 #ifndef FALSE
 113 # define FALSE 0
 114 #endif
 115 
 116 #define R_LIMIT 0x20000
 117 
 118 #define MAXISA     4
 119 #define MAXEISA   16  
 120 #define MAXPCI    16
 121 #define MAXIRQ    16 
 122 #define MAXTARGET  8
 123 
 124 /* PCI Bus And Device Limitations */
 125 
 126 #define MAX_PCI_DEVICES          32       /* Maximum # Of Devices Per Bus   */
 127 #define MAX_METHOD_2             16       /* Max Devices For Method 2       */
 128 #define MAX_PCI_BUS              16       /* Maximum # Of Busses Allowed    */
 129 
 130 
 131 #define SG_SIZE   64
 132 #define C_P_L_DIV 32     
 133 
 134 #define FREE      0
 135 #define USED      1
 136 #define TIMEOUT   2
 137 #define RESET     4
 138 #define LOCKED    8
 139 
 140 #define HD(cmd)  ((hostdata *)&(cmd->host->hostdata))
 141 #define CD(cmd)  ((struct eata_ccb *)(cmd->host_scribble))
 142 #define SD(host) ((hostdata *)&(host->hostdata))
 143 
 144 #define DELAY(x) { int i; i = jiffies + x; while (jiffies < i); }
 145 #define DEL2(x)  { ulong i; for (i = 0; i < 0xffff*x; i++); }
 146 
 147 /***********************************************
 148  *    EATA Command & Register definitions      *
 149  ***********************************************/
 150 #define PCI_REG_DPTconfig        0x40    
 151 #define PCI_REG_PumpModeAddress  0x44    
 152 #define PCI_REG_PumpModeData     0x48    
 153 #define PCI_REG_ConfigParam1     0x50    
 154 #define PCI_REG_ConfigParam2     0x54    
 155 
 156 
 157 #define EATA_CMD_PIO_READ_CONFIG 0xf0
 158 #define EATA_CMD_PIO_SET_CONFIG  0xf1
 159 #define EATA_CMD_PIO_SEND_CP     0xf2
 160 #define EATA_CMD_PIO_RECEIVE_SP  0xf3
 161 #define EATA_CMD_PIO_TRUNC       0xf4
 162 
 163 #define EATA_CMD_RESET           0xf9
 164 
 165 #define EATA_CMD_DMA_READ_CONFIG 0xfd
 166 #define EATA_CMD_DMA_SET_CONFIG  0xfe
 167 #define EATA_CMD_DMA_SEND_CP     0xff
 168 
 169 #define ECS_EMULATE_SENSE        0xd4
 170 
 171 #define HA_WCOMMAND 0x07        /* command register offset   */
 172 #define HA_WDMAADDR 0x02        /* DMA address LSB offset    */  
 173 #define HA_RAUXSTAT 0x08        /* aux status register offset*/
 174 #define HA_RSTATUS  0x07        /* status register offset    */
 175 #define HA_RDATA    0x00        /* data register (16bit)     */
 176 
 177 #define HA_ABUSY    0x01        /* aux busy bit              */
 178 #define HA_AIRQ     0x02        /* aux IRQ pending bit       */
 179 #define HA_SERROR   0x01        /* pr. command ended in error*/
 180 #define HA_SMORE    0x02        /* more data soon to come    */
 181 #define HA_SCORR    0x04        /* data corrected            */
 182 #define HA_SDRQ     0x08        /* data request active       */
 183 #define HA_SSC      0x10        /* seek complete             */
 184 #define HA_SFAULT   0x20        /* write fault               */
 185 #define HA_SREADY   0x40        /* drive ready               */
 186 #define HA_SBUSY    0x80        /* drive busy                */
 187 #define HA_SDRDY    HA_SSC+HA_SREADY+HA_SDRQ 
 188 
 189 /**********************************************
 190  * Message definitions                        *
 191  **********************************************/
 192 
 193 struct reg_bit {        /* reading this one will clear the interrupt    */
 194   unchar error:1;     /* previous command ended in an error           */
 195   unchar more:1;      /* more DATA coming soon, poll BSY & DRQ (PIO) */
 196   unchar corr:1;      /* data read was successfully corrected with ECC*/
 197   unchar drq:1;       /* data request active  */     
 198   unchar sc:1;        /* seek complete        */
 199   unchar fault:1;     /* write fault          */
 200   unchar ready:1;     /* drive ready          */
 201   unchar busy:1;      /* controller busy      */
 202 };
 203 
 204 struct reg_abit {       /* reading this won't clear the interrupt */
 205   unchar abusy:1;     /* auxiliary busy                         */
 206   unchar irq:1;       /* set when drive interrupt is asserted   */
 207   unchar dummy:6;
 208 };
 209 
 210 struct eata_register {              /* EATA register set */
 211   unchar data_reg[2];           /* R, couldn't figure this one out          */
 212   unchar cp_addr[4];            /* W, CP address register                   */
 213   union { 
 214     unchar command;                     /* W, command code: [read|set] conf, send CP*/
 215     struct reg_bit status;      /* R, see register_bit1                     */
 216     unchar statusunchar;
 217   } ovr;   
 218   struct reg_abit aux_stat;     /* R, see register_bit2                     */
 219 };
 220 
 221 /**********************************************
 222  *  Other  definitions                        *
 223  **********************************************/
 224 
 225 struct eata_sg_list
 226 {
 227   ulong data;
 228   ulong len;
 229 };
 230 
 231 struct get_conf {          /* Read Configuration Array  */
 232   ulong  len;                 /* Should return 0x22                     */
 233   unchar sig[4];              /* Signature MUST be "EATA"               */
 234   unchar    version2:4,
 235              version:4;       /* EATA Version level                     */
 236   unchar OCS_enabled:1,       /* Overlap Command Support enabled        */
 237          TAR_support:1,       /* SCSI Target Mode supported             */
 238               TRNXFR:1,       /* Truncate Transfer Cmd not necessary    */
 239                               /* Only used in PIO Mode                  */
 240         MORE_support:1,       /* MORE supported (only PIO Mode)         */
 241          DMA_support:1,       /* DMA supported Driver uses only         */
 242                               /* this mode                              */
 243            DMA_valid:1,       /* DRQ value in Byte 30 is valid          */
 244                  ATA:1,       /* ATA device connected (not supported)   */
 245            HAA_valid:1;       /* Hostadapter Address is valid           */
 246 
 247   ushort cppadlen;            /* Number of pad unchars send after CD data */
 248                               /* set to zero for DMA commands           */
 249   unchar scsi_id[4];          /* SCSI ID of controller 2-0 Byte 0 res.  */
 250                               /* if not, zero is returned               */
 251   ulong  cplen;               /* CP length: number of valid cp unchars  */
 252   ulong  splen;               /* Number of unchars returned after       */ 
 253                               /* Receive SP command                     */
 254   ushort queuesiz;            /* max number of queueable CPs            */
 255   ushort dummy;
 256   ushort SGsiz;               /* max number of SG table entries         */
 257   unchar    IRQ:4,            /* IRQ used this HA                       */
 258          IRQ_TR:1,            /* IRQ Trigger: 0=edge, 1=level           */
 259          SECOND:1,            /* This is a secondary controller         */  
 260     DMA_channel:2;            /* DRQ index, DRQ is 2comp of DRQX        */
 261   unchar sync;                /* device at ID 7 tru 0 is running in     */
 262                               /* synchronous mode, this will disappear  */
 263   unchar   DSBLE:1,           /* ISA i/o addressing is disabled         */
 264          FORCADR:1,           /* i/o address has been forced            */
 265                 :6;
 266   unchar  MAX_ID:5,           /* Max number of SCSI target IDs          */
 267         MAX_CHAN:3;           /* Number of SCSI busses on HBA           */
 268   unchar MAX_LUN;             /* Max number of LUNs                     */
 269   unchar        :5,          
 270          ID_qest:1,           /* Raidnum ID is questionable             */
 271           is_PCI:1,           /* HBA is PCI                             */
 272          is_EISA:1;           /* HBA is EISA                            */
 273   unchar unused[478]; 
 274 };
 275 
 276 struct eata_ccb {             /* Send Command Packet structure      */
 277  
 278   unchar SCSI_Reset:1,        /* Cause a SCSI Bus reset on the cmd  */
 279            HBA_Init:1,        /* Cause Controller to reinitialize   */
 280        Auto_Req_Sen:1,        /* Do Auto Request Sense on errors    */
 281             scatter:1,        /* Data Ptr points to a SG Packet     */
 282              Resrvd:1,        /* RFU                                */
 283           Interpret:1,        /* Interpret the SCSI cdb of own use  */
 284             DataOut:1,        /* Data Out phase with command        */
 285              DataIn:1;        /* Data In phase with command         */
 286   unchar reqlen;              /* Request Sense Length               */ 
 287                               /* Valid if Auto_Req_Sen=1            */
 288   unchar unused[3];
 289   unchar  FWNEST:1,           /* send cmd to phys RAID component*/
 290          unused2:7;
 291   unchar Phsunit:1,           /* physical unit on mirrored pair */
 292             I_AT:1,           /* inhibit address translation    */
 293          I_HBA_C:1,           /* HBA Inhibit caching            */
 294          unused3:5;
 295 
 296   unchar cp_id;               /* SCSI Device ID of target       */ 
 297   unchar    cp_lun:3,
 298                   :2,
 299          cp_luntar:1,         /* CP is for target ROUTINE       */
 300          cp_dispri:1,         /* Grant disconnect privilege     */
 301        cp_identify:1;         /* Always TRUE                    */         
 302   unchar cp_msg1;             /* Message bytes 0-3              */
 303   unchar cp_msg2;
 304   unchar cp_msg3;
 305   unchar cp_cdb[12];          /* Command Descriptor Block       */
 306   ulong  cp_datalen;          /* Data Transfer Length           */
 307                               /* If scatter=1 len of sg package */
 308   void *cp_viraddr;           /* address of this ccb            */
 309   ulong cp_dataDMA;           /* Data Address, if scatter=1     */
 310                               /* address of scatter packet      */  
 311   ulong cp_statDMA;           /* address for Status Packet      */ 
 312   ulong cp_reqDMA;            /* Request Sense Address, used if */
 313                               /* CP command ends with error     */
 314  
 315   ulong timeout;
 316   unchar retries;
 317   unchar status;              /* status of this queueslot       */
 318   struct eata_sg_list sg_list[SG_SIZE];
 319   Scsi_Cmnd *cmd;             /* address of cmd                 */
 320 };
 321 
 322 
 323 struct eata_sp
 324 {
 325   unchar hba_stat:7,          /* HBA status                     */
 326               EOC:1;          /* True if command finished       */
 327   unchar scsi_stat;           /* Target SCSI status             */       
 328   unchar reserved[2];
 329   ulong  residue_len;         /* Number of unchars not transferred */
 330   struct eata_ccb *ccb;       /* Address set in COMMAND PACKET  */
 331   unchar msg[12];
 332 };
 333 
 334 typedef struct hstd{
 335   char   vendor[9];
 336   char   name[18];
 337   char   revision[6];
 338   unchar bustype;              /* bustype of HBA             */
 339   unchar channel;              /* no. of scsi channel        */
 340   unchar state;                /* state of HBA               */
 341   unchar t_state[MAXTARGET];   /* state of Target (RESET,..) */
 342   uint   t_timeout[MAXTARGET]; /* timeouts on target         */
 343   unchar primary;              /* true if primary            */
 344   uint   last_ccb;             /* Last used ccb              */
 345   struct Scsi_Host *next;         
 346   struct Scsi_Host *prev;
 347   struct eata_sp sp;           /* status packet              */ 
 348   struct eata_ccb ccb[0];      /* ccb array begins here      */
 349 }hostdata;
 350 
 351 
 352 
 353 /* structure for max. 2 emulated drives */
 354 struct drive_geom_emul {
 355   unchar trans;                 /* translation flag 1=transl */
 356   unchar channel;               /* SCSI channel number       */
 357   unchar HBA;                   /* HBA number (prim/sec)     */
 358   unchar id;                    /* drive id                  */
 359   unchar lun;                   /* drive lun                 */
 360   uint   heads;                 /* number of heads           */
 361   uint   sectors;               /* number of sectors         */
 362   uint   cylinder;              /* number of cylinders       */
 363 };
 364 
 365 struct geom_emul {
 366   int bios_drives;               /* number of emulated drives */
 367   struct drive_geom_emul drv[2]; /* drive structures          */
 368 };
 369 
 370 struct lun_map {
 371   unchar   id:5,
 372          chan:3;
 373   unchar lun;
 374 };
 375 
 376 typedef struct emul_pp {
 377   unchar p_code:6,
 378            null:1,
 379          p_save:1;
 380   unchar p_lenght;
 381   ushort cylinder;
 382   unchar heads;
 383   unchar sectors;
 384   unchar null2;
 385   unchar s_lunmap:4,
 386               ems:1;
 387   ushort drive_type;   /* In Little Endian ! */
 388   struct lun_map lunmap[4];
 389 }emulpp;
 390 
 391 #endif /* _EATA_H */

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