xref: /netbsd-src/sys/arch/amiga/dev/sbicvar.h (revision ae9172d6cd9432a6a1a56760d86b32c57a66c39c)
1 /*	$NetBSD: sbicvar.h,v 1.3 1994/10/26 02:04:42 cgd Exp $	*/
2 
3 /*
4  * Copyright (c) 1990 The Regents of the University of California.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Van Jacobson of Lawrence Berkeley Laboratory.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the University of
21  *	California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  *	@(#)scsivar.h	7.1 (Berkeley) 5/8/90
39  */
40 #ifndef _SBICVAR_H_
41 #define _SBICVAR_H_
42 
43 /*
44  * The largest single request will be MAXPHYS bytes which will require
45  * at most MAXPHYS/NBPG+1 chain elements to describe, i.e. if none of
46  * the buffer pages are physically contiguous (MAXPHYS/NBPG) and the
47  * buffer is not page aligned (+1).
48  */
49 #define	DMAMAXIO	(MAXPHYS/NBPG+1)
50 
51 struct	dma_chain {
52 	int	dc_count;
53 	char	*dc_addr;
54 };
55 
56 struct	sbic_pending {
57 	TAILQ_ENTRY(sbic_pending) link;
58 	struct scsi_xfer *xs;
59 };
60 
61 struct	sbic_softc {
62 	struct	device sc_dev;
63 	struct	target_sync {
64 		u_char	state;
65 		u_char	period;
66 		u_char	offset;
67 	} sc_sync[8];
68 	struct	scsi_link sc_link;	/* proto for sub devices */
69 	sbic_regmap_p	sc_sbicp;	/* the SBIC */
70 	volatile void 	*sc_cregs;	/* driver specific regs */
71 	TAILQ_HEAD(,sbic_pending) sc_xslist;	/* LIFO */
72 	struct	sbic_pending sc_xsstore[8][8];	/* one for every unit */
73 	struct	scsi_xfer *sc_xs;	/* transfer from high level code */
74 	u_char	sc_flags;
75 	u_char	sc_scsiaddr;
76 	u_char	sc_stat[2];
77 	u_char	sc_msg[7];
78 	u_long	sc_clkfreq;
79 	u_long	sc_tcnt;		/* number of bytes transfered */
80 	u_char *sc_dmabuffer;
81 	u_char *sc_dmausrbuf;
82 	u_long  sc_dmausrlen;
83 	u_short sc_dmacmd;		/* used by dma drivers */
84 	u_short	sc_dmatimo;		/* dma timeout */
85 	u_long	sc_dmamask;		/* dma valid mem mask */
86 	struct	dma_chain sc_chain[DMAMAXIO];
87 	struct	dma_chain *sc_cur;
88 	struct	dma_chain *sc_last;
89 	int  (*sc_dmago)	__P((struct sbic_softc *, char *, int, int));
90 	int  (*sc_dmanext)	__P((struct sbic_softc *));
91 	void (*sc_dmafree)	__P((struct sbic_softc *));
92 	void (*sc_dmastop)	__P((struct sbic_softc *));
93 	u_short	gtsc_bankmask;		/* GVP specific bank selected */
94 };
95 
96 /* sc_flags */
97 #define	SBICF_ALIVE	0x01	/* controller initialized */
98 #define SBICF_DCFLUSH	0x02	/* need flush for overlap after dma finishes */
99 #define SBICF_SELECTED	0x04	/* bus is in selected state. */
100 #define SBICF_BADDMA	0x10	/* controller can only DMA to ztwobus space */
101 #define SBICF_BBUF	0x20	/* DMA input needs to be copied from bounce */
102 #define	SBICF_INTR	0x40	/* SBICF interrupt expected */
103 #define	SBICF_INDMA	0x80	/* not used yet, DMA I/O in progress */
104 
105 /* sync states */
106 #define SYNC_START	0	/* no sync handshake started */
107 #define SYNC_SENT	1	/* we sent sync request, no answer yet */
108 #define SYNC_DONE	2	/* target accepted our (or inferior) settings,
109 				   or it rejected the request and we stay async */
110 #ifdef DEBUG
111 #define	DDB_FOLLOW	0x04
112 #define DDB_IO		0x08
113 #endif
114 extern int sbic_inhibit_sync;
115 extern int sbic_no_dma;
116 extern int sbic_clock_override;
117 
118 #define	PHASE		0x07		/* mask for psns/pctl phase */
119 #define	DATA_OUT_PHASE	0x00
120 #define	DATA_IN_PHASE	0x01
121 #define	CMD_PHASE	0x02
122 #define	STATUS_PHASE	0x03
123 #define	BUS_FREE_PHASE	0x04
124 #define	ARB_SEL_PHASE	0x05	/* Fuji chip combines arbitration with sel. */
125 #define	MESG_OUT_PHASE	0x06
126 #define	MESG_IN_PHASE	0x07
127 
128 #define	MSG_CMD_COMPLETE	0x00
129 #define MSG_EXT_MESSAGE		0x01
130 #define	MSG_SAVE_DATA_PTR	0x02
131 #define	MSG_RESTORE_PTR		0x03
132 #define	MSG_DISCONNECT		0x04
133 #define	MSG_INIT_DETECT_ERROR	0x05
134 #define	MSG_ABORT		0x06
135 #define	MSG_REJECT		0x07
136 #define	MSG_NOOP		0x08
137 #define	MSG_PARITY_ERROR	0x09
138 #define	MSG_BUS_DEVICE_RESET	0x0C
139 #define	MSG_IDENTIFY		0x80
140 #define	MSG_IDENTIFY_DR		0xc0	/* (disconnect/reconnect allowed) */
141 #define	MSG_SYNC_REQ 		0x01
142 
143 
144 #define	STS_CHECKCOND	0x02	/* Check Condition (ie., read sense) */
145 #define	STS_CONDMET	0x04	/* Condition Met (ie., search worked) */
146 #define	STS_BUSY	0x08
147 #define	STS_INTERMED	0x10	/* Intermediate status sent */
148 #define	STS_EXT		0x80	/* Extended status valid */
149 
150 /*
151  * XXXX
152  */
153 struct scsi_fmt_cdb {
154 	int len;		/* cdb length (in bytes) */
155 	u_char cdb[28];		/* cdb to use on next read/write */
156 };
157 
158 struct buf;
159 struct scsi_xfer;
160 
161 void sbic_minphys __P((struct buf *bp));
162 u_int sbic_adinfo __P((void));
163 int sbic_scsicmd __P((struct scsi_xfer *));
164 
165 #endif /* _SBICVAR_H_ */
166