viareg.h revision 1.3 1 1.3 tsubai /* $NetBSD: viareg.h,v 1.3 2001/04/01 15:14:36 tsubai Exp $ */
2 1.1 tsubai
3 1.1 tsubai /*-
4 1.1 tsubai * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
5 1.1 tsubai * Michael L. Finch, Bradley A. Grantham, and
6 1.1 tsubai * Lawrence A. Kesteloot
7 1.1 tsubai * All rights reserved.
8 1.1 tsubai *
9 1.1 tsubai * Redistribution and use in source and binary forms, with or without
10 1.1 tsubai * modification, are permitted provided that the following conditions
11 1.1 tsubai * are met:
12 1.1 tsubai * 1. Redistributions of source code must retain the above copyright
13 1.1 tsubai * notice, this list of conditions and the following disclaimer.
14 1.1 tsubai * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 tsubai * notice, this list of conditions and the following disclaimer in the
16 1.1 tsubai * documentation and/or other materials provided with the distribution.
17 1.1 tsubai * 3. All advertising materials mentioning features or use of this software
18 1.1 tsubai * must display the following acknowledgement:
19 1.1 tsubai * This product includes software developed by the Alice Group.
20 1.1 tsubai * 4. The names of the Alice Group or any of its members may not be used
21 1.1 tsubai * to endorse or promote products derived from this software without
22 1.1 tsubai * specific prior written permission.
23 1.1 tsubai *
24 1.1 tsubai * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR
25 1.1 tsubai * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 1.1 tsubai * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 1.1 tsubai * IN NO EVENT SHALL THE ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT,
28 1.1 tsubai * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 1.1 tsubai * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 1.1 tsubai * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 1.1 tsubai * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 1.1 tsubai * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 1.1 tsubai * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 1.1 tsubai *
35 1.1 tsubai */
36 1.1 tsubai /*
37 1.1 tsubai
38 1.1 tsubai Prototype VIA control definitions
39 1.1 tsubai
40 1.1 tsubai 06/04/92,22:33:57 BG Let's see what I can do.
41 1.1 tsubai
42 1.1 tsubai */
43 1.1 tsubai
44 1.1 tsubai
45 1.1 tsubai /* VIA1 data register A */
46 1.1 tsubai #define DA1I_vSCCWrReq 0x80
47 1.1 tsubai #define DA1O_vPage2 0x40
48 1.1 tsubai #define DA1I_CPU_ID1 0x40
49 1.1 tsubai #define DA1O_vHeadSel 0x20
50 1.1 tsubai #define DA1O_vOverlay 0x10
51 1.1 tsubai #define DA1O_vSync 0x08
52 1.1 tsubai #define DA1O_RESERVED2 0x04
53 1.1 tsubai #define DA1O_RESERVED1 0x02
54 1.1 tsubai #define DA1O_RESERVED0 0x01
55 1.1 tsubai
56 1.1 tsubai /* VIA1 data register B */
57 1.1 tsubai #define DB1I_Par_Err 0x80
58 1.1 tsubai #define DB1O_vSndEnb 0x80
59 1.1 tsubai #define DB1O_Par_Enb 0x40
60 1.1 tsubai #define DB1O_vFDesk2 0x20
61 1.1 tsubai #define DB1O_vFDesk1 0x10
62 1.1 tsubai #define DB1I_vFDBInt 0x08
63 1.1 tsubai #define DB1O_rTCEnb 0x04
64 1.1 tsubai #define DB1O_rTCCLK 0x02
65 1.1 tsubai #define DB1O_rTCData 0x01
66 1.1 tsubai #define DB1I_rTCData 0x01
67 1.1 tsubai
68 1.1 tsubai /* VIA2 data register A */
69 1.1 tsubai #define DA2O_v2Ram1 0x80
70 1.1 tsubai #define DA2O_v2Ram0 0x40
71 1.1 tsubai #define DA2I_v2IRQ0 0x40
72 1.1 tsubai #define DA2I_v2IRQE 0x20
73 1.1 tsubai #define DA2I_v2IRQD 0x10
74 1.1 tsubai #define DA2I_v2IRQC 0x08
75 1.1 tsubai #define DA2I_v2IRQB 0x04
76 1.1 tsubai #define DA2I_v2IRQA 0x02
77 1.1 tsubai #define DA2I_v2IRQ9 0x01
78 1.1 tsubai
79 1.1 tsubai /* VIA2 data register B */
80 1.1 tsubai #define DB2O_v2VBL 0x80
81 1.1 tsubai #define DB2O_Par_Test 0x80
82 1.1 tsubai #define DB2I_v2SNDEXT 0x40
83 1.1 tsubai #define DB2I_v2TM0A 0x20
84 1.1 tsubai #define DB2I_v2TM1A 0x10
85 1.1 tsubai #define DB2I_vFC3 0x08
86 1.1 tsubai #define DB2O_vFC3 0x08
87 1.1 tsubai #define DB2O_v2PowerOff 0x04
88 1.1 tsubai #define DB2O_v2BusLk 0x02
89 1.1 tsubai #define DB2O_vCDis 0x01
90 1.1 tsubai #define DB2O_CEnable 0x01
91 1.1 tsubai
92 1.1 tsubai /*
93 1.1 tsubai * VIA1 interrupts
94 1.1 tsubai */
95 1.1 tsubai #define VIA1_T1 6
96 1.1 tsubai #define VIA1_T2 5
97 1.1 tsubai #define VIA1_ADBCLK 4
98 1.1 tsubai #define VIA1_ADBDATA 3
99 1.1 tsubai #define VIA1_ADBRDY 2
100 1.1 tsubai #define VIA1_VBLNK 1
101 1.1 tsubai #define VIA1_ONESEC 0
102 1.1 tsubai
103 1.1 tsubai /* VIA1 interrupt bits */
104 1.1 tsubai #define V1IF_IRQ 0x80
105 1.1 tsubai #define V1IF_T1 (1 << VIA1_T1)
106 1.1 tsubai #define V1IF_T2 (1 << VIA1_T2)
107 1.1 tsubai #define V1IF_ADBCLK (1 << VIA1_ADBCLK)
108 1.1 tsubai #define V1IF_ADBDATA (1 << VIA1_ADBDATA)
109 1.1 tsubai #define V1IF_ADBRDY (1 << VIA1_ADBRDY)
110 1.1 tsubai #define V1IF_VBLNK (1 << VIA1_VBLNK)
111 1.1 tsubai #define V1IF_ONESEC (1 << VIA1_ONESEC)
112 1.1 tsubai
113 1.1 tsubai /*
114 1.1 tsubai * VIA2 interrupts
115 1.1 tsubai */
116 1.1 tsubai #define VIA2_T1 6
117 1.1 tsubai #define VIA2_T2 5
118 1.1 tsubai #define VIA2_ASC 4
119 1.1 tsubai #define VIA2_SCSIIRQ 3
120 1.1 tsubai #define VIA2_EXPIRQ 2
121 1.1 tsubai #define VIA2_SLOTINT 1
122 1.1 tsubai #define VIA2_SCSIDRQ 0
123 1.1 tsubai
124 1.1 tsubai /* VIA2 interrupt bits */
125 1.1 tsubai #define V2IF_IRQ 0x80
126 1.1 tsubai #define V2IF_T1 (1 << VIA2_T1)
127 1.1 tsubai #define V2IF_T2 (1 << VIA2_T2)
128 1.1 tsubai #define V2IF_ASC (1 << VIA2_ASC)
129 1.1 tsubai #define V2IF_SCSIIRQ (1 << VIA2_SCSIIRQ)
130 1.1 tsubai #define V2IF_EXPIRQ (1 << VIA2_EXPIRQ)
131 1.1 tsubai #define V2IF_SLOTINT (1 << VIA2_SLOTINT)
132 1.1 tsubai #define V2IF_SCSIDRQ (1 << VIA2_SCSIDRQ)
133 1.1 tsubai
134 1.1 tsubai #define VIA1_INTS (V1IF_T1 | V1IF_ADBRDY)
135 1.1 tsubai #define VIA2_INTS (V2IF_T1 | V2IF_ASC | V2IF_SCSIIRQ | V2IF_SLOTINT | \
136 1.1 tsubai V2IF_SCSIDRQ)
137 1.1 tsubai
138 1.1 tsubai #define RBV_INTS (V2IF_T1 | V2IF_ASC | V2IF_SCSIIRQ | V2IF_SLOTINT | \
139 1.1 tsubai V2IF_SCSIDRQ | V1IF_ADBRDY)
140 1.1 tsubai
141 1.1 tsubai #define ACR_T1LATCH 0x40
142 1.1 tsubai
143 1.1 tsubai extern volatile unsigned char *Via1Base;
144 1.1 tsubai #define VIA1_addr Via1Base /* at PA 0x50f00000 */
145 1.1 tsubai #define VIA2OFF 1 /* VIA2 addr = VIA1_addr * 0x2000 */
146 1.1 tsubai #define RBVOFF 0x13 /* RBV addr = VIA1_addr * 0x13000 */
147 1.1 tsubai
148 1.1 tsubai #define VIA1 0
149 1.2 tsubai #define VIA2 0
150 1.1 tsubai
151 1.1 tsubai /* VIA interface registers */
152 1.3 tsubai #define vBufB 0x0000 /* register B */
153 1.3 tsubai #define vBufA 0x0200 /* register A */
154 1.3 tsubai #define vDirB 0x0400 /* data direction register */
155 1.1 tsubai #define vDirA 0x0600 /* data direction register */
156 1.1 tsubai #define vT1C 0x0800
157 1.1 tsubai #define vT1CH 0x0a00
158 1.1 tsubai #define vT1L 0x0c00
159 1.1 tsubai #define vT1LH 0x0e00
160 1.1 tsubai #define vT2C 0x1000
161 1.1 tsubai #define vT2CH 0x1200
162 1.1 tsubai #define vSR 0x1400 /* shift register */
163 1.1 tsubai #define vACR 0x1600 /* aux control register */
164 1.1 tsubai #define vPCR 0x1800 /* peripheral control register */
165 1.1 tsubai #define vIFR 0x1a00 /* interrupt flag register */
166 1.1 tsubai #define vIER 0x1c00 /* interrupt enable register */
167 1.1 tsubai
168 1.1 tsubai /* RBV interface registers */
169 1.1 tsubai #define rBufB 0 /* register B */
170 1.1 tsubai #define rBufA 2 /* register A */
171 1.1 tsubai #define rIFR 0x3 /* interrupt flag register (writes?) */
172 1.1 tsubai #define rIER 0x13 /* interrupt enable register */
173 1.1 tsubai #define rMonitor 0x10 /* Monitor type */
174 1.1 tsubai #define rSlotInt 0x12 /* Slot interrupt */
175 1.1 tsubai
176 1.1 tsubai /* RBV monitor type flags and masks */
177 1.1 tsubai #define RBVDepthMask 0x07 /* depth in bits */
178 1.1 tsubai #define RBVMonitorMask 0x38 /* Type numbers */
179 1.1 tsubai #define RBVOff 0x40 /* monitor turn off */
180 1.1 tsubai #define RBVMonIDNone 0x38 /* What RBV actually has for no video */
181 1.1 tsubai #define RBVMonIDOff 0x0 /* What rbv_vidstatus() returns for no video */
182 1.1 tsubai #define RBVMonID15BWP 0x08 /* BW portrait */
183 1.1 tsubai #define RBVMonIDRGB 0x10 /* color monitor */
184 1.1 tsubai #define RBVMonIDRGB15 0x28 /* 15 inch RGB */
185 1.1 tsubai #define RBVMonIDBW 0x30 /* No internal video */
186 1.1 tsubai
187 1.1 tsubai #define via_reg(v, r) (*(Via1Base + (r)))
188 1.1 tsubai
189 1.1 tsubai #include <machine/pio.h>
190 1.1 tsubai
191 1.1 tsubai static __inline void
192 1.1 tsubai via_reg_and(ign, reg, val)
193 1.1 tsubai int ign, reg, val;
194 1.1 tsubai {
195 1.1 tsubai volatile unsigned char *addr = Via1Base + reg;
196 1.1 tsubai
197 1.1 tsubai out8(addr, in8(addr) & val);
198 1.1 tsubai }
199 1.1 tsubai
200 1.1 tsubai static __inline void
201 1.1 tsubai via_reg_or(ign, reg, val)
202 1.1 tsubai int ign, reg, val;
203 1.1 tsubai {
204 1.1 tsubai volatile unsigned char *addr = Via1Base + reg;
205 1.1 tsubai
206 1.1 tsubai out8(addr, in8(addr) | val);
207 1.1 tsubai }
208 1.1 tsubai
209 1.1 tsubai static __inline void
210 1.1 tsubai via_reg_xor(ign, reg, val)
211 1.1 tsubai int ign, reg, val;
212 1.1 tsubai {
213 1.1 tsubai volatile unsigned char *addr = Via1Base + reg;
214 1.1 tsubai
215 1.1 tsubai out8(addr, in8(addr) ^ val);
216 1.1 tsubai }
217 1.1 tsubai
218 1.1 tsubai static __inline int
219 1.1 tsubai read_via_reg(ign, reg)
220 1.1 tsubai int ign, reg;
221 1.1 tsubai {
222 1.1 tsubai volatile unsigned char *addr = Via1Base + reg;
223 1.1 tsubai
224 1.1 tsubai return in8(addr);
225 1.1 tsubai }
226 1.1 tsubai
227 1.1 tsubai static __inline void
228 1.1 tsubai write_via_reg(ign, reg, val)
229 1.1 tsubai int ign, reg, val;
230 1.1 tsubai {
231 1.1 tsubai volatile unsigned char *addr = Via1Base + reg;
232 1.1 tsubai
233 1.1 tsubai out8(addr, val);
234 1.1 tsubai }
235 1.1 tsubai
236 1.1 tsubai
237 1.1 tsubai
238 1.1 tsubai #define vDirA_ADBState 0x30
239 1.1 tsubai
240 1.1 tsubai void via_init __P((void));
241 1.1 tsubai int rbv_vidstatus __P((void));
242 1.1 tsubai void via_shutdown __P((void));
243 1.1 tsubai void via_set_modem __P((int));
244 1.1 tsubai int add_nubus_intr __P((int, void (*) __P((void *, int)), void *));
245 1.1 tsubai void enable_nubus_intr __P((void));
246 1.1 tsubai void via1_register_irq __P((int, void (*)(void *), void *));
247 1.1 tsubai void via2_register_irq __P((int, void (*)(void *), void *));
248 1.1 tsubai
249 1.1 tsubai extern void (*via1itab[7]) __P((void *));
250 1.1 tsubai extern void (*via2itab[7]) __P((void *));
251