2007-05-21 23:25:54 +04:00
|
|
|
/* $NetBSD: wd33c93var.h,v 1.7 2007/05/21 19:25:55 rumble Exp $ */
|
2001-08-19 07:16:21 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Van Jacobson of Lawrence Berkeley Laboratory.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
2001-08-19 07:16:21 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* @(#)scsivar.h 7.1 (Berkeley) 5/8/90
|
|
|
|
*/
|
|
|
|
#ifndef _SBICVAR_H_
|
|
|
|
#define _SBICVAR_H_
|
|
|
|
#include <sys/callout.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
2001-11-10 10:32:42 +03:00
|
|
|
#define SBIC_NTARG 8
|
|
|
|
#define SBIC_NLUN 8
|
|
|
|
#define SBIC_NTAGS 256
|
|
|
|
|
|
|
|
#define SBIC_MAX_MSGLEN 8
|
|
|
|
|
|
|
|
#define SBIC_ABORT_TIMEOUT 2000 /* time to wait for abort */
|
|
|
|
#define SBIC_SENSE_TIMEOUT 1000 /* time to wait for sense */
|
2001-08-19 07:16:21 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ACB. Holds additional information for each SCSI command Comments: We
|
|
|
|
* need a separate scsi command block because we may need to overwrite it
|
2001-11-10 10:32:42 +03:00
|
|
|
* with a request sense command. Basically, we refrain from fiddling with
|
2001-08-19 07:16:21 +04:00
|
|
|
* the scsi_xfer struct (except do the expected updating of return values).
|
|
|
|
* We'll generally update: xs->{flags,resid,error,sense,status} and
|
|
|
|
* occasionally xs->retries.
|
|
|
|
*/
|
2001-11-22 02:22:25 +03:00
|
|
|
struct wd33c93_acb {
|
|
|
|
TAILQ_ENTRY(wd33c93_acb) chain;
|
2001-11-10 10:32:42 +03:00
|
|
|
struct scsipi_xfer *xs; /* SCSI xfer ctrl block from above */
|
|
|
|
int flags; /* Status */
|
|
|
|
#define ACB_FREE 0x00
|
|
|
|
#define ACB_ACTIVE 0x01
|
|
|
|
#define ACB_READY 0x02 /* ACB is on ready list */
|
|
|
|
#define ACB_DONE 0x04
|
|
|
|
#define ACB_SENSE 0x08 /* ACB Requesting sense */
|
|
|
|
#define ACB_COMPLETE 0x10 /* Disconnected at end of xfer */
|
|
|
|
#define ACB_RESET 0x20 /* Require Reset */
|
|
|
|
#define ACB_ABORT 0x40 /* Require Abort */
|
|
|
|
|
|
|
|
int timeout;
|
2004-12-08 01:23:45 +03:00
|
|
|
struct scsipi_generic cmd; /* SCSI command block */
|
2001-11-10 10:32:42 +03:00
|
|
|
int clen;
|
|
|
|
char *daddr; /* kva for data */
|
|
|
|
size_t dleft; /* bytes remaining */
|
|
|
|
u_char tag_type; /* TAG Type (0x20-0x22, 0=No Tags) */
|
|
|
|
u_char tag_id; /* TAG id number */
|
2001-08-19 07:16:21 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some info about each (possible) target on the SCSI bus. This should
|
|
|
|
* probably have been a "per target+lunit" structure, but we'll leave it at
|
|
|
|
* this for now. Is there a way to reliably hook it up to sc->fordriver??
|
|
|
|
*/
|
2001-11-10 10:32:42 +03:00
|
|
|
|
2001-11-22 02:22:25 +03:00
|
|
|
struct wd33c93_linfo {
|
|
|
|
LIST_ENTRY(wd33c93_linfo) link;
|
2001-11-10 10:32:42 +03:00
|
|
|
time_t last_used;
|
|
|
|
int lun;
|
|
|
|
int used; /* # slots in use */
|
|
|
|
u_char state;
|
|
|
|
#define L_STATE_IDLE 0
|
|
|
|
#define L_STATE_BUSY 1
|
|
|
|
#define L_STATE_ESTAT 2
|
2001-11-22 02:22:25 +03:00
|
|
|
struct wd33c93_acb *untagged;
|
|
|
|
struct wd33c93_acb *queued[SBIC_NTAGS];
|
2001-11-10 10:32:42 +03:00
|
|
|
};
|
|
|
|
|
2001-11-22 02:22:25 +03:00
|
|
|
struct wd33c93_tinfo {
|
2001-11-10 10:32:42 +03:00
|
|
|
int cmds; /* # of commands processed */
|
|
|
|
int dconns; /* # of disconnects */
|
|
|
|
|
2002-03-13 16:12:25 +03:00
|
|
|
u_char flags;
|
2001-11-10 10:32:42 +03:00
|
|
|
#define T_NEED_RESET 0x01 /* Should send a BUS_DEV_RESET */
|
|
|
|
#define T_NEGOTIATE 0x02 /* (Re)Negotiate synchronous options */
|
|
|
|
#define T_BUSY 0x04 /* Target is busy */
|
|
|
|
#define T_SYNCMODE 0x08 /* SYNC mode has been negotiated */
|
|
|
|
#define T_NOSYNC 0x10 /* Force ASYNC mode */
|
|
|
|
#define T_NODISC 0x20 /* Don't allow disconnect */
|
|
|
|
#define T_TAG 0x40 /* Turn on TAG QUEUEs */
|
2006-09-27 02:45:25 +04:00
|
|
|
#define T_WANTSYNC 0x80 /* Negotiatious should aim for sync */
|
2002-03-13 16:12:25 +03:00
|
|
|
u_char period; /* Period suggestion */
|
|
|
|
u_char offset; /* Offset suggestion */
|
2001-11-22 02:22:25 +03:00
|
|
|
struct wd33c93_linfo *lun[SBIC_NLUN]; /* LUN list for this target */
|
2001-08-19 07:16:21 +04:00
|
|
|
} tinfo_t;
|
|
|
|
|
2001-11-10 10:32:42 +03:00
|
|
|
/* Look up a lun in a tinfo */
|
|
|
|
#define TINFO_LUN(t, l) ((t)->lun[(l)])
|
|
|
|
|
2002-03-13 16:12:25 +03:00
|
|
|
struct wd33c93_softc {
|
2001-11-10 10:32:42 +03:00
|
|
|
struct device sc_dev;
|
|
|
|
|
|
|
|
struct scsipi_channel sc_channel; /* proto for sub devices */
|
|
|
|
struct scsipi_adapter sc_adapter;
|
|
|
|
struct device *sc_child; /* attached scsibus, if any */
|
|
|
|
struct callout sc_watchdog;
|
|
|
|
void *sc_driver; /* driver specific field */
|
|
|
|
|
|
|
|
int target; /* Currently active target */
|
|
|
|
int lun; /* Currently active LUN */
|
|
|
|
|
|
|
|
/* WD33c93 registers */
|
|
|
|
bus_space_tag_t sc_regt;
|
|
|
|
bus_space_handle_t sc_regh;
|
|
|
|
|
|
|
|
|
|
|
|
/* Data about the current nexus (updated for every cmd switch) */
|
2007-03-04 08:59:00 +03:00
|
|
|
void * sc_daddr; /* Current data pointer */
|
2001-11-10 10:32:42 +03:00
|
|
|
size_t sc_dleft; /* Data left to transfer */
|
|
|
|
ssize_t sc_tcnt; /* number of bytes transfered */
|
|
|
|
|
|
|
|
/* Lists of command blocks */
|
2001-11-22 02:22:25 +03:00
|
|
|
TAILQ_HEAD(acb_list, wd33c93_acb) ready_list;
|
2001-11-10 10:32:42 +03:00
|
|
|
|
2001-11-22 02:22:25 +03:00
|
|
|
struct wd33c93_acb *sc_nexus; /* current command */
|
|
|
|
struct wd33c93_tinfo sc_tinfo[8];
|
2001-11-10 10:32:42 +03:00
|
|
|
|
|
|
|
u_short sc_state;
|
|
|
|
u_short sc_status;
|
|
|
|
int sc_disc; /* current # of active nexus's */
|
|
|
|
int sc_flags;
|
|
|
|
|
|
|
|
/* Message stuff */
|
|
|
|
u_short sc_msgify; /* Last IDENTIFY message */
|
|
|
|
u_short sc_msgout; /* Current message out */
|
|
|
|
u_short sc_msgpriq; /* mesg_out queue (bitmap) */
|
|
|
|
u_short sc_msgoutq; /* mesg_out queue */
|
|
|
|
|
|
|
|
u_char sc_imsg[SBIC_MAX_MSGLEN];
|
|
|
|
u_char sc_omsg[SBIC_MAX_MSGLEN];
|
|
|
|
u_char sc_imsglen;
|
|
|
|
u_char sc_omsglen;
|
|
|
|
|
2006-10-02 02:02:55 +04:00
|
|
|
/* Static hardware attributes supplied by attachment */
|
2001-11-10 10:32:42 +03:00
|
|
|
int sc_id; /* SCSI ID for controller */
|
2006-03-09 02:46:22 +03:00
|
|
|
int sc_clkfreq; /* wd33c93 clk freq * 10 MHz */
|
2006-10-02 02:02:55 +04:00
|
|
|
uint8_t sc_dmamode; /* One of SBIC_CTL_*DMA */
|
|
|
|
|
|
|
|
/* Static hardware attributes derived by wd33c93_attach() */
|
2001-11-10 10:32:42 +03:00
|
|
|
int sc_chip; /* Chip variation */
|
|
|
|
int sc_rev; /* Chip revision */
|
|
|
|
int sc_cfflags; /* Copy of config flags */
|
|
|
|
int sc_maxxfer; /* Maximum transfer size */
|
2007-05-08 04:20:15 +04:00
|
|
|
uint8_t sc_maxoffset; /* Maximum sync offset (bytes) */
|
|
|
|
uint8_t sc_minsyncperiod; /* Minimum supported sync xfer period */
|
2006-09-27 02:45:25 +04:00
|
|
|
uint8_t sc_syncperiods[7]; /* Sync transfer periods (4ns units) */
|
2007-05-08 04:20:15 +04:00
|
|
|
uint8_t sc_fsyncperiods[3]; /* Sync transfer periods for Fast SCSI*/
|
2001-11-10 10:32:42 +03:00
|
|
|
|
2007-03-04 08:59:00 +03:00
|
|
|
int (*sc_dmasetup) (struct wd33c93_softc *, void **,
|
2004-01-10 05:55:54 +03:00
|
|
|
size_t *, int, size_t *);
|
|
|
|
int (*sc_dmago) (struct wd33c93_softc *);
|
|
|
|
void (*sc_dmastop) (struct wd33c93_softc *);
|
|
|
|
void (*sc_reset) (struct wd33c93_softc *);
|
2001-08-19 07:16:21 +04:00
|
|
|
};
|
|
|
|
|
2001-11-10 10:32:42 +03:00
|
|
|
/* values for sc_flags */
|
|
|
|
#define SBICF_SELECTED 0x01 /* bus is in selected state. */
|
|
|
|
#define SBICF_NODMA 0x02 /* Polled transfer */
|
|
|
|
#define SBICF_INDMA 0x04 /* DMA I/O in progress */
|
|
|
|
#define SBICF_SYNCNEGO 0x08 /* Sync negotiation in progress */
|
|
|
|
#define SBICF_ABORTING 0x10 /* Aborting */
|
2001-08-19 07:16:21 +04:00
|
|
|
|
2001-11-10 10:32:42 +03:00
|
|
|
/* values for sc_state */
|
2002-03-13 16:12:25 +03:00
|
|
|
#define SBIC_UNINITIALIZED 0 /* Driver not initialized */
|
2001-11-10 10:32:42 +03:00
|
|
|
#define SBIC_IDLE 1 /* waiting for something to do */
|
2002-03-13 16:12:25 +03:00
|
|
|
#define SBIC_SELECTING 2 /* SCSI command is arbiting */
|
2001-11-10 10:32:42 +03:00
|
|
|
#define SBIC_RESELECTED 3 /* Has been reselected */
|
|
|
|
#define SBIC_IDENTIFIED 4 /* Has gotten IFY but not TAG */
|
|
|
|
#define SBIC_CONNECTED 5 /* Actively using the SCSI bus */
|
|
|
|
#define SBIC_DISCONNECT 6 /* MSG_DISCONNECT received */
|
|
|
|
#define SBIC_CMDCOMPLETE 7 /* MSG_CMDCOMPLETE received */
|
2004-02-24 18:12:51 +03:00
|
|
|
#define SBIC_ERROR 8 /* Error has occurred */
|
2001-11-10 10:32:42 +03:00
|
|
|
#define SBIC_SELTIMEOUT 9 /* Select Timeout */
|
|
|
|
#define SBIC_CLEANING 10 /* Scrubbing ACB's */
|
|
|
|
#define SBIC_BUSRESET 11 /* SCSI RST has been issued */
|
|
|
|
|
|
|
|
/* values for sc_msgout */
|
|
|
|
#define SEND_DEV_RESET 0x0001
|
|
|
|
#define SEND_PARITY_ERROR 0x0002
|
|
|
|
#define SEND_INIT_DET_ERR 0x0004
|
|
|
|
#define SEND_REJECT 0x0008
|
2002-03-13 16:12:25 +03:00
|
|
|
#define SEND_IDENTIFY 0x0010
|
2001-11-10 10:32:42 +03:00
|
|
|
#define SEND_ABORT 0x0020
|
|
|
|
#define SEND_WDTR 0x0040
|
|
|
|
#define SEND_SDTR 0x0080
|
|
|
|
#define SEND_TAG 0x0100
|
2001-08-19 07:16:21 +04:00
|
|
|
|
2001-11-10 10:32:42 +03:00
|
|
|
/* WD33c93 chipset revisions - values for sc_rev */
|
|
|
|
#define SBIC_CHIP_UNKNOWN 0
|
|
|
|
#define SBIC_CHIP_WD33C93 1
|
|
|
|
#define SBIC_CHIP_WD33C93A 2
|
|
|
|
#define SBIC_CHIP_WD33C93B 3
|
|
|
|
|
|
|
|
#define SBIC_CHIP_LIST {"UNKNOWN", "WD33C93", "WD33C93A", "WD33C93B"}
|
2001-08-19 07:16:21 +04:00
|
|
|
|
2007-05-21 23:25:54 +04:00
|
|
|
/* macros for sc_cfflags */
|
|
|
|
#define CFFLAGS_NODISC(_cf, _t) ((_cf) & (1 << ( 0 + (_t))))
|
|
|
|
#define CFFLAGS_NOSYNC(_cf, _t) ((_cf) & (1 << ( 8 + (_t))))
|
|
|
|
#define CFFLAGS_NOTAGS(_cf, _t) ((_cf) & (1 << (16 + (_t))))
|
|
|
|
|
2001-08-19 07:16:21 +04:00
|
|
|
/*
|
|
|
|
* States returned by our state machine
|
|
|
|
*/
|
2001-11-10 10:32:42 +03:00
|
|
|
#define SBIC_STATE_ERROR -1
|
|
|
|
#define SBIC_STATE_DONE 0
|
|
|
|
#define SBIC_STATE_RUNNING 1
|
|
|
|
#define SBIC_STATE_DISCONNECT 2
|
|
|
|
|
|
|
|
#define DEBUG_ACBS 0x01
|
|
|
|
#define DEBUG_INTS 0x02
|
|
|
|
#define DEBUG_CMDS 0x04
|
|
|
|
#define DEBUG_MISC 0x08
|
|
|
|
#define DEBUG_TRAC 0x10
|
|
|
|
#define DEBUG_RSEL 0x20
|
|
|
|
#define DEBUG_PHASE 0x40
|
|
|
|
#define DEBUG_DMA 0x80
|
|
|
|
#define DEBUG_CCMDS 0x100
|
|
|
|
#define DEBUG_MSGS 0x200
|
|
|
|
#define DEBUG_TAGS 0x400
|
|
|
|
#define DEBUG_SYNC 0x800
|
2001-08-19 07:16:21 +04:00
|
|
|
|
2001-11-10 10:32:42 +03:00
|
|
|
#ifdef DEBUG
|
2001-11-22 02:22:25 +03:00
|
|
|
extern int wd33c93_debug_flags;
|
2001-11-10 10:32:42 +03:00
|
|
|
#define SBIC_DEBUG(level, str) \
|
|
|
|
do { \
|
2001-11-22 02:22:25 +03:00
|
|
|
if (wd33c93_debug & __CONCAT(DEBUG_,level)) \
|
2001-11-10 10:32:42 +03:00
|
|
|
printf str; \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define SBIC_DEBUG(level, str)
|
|
|
|
#endif
|
2001-08-19 07:16:21 +04:00
|
|
|
|
|
|
|
struct buf;
|
|
|
|
struct scsipi_xfer;
|
|
|
|
|
2004-01-10 05:55:54 +03:00
|
|
|
void wd33c93_scsi_request (struct scsipi_channel *,
|
|
|
|
scsipi_adapter_req_t, void *);
|
|
|
|
void wd33c93_attach (struct wd33c93_softc *);
|
|
|
|
int wd33c93_intr (struct wd33c93_softc *);
|
2001-08-19 07:16:21 +04:00
|
|
|
|
|
|
|
#endif /* _SBICVAR_H_ */
|