157c801f5SMatt Jacob /* $Id: ispvar.h,v 1.10 1999/02/09 01:11:35 mjacob Exp $ */ 257c801f5SMatt Jacob /* release_03_16_99 */ 36054c3f6SMatt Jacob /* 46054c3f6SMatt Jacob * Soft Definitions for for Qlogic ISP SCSI adapters. 56054c3f6SMatt Jacob * 66054c3f6SMatt Jacob *--------------------------------------- 76054c3f6SMatt Jacob * Copyright (c) 1997, 1998 by Matthew Jacob 86054c3f6SMatt Jacob * NASA/Ames Research Center 96054c3f6SMatt Jacob * All rights reserved. 106054c3f6SMatt Jacob *--------------------------------------- 116054c3f6SMatt Jacob * Redistribution and use in source and binary forms, with or without 126054c3f6SMatt Jacob * modification, are permitted provided that the following conditions 136054c3f6SMatt Jacob * are met: 146054c3f6SMatt Jacob * 1. Redistributions of source code must retain the above copyright 156054c3f6SMatt Jacob * notice immediately at the beginning of the file, without modification, 166054c3f6SMatt Jacob * this list of conditions, and the following disclaimer. 176054c3f6SMatt Jacob * 2. Redistributions in binary form must reproduce the above copyright 186054c3f6SMatt Jacob * notice, this list of conditions and the following disclaimer in the 196054c3f6SMatt Jacob * documentation and/or other materials provided with the distribution. 206054c3f6SMatt Jacob * 3. The name of the author may not be used to endorse or promote products 216054c3f6SMatt Jacob * derived from this software without specific prior written permission. 226054c3f6SMatt Jacob * 236054c3f6SMatt Jacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 246054c3f6SMatt Jacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 256054c3f6SMatt Jacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 266054c3f6SMatt Jacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 276054c3f6SMatt Jacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 286054c3f6SMatt Jacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 296054c3f6SMatt Jacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 306054c3f6SMatt Jacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 316054c3f6SMatt Jacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 326054c3f6SMatt Jacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 336054c3f6SMatt Jacob * SUCH DAMAGE. 346054c3f6SMatt Jacob * 356054c3f6SMatt Jacob */ 366054c3f6SMatt Jacob 376054c3f6SMatt Jacob #ifndef _ISPVAR_H 386054c3f6SMatt Jacob #define _ISPVAR_H 396054c3f6SMatt Jacob 4057c801f5SMatt Jacob #if defined(__NetBSD__) || defined(__OpenBSD__) 416054c3f6SMatt Jacob #include <dev/ic/ispmbox.h> 426054c3f6SMatt Jacob #endif 436054c3f6SMatt Jacob #ifdef __FreeBSD__ 446054c3f6SMatt Jacob #include <dev/isp/ispmbox.h> 456054c3f6SMatt Jacob #endif 466054c3f6SMatt Jacob #ifdef __linux__ 47c3055363SMatt Jacob #include "ispmbox.h" 486054c3f6SMatt Jacob #endif 496054c3f6SMatt Jacob 50478f8a96SJustin T. Gibbs #define ISP_CORE_VERSION_MAJOR 1 5110f20e40SMatt Jacob #define ISP_CORE_VERSION_MINOR 6 52478f8a96SJustin T. Gibbs 536054c3f6SMatt Jacob /* 54cbf57b47SMatt Jacob * Vector for bus specific code to provide specific services. 556054c3f6SMatt Jacob */ 566054c3f6SMatt Jacob struct ispsoftc; 576054c3f6SMatt Jacob struct ispmdvec { 586054c3f6SMatt Jacob u_int16_t (*dv_rd_reg) __P((struct ispsoftc *, int)); 596054c3f6SMatt Jacob void (*dv_wr_reg) __P((struct ispsoftc *, int, u_int16_t)); 606054c3f6SMatt Jacob int (*dv_mbxdma) __P((struct ispsoftc *)); 616054c3f6SMatt Jacob int (*dv_dmaset) __P((struct ispsoftc *, 626054c3f6SMatt Jacob ISP_SCSI_XFER_T *, ispreq_t *, u_int8_t *, u_int8_t)); 636054c3f6SMatt Jacob void (*dv_dmaclr) 646054c3f6SMatt Jacob __P((struct ispsoftc *, ISP_SCSI_XFER_T *, u_int32_t)); 656054c3f6SMatt Jacob void (*dv_reset0) __P((struct ispsoftc *)); 666054c3f6SMatt Jacob void (*dv_reset1) __P((struct ispsoftc *)); 676054c3f6SMatt Jacob void (*dv_dregs) __P((struct ispsoftc *)); 686054c3f6SMatt Jacob const u_int16_t *dv_ispfw; /* ptr to f/w */ 696054c3f6SMatt Jacob u_int16_t dv_fwlen; /* length of f/w */ 706054c3f6SMatt Jacob u_int16_t dv_codeorg; /* code ORG for f/w */ 716054c3f6SMatt Jacob u_int16_t dv_fwrev; /* f/w revision */ 726054c3f6SMatt Jacob /* 736054c3f6SMatt Jacob * Initial values for conf1 register 746054c3f6SMatt Jacob */ 756054c3f6SMatt Jacob u_int16_t dv_conf1; 766054c3f6SMatt Jacob u_int16_t dv_clock; /* clock frequency */ 776054c3f6SMatt Jacob }; 786054c3f6SMatt Jacob 796054c3f6SMatt Jacob #define MAX_TARGETS 16 8057c801f5SMatt Jacob #ifdef ISP2100_FABRIC 8157c801f5SMatt Jacob #define MAX_FC_TARG 256 8257c801f5SMatt Jacob #else 836054c3f6SMatt Jacob #define MAX_FC_TARG 126 8457c801f5SMatt Jacob #endif 859f8afea4SMatt Jacob #define DEFAULT_LOOPID 113 866054c3f6SMatt Jacob 87478f8a96SJustin T. Gibbs /* queue length must be a power of two */ 886054c3f6SMatt Jacob #define QENTRY_LEN 64 89478f8a96SJustin T. Gibbs #define RQUEST_QUEUE_LEN MAXISPREQUEST 9057c801f5SMatt Jacob #define RESULT_QUEUE_LEN (MAXISPREQUEST/2) 916054c3f6SMatt Jacob #define ISP_QUEUE_ENTRY(q, idx) ((q) + ((idx) * QENTRY_LEN)) 926054c3f6SMatt Jacob #define ISP_QUEUE_SIZE(n) ((n) * QENTRY_LEN) 93478f8a96SJustin T. Gibbs #define ISP_NXT_QENTRY(idx, qlen) (((idx) + 1) & ((qlen)-1)) 94478f8a96SJustin T. Gibbs #define ISP_QAVAIL(in, out, qlen) \ 95478f8a96SJustin T. Gibbs ((in == out)? (qlen - 1) : ((in > out)? \ 96478f8a96SJustin T. Gibbs ((qlen - 1) - (in - out)) : (out - in - 1))) 976054c3f6SMatt Jacob /* 98cbf57b47SMatt Jacob * SCSI Specific Host Adapter Parameters 996054c3f6SMatt Jacob */ 1006054c3f6SMatt Jacob 1016054c3f6SMatt Jacob typedef struct { 102478f8a96SJustin T. Gibbs u_int isp_req_ack_active_neg : 1, 1036054c3f6SMatt Jacob isp_data_line_active_neg: 1, 1046054c3f6SMatt Jacob isp_cmd_dma_burst_enable: 1, 1056054c3f6SMatt Jacob isp_data_dma_burst_enabl: 1, 106128101f3SMatt Jacob isp_fifo_threshold : 3, 107cbf57b47SMatt Jacob isp_ultramode : 1, 1086054c3f6SMatt Jacob isp_diffmode : 1, 109478f8a96SJustin T. Gibbs isp_fast_mttr : 1, 1106054c3f6SMatt Jacob isp_initiator_id : 4, 1116054c3f6SMatt Jacob isp_async_data_setup : 4; 1126054c3f6SMatt Jacob u_int16_t isp_selection_timeout; 1136054c3f6SMatt Jacob u_int16_t isp_max_queue_depth; 1146054c3f6SMatt Jacob u_int16_t isp_clock; 1156054c3f6SMatt Jacob u_int8_t isp_tag_aging; 1166054c3f6SMatt Jacob u_int8_t isp_bus_reset_delay; 1176054c3f6SMatt Jacob u_int8_t isp_retry_count; 1186054c3f6SMatt Jacob u_int8_t isp_retry_delay; 1196054c3f6SMatt Jacob struct { 120cbf57b47SMatt Jacob u_int 121478f8a96SJustin T. Gibbs dev_enable : 1, 122cbf57b47SMatt Jacob dev_announced : 1, 123cbf57b47SMatt Jacob dev_update : 1, 124cbf57b47SMatt Jacob dev_refresh : 1, 125478f8a96SJustin T. Gibbs exc_throttle : 7, 126478f8a96SJustin T. Gibbs sync_offset : 4, 127478f8a96SJustin T. Gibbs sync_period : 8; 128478f8a96SJustin T. Gibbs u_int16_t dev_flags; /* persistent device flags */ 129478f8a96SJustin T. Gibbs u_int16_t cur_dflags; /* current device flags */ 1306054c3f6SMatt Jacob } isp_devparam[MAX_TARGETS]; 1316054c3f6SMatt Jacob } sdparam; /* scsi device parameters */ 1326054c3f6SMatt Jacob 1336054c3f6SMatt Jacob /* 1346054c3f6SMatt Jacob * Device Flags 1356054c3f6SMatt Jacob */ 136478f8a96SJustin T. Gibbs #define DPARM_DISC 0x8000 137478f8a96SJustin T. Gibbs #define DPARM_PARITY 0x4000 138478f8a96SJustin T. Gibbs #define DPARM_WIDE 0x2000 139478f8a96SJustin T. Gibbs #define DPARM_SYNC 0x1000 140478f8a96SJustin T. Gibbs #define DPARM_TQING 0x0800 141478f8a96SJustin T. Gibbs #define DPARM_ARQ 0x0400 142478f8a96SJustin T. Gibbs #define DPARM_QFRZ 0x0200 143478f8a96SJustin T. Gibbs #define DPARM_RENEG 0x0100 144478f8a96SJustin T. Gibbs #define DPARM_NARROW 0x0080 /* Possibly only available with >= 7.55 fw */ 145478f8a96SJustin T. Gibbs #define DPARM_ASYNC 0x0040 /* Possibly only available with >= 7.55 fw */ 14610f20e40SMatt Jacob #define DPARM_DEFAULT (0xFF00 & ~DPARM_QFRZ) 147478f8a96SJustin T. Gibbs #define DPARM_SAFE_DFLT (DPARM_DEFAULT & ~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING)) 148478f8a96SJustin T. Gibbs 1496054c3f6SMatt Jacob 1506054c3f6SMatt Jacob #define ISP_20M_SYNCPARMS 0x080c 1516054c3f6SMatt Jacob #define ISP_10M_SYNCPARMS 0x0c19 1526054c3f6SMatt Jacob #define ISP_08M_SYNCPARMS 0x0c25 1536054c3f6SMatt Jacob #define ISP_05M_SYNCPARMS 0x0c32 1546054c3f6SMatt Jacob #define ISP_04M_SYNCPARMS 0x0c41 1556054c3f6SMatt Jacob 1566054c3f6SMatt Jacob /* 1576054c3f6SMatt Jacob * Fibre Channel Specifics 1586054c3f6SMatt Jacob */ 1596054c3f6SMatt Jacob typedef struct { 1606054c3f6SMatt Jacob u_int64_t isp_wwn; /* WWN of adapter */ 161478f8a96SJustin T. Gibbs u_int8_t isp_loopid; /* hard loop id */ 162478f8a96SJustin T. Gibbs u_int8_t isp_alpa; /* ALPA */ 163478f8a96SJustin T. Gibbs u_int8_t isp_execthrottle; 1646054c3f6SMatt Jacob u_int8_t isp_retry_delay; 165478f8a96SJustin T. Gibbs u_int8_t isp_retry_count; 1666054c3f6SMatt Jacob u_int8_t isp_fwstate; /* ISP F/W state */ 167478f8a96SJustin T. Gibbs u_int16_t isp_maxalloc; 168478f8a96SJustin T. Gibbs u_int16_t isp_maxfrmlen; 169478f8a96SJustin T. Gibbs u_int16_t isp_fwoptions; 1706054c3f6SMatt Jacob /* 17157c801f5SMatt Jacob * Port Data Base 17257c801f5SMatt Jacob */ 17357c801f5SMatt Jacob isp_pdb_t isp_pdb[MAX_FC_TARG]; 17457c801f5SMatt Jacob 17557c801f5SMatt Jacob /* 1766054c3f6SMatt Jacob * Scratch DMA mapped in area to fetch Port Database stuff, etc. 1776054c3f6SMatt Jacob */ 1786054c3f6SMatt Jacob volatile caddr_t isp_scratch; 1796054c3f6SMatt Jacob u_int32_t isp_scdma; 1806054c3f6SMatt Jacob } fcparam; 1816054c3f6SMatt Jacob 1826054c3f6SMatt Jacob #define ISP2100_SCRLEN 0x100 1836054c3f6SMatt Jacob 1846054c3f6SMatt Jacob #define FW_CONFIG_WAIT 0x0000 1856054c3f6SMatt Jacob #define FW_WAIT_AL_PA 0x0001 1866054c3f6SMatt Jacob #define FW_WAIT_LOGIN 0x0002 1876054c3f6SMatt Jacob #define FW_READY 0x0003 1886054c3f6SMatt Jacob #define FW_LOSS_OF_SYNC 0x0004 1896054c3f6SMatt Jacob #define FW_ERROR 0x0005 1906054c3f6SMatt Jacob #define FW_REINIT 0x0006 1916054c3f6SMatt Jacob #define FW_NON_PART 0x0007 1926054c3f6SMatt Jacob 193c3055363SMatt Jacob #ifdef ISP_TARGET_MODE 194c3055363SMatt Jacob /* 195c3055363SMatt Jacob * Some temporary Target Mode definitions 196c3055363SMatt Jacob */ 197c3055363SMatt Jacob typedef struct tmd_cmd { 198c3055363SMatt Jacob u_int8_t cd_iid; /* initiator */ 199c3055363SMatt Jacob u_int8_t cd_tgt; /* target */ 200c3055363SMatt Jacob u_int8_t cd_lun; /* LUN for this command */ 201c3055363SMatt Jacob u_int8_t cd_state; 202c3055363SMatt Jacob u_int8_t cd_cdb[16]; /* command bytes */ 203c3055363SMatt Jacob u_int8_t cd_sensedata[20]; 204c3055363SMatt Jacob u_int16_t cd_rxid; 205c3055363SMatt Jacob u_int32_t cd_datalen; 206c3055363SMatt Jacob u_int32_t cd_totbytes; 207c3055363SMatt Jacob void * cd_hba; 208c3055363SMatt Jacob } tmd_cmd_t; 209c3055363SMatt Jacob 210c3055363SMatt Jacob /* 211c3055363SMatt Jacob * Async Target Mode Event Definitions 212c3055363SMatt Jacob */ 213c3055363SMatt Jacob #define TMD_BUS_RESET 0 214c3055363SMatt Jacob #define TMD_BDR 1 215c3055363SMatt Jacob 216c3055363SMatt Jacob /* 217c3055363SMatt Jacob * Immediate Notify data structure. 218c3055363SMatt Jacob */ 219c3055363SMatt Jacob #define NOTIFY_MSGLEN 5 220c3055363SMatt Jacob typedef struct { 221c3055363SMatt Jacob u_int8_t nt_iid; /* initiator */ 222c3055363SMatt Jacob u_int8_t nt_tgt; /* target */ 223c3055363SMatt Jacob u_int8_t nt_lun; /* LUN for this command */ 224c3055363SMatt Jacob u_int8_t nt_msg[NOTIFY_MSGLEN]; /* SCSI message byte(s) */ 225c3055363SMatt Jacob } tmd_notify_t; 226c3055363SMatt Jacob 227c3055363SMatt Jacob #endif 2289f8afea4SMatt Jacob 2296054c3f6SMatt Jacob /* 2306054c3f6SMatt Jacob * Soft Structure per host adapter 2316054c3f6SMatt Jacob */ 2326054c3f6SMatt Jacob struct ispsoftc { 2336054c3f6SMatt Jacob /* 2346054c3f6SMatt Jacob * Platform (OS) specific data 2356054c3f6SMatt Jacob */ 2366054c3f6SMatt Jacob struct isposinfo isp_osinfo; 2376054c3f6SMatt Jacob 2386054c3f6SMatt Jacob /* 2396054c3f6SMatt Jacob * Pointer to bus specific data 2406054c3f6SMatt Jacob */ 2416054c3f6SMatt Jacob struct ispmdvec * isp_mdvec; 2426054c3f6SMatt Jacob 2436054c3f6SMatt Jacob /* 2449f8afea4SMatt Jacob * Mostly nonvolatile state, debugging, etc.. 2456054c3f6SMatt Jacob */ 2466054c3f6SMatt Jacob 247478f8a96SJustin T. Gibbs u_int : 8, 2486054c3f6SMatt Jacob isp_confopts : 8, 24957c801f5SMatt Jacob : 1, 25057c801f5SMatt Jacob isp_used : 1, 251478f8a96SJustin T. Gibbs isp_dblev : 3, 252478f8a96SJustin T. Gibbs isp_gotdparms : 1, 253478f8a96SJustin T. Gibbs isp_dogactive : 1, 254478f8a96SJustin T. Gibbs isp_bustype : 1, /* BUS Implementation */ 255478f8a96SJustin T. Gibbs isp_type : 8; /* HBA Type and Revision */ 2566054c3f6SMatt Jacob 257478f8a96SJustin T. Gibbs u_int16_t isp_fwrev; /* Running F/W revision */ 258478f8a96SJustin T. Gibbs u_int16_t isp_romfw_rev; /* 'ROM' F/W revision */ 2596054c3f6SMatt Jacob void * isp_param; 2606054c3f6SMatt Jacob 2616054c3f6SMatt Jacob /* 262478f8a96SJustin T. Gibbs * Volatile state 2636054c3f6SMatt Jacob */ 264478f8a96SJustin T. Gibbs 265478f8a96SJustin T. Gibbs volatile u_int 266478f8a96SJustin T. Gibbs : 19, 267478f8a96SJustin T. Gibbs isp_state : 3, 268478f8a96SJustin T. Gibbs isp_sendmarker : 1, /* send a marker entry */ 26957c801f5SMatt Jacob isp_update : 1, /* update parameters */ 270478f8a96SJustin T. Gibbs isp_nactive : 9; /* how many commands active */ 271478f8a96SJustin T. Gibbs 272478f8a96SJustin T. Gibbs /* 273478f8a96SJustin T. Gibbs * Result and Request Queue indices. 274478f8a96SJustin T. Gibbs */ 275478f8a96SJustin T. Gibbs volatile u_int8_t isp_reqodx; /* index of last ISP pickup */ 2766054c3f6SMatt Jacob volatile u_int8_t isp_reqidx; /* index of next request */ 2776054c3f6SMatt Jacob volatile u_int8_t isp_residx; /* index of next result */ 278478f8a96SJustin T. Gibbs volatile u_int8_t isp_seqno; /* rolling sequence # */ 2796054c3f6SMatt Jacob 2806054c3f6SMatt Jacob /* 2816054c3f6SMatt Jacob * Sheer laziness, but it gets us around the problem 2826054c3f6SMatt Jacob * where we don't have a clean way of remembering 2836054c3f6SMatt Jacob * which transaction is bound to which ISP queue entry. 2846054c3f6SMatt Jacob * 2856054c3f6SMatt Jacob * There are other more clever ways to do this, but, 2866054c3f6SMatt Jacob * jeez, so I blow a couple of KB per host adapter... 2876054c3f6SMatt Jacob * and it *is* faster. 2886054c3f6SMatt Jacob */ 289cbf57b47SMatt Jacob ISP_SCSI_XFER_T *isp_xflist[RQUEST_QUEUE_LEN]; 2906054c3f6SMatt Jacob 2916054c3f6SMatt Jacob /* 292478f8a96SJustin T. Gibbs * request/result queues and dma handles for them. 2936054c3f6SMatt Jacob */ 2946054c3f6SMatt Jacob volatile caddr_t isp_rquest; 2956054c3f6SMatt Jacob volatile caddr_t isp_result; 2966054c3f6SMatt Jacob u_int32_t isp_rquest_dma; 2976054c3f6SMatt Jacob u_int32_t isp_result_dma; 2989f8afea4SMatt Jacob 299c3055363SMatt Jacob #ifdef ISP_TARGET_MODE 300c3055363SMatt Jacob /* 301c3055363SMatt Jacob * Vectors for handling target mode support. 302c3055363SMatt Jacob * 303c3055363SMatt Jacob * isp_tmd_newcmd is for feeding a newly arrived command to some 304c3055363SMatt Jacob * upper layer. 305c3055363SMatt Jacob * 306c3055363SMatt Jacob * isp_tmd_event is for notifying some upper layer that an event has 307c3055363SMatt Jacob * occurred that is not necessarily tied to any target (e.g., a SCSI 308c3055363SMatt Jacob * Bus Reset). 309c3055363SMatt Jacob * 310c3055363SMatt Jacob * isp_tmd_notify is for notifying some upper layer that some 311c3055363SMatt Jacob * event is now occurring that is either pertinent for a specific 312c3055363SMatt Jacob * device or for a specific command (e.g., BDR or ABORT TAG). 313c3055363SMatt Jacob * 314c3055363SMatt Jacob * It is left undefined (for now) how pools of commands are managed. 315c3055363SMatt Jacob */ 316c3055363SMatt Jacob void (*isp_tmd_newcmd) __P((void *, tmd_cmd_t *)); 317c3055363SMatt Jacob void (*isp_tmd_event) __P((void *, int)); 318c3055363SMatt Jacob void (*isp_tmd_notify) __P((void *, tmd_notify_t *)); 319c3055363SMatt Jacob #endif 3206054c3f6SMatt Jacob }; 3216054c3f6SMatt Jacob 3226054c3f6SMatt Jacob /* 3236054c3f6SMatt Jacob * ISP States 3246054c3f6SMatt Jacob */ 3256054c3f6SMatt Jacob #define ISP_NILSTATE 0 3266054c3f6SMatt Jacob #define ISP_RESETSTATE 1 3276054c3f6SMatt Jacob #define ISP_INITSTATE 2 3286054c3f6SMatt Jacob #define ISP_RUNSTATE 3 3296054c3f6SMatt Jacob 3306054c3f6SMatt Jacob /* 3316054c3f6SMatt Jacob * ISP Configuration Options 3326054c3f6SMatt Jacob */ 3336054c3f6SMatt Jacob #define ISP_CFG_NORELOAD 0x80 /* don't download f/w */ 33410f20e40SMatt Jacob #define ISP_CFG_NONVRAM 0x40 /* ignore NVRAM */ 3356054c3f6SMatt Jacob 336478f8a96SJustin T. Gibbs #define ISP_FW_REV(maj, min) ((maj) << 10| (min)) 337478f8a96SJustin T. Gibbs 3386054c3f6SMatt Jacob /* 339478f8a96SJustin T. Gibbs * Bus (implementation) types 340478f8a96SJustin T. Gibbs */ 341478f8a96SJustin T. Gibbs #define ISP_BT_PCI 0 /* PCI Implementations */ 342478f8a96SJustin T. Gibbs #define ISP_BT_SBUS 1 /* SBus Implementations */ 343478f8a96SJustin T. Gibbs 344478f8a96SJustin T. Gibbs /* 345478f8a96SJustin T. Gibbs * Chip Types 3466054c3f6SMatt Jacob */ 3476054c3f6SMatt Jacob #define ISP_HA_SCSI 0xf 348478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_UNKNOWN 0x1 349478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1020 0x2 350478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1020A 0x3 351478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1040 0x4 352478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1040A 0x5 353478f8a96SJustin T. Gibbs #define ISP_HA_SCSI_1040B 0x6 35457c801f5SMatt Jacob #define ISP_HA_SCSI_1080 0xe 3556054c3f6SMatt Jacob #define ISP_HA_FC 0xf0 3566054c3f6SMatt Jacob #define ISP_HA_FC_2100 0x10 3576054c3f6SMatt Jacob 35857c801f5SMatt Jacob #define IS_SCSI(isp) (isp->isp_type & ISP_HA_SCSI) 35957c801f5SMatt Jacob #define IS_1080(isp) (isp->isp_type == ISP_HA_SCSI_1080) 36057c801f5SMatt Jacob #define IS_FC(isp) (isp->isp_type & ISP_HA_FC) 36157c801f5SMatt Jacob 3626054c3f6SMatt Jacob /* 363cbf57b47SMatt Jacob * Macros to read, write ISP registers through bus specific code. 3646054c3f6SMatt Jacob */ 3656054c3f6SMatt Jacob 3666054c3f6SMatt Jacob #define ISP_READ(isp, reg) \ 3676054c3f6SMatt Jacob (*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg)) 3686054c3f6SMatt Jacob 3696054c3f6SMatt Jacob #define ISP_WRITE(isp, reg, val) \ 3706054c3f6SMatt Jacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val)) 3716054c3f6SMatt Jacob 3726054c3f6SMatt Jacob #define ISP_MBOXDMASETUP(isp) \ 3736054c3f6SMatt Jacob (*(isp)->isp_mdvec->dv_mbxdma)((isp)) 3746054c3f6SMatt Jacob 3756054c3f6SMatt Jacob #define ISP_DMASETUP(isp, xs, req, iptrp, optr) \ 3766054c3f6SMatt Jacob (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr)) 3776054c3f6SMatt Jacob 3786054c3f6SMatt Jacob #define ISP_DMAFREE(isp, xs, seqno) \ 3796054c3f6SMatt Jacob if ((isp)->isp_mdvec->dv_dmaclr) \ 3806054c3f6SMatt Jacob (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (seqno)) 3816054c3f6SMatt Jacob 3826054c3f6SMatt Jacob #define ISP_RESET0(isp) \ 3836054c3f6SMatt Jacob if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp)) 3846054c3f6SMatt Jacob #define ISP_RESET1(isp) \ 3856054c3f6SMatt Jacob if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp)) 3866054c3f6SMatt Jacob #define ISP_DUMPREGS(isp) \ 3876054c3f6SMatt Jacob if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp)) 3886054c3f6SMatt Jacob 3896054c3f6SMatt Jacob #define ISP_SETBITS(isp, reg, val) \ 3906054c3f6SMatt Jacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val)) 3916054c3f6SMatt Jacob 3926054c3f6SMatt Jacob #define ISP_CLRBITS(isp, reg, val) \ 3936054c3f6SMatt Jacob (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val)) 3946054c3f6SMatt Jacob 3956054c3f6SMatt Jacob /* 3966054c3f6SMatt Jacob * Function Prototypes 3976054c3f6SMatt Jacob */ 3986054c3f6SMatt Jacob 3996054c3f6SMatt Jacob /* 400478f8a96SJustin T. Gibbs * Reset Hardware. Totally. Assumes that you'll follow this with 401478f8a96SJustin T. Gibbs * a call to isp_init. 4026054c3f6SMatt Jacob */ 4036054c3f6SMatt Jacob void isp_reset __P((struct ispsoftc *)); 4046054c3f6SMatt Jacob 4056054c3f6SMatt Jacob /* 4066054c3f6SMatt Jacob * Initialize Hardware to known state 4076054c3f6SMatt Jacob */ 4086054c3f6SMatt Jacob void isp_init __P((struct ispsoftc *)); 4096054c3f6SMatt Jacob 4106054c3f6SMatt Jacob /* 411478f8a96SJustin T. Gibbs * Reset the ISP and call completion for any orphaned commands. 412478f8a96SJustin T. Gibbs */ 413478f8a96SJustin T. Gibbs void isp_restart __P((struct ispsoftc *)); 414478f8a96SJustin T. Gibbs 415478f8a96SJustin T. Gibbs /* 4166054c3f6SMatt Jacob * Interrupt Service Routine 4176054c3f6SMatt Jacob */ 4186054c3f6SMatt Jacob int isp_intr __P((void *)); 4196054c3f6SMatt Jacob 4206054c3f6SMatt Jacob /* 4216054c3f6SMatt Jacob * Command Entry Point 4226054c3f6SMatt Jacob */ 423478f8a96SJustin T. Gibbs int32_t ispscsicmd __P((ISP_SCSI_XFER_T *)); 424478f8a96SJustin T. Gibbs 425478f8a96SJustin T. Gibbs /* 426cbf57b47SMatt Jacob * Platform Dependent to External to Internal Control Function 427478f8a96SJustin T. Gibbs * 428478f8a96SJustin T. Gibbs * For: Aborting a running command - arg is an ISP_SCSI_XFER_T * 429478f8a96SJustin T. Gibbs * Resetting a Device - arg is target to reset 430478f8a96SJustin T. Gibbs * Resetting a BUS - arg is ignored 431478f8a96SJustin T. Gibbs * Updating parameters - arg is ignored 432478f8a96SJustin T. Gibbs * 433cbf57b47SMatt Jacob * First argument is this instance's softc pointer. 434478f8a96SJustin T. Gibbs * Second argument is an index into xflist array. 435478f8a96SJustin T. Gibbs * Assumes all locks must be held already. 436478f8a96SJustin T. Gibbs */ 437478f8a96SJustin T. Gibbs typedef enum { 438478f8a96SJustin T. Gibbs ISPCTL_RESET_BUS, 439478f8a96SJustin T. Gibbs ISPCTL_RESET_DEV, 440478f8a96SJustin T. Gibbs ISPCTL_ABORT_CMD, 441478f8a96SJustin T. Gibbs ISPCTL_UPDATE_PARAMS, 44257c801f5SMatt Jacob ISPCTL_FCLINK_TEST 443478f8a96SJustin T. Gibbs } ispctl_t; 444478f8a96SJustin T. Gibbs int isp_control __P((struct ispsoftc *, ispctl_t, void *)); 445478f8a96SJustin T. Gibbs 446cbf57b47SMatt Jacob 447cbf57b47SMatt Jacob /* 448cbf57b47SMatt Jacob * Platform Dependent to Internal to External Control Function 449cbf57b47SMatt Jacob * (each platform must provide such a function) 450cbf57b47SMatt Jacob * 451cbf57b47SMatt Jacob * For: Announcing Target Paramter Changes (arg is target) 452cbf57b47SMatt Jacob * 453cbf57b47SMatt Jacob * Assumes all locks are held. 454cbf57b47SMatt Jacob */ 455cbf57b47SMatt Jacob 456cbf57b47SMatt Jacob typedef enum { 45710f20e40SMatt Jacob ISPASYNC_NEW_TGT_PARAMS, 45857c801f5SMatt Jacob ISPASYNC_BUS_RESET, /* Bus Reset */ 45910f20e40SMatt Jacob ISPASYNC_LOOP_DOWN, /* Obvious FC only */ 46057c801f5SMatt Jacob ISPASYNC_LOOP_UP, /* "" */ 46157c801f5SMatt Jacob ISPASYNC_PDB_CHANGE_COMPLETE, /* "" */ 46257c801f5SMatt Jacob ISPASYNC_CHANGE_NOTIFY /* "" */ 463cbf57b47SMatt Jacob } ispasync_t; 464cbf57b47SMatt Jacob int isp_async __P((struct ispsoftc *, ispasync_t, void *)); 465cbf57b47SMatt Jacob 466478f8a96SJustin T. Gibbs /* 467478f8a96SJustin T. Gibbs * lost command routine (XXXX IN TRANSITION XXXX) 468478f8a96SJustin T. Gibbs */ 469478f8a96SJustin T. Gibbs void isp_lostcmd __P((struct ispsoftc *, ISP_SCSI_XFER_T *)); 470478f8a96SJustin T. Gibbs 4716054c3f6SMatt Jacob 4726054c3f6SMatt Jacob #endif /* _ISPVAR_H */ 473