stp4020reg.h revision 1.1 1 1.1 pk /* $NetBSD: stp4020reg.h,v 1.1 1998/11/22 22:14:35 pk Exp $ */
2 1.1 pk
3 1.1 pk /*-
4 1.1 pk * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.1 pk * All rights reserved.
6 1.1 pk *
7 1.1 pk * This code is derived from software contributed to The NetBSD Foundation
8 1.1 pk * by Paul Kranenburg.
9 1.1 pk *
10 1.1 pk * Redistribution and use in source and binary forms, with or without
11 1.1 pk * modification, are permitted provided that the following conditions
12 1.1 pk * are met:
13 1.1 pk * 1. Redistributions of source code must retain the above copyright
14 1.1 pk * notice, this list of conditions and the following disclaimer.
15 1.1 pk * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 pk * notice, this list of conditions and the following disclaimer in the
17 1.1 pk * documentation and/or other materials provided with the distribution.
18 1.1 pk * 3. All advertising materials mentioning features or use of this software
19 1.1 pk * must display the following acknowledgement:
20 1.1 pk * This product includes software developed by the NetBSD
21 1.1 pk * Foundation, Inc. and its contributors.
22 1.1 pk * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 pk * contributors may be used to endorse or promote products derived
24 1.1 pk * from this software without specific prior written permission.
25 1.1 pk *
26 1.1 pk * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 pk * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 pk * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 pk * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 pk * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 pk * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 pk * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 pk * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 pk * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 pk * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 pk * POSSIBILITY OF SUCH DAMAGE.
37 1.1 pk */
38 1.1 pk
39 1.1 pk
40 1.1 pk #ifndef _STP4020_REG_H
41 1.1 pk #define _STP4020_REG_H
42 1.1 pk
43 1.1 pk /*
44 1.1 pk * STP4020: SBus/PCMCIA bridge supporting two Type-3 PCMCIA cards.
45 1.1 pk * Programming information source:
46 1.1 pk * - http://www.sun.com/microelectronics/datasheets/stp4020/
47 1.1 pk * - SunOS 5.5 header file
48 1.1 pk */
49 1.1 pk
50 1.1 pk /*
51 1.1 pk * General chip attibutes.
52 1.1 pk */
53 1.1 pk #define STP4020_NSOCK 2 /* number of PCCARD sockets per STP4020 */
54 1.1 pk #define STP4020_NWIN 3 /* number of windows per socket */
55 1.1 pk
56 1.1 pk /*
57 1.1 pk * Socket control registers.
58 1.1 pk *
59 1.1 pk * Each PCMCIA socket has two interface control registers and two interface
60 1.1 pk * status registers associated with it.
61 1.1 pk */
62 1.1 pk
63 1.1 pk /*
64 1.1 pk * Socket Interface Control register 0
65 1.1 pk */
66 1.1 pk #define STP4020_ICR0_rsvd1 0xc000 /* reserved bits */
67 1.1 pk #define STP4020_ICR0_PROMEN 0x2000 /* FCode PROM enable */
68 1.1 pk /* Status change interrupts can be routed to one of two SBus interrupt levels:*/
69 1.1 pk #define STP4020_ICR0_SCILVL 0x1000 /* card status change interrupt level */
70 1.1 pk #define STP4020_ICR0_SCILVL_SB0 0x0000 /* interrupt on *SB_INT[0] */
71 1.1 pk #define STP4020_ICR0_SCILVL_SB1 0x1000 /* interrupt on *SB_INT[1] */
72 1.1 pk /* Interrupt enable bits: */
73 1.1 pk #define STP4020_ICR0_CDIE 0x0800 /* card detect interrupt enable */
74 1.1 pk #define STP4020_ICR0_BVD2IE 0x0400 /* battery voltage detect 2 int en. */
75 1.1 pk #define STP4020_ICR0_BVD1IE 0x0200 /* battery voltage detect 1 int en. */
76 1.1 pk #define STP4020_ICR0_RDYIE 0x0100 /* ready/busy interrupt enable */
77 1.1 pk #define STP4020_ICR0_WPIE 0x0080 /* write protect interrupt enable */
78 1.1 pk #define STP4020_ICR0_CTOIE 0x0040 /* PC card timeout interrupt enable */
79 1.1 pk #define STP4020_ICR0_rsvd2 0x0020 /* */
80 1.1 pk #define STP4020_ICR0_IOIE 0x0010 /* I/O (*IRQ) interrupt enable */
81 1.1 pk /* PC card I/O interrupts can also be routed to one of two SBus intr levels: */
82 1.1 pk #define STP4020_ICR0_IOILVL 0x0008 /* I/O (*IRQ) interrupt level (SBus) */
83 1.1 pk #define STP4020_ICR0_IOILVL_SB0 0x0000 /* interrupt on *SB_INT[0] */
84 1.1 pk #define STP4020_ICR0_IOILVL_SB1 0x0008 /* interrupt on *SB_INT[1] */
85 1.1 pk
86 1.1 pk #define STP4020_ICR0_SPKREN 0x0004 /* *SPKR_OUT enable */
87 1.1 pk #define STP4020_ICR0_RESET 0x0002 /* PC card reset */
88 1.1 pk #define STP4020_ICR0_IFTYPE 0x0001 /* PC card interface type */
89 1.1 pk #define STP4020_ICR0_IFTYPE_MEM 0x0000 /* MEMORY only */
90 1.1 pk #define STP4020_ICR0_IFTYPE_IO 0x0001 /* MEMORY and I/O */
91 1.1 pk #define STP4020_ICR0_BITS "\177\010" \
92 1.1 pk "b\0IFTYPE\0b\1RESET\0b\2SPKREN\0" \
93 1.1 pk "b\3IOILVL\0b\4IOIE\0b\6CTOIE\0" \
94 1.1 pk "b\7WPIE\0b\10RDYIE\0b\11BVD1IE\0b\12BVD2IE\0"\
95 1.1 pk "b\13CDIE\0b\14SCILV\0b\15PROMEN\0\0"
96 1.1 pk
97 1.1 pk /* Shorthand for all status change interrupts enables */
98 1.1 pk #define STP4020_ICR0_ALL_STATUS_IE ( \
99 1.1 pk STP4020_ICR0_CDIE | \
100 1.1 pk STP4020_ICR0_BVD2IE | \
101 1.1 pk STP4020_ICR0_BVD1IE | \
102 1.1 pk STP4020_ICR0_RDYIE | \
103 1.1 pk STP4020_ICR0_WPIE | \
104 1.1 pk STP4020_ICR0_CTOIE \
105 1.1 pk )
106 1.1 pk
107 1.1 pk /*
108 1.1 pk * Socket Interface Control register 1
109 1.1 pk */
110 1.1 pk #define STP4020_ICR1_LPBKEN 0x8000 /* PC card data loopback enable */
111 1.1 pk #define STP4020_ICR1_CD1DB 0x4000 /* card detect 1 diagnostic bit */
112 1.1 pk #define STP4020_ICR1_BVD2DB 0x2000 /* battery voltage detect 2 diag bit */
113 1.1 pk #define STP4020_ICR1_BVD1DB 0x1000 /* battery voltage detect 1 diag bit */
114 1.1 pk #define STP4020_ICR1_RDYDB 0x0800 /* ready/busy diagnostic bit */
115 1.1 pk #define STP4020_ICR1_WPDB 0x0400 /* write protect diagnostic bit */
116 1.1 pk #define STP4020_ICR1_WAITDB 0x0200 /* *WAIT diagnostic bit */
117 1.1 pk #define STP4020_ICR1_DIAGEN 0x0100 /* diagnostic enable bit */
118 1.1 pk #define STP4020_ICR1_rsvd1 0x0080 /* reserved */
119 1.1 pk #define STP4020_ICR1_APWREN 0x0040 /* PC card auto power switch enable */
120 1.1 pk
121 1.1 pk /*
122 1.1 pk * The Vpp controls are two-bit fields which specify which voltage
123 1.1 pk * should be switched onto Vpp for this socket.
124 1.1 pk *
125 1.1 pk * Both of the "no connect" states are equal.
126 1.1 pk */
127 1.1 pk #define STP4020_ICR1_VPP2EN 0x0030 /* Vpp2 power enable */
128 1.1 pk #define STP4020_ICR1_VPP2_OFF 0x0000 /* no connect */
129 1.1 pk #define STP4020_ICR1_VPP2_VCC 0x0010 /* Vcc switched onto Vpp2 */
130 1.1 pk #define STP4020_ICR1_VPP2_VPP 0x0020 /* Vpp switched onto Vpp2 */
131 1.1 pk #define STP4020_ICR1_VPP2_ZIP 0x0030 /* no connect */
132 1.1 pk
133 1.1 pk #define STP4020_ICR1_VPP1EN 0x000c /* Vpp1 power enable */
134 1.1 pk #define STP4020_ICR1_VPP1_OFF 0x0000 /* no connect */
135 1.1 pk #define STP4020_ICR1_VPP1_VCC 0x0004 /* Vcc switched onto Vpp1 */
136 1.1 pk #define STP4020_ICR1_VPP1_VPP 0x0008 /* Vpp switched onto Vpp1 */
137 1.1 pk #define STP4020_ICR1_VPP1_ZIP 0x000c /* no connect */
138 1.1 pk
139 1.1 pk #define STP4020_ICR1_MSTPWR 0x0002 /* PC card master power enable */
140 1.1 pk #define STP4020_ICR1_PCIFOE 0x0001 /* PC card interface output enable */
141 1.1 pk
142 1.1 pk #define STP4020_ICR1_BITS "\177\010" \
143 1.1 pk "b\0PCIFOE\0b\1MSTPWR\0f\2\2VPP1EN\0" \
144 1.1 pk "f\4\2VPP2EN\0b\6APWREN\0b\10DIAGEN\0" \
145 1.1 pk "b\11WAITDB\0b\12WPDB\0b\13RDYDB\0" \
146 1.1 pk "b\14BVD1D\0b\15BVD2D\0\16CD1DB\0b\17LPBKEN\0"
147 1.1 pk
148 1.1 pk /*
149 1.1 pk * Socket Interface Status register 0
150 1.1 pk *
151 1.1 pk * Some signals in this register change meaning depending on whether
152 1.1 pk * the socket is configured as MEMORY-ONLY or MEMORY & I/O:
153 1.1 pk * mo: valid only if the socket is in memory-only mode
154 1.1 pk * io: valid only if the socket is in memory and I/O mode.
155 1.1 pk *
156 1.1 pk * Pending interrupts are cleared by writing the corresponding status
157 1.1 pk * bit set in the upper half of this register.
158 1.1 pk */
159 1.1 pk #define STP4020_ISR0_ZERO 0x8000 /* always reads back as zero (mo) */
160 1.1 pk #define STP4020_ISR0_IOINT 0x8000 /* PC card I/O intr (*IRQ) posted (io)*/
161 1.1 pk #define STP4020_ISR0_SCINT 0x4000 /* status change interrupt posted */
162 1.1 pk #define STP4020_ISR0_CDCHG 0x2000 /* card detect status change */
163 1.1 pk #define STP4020_ISR0_BVD2CHG 0x1000 /* battery voltage detect 2 status change */
164 1.1 pk #define STP4020_ISR0_BVD1CHG 0x0800 /* battery voltage detect 1 status change */
165 1.1 pk #define STP4020_ISR0_RDYCHG 0x0400 /* ready/busy status change */
166 1.1 pk #define STP4020_ISR0_WPCHG 0x0200 /* write protect status change */
167 1.1 pk #define STP4020_ISR0_PCTO 0x0100 /* PC card access timeout */
168 1.1 pk #define STP4020_ISR0_ALL_STATUS_IRQ 0x7f00
169 1.1 pk
170 1.1 pk #define STP4020_ISR0_LIVE 0x00ff /* live status bit mask */
171 1.1 pk #define STP4020_ISR0_CD2ST 0x0080 /* card detect 2 live status */
172 1.1 pk #define STP4020_ISR0_CD1ST 0x0040 /* card detect 1 live status */
173 1.1 pk #define STP4020_ISR0_BVD2ST 0x0020 /* battery voltage detect 2 live status (mo) */
174 1.1 pk #define STP4020_ISR0_SPKR 0x0020 /* SPKR signal live status (io)*/
175 1.1 pk #define STP4020_ISR0_BVD1ST 0x0010 /* battery voltage detect 1 live status (mo) */
176 1.1 pk #define STP4020_ISR0_STSCHG 0x0010 /* I/O *STSCHG signal live status (io)*/
177 1.1 pk #define STP4020_ISR0_RDYST 0x0008 /* ready/busy live status (mo) */
178 1.1 pk #define STP4020_ISR0_IOREQ 0x0008 /* I/O *REQ signal live status (io) */
179 1.1 pk #define STP4020_ISR0_WPST 0x0004 /* write protect live status (mo) */
180 1.1 pk #define STP4020_ISR0_IOIS16 0x0004 /* IOIS16 signal live status (io) */
181 1.1 pk #define STP4020_ISR0_WAITST 0x0002 /* wait signal live status */
182 1.1 pk #define STP4020_ISR0_PWRON 0x0001 /* PC card power status */
183 1.1 pk
184 1.1 pk #define STP4020_ISR0_IOBITS "\177\010" \
185 1.1 pk "b\0PWRON\0b\1WAITST\0b\2IOIS16\0b\3IOREQ\0" \
186 1.1 pk "b\4STSCHG\0b\5SPKR\0b\6CD1ST\0b\7CD2ST\0" \
187 1.1 pk "b\10PCTO\0b\11WPCHG\0b\12RDYCHG\0" \
188 1.1 pk "b\13BVD1CHG\0b\14BVD2CHG\0b\15CDCHG\0" \
189 1.1 pk "b\16SCINT\0b\17IOINT\0\0"
190 1.1 pk #define STP4020_ISR0_MOBITS "\177\010" \
191 1.1 pk "b\0PWRON\0b\1WAITST\0b\2WPST\0b\3RDYST\0" \
192 1.1 pk "b\4BVD1ST\0b\5BVD2ST\0b\6CD1ST\0b\7CD2ST\0" \
193 1.1 pk "b\10PCTO\0b\11WPCHG\0b\12RDYCHG\0" \
194 1.1 pk "b\13BVD1CHG\0b\14BVD2CHG\0b\15CDCHG\0" \
195 1.1 pk "b\16SCINT\0\0"
196 1.1 pk
197 1.1 pk /*
198 1.1 pk * Socket Interface Status register 1
199 1.1 pk */
200 1.1 pk #define STP4020_ISR1_rsvd 0xffc0 /* reserved */
201 1.1 pk #define STP4020_ISR1_PCTYPE_M 0x0030 /* PC card type(s) supported bit mask */
202 1.1 pk #define STP4020_ISR1_PCTYPE_S 4 /* PC card type(s) supported bit shift */
203 1.1 pk #define STP4020_ISR1_REV_M 0x000f /* ASIC revision level bit mask */
204 1.1 pk #define STP4020_ISR1_REV_S 0 /* ASIC revision level bit shift */
205 1.1 pk #define STP4020_ISR1_BITS "\177\010" \
206 1.1 pk "f\0\4REV\0f\4\2PCTYPE\0\0" \
207 1.1 pk
208 1.1 pk
209 1.1 pk /*
210 1.1 pk * Socket window control/status register definitions.
211 1.1 pk *
212 1.1 pk * According to SunOS 5.5:
213 1.1 pk * "Each PCMCIA socket has three windows associated with it; each of
214 1.1 pk * these windows can be programmed to map in either the AM, CM or IO
215 1.1 pk * space on the PC card. Each window can also be programmed with a
216 1.1 pk * starting or base address relative to the PC card's address zero.
217 1.1 pk * Each window is a fixed 1Mb in size.
218 1.1 pk *
219 1.1 pk * Each window has two window control registers associated with it to
220 1.1 pk * control the window's PCMCIA bus timing parameters, PC card address
221 1.1 pk * space that that window maps, and the base address in the
222 1.1 pk * selected PC card's address space."
223 1.1 pk */
224 1.1 pk #define STP4020_WINDOW_SIZE (1024*1024) /* 1MB */
225 1.1 pk #define STP4020_WINDOW_SHIFT 20 /* for 1MB */
226 1.1 pk
227 1.1 pk /*
228 1.1 pk * PC card Window Control register 0
229 1.1 pk */
230 1.1 pk #define STP4020_WCR0_rsvd 0x8000 /* reserved */
231 1.1 pk #define STP4020_WCR0_CMDLNG_M 0x7c00 /* command strobe length bit mask */
232 1.1 pk #define STP4020_WCR0_CMDLNG_S 10 /* command strobe length bit shift */
233 1.1 pk #define STP4020_WCR0_CMDDLY_M 0x0300 /* command strobe delay bit mask */
234 1.1 pk #define STP4020_WCR0_CMDDLY_S 8 /* command strobe delay bit shift */
235 1.1 pk #define STP4020_MEM_SPEED_MIN 100
236 1.1 pk #define STP4020_MEM_SPEED_MAX 1370
237 1.1 pk /*
238 1.1 pk * The ASPSEL (Address Space Select) bits control which of the three PC card
239 1.1 pk * address spaces this window maps in.
240 1.1 pk */
241 1.1 pk #define STP4020_WCR0_ASPSEL_M 0x00c0 /* address space select bit mask */
242 1.1 pk #define STP4020_WCR0_ASPSEL_AM 0x0000 /* attribute memory */
243 1.1 pk #define STP4020_WCR0_ASPSEL_CM 0x0040 /* common memory */
244 1.1 pk #define STP4020_WCR0_ASPSEL_IO 0x0080 /* I/O */
245 1.1 pk /*
246 1.1 pk * The base address controls which 1MB range in the 64MB card address space
247 1.1 pk * this window maps to.
248 1.1 pk */
249 1.1 pk #define STP4020_WCR0_BASE_M 0x0003f /* base address bit mask */
250 1.1 pk #define STP4020_WCR0_BASE_S 0 /* base address bit shift */
251 1.1 pk
252 1.1 pk #define STP4020_ADDR2PAGE(x) ((x) >> 20)
253 1.1 pk
254 1.1 pk /*
255 1.1 pk * PC card Window Control register 1
256 1.1 pk */
257 1.1 pk #define STP4020_WCR1_rsvd 0xffe0 /* reserved */
258 1.1 pk #define STP4020_WCR1_RECDLY_M 0x0018 /* recovery delay bit mask */
259 1.1 pk #define STP4020_WCR1_RECDLY_S 3 /* recovery delay bit shift */
260 1.1 pk #define STP4020_WCR1_WAITDLY_M 0x0006 /* *WAIT signal delay bit mask */
261 1.1 pk #define STP4020_WCR1_WAITDLY_S 1 /* *WAIT signal delay bit shift */
262 1.1 pk #define STP4020_WCR1_WAITREQ_M 0x0001 /* *WAIT signal is required bit mask */
263 1.1 pk #define STP4020_WCR1_WAITREQ_S 0 /* *WAIT signal is required bit shift */
264 1.1 pk
265 1.1 pk #if for_reference_only
266 1.1 pk /*
267 1.1 pk * STP4020 CSR structures
268 1.1 pk *
269 1.1 pk * There is one stp4020_regs_t structure per instance, and it refers to
270 1.1 pk * the complete Stp4020 register set.
271 1.1 pk *
272 1.1 pk * For each socket, there is one stp4020_socket_csr_t structure, which
273 1.1 pk * refers to all the registers for that socket. That structure is
274 1.1 pk * made up of the window register structures as well as the registers
275 1.1 pk * that control overall socket operation.
276 1.1 pk *
277 1.1 pk * For each window, there is one stp4020_window_ctl_t structure, which
278 1.1 pk * refers to all the registers for that window.
279 1.1 pk */
280 1.1 pk
281 1.1 pk /*
282 1.1 pk * per-window CSR structure
283 1.1 pk */
284 1.1 pk typedef struct stp4020_window_ctl_t {
285 1.1 pk volatile ushort_t ctl0; /* window control register 0 */
286 1.1 pk volatile ushort_t ctl1; /* window control register 1 */
287 1.1 pk } stp4020_window_ctl_t;
288 1.1 pk
289 1.1 pk /*
290 1.1 pk * per-socket CSR structure
291 1.1 pk */
292 1.1 pk typedef struct stp4020_socket_csr_t {
293 1.1 pk volatile struct stp4020_window_ctl_t window[STP4020_NWIN];
294 1.1 pk volatile ushort_t ctl0; /* socket control register 0 */
295 1.1 pk volatile ushort_t ctl1; /* socket control register 1 */
296 1.1 pk volatile ushort_t stat0; /* socket status register 0 */
297 1.1 pk volatile ushort_t stat1; /* socket status register 1 */
298 1.1 pk volatile uchar_t filler[12]; /* filler space */
299 1.1 pk } stp4020_socket_csr_t;
300 1.1 pk
301 1.1 pk /*
302 1.1 pk * per-instance CSR structure
303 1.1 pk */
304 1.1 pk typedef struct stp4020_regs_t {
305 1.1 pk struct stp4020_socket_csr_t socket[STP4020_NSOCK]; /* socket CSRs */
306 1.1 pk } stp4020_regs_t;
307 1.1 pk #endif /* reference */
308 1.1 pk
309 1.1 pk /* Size of control and status register banks */
310 1.1 pk #define STP4020_SOCKREGS_SIZE 32
311 1.1 pk #define STP4020_WINREGS_SIZE 4
312 1.1 pk
313 1.1 pk /* Relative socket control & status register offsets */
314 1.1 pk #define STP4020_ICR0_IDX 12
315 1.1 pk #define STP4020_ICR1_IDX 14
316 1.1 pk #define STP4020_ISR0_IDX 16
317 1.1 pk #define STP4020_ISR1_IDX 18
318 1.1 pk
319 1.1 pk /* Relative Window control register offsets */
320 1.1 pk #define STP4020_WCR0_IDX 0
321 1.1 pk #define STP4020_WCR1_IDX 2
322 1.1 pk
323 1.1 pk /* Socket control and status register offsets */
324 1.1 pk #define STP4020_ICR0_REG(s) ((32 * (s)) + STP4020_ICR0_IDX)
325 1.1 pk #define STP4020_ICR1_REG(s) ((32 * (s)) + STP4020_ICR1_IDX)
326 1.1 pk #define STP4020_ISR0_REG(s) ((32 * (s)) + STP4020_ISR0_IDX)
327 1.1 pk #define STP4020_ISR1_REG(s) ((32 * (s)) + STP4020_ISR1_IDX)
328 1.1 pk
329 1.1 pk /* Window control and status registers; one set per socket */
330 1.1 pk #define STP4020_WCR0_REG(s,w) ((32 * (s)) + (4 * (w)) + STP4020_WCR0_IDX)
331 1.1 pk #define STP4020_WCR1_REG(s,w) ((32 * (s)) + (4 * (w)) + STP4020_WCR1_IDX)
332 1.1 pk
333 1.1 pk #endif /* _STP4020_REG_H */
334