1 /* $NetBSD: tcdsreg.h,v 1.9 2021/12/05 02:59:50 msaitoh Exp $ */
2 
3 /*
4  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Authors: Keith Bostic, Chris G. Demetriou
8  *
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  */
29 
30 /*
31  * Offsets to the SCSI chips
32  */
33 #define   TCDS_SCSI0_OFFSET   0x080000
34 #define   TCDS_SCSI1_OFFSET   0x080100
35 
36 /*
37  * TCDS register offsets, bit masks.
38  */
39 #define   TCDS_EEPROM                     0x000000          /* EEPROM offset */
40 #define   TCDS_EEPROM_IDS                 0x000008          /* SCSI IDs offset in EEPROM */
41 
42 #define   TCDS_CIR              0x040000          /* CIR offset */
43 
44 /*
45  * TCDS CIR control bits.
46  */
47 #define   TCDS_CIR_GPO_0                0x00000001          /* Not used */
48 #define   TCDS_CIR_GPO_1                0x00000002          /* Not used */
49 #define   TCDS_CIR_GPO_2                0x00000004          /* Not used */
50 #define   TCDS_CIR_STD                  0x00000008          /* Serial transmit disable */
51 #define   TCDS_CIR_GPI_0                0x00000010          /* Not used */
52 #define   TCDS_CIR_GPI_1                0x00000020          /* Not used */
53 #define   TCDS_CIR_GPI_2                0x00000040          /* 1 = 25MHz, 0 = 40MHz */
54 #define   TCDS_CIR_GPI_3                0x00000080          /* Not used */
55 #define TCDS_CIR_SCSI0_DMAENA 0x00000100          /* SCSI 0 DMA enable */
56 #define TCDS_CIR_SCSI1_DMAENA 0x00000200          /* SCSI 1 DMA enable */
57 #define   TCDS_CIR_SCSI0_RESET          0x00000400          /* SCSI 0 reset */
58 #define   TCDS_CIR_SCSI1_RESET          0x00000800          /* SCSI 1 reset */
59 #define   TCDS_CIR_SCSI0_DMA_TEST       0x00001000          /* SCSI 0 DMA buf parity test */
60 #define   TCDS_CIR_SCSI1_DMA_TEST       0x00002000          /* SCSI 1 DMA buf parity test */
61 #define   TCDS_CIR_DB_PAR               0x00004000          /* DB parity test mode */
62 #define   TCDS_CIR_TC_PAR               0x00008000          /* TC parity test mode */
63 #define   TCDS_CIR_ALLCONTROL 0x0000ffff          /* all control bits */
64 
65 /* TCDS CIR interrupt bits. */
66 #define   TCDS_CIR_SCSI0_DREQ 0x00010000          /* SCSI 0 DREQ */
67 #define   TCDS_CIR_SCSI1_DREQ 0x00020000          /* SCSI 1 DREQ */
68 #define   TCDS_CIR_SCSI0_INT  0x00040000          /* SCSI 0 interrupt */
69 #define   TCDS_CIR_SCSI1_INT  0x00080000          /* SCSI 1 interrupt */
70 #define   TCDS_CIR_SCSI0_PREFETCH       0x00100000          /* SCSI 0 prefetch */
71 #define   TCDS_CIR_SCSI1_PREFETCH       0x00200000          /* SCSI 1 prefetch */
72 #define   TCDS_CIR_SCSI0_DMA  0x00400000          /* SCSI 0 DMA error */
73 #define   TCDS_CIR_SCSI1_DMA  0x00800000          /* SCSI 1 DMA error */
74 #define   TCDS_CIR_SCSI0_DB   0x01000000          /* SCSI 0 DB parity */
75 #define   TCDS_CIR_SCSI1_DB   0x02000000          /* SCSI 1 DB parity */
76 #define   TCDS_CIR_SCSI0_DMAB_PAR       0x04000000          /* SCSI 0 DMA buffer parity */
77 #define   TCDS_CIR_SCSI1_DMAB_PAR       0x08000000          /* SCSI 1 DMA buffer parity */
78 #define   TCDS_CIR_SCSI0_DMAR_PAR       0x10000000          /* SCSI 0 DMA read parity */
79 #define   TCDS_CIR_SCSI1_DMAR_PAR       0x20000000          /* SCSI 1 DMA read parity */
80 #define   TCDS_CIR_TCIOW_PAR  0x40000000          /* TC I/O write parity */
81 #define   TCDS_CIR_TCIOA_PAR  0x80000000          /* TC I/O address parity */
82 #define   TCDS_CIR_ALLINTR    0xffff0000          /* all interrupt bits */
83 
84 #define TCDS_CIR_CLR(c, b)    c = ((c | TCDS_CIR_ALLINTR) & ~b)
85 #define TCDS_CIR_SET(c, b)    c = ((c | TCDS_CIR_ALLINTR) | b)
86 
87 /* TCDS IMER masks and enables, for interrupts in the CIR. */
88 #define   TCDS_IMER_SCSI0_MASK                0x04          /* SCSI 0 intr/enable mask */
89 #define   TCDS_IMER_SCSI1_MASK                0x08          /* SCSI 1 intr/enable mask */
90 #define   TCDS_IMER_SCSI0_ENB (TCDS_IMER_SCSI0_MASK << 16)
91 #define   TCDS_IMER_SCSI1_ENB (TCDS_IMER_SCSI1_MASK << 16)
92 #define   TCDS_IMER             0x040004          /* IMER offset */
93 
94 #define   TCDS_SCSI0_DMA_ADDR   0x041000          /* DMA address */
95 #define   TCDS_SCSI0_DMA_INTR   0x041004          /* DMA interrupt control */
96 #define   TCDS_SCSI0_DMA_DUD0   0x041008          /* DMA unaligned data[0] */
97 #define   TCDS_SCSI0_DMA_DUD1   0x04100c          /* DMA unaligned data[1] */
98 
99 #define   TCDS_SCSI1_DMA_ADDR   0x041100          /* DMA address */
100 #define   TCDS_SCSI1_DMA_INTR   0x041104          /* DMA interrupt control */
101 #define   TCDS_SCSI1_DMA_DUD0   0x041108          /* DMA unaligned data[0] */
102 #define   TCDS_SCSI1_DMA_DUD1   0x04110c          /* DMA unaligned data[1] */
103 
104 #define   TCDS_DIC_ADDRMASK         0x03          /* DMA address bits <1:0> */
105 #define   TCDS_DIC_READ_PREFETCH              0x40          /* DMA read prefetch enable */
106 #define   TCDS_DIC_WRITE                      0x80          /* DMA write */
107 
108 #define   TCDS_DUD0_VALID00   0x00000001          /* byte 00 valid mask (zero) */
109 #define   TCDS_DUD0_VALID01   0x00000002          /* byte 01 valid mask */
110 #define   TCDS_DUD0_VALID10   0x00000004          /* byte 10 valid mask */
111 #define   TCDS_DUD0_VALID11   0x00000008          /* byte 11 valid mask */
112 #define   TCDS_DUD0_VALIDBITS 0x0000000f          /* bits that show valid bytes */
113 
114 #define   TCDS_DUD1_VALID00   0x01000000          /* byte 00 valid mask */
115 #define   TCDS_DUD1_VALID01   0x02000000          /* byte 01 valid mask */
116 #define   TCDS_DUD1_VALID10   0x04000000          /* byte 10 valid mask */
117 #define   TCDS_DUD1_VALID11   0x08000000          /* byte 11 valid mask (zero) */
118 #define   TCDS_DUD1_VALIDBITS 0x0f000000          /* bits that show valid bytes */
119 
120 #define   TCDS_DUD_BYTE00               0x000000ff          /* byte 00 mask */
121 #define   TCDS_DUD_BYTE01               0x0000ff00          /* byte 01 mask */
122 #define   TCDS_DUD_BYTE10               0x00ff0000          /* byte 10 mask */
123 #define   TCDS_DUD_BYTE11               0xff000000          /* byte 11 mask */
124 
125 #if 0
126 int  tcds_scsi_iserr(struct dma_softc *);
127 int  tcds_scsi_isintr(int, int);
128 void tcds_dma_disable(int);
129 void tcds_dma_enable(int);
130 void tcds_dma_init(struct dma_softc *, int);
131 void tcds_scsi_disable(int);
132 void tcds_scsi_enable(int);
133 void tcds_scsi_reset(int);
134 
135 /*
136  * XXX
137  * Start of MACH #defines, minimal changes to port to NetBSD.
138  *
139  * The following register is the SCSI control interrupt register.  It
140  * starts, stops and resets scsi DMA.  It takes over the SCSI functions
141  * that were handled by the ASIC on the 3min.
142  */
143 #define KN15AA_SYS_SCSI                 0x1d0000000
144 #define KN15AA_REG_SCSI_CIR   (KN15AA_SYS_SCSI + 0x80000)
145 #define SCSI_CIR_AIOPAR                 0x80000000 /* TC IO Address parity error */
146 #define SCSI_CIR_WDIOPAR      0x40000000 /* TC IO  write data parity error */
147 #define SCSI_CIR_DMARPAR1     0x20000000 /* SCSI[1] TC DMA read data parity */
148 #define SCSI_CIR_DMARPAR0     0x10000000 /* SCSI[0] TC DMA read data parity */
149 #define SCSI_CIR_DMABUFPAR1   0x08000000 /* SCSI[1] DMA buffer parity error */
150 #define SCSI_CIR_DMABUFPAR0   0x04000000 /* SCSI[0] DMA buffer parity error */
151 #define SCSI_CIR_DBPAR1                 0x02000000 /* SCSI[1] DB parity error */
152 #define SCSI_CIR_DBPAR0                 0x01000000 /* SCSI[0] DB parity error */
153 #define SCSI_CIR_DMAERR1      0x00800000 /* SCSI[1] DMA error */
154 #define SCSI_CIR_DMAERR0      0x00400000 /* SCSI[0] DMA error */
155 #if fmm50
156 #define SCSI_CIR_xxx0                   0x00200000 /* RESERVED */
157 #define SCSI_CIR_xxx1                   0x00100000 /* RESERVED */
158 #else
159 #define SCSI_CIR_PREF1                  0x00200000 /* 53C94 prefetch interrupt */
160 #define SCSI_CIR_PREF0                  0x00100000 /* 53C94 prefetch interrupt */
161 #endif
162 #define SCSI_CIR_53C94_INT1   0x00080000 /* SCSI[1] 53C94 Interrupt */
163 #define SCSI_CIR_53C94_INT0   0x00040000 /* SCSI[0] 53C94 Interrupt */
164 #define SCSI_CIR_53C94_DREQ1  0x00020000 /* SCSI[1] 53C94 DREQ */
165 #define SCSI_CIR_53C94_DREQ0  0x00010000 /* SCSI[0] 53C94 DREQ */
166 #define SCSI_CIR_TC_PAR_TEST  0x00008000 /* TC parity test mode */
167 #define SCSI_CIR_DB_PAR_TEST  0x00004000 /* DB parity test mode */
168 #define SCSI_CIR_DBUF_PAR_TEST1         0x00002000 /* SCSI[1] DMA buffer parity test */
169 #define SCSI_CIR_DBUF_PAR_TEST0         0x00001000 /* SCSI[0] DMA buffer parity test */
170 #define SCSI_CIR_RESET1                 0x00000800 /* SCSI[1] ~Reset,enable(0)/disable(1) */
171 #define SCSI_CIR_RESET0                 0x00000400 /* SCSI[0] ~Reset,enable(0)/disable(1) */
172 #define SCSI_CIR_DMAENA1      0x00000200 /* SCSI[1] DMA enable */
173 #define SCSI_CIR_DMAENA0      0x00000100 /* SCSI[1] DMA enable */
174 #define SCSI_CIR_GPI3                   0x00000080 /* General purpose input <3> */
175 #define SCSI_CIR_GPI2                   0x00000040 /* General purpose input <2> */
176 #define SCSI_CIR_GPI1                   0x00000020 /* General purpose input <1> */
177 #define SCSI_CIR_GPI0                   0x00000010 /* General purpose input <0> */
178 #define SCSI_CIR_TXDIS                  0x00000008 /* TXDIS- serial transmit disable */
179 #define SCSI_CIR_GPO2                   0x00000004 /* General purpose output <2> */
180 #define SCSI_CIR_GPO1                   0x00000002 /* General purpose output <1> */
181 #define SCSI_CIR_GPO0                   0x00000001 /* General purpose output <0> */
182 #define SCSI_CIR_ERROR (SCSI_CIR_AIOPAR | SCSI_CIR_WDIOPAR | SCSI_CIR_DMARPAR1 | SCSI_CIR_DMARPAR0 | SCSI_CIR_DMABUFPAR1 | SCSI_CIR_DMABUFPAR0 | SCSI_CIR_DBPAR1 |SCSI_CIR_DBPAR0 | SCSI_CIR_DMAERR1 | SCSI_CIR_DMAERR0 )
183 
184 #define KN15AA_REG_SCSI_DMAPTR0 (KN15AA_SYS_SCSI + 0x82000)
185 #define KN15AA_REG_SCSI_DMAPTR1 (KN15AA_SYS_SCSI + 0x82200)
186 
187 #define KN15AA_REG_SCSI_DIC0 (KN15AA_SYS_SCSI + 0x82008)
188 #define KN15AA_REG_SCSI_DIC1 (KN15AA_SYS_SCSI + 0x82208)
189 #define SCSI_DIC_DMADIR                 0x00000080 /* DMA direction read(0)/write(1) */
190 #define SCSI_DIC_PREFENA      0x00000040 /* DMA read prefetch dis(0)/ena(1) */
191 #define SCSI_DIC_DMAADDR1     0x00000002 /* DMA address <1> */
192 #define SCSI_DIC_DMAADDR0     0x00000001 /* DMA address <0> */
193 #define SCSI_DIC_ADDR_MASK    (SCSI_DIC_DMAADDR0 |SCSI_DIC_DMAADDR1)
194 
195 #define KN15AA_REG_SCSI_94REG0          (KN15AA_SYS_SCSI + 0x100000)
196 #define KN15AA_REG_SCSI_94REG1          (KN15AA_SYS_SCSI + 0x100200)
197 
198 #define KN15AA_REG_SCSI_IMER  (KN15AA_SYS_SCSI + 0x80008)
199 
200 /* these are the bits that were unaligned at the beginning of the DMA */
201 #define KN15AA_REG_SCSI_DUDB0 (KN15AA_SYS_SCSI + 0x82010)
202 #define KN15AA_REG_SCSI_DUDB1 (KN15AA_SYS_SCSI + 0x82210)
203 #         define SCSI_DUDB_MASK01       0x00000001 /* Mask bit for byte[01] */
204 #         define SCSI_DUDB_MASK10       0x00000002 /* Mask bit for byte[10] */
205 #         define SCSI_DUDB_MASK11       0x00000004 /* Mask bit for byte[11] */
206 
207 /* these are the bits that were unaligned at the end of the DMA */
208 #define KN15AA_REG_SCSI_DUDE0 (KN15AA_SYS_SCSI + 0x82018)
209 #define KN15AA_REG_SCSI_DUDE1 (KN15AA_SYS_SCSI + 0x82218)
210 #         define SCSI_DUDE_MASK00       0x1000000 /* Mask bit for byte[00] */
211 #         define SCSI_DUDE_MASK01       0x2000000 /* Mask bit for byte[01] */
212 #         define SCSI_DUDE_MASK10       0x4000000 /* Mask bit for byte[10] */
213 
214 #define   SCSI_CIR  ALPHA_PHYS_TO_K0SEG(KN15AA_REG_SCSI_CIR)
215 #define   SCSI_IMER ALPHA_PHYS_TO_K0SEG(KN15AA_REG_SCSI_IMER)
216 
217 #endif
218