atppcvar.h revision 1.4.2.2 1 1.4.2.2 skrll /* $NetBSD: atppcvar.h,v 1.4.2.2 2004/08/03 10:46:10 skrll Exp $ */
2 1.4.2.2 skrll
3 1.4.2.2 skrll /*-
4 1.4.2.2 skrll * Copyright (c) 2001 Alcove - Nicolas Souchu
5 1.4.2.2 skrll * All rights reserved.
6 1.4.2.2 skrll *
7 1.4.2.2 skrll * Redistribution and use in source and binary forms, with or without
8 1.4.2.2 skrll * modification, are permitted provided that the following conditions
9 1.4.2.2 skrll * are met:
10 1.4.2.2 skrll * 1. Redistributions of source code must retain the above copyright
11 1.4.2.2 skrll * notice, this list of conditions and the following disclaimer.
12 1.4.2.2 skrll * 2. Redistributions in binary form must reproduce the above copyright
13 1.4.2.2 skrll * notice, this list of conditions and the following disclaimer in the
14 1.4.2.2 skrll * documentation and/or other materials provided with the distribution.
15 1.4.2.2 skrll *
16 1.4.2.2 skrll * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.4.2.2 skrll * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.4.2.2 skrll * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.4.2.2 skrll * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.4.2.2 skrll * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.4.2.2 skrll * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.4.2.2 skrll * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.4.2.2 skrll * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.4.2.2 skrll * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.4.2.2 skrll * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.4.2.2 skrll * SUCH DAMAGE.
27 1.4.2.2 skrll *
28 1.4.2.2 skrll * FreeBSD: src/sys/isa/ppcreg.h,v 1.10.2.4 2001/10/02 05:21:45 nsouch Exp
29 1.4.2.2 skrll *
30 1.4.2.2 skrll */
31 1.4.2.2 skrll
32 1.4.2.2 skrll #ifndef __ATPPCVAR_H
33 1.4.2.2 skrll #define __ATPPCVAR_H
34 1.4.2.2 skrll
35 1.4.2.2 skrll #include <machine/bus.h>
36 1.4.2.2 skrll #include <machine/types.h>
37 1.4.2.2 skrll #include <sys/device.h>
38 1.4.2.2 skrll #include <sys/callout.h>
39 1.4.2.2 skrll
40 1.4.2.2 skrll #include <dev/ppbus/ppbus_conf.h>
41 1.4.2.2 skrll
42 1.4.2.2 skrll
43 1.4.2.2 skrll /* Maximum time to wait for device response */
44 1.4.2.2 skrll #define MAXBUSYWAIT (5 * (hz))
45 1.4.2.2 skrll
46 1.4.2.2 skrll /* Poll interval when wating for device to become ready */
47 1.4.2.2 skrll #define ATPPC_POLL ((hz)/10)
48 1.4.2.2 skrll
49 1.4.2.2 skrll /* Interrupt priority level for atppc device */
50 1.4.2.2 skrll #define IPL_ATPPC IPL_TTY
51 1.4.2.2 skrll #define splatppc spltty
52 1.4.2.2 skrll
53 1.4.2.2 skrll
54 1.4.2.2 skrll /* Diagnostic and verbose printing macros */
55 1.4.2.2 skrll
56 1.4.2.2 skrll #ifdef ATPPC_DEBUG
57 1.4.2.2 skrll extern int atppc_debug;
58 1.4.2.2 skrll #define ATPPC_DPRINTF(arg) if(atppc_debug) printf arg
59 1.4.2.2 skrll #else
60 1.4.2.2 skrll #define ATPPC_DPRINTF(arg)
61 1.4.2.2 skrll #endif
62 1.4.2.2 skrll
63 1.4.2.2 skrll #ifdef ATPPC_VERBOSE
64 1.4.2.2 skrll extern int atppc_verbose;
65 1.4.2.2 skrll #define ATPPC_VPRINTF(arg) if(atppc_verbose) printf arg
66 1.4.2.2 skrll #else
67 1.4.2.2 skrll #define ATPPC_VPRINTF(arg)
68 1.4.2.2 skrll #endif
69 1.4.2.2 skrll
70 1.4.2.2 skrll
71 1.4.2.2 skrll /* Flag used in DMA transfer */
72 1.4.2.2 skrll #define ATPPC_DMA_MODE_READ 0x0
73 1.4.2.2 skrll #define ATPPC_DMA_MODE_WRITE 0x1
74 1.4.2.2 skrll
75 1.4.2.2 skrll
76 1.4.2.2 skrll /* Flags passed via config */
77 1.4.2.2 skrll #define ATPPC_FLAG_DISABLE_INTR 0x01
78 1.4.2.2 skrll #define ATPPC_FLAG_DISABLE_DMA 0x02
79 1.4.2.2 skrll
80 1.4.2.2 skrll
81 1.4.2.2 skrll /* Locking for atppc device */
82 1.4.2.2 skrll #if defined(MULTIPROCESSOR) || defined (LOCKDEBUG)
83 1.4.2.2 skrll #include <sys/lock.h>
84 1.4.2.2 skrll #define ATPPC_SC_LOCK(sc) (&((sc)->sc_lock))
85 1.4.2.2 skrll #define ATPPC_LOCK_INIT(sc) simple_lock_init(ATPPC_SC_LOCK((sc)))
86 1.4.2.2 skrll #define ATPPC_LOCK(sc) simple_lock(ATPPC_SC_LOCK((sc)))
87 1.4.2.2 skrll #define ATPPC_UNLOCK(sc) simple_unlock(ATPPC_SC_LOCK((sc)))
88 1.4.2.2 skrll #else /* !(MULTIPROCESSOR) && !(LOCKDEBUG) */
89 1.4.2.2 skrll #define ATPPC_LOCK_INIT(sc)
90 1.4.2.2 skrll #define ATPPC_LOCK(sc)
91 1.4.2.2 skrll #define ATPPC_UNLOCK(sc)
92 1.4.2.2 skrll #define ATPPC_SC_LOCK(sc) NULL
93 1.4.2.2 skrll #endif /* MULTIPROCESSOR || LOCKDEBUG */
94 1.4.2.2 skrll
95 1.4.2.2 skrll /* Single softintr callback entry */
96 1.4.2.2 skrll struct atppc_handler_node {
97 1.4.2.2 skrll void (*func)(void *);
98 1.4.2.2 skrll void * arg;
99 1.4.2.2 skrll SLIST_ENTRY(atppc_handler_node) entries;
100 1.4.2.2 skrll };
101 1.4.2.2 skrll
102 1.4.2.2 skrll /* Generic structure to hold parallel port chipset info. */
103 1.4.2.2 skrll struct atppc_softc {
104 1.4.2.2 skrll /* Generic device attributes */
105 1.4.2.2 skrll struct device sc_dev;
106 1.4.2.2 skrll
107 1.4.2.2 skrll #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
108 1.4.2.2 skrll /* Simple lock */
109 1.4.2.2 skrll struct simplelock sc_lock;
110 1.4.2.2 skrll #endif
111 1.4.2.2 skrll
112 1.4.2.2 skrll /* Machine independent bus infrastructure */
113 1.4.2.2 skrll bus_space_tag_t sc_iot;
114 1.4.2.2 skrll bus_space_handle_t sc_ioh;
115 1.4.2.2 skrll bus_dma_tag_t sc_dmat;
116 1.4.2.2 skrll bus_dmamap_t sc_dmapt;
117 1.4.2.2 skrll bus_size_t sc_dma_maxsize;
118 1.4.2.2 skrll
119 1.4.2.2 skrll /* Child device */
120 1.4.2.2 skrll struct device * child;
121 1.4.2.2 skrll
122 1.4.2.2 skrll /* Opaque handle used for interrupt handler establishment */
123 1.4.2.2 skrll void * sc_ieh;
124 1.4.2.2 skrll
125 1.4.2.2 skrll /* List of soft interrupts to call */
126 1.4.2.2 skrll SLIST_HEAD(handler_list, atppc_handler_node) sc_handler_listhead;
127 1.4.2.2 skrll
128 1.4.2.2 skrll /* Input buffer: working pointers, and size in bytes. */
129 1.4.2.2 skrll char * sc_inb;
130 1.4.2.2 skrll char * sc_inbstart;
131 1.4.2.2 skrll u_int32_t sc_inb_nbytes;
132 1.4.2.2 skrll int sc_inerr;
133 1.4.2.2 skrll
134 1.4.2.2 skrll /* Output buffer pointer, working pointer, and size in bytes. */
135 1.4.2.2 skrll char * sc_outb;
136 1.4.2.2 skrll char * sc_outbstart;
137 1.4.2.2 skrll u_int32_t sc_outb_nbytes;
138 1.4.2.2 skrll int sc_outerr;
139 1.4.2.2 skrll
140 1.4.2.2 skrll /* DMA functions: setup by bus specific attach code */
141 1.4.2.2 skrll int (*sc_dma_start)(struct atppc_softc *, void *, u_int, u_int8_t);
142 1.4.2.2 skrll int (*sc_dma_finish)(struct atppc_softc *);
143 1.4.2.2 skrll int (*sc_dma_abort)(struct atppc_softc *);
144 1.4.2.2 skrll int (*sc_dma_malloc)(struct device *, caddr_t *, bus_addr_t *,
145 1.4.2.2 skrll bus_size_t);
146 1.4.2.2 skrll void (*sc_dma_free)(struct device *, caddr_t *, bus_addr_t *,
147 1.4.2.2 skrll bus_size_t);
148 1.4.2.2 skrll
149 1.4.2.2 skrll /* Microsequence related members */
150 1.4.2.2 skrll char * sc_ptr; /* microseq current pointer */
151 1.4.2.2 skrll int sc_accum; /* microseq accumulator */
152 1.4.2.2 skrll
153 1.4.2.2 skrll /* Device attachment state */
154 1.4.2.2 skrll #define ATPPC_ATTACHED 1
155 1.4.2.2 skrll #define ATPPC_NOATTACH 0
156 1.4.2.2 skrll u_int8_t sc_dev_ok;
157 1.4.2.2 skrll
158 1.4.2.2 skrll /*
159 1.4.2.2 skrll * Hardware capabilities flags: standard mode and nibble mode are
160 1.4.2.2 skrll * assumed to always be available since if they aren't you don't
161 1.4.2.2 skrll * HAVE a parallel port.
162 1.4.2.2 skrll */
163 1.4.2.2 skrll #define ATPPC_HAS_INTR 0x01 /* Interrupt available */
164 1.4.2.2 skrll #define ATPPC_HAS_DMA 0x02 /* DMA available */
165 1.4.2.2 skrll #define ATPPC_HAS_FIFO 0x04 /* FIFO available */
166 1.4.2.2 skrll #define ATPPC_HAS_PS2 0x08 /* PS2 mode capable */
167 1.4.2.2 skrll #define ATPPC_HAS_ECP 0x10 /* ECP mode available */
168 1.4.2.2 skrll #define ATPPC_HAS_EPP 0x20 /* EPP mode available */
169 1.4.2.2 skrll u_int8_t sc_has; /* Chipset detected capabilities */
170 1.4.2.2 skrll
171 1.4.2.2 skrll /* Flags specifying mode of chipset operation . */
172 1.4.2.2 skrll #define ATPPC_MODE_STD 0x01 /* Use centronics-compatible mode */
173 1.4.2.2 skrll #define ATPPC_MODE_PS2 0x02 /* Use PS2 mode */
174 1.4.2.2 skrll #define ATPPC_MODE_EPP 0x04 /* Use EPP mode */
175 1.4.2.2 skrll #define ATPPC_MODE_ECP 0x08 /* Use ECP mode */
176 1.4.2.2 skrll #define ATPPC_MODE_NIBBLE 0x10 /* Use nibble mode */
177 1.4.2.2 skrll #define ATPPC_MODE_FAST 0x20 /* Use Fast Centronics mode */
178 1.4.2.2 skrll u_int8_t sc_mode; /* Current operational mode */
179 1.4.2.2 skrll
180 1.4.2.2 skrll /* Flags which further define chipset operation */
181 1.4.2.2 skrll #define ATPPC_USE_INTR 0x01 /* Use interrupts */
182 1.4.2.2 skrll #define ATPPC_USE_DMA 0x02 /* Use DMA */
183 1.4.2.2 skrll u_int8_t sc_use; /* Capabilities to use */
184 1.4.2.2 skrll
185 1.4.2.2 skrll /* Parallel Port Chipset model. */
186 1.4.2.2 skrll #define SMC_LIKE 0
187 1.4.2.2 skrll #define SMC_37C665GT 1
188 1.4.2.2 skrll #define SMC_37C666GT 2
189 1.4.2.2 skrll #define NS_PC87332 3
190 1.4.2.2 skrll #define NS_PC87306 4
191 1.4.2.2 skrll #define INTEL_820191AA 5 /* XXX not implemented */
192 1.4.2.2 skrll #define GENERIC 6
193 1.4.2.2 skrll #define WINB_W83877F 7
194 1.4.2.2 skrll #define WINB_W83877AF 8
195 1.4.2.2 skrll #define WINB_UNKNOWN 9
196 1.4.2.2 skrll #define NS_PC87334 10
197 1.4.2.2 skrll #define SMC_37C935 11
198 1.4.2.2 skrll #define NS_PC87303 12
199 1.4.2.2 skrll u_int8_t sc_model; /* chipset model */
200 1.4.2.2 skrll
201 1.4.2.2 skrll /* EPP mode */
202 1.4.2.2 skrll #define ATPPC_EPP_1_9 0x0
203 1.4.2.2 skrll #define ATPPC_EPP_1_7 0x1
204 1.4.2.2 skrll u_int8_t sc_epp;
205 1.4.2.2 skrll
206 1.4.2.2 skrll /* Parallel Port Chipset Type. SMC versus GENERIC (others) */
207 1.4.2.2 skrll #define ATPPC_TYPE_SMCLIKE 0
208 1.4.2.2 skrll #define ATPPC_TYPE_GENERIC 1
209 1.4.2.2 skrll u_int8_t sc_type; /* generic or smclike chipset type */
210 1.4.2.2 skrll
211 1.4.2.2 skrll /* Stored register values after an interrupt occurs */
212 1.4.2.2 skrll u_int8_t sc_ecr_intr;
213 1.4.2.2 skrll u_int8_t sc_ctr_intr;
214 1.4.2.2 skrll u_int8_t sc_str_intr;
215 1.4.2.2 skrll
216 1.4.2.2 skrll #define ATPPC_IRQ_NONE 0x0
217 1.4.2.2 skrll #define ATPPC_IRQ_nACK 0x1
218 1.4.2.2 skrll #define ATPPC_IRQ_DMA 0x2
219 1.4.2.2 skrll #define ATPPC_IRQ_FIFO 0x4
220 1.4.2.2 skrll #define ATPPC_IRQ_nFAULT 0x8
221 1.4.2.2 skrll u_int8_t sc_irqstat; /* Record irq settings */
222 1.4.2.2 skrll
223 1.4.2.2 skrll #define ATPPC_DMA_INIT 0x01
224 1.4.2.2 skrll #define ATPPC_DMA_STARTED 0x02
225 1.4.2.2 skrll #define ATPPC_DMA_COMPLETE 0x03
226 1.4.2.2 skrll #define ATPPC_DMA_INTERRUPTED 0x04
227 1.4.2.2 skrll #define ATPPC_DMA_ERROR 0x05
228 1.4.2.2 skrll u_int8_t sc_dmastat; /* Record dma state */
229 1.4.2.2 skrll
230 1.4.2.2 skrll #define ATPPC_PWORD_MASK 0x30
231 1.4.2.2 skrll #define ATPPC_PWORD_16 0x00
232 1.4.2.2 skrll #define ATPPC_PWORD_8 0x10
233 1.4.2.2 skrll #define ATPPC_PWORD_32 0x20
234 1.4.2.2 skrll u_int8_t sc_pword; /* PWord size: used for FIFO DMA transfers */
235 1.4.2.2 skrll u_int8_t sc_fifo; /* FIFO size */
236 1.4.2.2 skrll
237 1.4.2.2 skrll /* Indicates number of PWords in FIFO queues that generate interrupt */
238 1.4.2.2 skrll u_int8_t sc_wthr; /* writeIntrThresold */
239 1.4.2.2 skrll u_int8_t sc_rthr; /* readIntrThresold */
240 1.4.2.2 skrll };
241 1.4.2.2 skrll
242 1.4.2.2 skrll
243 1.4.2.2 skrll
244 1.4.2.2 skrll #ifdef _KERNEL
245 1.4.2.2 skrll
246 1.4.2.2 skrll /* Function prototypes */
247 1.4.2.2 skrll
248 1.4.2.2 skrll /* Soft config attach/detach routines */
249 1.4.2.2 skrll void atppc_sc_attach __P((struct atppc_softc *));
250 1.4.2.2 skrll int atppc_sc_detach __P((struct atppc_softc *, int));
251 1.4.2.2 skrll
252 1.4.2.2 skrll /* Detection routines */
253 1.4.2.2 skrll int atppc_detect_port __P((bus_space_tag_t, bus_space_handle_t));
254 1.4.2.2 skrll
255 1.4.2.2 skrll /* Interrupt handler for atppc device */
256 1.4.2.2 skrll int atppcintr __P((void *));
257 1.4.2.2 skrll
258 1.4.2.2 skrll #endif /* _KERNEL */
259 1.4.2.2 skrll
260 1.4.2.2 skrll #endif /* __ATPPCVAR_H */
261