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