Home | History | Annotate | Line # | Download | only in ic
wd33c93var.h revision 1.1.2.2
      1  1.1.2.2  bjh21 /*	$NetBSD: wd33c93var.h,v 1.1.2.2 2006/08/28 21:57:54 bjh21 Exp $	*/
      2      1.1  bjh21 
      3      1.1  bjh21 /*
      4      1.1  bjh21  * Copyright (c) 1990 The Regents of the University of California.
      5      1.1  bjh21  * All rights reserved.
      6      1.1  bjh21  *
      7      1.1  bjh21  * This code is derived from software contributed to Berkeley by
      8      1.1  bjh21  * Van Jacobson of Lawrence Berkeley Laboratory.
      9      1.1  bjh21  *
     10      1.1  bjh21  * Redistribution and use in source and binary forms, with or without
     11      1.1  bjh21  * modification, are permitted provided that the following conditions
     12      1.1  bjh21  * are met:
     13      1.1  bjh21  * 1. Redistributions of source code must retain the above copyright
     14      1.1  bjh21  *    notice, this list of conditions and the following disclaimer.
     15      1.1  bjh21  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.1  bjh21  *    notice, this list of conditions and the following disclaimer in the
     17      1.1  bjh21  *    documentation and/or other materials provided with the distribution.
     18      1.1  bjh21  * 3. Neither the name of the University nor the names of its contributors
     19      1.1  bjh21  *    may be used to endorse or promote products derived from this software
     20      1.1  bjh21  *    without specific prior written permission.
     21      1.1  bjh21  *
     22      1.1  bjh21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23      1.1  bjh21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24      1.1  bjh21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25      1.1  bjh21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26      1.1  bjh21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27      1.1  bjh21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28      1.1  bjh21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29      1.1  bjh21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30      1.1  bjh21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31      1.1  bjh21  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32      1.1  bjh21  * SUCH DAMAGE.
     33      1.1  bjh21  *
     34      1.1  bjh21  *  @(#)scsivar.h   7.1 (Berkeley) 5/8/90
     35      1.1  bjh21  */
     36      1.1  bjh21 #ifndef _SBICVAR_H_
     37      1.1  bjh21 #define _SBICVAR_H_
     38      1.1  bjh21 #include <sys/callout.h>
     39      1.1  bjh21 #include <sys/malloc.h>
     40      1.1  bjh21 
     41      1.1  bjh21 #define SBIC_NTARG	8
     42      1.1  bjh21 #define SBIC_NLUN	8
     43      1.1  bjh21 #define SBIC_NTAGS	256
     44      1.1  bjh21 
     45      1.1  bjh21 #define SBIC_MAX_MSGLEN 8
     46      1.1  bjh21 
     47      1.1  bjh21 #define	SBIC_ABORT_TIMEOUT	2000	/* time to wait for abort */
     48      1.1  bjh21 #define	SBIC_SENSE_TIMEOUT	1000	/* time to wait for sense */
     49      1.1  bjh21 
     50      1.1  bjh21 /*
     51      1.1  bjh21  * ACB. Holds additional information for each SCSI command Comments: We
     52      1.1  bjh21  * need a separate scsi command block because we may need to overwrite it
     53      1.1  bjh21  * with a request sense command.  Basically, we refrain from fiddling with
     54      1.1  bjh21  * the scsi_xfer struct (except do the expected updating of return values).
     55      1.1  bjh21  * We'll generally update: xs->{flags,resid,error,sense,status} and
     56      1.1  bjh21  * occasionally xs->retries.
     57      1.1  bjh21  */
     58      1.1  bjh21 struct wd33c93_acb {
     59      1.1  bjh21 	TAILQ_ENTRY(wd33c93_acb) chain;
     60      1.1  bjh21 	struct scsipi_xfer *xs;		/* SCSI xfer ctrl block from above */
     61      1.1  bjh21 	int	flags;			/* Status */
     62      1.1  bjh21 #define ACB_FREE	0x00
     63      1.1  bjh21 #define ACB_ACTIVE	0x01
     64      1.1  bjh21 #define ACB_READY	0x02		/* ACB is on ready list */
     65      1.1  bjh21 #define ACB_DONE	0x04
     66      1.1  bjh21 #define ACB_SENSE	0x08		/* ACB Requesting sense */
     67      1.1  bjh21 #define ACB_COMPLETE	0x10		/* Disconnected at end of xfer */
     68      1.1  bjh21 #define ACB_RESET	0x20		/* Require Reset */
     69      1.1  bjh21 #define ACB_ABORT	0x40		/* Require Abort */
     70      1.1  bjh21 
     71      1.1  bjh21 	int	timeout;
     72      1.1  bjh21 	struct scsipi_generic cmd;	/* SCSI command block */
     73      1.1  bjh21 	int	clen;
     74      1.1  bjh21 	char	*daddr;			/* kva for data */
     75      1.1  bjh21 	size_t	dleft;			/* bytes remaining */
     76      1.1  bjh21 	u_char	tag_type;		/* TAG Type (0x20-0x22, 0=No Tags) */
     77      1.1  bjh21 	u_char	tag_id;			/* TAG id number */
     78      1.1  bjh21 };
     79      1.1  bjh21 
     80      1.1  bjh21 /*
     81      1.1  bjh21  * Some info about each (possible) target on the SCSI bus.  This should
     82      1.1  bjh21  * probably have been a "per target+lunit" structure, but we'll leave it at
     83      1.1  bjh21  * this for now.  Is there a way to reliably hook it up to sc->fordriver??
     84      1.1  bjh21  */
     85      1.1  bjh21 
     86      1.1  bjh21 struct wd33c93_linfo {
     87      1.1  bjh21 	LIST_ENTRY(wd33c93_linfo)	link;
     88      1.1  bjh21 	time_t	last_used;
     89      1.1  bjh21 	int	lun;
     90      1.1  bjh21 	int	used;			/* # slots in use */
     91      1.1  bjh21 	u_char	state;
     92      1.1  bjh21 #define L_STATE_IDLE	0
     93      1.1  bjh21 #define L_STATE_BUSY	1
     94      1.1  bjh21 #define L_STATE_ESTAT	2
     95      1.1  bjh21 	struct wd33c93_acb	*untagged;
     96      1.1  bjh21 	struct wd33c93_acb	*queued[SBIC_NTAGS];
     97      1.1  bjh21 };
     98      1.1  bjh21 
     99      1.1  bjh21 struct wd33c93_tinfo {
    100      1.1  bjh21 	int	cmds;			/* # of commands processed */
    101      1.1  bjh21 	int	dconns;			/* # of disconnects */
    102      1.1  bjh21 
    103      1.1  bjh21 	u_char	flags;
    104      1.1  bjh21 #define T_NEED_RESET	0x01		/* Should send a BUS_DEV_RESET */
    105      1.1  bjh21 #define T_NEGOTIATE	0x02		/* (Re)Negotiate synchronous options */
    106      1.1  bjh21 #define T_BUSY		0x04		/* Target is busy */
    107      1.1  bjh21 #define T_SYNCMODE	0x08		/* SYNC mode has been negotiated */
    108      1.1  bjh21 #define T_NOSYNC	0x10		/* Force ASYNC mode */
    109      1.1  bjh21 #define T_NODISC	0x20		/* Don't allow disconnect */
    110      1.1  bjh21 #define T_TAG		0x40		/* Turn on TAG QUEUEs */
    111      1.1  bjh21 	u_char	period;			/* Period suggestion */
    112      1.1  bjh21 	u_char	offset;			/* Offset suggestion */
    113      1.1  bjh21 	struct wd33c93_linfo *lun[SBIC_NLUN]; /* LUN list for this target */
    114      1.1  bjh21 } tinfo_t;
    115      1.1  bjh21 
    116      1.1  bjh21 /* Look up a lun in a tinfo */
    117      1.1  bjh21 #define TINFO_LUN(t, l) 	((t)->lun[(l)])
    118      1.1  bjh21 
    119      1.1  bjh21 struct wd33c93_softc {
    120      1.1  bjh21 	struct device	sc_dev;
    121      1.1  bjh21 
    122      1.1  bjh21 	struct scsipi_channel sc_channel; /* proto for sub devices */
    123      1.1  bjh21 	struct scsipi_adapter sc_adapter;
    124      1.1  bjh21 	struct device *sc_child;	/* attached scsibus, if any */
    125      1.1  bjh21 	struct callout sc_watchdog;
    126      1.1  bjh21 	void	*sc_driver;		/* driver specific field */
    127      1.1  bjh21 
    128      1.1  bjh21 	int	target;			/* Currently active target */
    129      1.1  bjh21 	int	lun;			/* Currently active LUN */
    130      1.1  bjh21 
    131      1.1  bjh21 	/* WD33c93 registers */
    132      1.1  bjh21 	bus_space_tag_t 	sc_regt;
    133      1.1  bjh21 	bus_space_handle_t 	sc_regh;
    134      1.1  bjh21 
    135      1.1  bjh21 
    136      1.1  bjh21 	/* Data about the current nexus (updated for every cmd switch) */
    137      1.1  bjh21 	caddr_t	sc_daddr;		/* Current data pointer */
    138      1.1  bjh21 	size_t	sc_dleft;		/* Data left to transfer */
    139      1.1  bjh21 	ssize_t	sc_tcnt;		/* number of bytes transfered */
    140      1.1  bjh21 
    141      1.1  bjh21 	/* Lists of command blocks */
    142      1.1  bjh21 	TAILQ_HEAD(acb_list, wd33c93_acb) ready_list;
    143      1.1  bjh21 
    144      1.1  bjh21 	struct wd33c93_acb	 *sc_nexus;	/* current command */
    145      1.1  bjh21 	struct wd33c93_tinfo sc_tinfo[8];
    146      1.1  bjh21 
    147      1.1  bjh21 	u_short	sc_state;
    148      1.1  bjh21 	u_short	sc_status;
    149      1.1  bjh21 	int	sc_disc;		/* current # of active nexus's */
    150      1.1  bjh21 	int	sc_flags;
    151      1.1  bjh21 
    152      1.1  bjh21 	/* Message stuff */
    153      1.1  bjh21 	u_short	sc_msgify;		/* Last IDENTIFY message */
    154      1.1  bjh21 	u_short	sc_msgout;		/* Current message out */
    155      1.1  bjh21 	u_short	sc_msgpriq;		/* mesg_out queue (bitmap) */
    156      1.1  bjh21 	u_short	sc_msgoutq;		/* mesg_out queue */
    157      1.1  bjh21 
    158      1.1  bjh21 	u_char	sc_imsg[SBIC_MAX_MSGLEN];
    159      1.1  bjh21 	u_char	sc_omsg[SBIC_MAX_MSGLEN];
    160      1.1  bjh21 	u_char	sc_imsglen;
    161      1.1  bjh21 	u_char	sc_omsglen;
    162      1.1  bjh21 
    163      1.1  bjh21 	/* Static hardware attributes */
    164      1.1  bjh21 	int	sc_id;			/* SCSI ID for controller */
    165      1.1  bjh21 	int	sc_clkfreq;		/* wd33c93 clk freq * 10 MHz */
    166      1.1  bjh21 	int	sc_chip;		/* Chip variation */
    167      1.1  bjh21 	int	sc_rev;			/* Chip revision */
    168      1.1  bjh21 	int	sc_cfflags;		/* Copy of config flags */
    169      1.1  bjh21 	int	sc_maxxfer;		/* Maximum transfer size */
    170  1.1.2.2  bjh21 	uint8_t	sc_maxoffset;		/* Maximum sync ofset (bytes) */
    171  1.1.2.2  bjh21 	uint8_t	sc_syncperiods[7];	/* Sync transfer periods (4ns units) */
    172      1.1  bjh21 
    173      1.1  bjh21 	int  (*sc_dmasetup) (struct wd33c93_softc *, caddr_t *,
    174      1.1  bjh21 					    size_t *, int, size_t *);
    175      1.1  bjh21 	int  (*sc_dmago) (struct wd33c93_softc *);
    176      1.1  bjh21 	void (*sc_dmastop) (struct wd33c93_softc *);
    177      1.1  bjh21 	void (*sc_reset) (struct wd33c93_softc *);
    178      1.1  bjh21 };
    179      1.1  bjh21 
    180      1.1  bjh21 /* values for sc_flags */
    181      1.1  bjh21 #define SBICF_SELECTED		0x01	/* bus is in selected state. */
    182      1.1  bjh21 #define SBICF_NODMA		0x02	/* Polled transfer */
    183      1.1  bjh21 #define SBICF_INDMA		0x04	/* DMA I/O in progress */
    184      1.1  bjh21 #define SBICF_SYNCNEGO		0x08	/* Sync negotiation in progress */
    185      1.1  bjh21 #define SBICF_ABORTING		0x10	/* Aborting */
    186      1.1  bjh21 
    187      1.1  bjh21 /* values for sc_state */
    188      1.1  bjh21 #define SBIC_UNINITIALIZED	0	/* Driver not initialized */
    189      1.1  bjh21 #define SBIC_IDLE		1	/* waiting for something to do */
    190      1.1  bjh21 #define SBIC_SELECTING		2	/* SCSI command is arbiting */
    191      1.1  bjh21 #define SBIC_RESELECTED		3	/* Has been reselected */
    192      1.1  bjh21 #define SBIC_IDENTIFIED		4	/* Has gotten IFY but not TAG */
    193      1.1  bjh21 #define SBIC_CONNECTED		5	/* Actively using the SCSI bus */
    194      1.1  bjh21 #define	SBIC_DISCONNECT		6	/* MSG_DISCONNECT received */
    195      1.1  bjh21 #define	SBIC_CMDCOMPLETE 	7	/* MSG_CMDCOMPLETE received */
    196      1.1  bjh21 #define	SBIC_ERROR		8	/* Error has occurred */
    197      1.1  bjh21 #define SBIC_SELTIMEOUT		9	/* Select Timeout */
    198      1.1  bjh21 #define	SBIC_CLEANING		10	/* Scrubbing ACB's */
    199      1.1  bjh21 #define SBIC_BUSRESET		11	/* SCSI RST has been issued */
    200      1.1  bjh21 
    201      1.1  bjh21 /* values for sc_msgout */
    202      1.1  bjh21 #define SEND_DEV_RESET		0x0001
    203      1.1  bjh21 #define SEND_PARITY_ERROR	0x0002
    204      1.1  bjh21 #define SEND_INIT_DET_ERR	0x0004
    205      1.1  bjh21 #define SEND_REJECT		0x0008
    206      1.1  bjh21 #define SEND_IDENTIFY		0x0010
    207      1.1  bjh21 #define SEND_ABORT		0x0020
    208      1.1  bjh21 #define SEND_WDTR		0x0040
    209      1.1  bjh21 #define SEND_SDTR		0x0080
    210      1.1  bjh21 #define SEND_TAG		0x0100
    211      1.1  bjh21 
    212      1.1  bjh21 /* WD33c93 chipset revisions - values for sc_rev */
    213      1.1  bjh21 #define	SBIC_CHIP_UNKNOWN	0
    214      1.1  bjh21 #define	SBIC_CHIP_WD33C93	1
    215      1.1  bjh21 #define	SBIC_CHIP_WD33C93A	2
    216      1.1  bjh21 #define	SBIC_CHIP_WD33C93B	3
    217      1.1  bjh21 
    218      1.1  bjh21 #define SBIC_CHIP_LIST		{"UNKNOWN", "WD33C93", "WD33C93A", "WD33C93B"}
    219      1.1  bjh21 
    220      1.1  bjh21 /*
    221      1.1  bjh21  * States returned by our state machine
    222      1.1  bjh21  */
    223      1.1  bjh21 #define SBIC_STATE_ERROR	-1
    224      1.1  bjh21 #define SBIC_STATE_DONE		0
    225      1.1  bjh21 #define SBIC_STATE_RUNNING	1
    226      1.1  bjh21 #define SBIC_STATE_DISCONNECT	2
    227      1.1  bjh21 
    228      1.1  bjh21 #define DEBUG_ACBS	0x01
    229      1.1  bjh21 #define DEBUG_INTS	0x02
    230      1.1  bjh21 #define DEBUG_CMDS	0x04
    231      1.1  bjh21 #define DEBUG_MISC	0x08
    232      1.1  bjh21 #define DEBUG_TRAC	0x10
    233      1.1  bjh21 #define DEBUG_RSEL	0x20
    234      1.1  bjh21 #define DEBUG_PHASE	0x40
    235      1.1  bjh21 #define DEBUG_DMA	0x80
    236      1.1  bjh21 #define DEBUG_CCMDS	0x100
    237      1.1  bjh21 #define DEBUG_MSGS	0x200
    238      1.1  bjh21 #define DEBUG_TAGS	0x400
    239      1.1  bjh21 #define DEBUG_SYNC	0x800
    240      1.1  bjh21 
    241      1.1  bjh21 #ifdef DEBUG
    242      1.1  bjh21 extern int wd33c93_debug_flags;
    243      1.1  bjh21 #define SBIC_DEBUG(level, str)						\
    244      1.1  bjh21 	do {								\
    245      1.1  bjh21 		if (wd33c93_debug & __CONCAT(DEBUG_,level))		\
    246      1.1  bjh21 			 printf str;					\
    247      1.1  bjh21 	} while (0)
    248      1.1  bjh21 #else
    249      1.1  bjh21 #define SBIC_DEBUG(level, str)
    250      1.1  bjh21 #endif
    251      1.1  bjh21 
    252      1.1  bjh21 struct buf;
    253      1.1  bjh21 struct scsipi_xfer;
    254      1.1  bjh21 
    255      1.1  bjh21 void wd33c93_minphys (struct buf *);
    256      1.1  bjh21 void wd33c93_scsi_request (struct scsipi_channel *,
    257      1.1  bjh21 				scsipi_adapter_req_t, void *);
    258      1.1  bjh21 void wd33c93_attach (struct wd33c93_softc *);
    259      1.1  bjh21 int  wd33c93_intr (struct wd33c93_softc *);
    260      1.1  bjh21 
    261      1.1  bjh21 #endif /* _SBICVAR_H_ */
    262