1/* $FreeBSD$ */
2/*	$NecBSD: ctvar.h,v 1.4.14.3 2001/06/20 06:13:34 honda Exp $	*/
3/*	$NetBSD$	*/
4
5/*-
6 * [NetBSD for NEC PC-98 series]
7 *  Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001
8 *	NetBSD/pc98 porting staff. All rights reserved.
9 *  Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001
10 *	Naofumi HONDA. All rights reserved.
11 *
12 *  Redistribution and use in source and binary forms, with or without
13 *  modification, are permitted provided that the following conditions
14 *  are met:
15 *  1. Redistributions of source code must retain the above copyright
16 *     notice, this list of conditions and the following disclaimer.
17 *  2. Redistributions in binary form must reproduce the above copyright
18 *     notice, this list of conditions and the following disclaimer in the
19 *     documentation and/or other materials provided with the distribution.
20 *  3. The name of the author may not be used to endorse or promote products
21 *     derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef	_CTVAR_H_
37#define	_CTVAR_H_
38/*
39 * ctvar.h
40 * Generic wd33c93 chip driver's definitions
41 */
42
43/*****************************************************************
44 * Host adapter structure
45 *****************************************************************/
46struct ct_bus_access_handle {
47	bus_space_tag_t ch_iot;			/* core chip ctrl port tag */
48	bus_space_tag_t ch_delayt;		/* delay port tag */
49	bus_space_tag_t ch_datat;		/* data port tag (pio) */
50	bus_space_tag_t ch_memt;		/* data port tag (shm) */
51
52	bus_space_handle_t ch_ioh;
53	bus_space_handle_t ch_delaybah;
54	bus_space_handle_t ch_datah;
55	bus_space_handle_t ch_memh;
56
57	void (*ch_bus_weight)(struct ct_bus_access_handle *);
58
59#ifdef	CT_USE_RELOCATE_OFFSET
60	bus_addr_t ch_offset[4];
61#endif	/* CT_USE_RELOCATE_OFFSET */
62};
63
64struct ct_softc {
65	struct scsi_low_softc sc_sclow;		/* generic data */
66
67	struct ct_bus_access_handle sc_ch;	/* bus access handle */
68
69	struct resource *port_res;
70	struct resource *mem_res;
71	struct resource *irq_res;
72	struct resource *drq_res;
73
74	bus_dma_tag_t sc_dmat;			/* data DMA tag */
75	bus_dmamap_t sc_dmamapt;		/* data DMAMAP tag */
76
77	void *sc_ih;
78
79	int sc_chiprev;			/* chip version */
80#define	CT_WD33C93			0x00000
81#define	CT_WD33C93_A			0x10000
82#define	CT_AM33C93_A			0x10001
83#define	CT_WD33C93_B			0x20000
84#define	CT_WD33C93_C			0x30000
85
86	int sc_xmode;
87#define	CT_XMODE_PIO			1
88#define	CT_XMODE_DMA			2
89
90	int sc_dma;			/* dma transfer start */
91#define	CT_DMA_PIOSTART			1
92#define	CT_DMA_DMASTART			2
93
94	int sc_satgo;			/* combination cmd start */
95#define	CT_SAT_GOING			1
96
97	int sc_tmaxcnt;
98	int sc_atten;			/* attention */
99	u_int8_t sc_creg;		/* control register value */
100
101	int sc_chipclk;			/* chipclk 0, 10, 15, 20 */
102	struct ct_synch_data {
103		u_int cs_period;
104		u_int cs_syncr;
105	} *sc_sdp;			/* synchronous data table pt */
106
107	struct ct_synch_data sc_default_sdt[16];
108
109	/*
110	 * Machdep stuff.
111	 */
112	void *ct_hw;			/* point to bshw_softc etc ... */
113	int (*ct_dma_xfer_start)(struct ct_softc *);
114	int (*ct_pio_xfer_start)(struct ct_softc *);
115	void (*ct_dma_xfer_stop)(struct ct_softc *);
116	void (*ct_pio_xfer_stop)(struct ct_softc *);
117	void (*ct_bus_reset)(struct ct_softc *);
118	void (*ct_synch_setup)(struct ct_softc *, struct targ_info *);
119};
120
121/*****************************************************************
122 * Lun information
123 *****************************************************************/
124struct ct_targ_info {
125	struct targ_info cti_ti;
126
127	u_int8_t cti_syncreg;
128};
129
130/*****************************************************************
131 * PROTO
132 *****************************************************************/
133int ctprobesubr(struct ct_bus_access_handle *, u_int, int, u_int, int *);
134void ctattachsubr(struct ct_softc *);
135int ctintr(void *);
136#endif	/* !_CTVAR_H_ */
137