atppcvar.h revision 1.13 1 1.13 andvar /* $NetBSD: atppcvar.h,v 1.13 2024/08/13 16:23:48 andvar 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.3 bjh21 * 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.9 ad #include <sys/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.12 jakllsch #include <sys/mutex.h>
40 1.12 jakllsch #include <sys/condvar.h>
41 1.1 jdolecek
42 1.1 jdolecek #include <dev/ppbus/ppbus_conf.h>
43 1.1 jdolecek
44 1.1 jdolecek
45 1.1 jdolecek /* Maximum time to wait for device response */
46 1.1 jdolecek #define MAXBUSYWAIT (5 * (hz))
47 1.1 jdolecek
48 1.12 jakllsch /* Poll interval when waiting for device to become ready */
49 1.1 jdolecek #define ATPPC_POLL ((hz)/10)
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 /* Single softintr callback entry */
79 1.1 jdolecek struct atppc_handler_node {
80 1.1 jdolecek void (*func)(void *);
81 1.8 christos void *arg;
82 1.1 jdolecek SLIST_ENTRY(atppc_handler_node) entries;
83 1.1 jdolecek };
84 1.1 jdolecek
85 1.1 jdolecek /* Generic structure to hold parallel port chipset info. */
86 1.1 jdolecek struct atppc_softc {
87 1.1 jdolecek /* Generic device attributes */
88 1.10 cegger device_t sc_dev;
89 1.1 jdolecek
90 1.12 jakllsch kmutex_t sc_lock;
91 1.12 jakllsch kcondvar_t sc_out_cv;
92 1.12 jakllsch kcondvar_t sc_in_cv;
93 1.1 jdolecek
94 1.1 jdolecek /* Machine independent bus infrastructure */
95 1.1 jdolecek bus_space_tag_t sc_iot;
96 1.1 jdolecek bus_space_handle_t sc_ioh;
97 1.1 jdolecek bus_dma_tag_t sc_dmat;
98 1.1 jdolecek bus_dmamap_t sc_dmapt;
99 1.1 jdolecek bus_size_t sc_dma_maxsize;
100 1.1 jdolecek
101 1.1 jdolecek /* Child device */
102 1.10 cegger device_t child;
103 1.1 jdolecek
104 1.1 jdolecek /* Opaque handle used for interrupt handler establishment */
105 1.8 christos void *sc_ieh;
106 1.1 jdolecek
107 1.1 jdolecek /* List of soft interrupts to call */
108 1.1 jdolecek SLIST_HEAD(handler_list, atppc_handler_node) sc_handler_listhead;
109 1.1 jdolecek
110 1.1 jdolecek /* Input buffer: working pointers, and size in bytes. */
111 1.1 jdolecek char * sc_inb;
112 1.1 jdolecek char * sc_inbstart;
113 1.1 jdolecek u_int32_t sc_inb_nbytes;
114 1.1 jdolecek int sc_inerr;
115 1.1 jdolecek
116 1.1 jdolecek /* Output buffer pointer, working pointer, and size in bytes. */
117 1.1 jdolecek char * sc_outb;
118 1.1 jdolecek char * sc_outbstart;
119 1.1 jdolecek u_int32_t sc_outb_nbytes;
120 1.1 jdolecek int sc_outerr;
121 1.1 jdolecek
122 1.1 jdolecek /* DMA functions: setup by bus specific attach code */
123 1.1 jdolecek int (*sc_dma_start)(struct atppc_softc *, void *, u_int, u_int8_t);
124 1.1 jdolecek int (*sc_dma_finish)(struct atppc_softc *);
125 1.1 jdolecek int (*sc_dma_abort)(struct atppc_softc *);
126 1.10 cegger int (*sc_dma_malloc)(device_t, void **, bus_addr_t *,
127 1.1 jdolecek bus_size_t);
128 1.10 cegger void (*sc_dma_free)(device_t, void **, bus_addr_t *,
129 1.1 jdolecek bus_size_t);
130 1.6 perry
131 1.1 jdolecek /* Microsequence related members */
132 1.1 jdolecek char * sc_ptr; /* microseq current pointer */
133 1.1 jdolecek int sc_accum; /* microseq accumulator */
134 1.1 jdolecek
135 1.1 jdolecek /* Device attachment state */
136 1.1 jdolecek #define ATPPC_ATTACHED 1
137 1.1 jdolecek #define ATPPC_NOATTACH 0
138 1.1 jdolecek u_int8_t sc_dev_ok;
139 1.1 jdolecek
140 1.6 perry /*
141 1.6 perry * Hardware capabilities flags: standard mode and nibble mode are
142 1.6 perry * assumed to always be available since if they aren't you don't
143 1.1 jdolecek * HAVE a parallel port.
144 1.1 jdolecek */
145 1.1 jdolecek #define ATPPC_HAS_INTR 0x01 /* Interrupt available */
146 1.1 jdolecek #define ATPPC_HAS_DMA 0x02 /* DMA available */
147 1.1 jdolecek #define ATPPC_HAS_FIFO 0x04 /* FIFO available */
148 1.1 jdolecek #define ATPPC_HAS_PS2 0x08 /* PS2 mode capable */
149 1.1 jdolecek #define ATPPC_HAS_ECP 0x10 /* ECP mode available */
150 1.1 jdolecek #define ATPPC_HAS_EPP 0x20 /* EPP mode available */
151 1.1 jdolecek u_int8_t sc_has; /* Chipset detected capabilities */
152 1.1 jdolecek
153 1.1 jdolecek /* Flags specifying mode of chipset operation . */
154 1.1 jdolecek #define ATPPC_MODE_STD 0x01 /* Use centronics-compatible mode */
155 1.6 perry #define ATPPC_MODE_PS2 0x02 /* Use PS2 mode */
156 1.1 jdolecek #define ATPPC_MODE_EPP 0x04 /* Use EPP mode */
157 1.1 jdolecek #define ATPPC_MODE_ECP 0x08 /* Use ECP mode */
158 1.1 jdolecek #define ATPPC_MODE_NIBBLE 0x10 /* Use nibble mode */
159 1.1 jdolecek #define ATPPC_MODE_FAST 0x20 /* Use Fast Centronics mode */
160 1.1 jdolecek u_int8_t sc_mode; /* Current operational mode */
161 1.1 jdolecek
162 1.1 jdolecek /* Flags which further define chipset operation */
163 1.1 jdolecek #define ATPPC_USE_INTR 0x01 /* Use interrupts */
164 1.1 jdolecek #define ATPPC_USE_DMA 0x02 /* Use DMA */
165 1.1 jdolecek u_int8_t sc_use; /* Capabilities to use */
166 1.1 jdolecek
167 1.1 jdolecek /* Parallel Port Chipset model. */
168 1.1 jdolecek #define SMC_LIKE 0
169 1.1 jdolecek #define SMC_37C665GT 1
170 1.1 jdolecek #define SMC_37C666GT 2
171 1.1 jdolecek #define NS_PC87332 3
172 1.1 jdolecek #define NS_PC87306 4
173 1.1 jdolecek #define INTEL_820191AA 5 /* XXX not implemented */
174 1.1 jdolecek #define GENERIC 6
175 1.1 jdolecek #define WINB_W83877F 7
176 1.1 jdolecek #define WINB_W83877AF 8
177 1.1 jdolecek #define WINB_UNKNOWN 9
178 1.1 jdolecek #define NS_PC87334 10
179 1.1 jdolecek #define SMC_37C935 11
180 1.1 jdolecek #define NS_PC87303 12
181 1.1 jdolecek u_int8_t sc_model; /* chipset model */
182 1.1 jdolecek
183 1.1 jdolecek /* EPP mode */
184 1.1 jdolecek #define ATPPC_EPP_1_9 0x0
185 1.1 jdolecek #define ATPPC_EPP_1_7 0x1
186 1.1 jdolecek u_int8_t sc_epp;
187 1.1 jdolecek
188 1.1 jdolecek /* Parallel Port Chipset Type. SMC versus GENERIC (others) */
189 1.1 jdolecek #define ATPPC_TYPE_SMCLIKE 0
190 1.1 jdolecek #define ATPPC_TYPE_GENERIC 1
191 1.1 jdolecek u_int8_t sc_type; /* generic or smclike chipset type */
192 1.1 jdolecek
193 1.1 jdolecek /* Stored register values after an interrupt occurs */
194 1.1 jdolecek u_int8_t sc_ecr_intr;
195 1.1 jdolecek u_int8_t sc_ctr_intr;
196 1.1 jdolecek u_int8_t sc_str_intr;
197 1.1 jdolecek
198 1.1 jdolecek #define ATPPC_IRQ_NONE 0x0
199 1.1 jdolecek #define ATPPC_IRQ_nACK 0x1
200 1.1 jdolecek #define ATPPC_IRQ_DMA 0x2
201 1.1 jdolecek #define ATPPC_IRQ_FIFO 0x4
202 1.1 jdolecek #define ATPPC_IRQ_nFAULT 0x8
203 1.1 jdolecek u_int8_t sc_irqstat; /* Record irq settings */
204 1.1 jdolecek
205 1.1 jdolecek #define ATPPC_DMA_INIT 0x01
206 1.1 jdolecek #define ATPPC_DMA_STARTED 0x02
207 1.1 jdolecek #define ATPPC_DMA_COMPLETE 0x03
208 1.1 jdolecek #define ATPPC_DMA_INTERRUPTED 0x04
209 1.1 jdolecek #define ATPPC_DMA_ERROR 0x05
210 1.1 jdolecek u_int8_t sc_dmastat; /* Record dma state */
211 1.1 jdolecek
212 1.1 jdolecek #define ATPPC_PWORD_MASK 0x30
213 1.1 jdolecek #define ATPPC_PWORD_16 0x00
214 1.1 jdolecek #define ATPPC_PWORD_8 0x10
215 1.1 jdolecek #define ATPPC_PWORD_32 0x20
216 1.1 jdolecek u_int8_t sc_pword; /* PWord size: used for FIFO DMA transfers */
217 1.1 jdolecek u_int8_t sc_fifo; /* FIFO size */
218 1.1 jdolecek
219 1.1 jdolecek /* Indicates number of PWords in FIFO queues that generate interrupt */
220 1.13 andvar u_int8_t sc_wthr; /* writeIntrThreshold */
221 1.13 andvar u_int8_t sc_rthr; /* readIntrThreshold */
222 1.1 jdolecek };
223 1.1 jdolecek
224 1.1 jdolecek
225 1.1 jdolecek
226 1.1 jdolecek #ifdef _KERNEL
227 1.1 jdolecek
228 1.1 jdolecek /* Function prototypes */
229 1.1 jdolecek
230 1.1 jdolecek /* Soft config attach/detach routines */
231 1.5 perry void atppc_sc_attach(struct atppc_softc *);
232 1.5 perry int atppc_sc_detach(struct atppc_softc *, int);
233 1.1 jdolecek
234 1.1 jdolecek /* Detection routines */
235 1.5 perry int atppc_detect_port(bus_space_tag_t, bus_space_handle_t);
236 1.1 jdolecek
237 1.1 jdolecek /* Interrupt handler for atppc device */
238 1.5 perry int atppcintr(void *);
239 1.1 jdolecek
240 1.1 jdolecek #endif /* _KERNEL */
241 1.1 jdolecek
242 1.6 perry #endif /* __ATPPCVAR_H */
243