pi1ppcvar.h revision 1.1.18.2 1 1.1.18.2 yamt /* $NetBSD: pi1ppcvar.h,v 1.1.18.2 2006/06/21 14:55:30 yamt Exp $ */
2 1.1.18.2 yamt
3 1.1.18.2 yamt /*-
4 1.1.18.2 yamt * Copyright (c) 2001 Alcove - Nicolas Souchu
5 1.1.18.2 yamt * Copyright (c) 2005 Joe Britt <britt (at) danger.com> - SGI PI1 version
6 1.1.18.2 yamt * All rights reserved.
7 1.1.18.2 yamt *
8 1.1.18.2 yamt * Redistribution and use in source and binary forms, with or without
9 1.1.18.2 yamt * modification, are permitted provided that the following conditions
10 1.1.18.2 yamt * are met:
11 1.1.18.2 yamt * 1. Redistributions of source code must retain the above copyright
12 1.1.18.2 yamt * notice, this list of conditions and the following disclaimer.
13 1.1.18.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
14 1.1.18.2 yamt * notice, this list of conditions and the following disclaimer in the
15 1.1.18.2 yamt * documentation and/or other materials provided with the distribution.
16 1.1.18.2 yamt *
17 1.1.18.2 yamt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 1.1.18.2 yamt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 1.1.18.2 yamt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 1.1.18.2 yamt * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 1.1.18.2 yamt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 1.1.18.2 yamt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 1.1.18.2 yamt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 1.1.18.2 yamt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 1.1.18.2 yamt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 1.1.18.2 yamt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 1.1.18.2 yamt * SUCH DAMAGE.
28 1.1.18.2 yamt *
29 1.1.18.2 yamt * FreeBSD: src/sys/isa/ppcreg.h,v 1.10.2.4 2001/10/02 05:21:45 nsouch Exp
30 1.1.18.2 yamt *
31 1.1.18.2 yamt */
32 1.1.18.2 yamt
33 1.1.18.2 yamt #ifndef __PI1PPCVAR_H
34 1.1.18.2 yamt #define __PI1PPCVAR_H
35 1.1.18.2 yamt
36 1.1.18.2 yamt #include <machine/bus.h>
37 1.1.18.2 yamt #include <machine/types.h>
38 1.1.18.2 yamt #include <sys/device.h>
39 1.1.18.2 yamt #include <sys/callout.h>
40 1.1.18.2 yamt
41 1.1.18.2 yamt #include <dev/ppbus/ppbus_conf.h>
42 1.1.18.2 yamt
43 1.1.18.2 yamt
44 1.1.18.2 yamt /* Maximum time to wait for device response */
45 1.1.18.2 yamt #define MAXBUSYWAIT (5 * (hz))
46 1.1.18.2 yamt
47 1.1.18.2 yamt /* Poll interval when wating for device to become ready */
48 1.1.18.2 yamt #define PI1PPC_POLL ((hz)/10)
49 1.1.18.2 yamt
50 1.1.18.2 yamt /* Interrupt priority level for pi1ppc device */
51 1.1.18.2 yamt #define IPL_PI1PPC IPL_TTY
52 1.1.18.2 yamt #define splpi1ppc spltty
53 1.1.18.2 yamt
54 1.1.18.2 yamt
55 1.1.18.2 yamt /* Diagnostic and verbose printing macros */
56 1.1.18.2 yamt
57 1.1.18.2 yamt #ifdef PI1PPC_DEBUG
58 1.1.18.2 yamt extern int pi1ppc_debug;
59 1.1.18.2 yamt #define PI1PPC_DPRINTF(arg) if(pi1ppc_debug) printf arg
60 1.1.18.2 yamt #else
61 1.1.18.2 yamt #define PI1PPC_DPRINTF(arg)
62 1.1.18.2 yamt #endif
63 1.1.18.2 yamt
64 1.1.18.2 yamt #ifdef PI1PPC_VERBOSE
65 1.1.18.2 yamt extern int pi1ppc_verbose;
66 1.1.18.2 yamt #define PI1PPC_VPRINTF(arg) if(pi1ppc_verbose) printf arg
67 1.1.18.2 yamt #else
68 1.1.18.2 yamt #define PI1PPC_VPRINTF(arg)
69 1.1.18.2 yamt #endif
70 1.1.18.2 yamt
71 1.1.18.2 yamt
72 1.1.18.2 yamt /* Flag used in DMA transfer */
73 1.1.18.2 yamt #define PI1PPC_DMA_MODE_READ 0x0
74 1.1.18.2 yamt #define PI1PPC_DMA_MODE_WRITE 0x1
75 1.1.18.2 yamt
76 1.1.18.2 yamt
77 1.1.18.2 yamt /* Flags passed via config */
78 1.1.18.2 yamt #define PI1PPC_FLAG_DISABLE_INTR 0x01
79 1.1.18.2 yamt #define PI1PPC_FLAG_DISABLE_DMA 0x02
80 1.1.18.2 yamt
81 1.1.18.2 yamt
82 1.1.18.2 yamt /* Locking for pi1ppc device */
83 1.1.18.2 yamt #if defined(MULTIPROCESSOR) || defined (LOCKDEBUG)
84 1.1.18.2 yamt #include <sys/lock.h>
85 1.1.18.2 yamt #define PI1PPC_SC_LOCK(sc) (&((sc)->sc_lock))
86 1.1.18.2 yamt #define PI1PPC_LOCK_INIT(sc) simple_lock_init(PI1PPC_SC_LOCK((sc)))
87 1.1.18.2 yamt #define PI1PPC_LOCK(sc) simple_lock(PI1PPC_SC_LOCK((sc)))
88 1.1.18.2 yamt #define PI1PPC_UNLOCK(sc) simple_unlock(PI1PPC_SC_LOCK((sc)))
89 1.1.18.2 yamt #else /* !(MULTIPROCESSOR) && !(LOCKDEBUG) */
90 1.1.18.2 yamt #define PI1PPC_LOCK_INIT(sc)
91 1.1.18.2 yamt #define PI1PPC_LOCK(sc)
92 1.1.18.2 yamt #define PI1PPC_UNLOCK(sc)
93 1.1.18.2 yamt #define PI1PPC_SC_LOCK(sc) NULL
94 1.1.18.2 yamt #endif /* MULTIPROCESSOR || LOCKDEBUG */
95 1.1.18.2 yamt
96 1.1.18.2 yamt /* Single softintr callback entry */
97 1.1.18.2 yamt struct pi1ppc_handler_node {
98 1.1.18.2 yamt void (*func)(void *);
99 1.1.18.2 yamt void * arg;
100 1.1.18.2 yamt SLIST_ENTRY(pi1ppc_handler_node) entries;
101 1.1.18.2 yamt };
102 1.1.18.2 yamt
103 1.1.18.2 yamt /* Generic structure to hold parallel port chipset info. */
104 1.1.18.2 yamt struct pi1ppc_softc {
105 1.1.18.2 yamt /* Generic device attributes */
106 1.1.18.2 yamt struct device sc_dev;
107 1.1.18.2 yamt
108 1.1.18.2 yamt #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
109 1.1.18.2 yamt /* Simple lock */
110 1.1.18.2 yamt struct simplelock sc_lock;
111 1.1.18.2 yamt #endif
112 1.1.18.2 yamt
113 1.1.18.2 yamt /* Machine independent bus infrastructure */
114 1.1.18.2 yamt bus_space_tag_t sc_iot;
115 1.1.18.2 yamt bus_space_handle_t sc_ioh;
116 1.1.18.2 yamt bus_dma_tag_t sc_dmat;
117 1.1.18.2 yamt bus_dmamap_t sc_dmapt;
118 1.1.18.2 yamt bus_size_t sc_dma_maxsize;
119 1.1.18.2 yamt
120 1.1.18.2 yamt /* Child device */
121 1.1.18.2 yamt struct device * child;
122 1.1.18.2 yamt
123 1.1.18.2 yamt /* Opaque handle used for interrupt handler establishment */
124 1.1.18.2 yamt void * sc_ieh;
125 1.1.18.2 yamt
126 1.1.18.2 yamt /* List of soft interrupts to call */
127 1.1.18.2 yamt SLIST_HEAD(handler_list, pi1ppc_handler_node) sc_handler_listhead;
128 1.1.18.2 yamt
129 1.1.18.2 yamt /* Input buffer: working pointers, and size in bytes. */
130 1.1.18.2 yamt char * sc_inb;
131 1.1.18.2 yamt char * sc_inbstart;
132 1.1.18.2 yamt u_int32_t sc_inb_nbytes;
133 1.1.18.2 yamt int sc_inerr;
134 1.1.18.2 yamt
135 1.1.18.2 yamt /* Output buffer pointer, working pointer, and size in bytes. */
136 1.1.18.2 yamt char * sc_outb;
137 1.1.18.2 yamt char * sc_outbstart;
138 1.1.18.2 yamt u_int32_t sc_outb_nbytes;
139 1.1.18.2 yamt int sc_outerr;
140 1.1.18.2 yamt
141 1.1.18.2 yamt /* DMA functions: setup by bus specific attach code */
142 1.1.18.2 yamt int (*sc_dma_start)(struct pi1ppc_softc *, void *, u_int, u_int8_t);
143 1.1.18.2 yamt int (*sc_dma_finish)(struct pi1ppc_softc *);
144 1.1.18.2 yamt int (*sc_dma_abort)(struct pi1ppc_softc *);
145 1.1.18.2 yamt int (*sc_dma_malloc)(struct device *, caddr_t *, bus_addr_t *,
146 1.1.18.2 yamt bus_size_t);
147 1.1.18.2 yamt void (*sc_dma_free)(struct device *, caddr_t *, bus_addr_t *,
148 1.1.18.2 yamt bus_size_t);
149 1.1.18.2 yamt
150 1.1.18.2 yamt /* Microsequence related members */
151 1.1.18.2 yamt char * sc_ptr; /* microseq current pointer */
152 1.1.18.2 yamt int sc_accum; /* microseq accumulator */
153 1.1.18.2 yamt
154 1.1.18.2 yamt /* Device attachment state */
155 1.1.18.2 yamt #define PI1PPC_ATTACHED 1
156 1.1.18.2 yamt #define PI1PPC_NOATTACH 0
157 1.1.18.2 yamt u_int8_t sc_dev_ok;
158 1.1.18.2 yamt
159 1.1.18.2 yamt /*
160 1.1.18.2 yamt * Hardware capabilities flags: standard mode and nibble mode are
161 1.1.18.2 yamt * assumed to always be available since if they aren't you don't
162 1.1.18.2 yamt * HAVE a parallel port.
163 1.1.18.2 yamt */
164 1.1.18.2 yamt #define PI1PPC_HAS_INTR 0x01 /* Interrupt available */
165 1.1.18.2 yamt #define PI1PPC_HAS_DMA 0x02 /* DMA available */
166 1.1.18.2 yamt #define PI1PPC_HAS_FIFO 0x04 /* FIFO available */
167 1.1.18.2 yamt #define PI1PPC_HAS_PS2 0x08 /* PS2 mode capable */
168 1.1.18.2 yamt u_int8_t sc_has; /* Chipset detected capabilities */
169 1.1.18.2 yamt
170 1.1.18.2 yamt /* Flags specifying mode of chipset operation . */
171 1.1.18.2 yamt #define PI1PPC_MODE_STD 0x01 /* Use centronics-compatible mode */
172 1.1.18.2 yamt #define PI1PPC_MODE_PS2 0x02 /* Use PS2 mode */
173 1.1.18.2 yamt #define PI1PPC_MODE_NIBBLE 0x10 /* Use nibble mode */
174 1.1.18.2 yamt u_int8_t sc_mode; /* Current operational mode */
175 1.1.18.2 yamt
176 1.1.18.2 yamt /* Flags which further define chipset operation */
177 1.1.18.2 yamt #define PI1PPC_USE_INTR 0x01 /* Use interrupts */
178 1.1.18.2 yamt #define PI1PPC_USE_DMA 0x02 /* Use DMA */
179 1.1.18.2 yamt u_int8_t sc_use; /* Capabilities to use */
180 1.1.18.2 yamt
181 1.1.18.2 yamt /* Parallel Port Chipset model. */
182 1.1.18.2 yamt #define GENERIC 6
183 1.1.18.2 yamt u_int8_t sc_model; /* chipset model */
184 1.1.18.2 yamt
185 1.1.18.2 yamt /* EPP mode - UNUSED */
186 1.1.18.2 yamt u_int8_t sc_epp;
187 1.1.18.2 yamt
188 1.1.18.2 yamt /* Parallel Port Chipset Type. Only Indy-style needed? */
189 1.1.18.2 yamt #define PI1PPC_TYPE_INDY 0
190 1.1.18.2 yamt u_int8_t sc_type;
191 1.1.18.2 yamt
192 1.1.18.2 yamt /* Stored register values after an interrupt occurs */
193 1.1.18.2 yamt u_int8_t sc_ecr_intr;
194 1.1.18.2 yamt u_int8_t sc_ctr_intr;
195 1.1.18.2 yamt u_int8_t sc_str_intr;
196 1.1.18.2 yamt
197 1.1.18.2 yamt #define PI1PPC_IRQ_NONE 0x0
198 1.1.18.2 yamt #define PI1PPC_IRQ_nACK 0x1
199 1.1.18.2 yamt #define PI1PPC_IRQ_DMA 0x2
200 1.1.18.2 yamt #define PI1PPC_IRQ_FIFO 0x4
201 1.1.18.2 yamt #define PI1PPC_IRQ_nFAULT 0x8
202 1.1.18.2 yamt u_int8_t sc_irqstat; /* Record irq settings */
203 1.1.18.2 yamt
204 1.1.18.2 yamt #define PI1PPC_DMA_INIT 0x01
205 1.1.18.2 yamt #define PI1PPC_DMA_STARTED 0x02
206 1.1.18.2 yamt #define PI1PPC_DMA_COMPLETE 0x03
207 1.1.18.2 yamt #define PI1PPC_DMA_INTERRUPTED 0x04
208 1.1.18.2 yamt #define PI1PPC_DMA_ERROR 0x05
209 1.1.18.2 yamt u_int8_t sc_dmastat; /* Record dma state */
210 1.1.18.2 yamt
211 1.1.18.2 yamt #define PI1PPC_PWORD_MASK 0x30
212 1.1.18.2 yamt #define PI1PPC_PWORD_16 0x00
213 1.1.18.2 yamt #define PI1PPC_PWORD_8 0x10
214 1.1.18.2 yamt #define PI1PPC_PWORD_32 0x20
215 1.1.18.2 yamt u_int8_t sc_pword; /* PWord size: used for FIFO DMA transfers */
216 1.1.18.2 yamt u_int8_t sc_fifo; /* FIFO size */
217 1.1.18.2 yamt
218 1.1.18.2 yamt /* Indicates number of PWords in FIFO queues that generate interrupt */
219 1.1.18.2 yamt u_int8_t sc_wthr; /* writeIntrThresold */
220 1.1.18.2 yamt u_int8_t sc_rthr; /* readIntrThresold */
221 1.1.18.2 yamt };
222 1.1.18.2 yamt
223 1.1.18.2 yamt
224 1.1.18.2 yamt
225 1.1.18.2 yamt #ifdef _KERNEL
226 1.1.18.2 yamt
227 1.1.18.2 yamt /* Function prototypes */
228 1.1.18.2 yamt
229 1.1.18.2 yamt /* Soft config attach/detach routines */
230 1.1.18.2 yamt void pi1ppc_sc_attach(struct pi1ppc_softc *);
231 1.1.18.2 yamt int pi1ppc_sc_detach(struct pi1ppc_softc *, int);
232 1.1.18.2 yamt
233 1.1.18.2 yamt /* Detection routines */
234 1.1.18.2 yamt int pi1ppc_detect_port(bus_space_tag_t, bus_space_handle_t);
235 1.1.18.2 yamt
236 1.1.18.2 yamt /* Interrupt handler for pi1ppc device */
237 1.1.18.2 yamt int pi1ppcintr(void *);
238 1.1.18.2 yamt
239 1.1.18.2 yamt #endif /* _KERNEL */
240 1.1.18.2 yamt
241 1.1.18.2 yamt #endif /* __PI1PPCVAR_H */
242