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