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