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