maplevar.h revision 1.8 1 1.8 tsutsui /* $NetBSD: maplevar.h,v 1.8 2005/02/19 15:37:35 tsutsui Exp $ */
2 1.5 itohy
3 1.5 itohy /*-
4 1.5 itohy * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 1.5 itohy * All rights reserved.
6 1.5 itohy *
7 1.5 itohy * This code is derived from software contributed to The NetBSD Foundation
8 1.5 itohy * by ITOH Yasufumi.
9 1.5 itohy *
10 1.5 itohy * Redistribution and use in source and binary forms, with or without
11 1.5 itohy * modification, are permitted provided that the following conditions
12 1.5 itohy * are met:
13 1.5 itohy * 1. Redistributions of source code must retain the above copyright
14 1.5 itohy * notice, this list of conditions and the following disclaimer.
15 1.5 itohy * 2. Redistributions in binary form must reproduce the above copyright
16 1.5 itohy * notice, this list of conditions and the following disclaimer in the
17 1.5 itohy * documentation and/or other materials provided with the distribution.
18 1.5 itohy * 3. All advertising materials mentioning features or use of this software
19 1.5 itohy * must display the following acknowledgement:
20 1.5 itohy * This product includes software developed by the NetBSD
21 1.5 itohy * Foundation, Inc. and its contributors.
22 1.5 itohy * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.5 itohy * contributors may be used to endorse or promote products derived
24 1.5 itohy * from this software without specific prior written permission.
25 1.5 itohy *
26 1.5 itohy * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.5 itohy * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.5 itohy * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.5 itohy * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.5 itohy * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.5 itohy * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.5 itohy * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.5 itohy * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.5 itohy * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.5 itohy * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.5 itohy * POSSIBILITY OF SUCH DAMAGE.
37 1.5 itohy */
38 1.5 itohy
39 1.2 marcus /*-
40 1.1 marcus * Copyright (c) 2001 Marcus Comstedt
41 1.1 marcus * All rights reserved.
42 1.1 marcus *
43 1.1 marcus * Redistribution and use in source and binary forms, with or without
44 1.1 marcus * modification, are permitted provided that the following conditions
45 1.1 marcus * are met:
46 1.1 marcus * 1. Redistributions of source code must retain the above copyright
47 1.1 marcus * notice, this list of conditions and the following disclaimer.
48 1.1 marcus * 2. Redistributions in binary form must reproduce the above copyright
49 1.1 marcus * notice, this list of conditions and the following disclaimer in the
50 1.1 marcus * documentation and/or other materials provided with the distribution.
51 1.1 marcus * 3. All advertising materials mentioning features or use of this software
52 1.1 marcus * must display the following acknowledgement:
53 1.2 marcus * This product includes software developed by Marcus Comstedt.
54 1.2 marcus * 4. Neither the name of The NetBSD Foundation nor the names of its
55 1.2 marcus * contributors may be used to endorse or promote products derived
56 1.2 marcus * from this software without specific prior written permission.
57 1.1 marcus *
58 1.2 marcus * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
59 1.2 marcus * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
60 1.2 marcus * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
61 1.2 marcus * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
62 1.2 marcus * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
63 1.2 marcus * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
64 1.2 marcus * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
65 1.2 marcus * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
66 1.2 marcus * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67 1.2 marcus * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
68 1.2 marcus * POSSIBILITY OF SUCH DAMAGE.
69 1.1 marcus */
70 1.1 marcus
71 1.5 itohy #include <sys/queue.h>
72 1.5 itohy
73 1.5 itohy #define MAPLE_PORTS 4
74 1.5 itohy #define MAPLE_SUBUNITS 6
75 1.5 itohy
76 1.5 itohy #define MAPLE_NFUNC 32
77 1.5 itohy
78 1.5 itohy struct maple_func {
79 1.5 itohy int f_funcno;
80 1.5 itohy struct maple_unit *f_unit;
81 1.5 itohy struct device *f_dev;
82 1.5 itohy
83 1.5 itohy /* callback */
84 1.5 itohy void (*f_callback)(void *, struct maple_response *,
85 1.5 itohy int /*len*/, int /*flags*/);
86 1.5 itohy void *f_arg;
87 1.5 itohy
88 1.8 tsutsui uint32_t f_work; /* for periodic GETCOND and ping */
89 1.5 itohy
90 1.5 itohy /* periodic command request */
91 1.5 itohy enum maple_periodic_stat {
92 1.5 itohy MAPLE_PERIODIC_NONE,
93 1.5 itohy MAPLE_PERIODIC_INQ,
94 1.5 itohy MAPLE_PERIODIC_DEFERED
95 1.5 itohy } f_periodic_stat;
96 1.5 itohy TAILQ_ENTRY(maple_func) f_periodicq;
97 1.5 itohy
98 1.5 itohy /* command request */
99 1.5 itohy int f_command;
100 1.5 itohy int f_datalen;
101 1.7 itohy const void *f_dataaddr;
102 1.5 itohy enum maple_command_stat {
103 1.5 itohy MAPLE_CMDSTAT_NONE, /* not in queue */
104 1.5 itohy MAPLE_CMDSTAT_ASYNC, /* process immediately */
105 1.5 itohy MAPLE_CMDSTAT_PERIODIC_DEFERED, /* periodic but process imdtly*/
106 1.5 itohy MAPLE_CMDSTAT_ASYNC_PERIODICQ, /* async but on periodic queue*/
107 1.5 itohy MAPLE_CMDSTAT_PERIODIC /* process on periodic timing */
108 1.5 itohy } f_cmdstat;
109 1.5 itohy TAILQ_ENTRY(maple_func) f_cmdq;
110 1.5 itohy };
111 1.5 itohy
112 1.6 itohy /* work-around problem with 3rd party memory cards */
113 1.6 itohy #define MAPLE_MEMCARD_PING_HACK
114 1.6 itohy
115 1.5 itohy struct maple_unit {
116 1.5 itohy int port, subunit;
117 1.5 itohy struct maple_func u_func[MAPLE_NFUNC];
118 1.8 tsutsui uint32_t getcond_func_set;
119 1.5 itohy int u_ping_func; /* function used for ping */
120 1.8 tsutsui uint32_t u_noping; /* stop ping (bitmap of function) */
121 1.6 itohy #ifdef MAPLE_MEMCARD_PING_HACK
122 1.6 itohy enum maple_ping_stat {
123 1.6 itohy MAPLE_PING_NORMAL, /* ping with GETCOND */
124 1.6 itohy MAPLE_PING_MEMCARD, /* memory card, possibly 3rd party */
125 1.6 itohy MAPLE_PING_MINFO /* poorly implemented 3rd party card */
126 1.6 itohy } u_ping_stat;
127 1.6 itohy #endif
128 1.5 itohy struct maple_devinfo devinfo;
129 1.5 itohy
130 1.5 itohy /* DMA status / function */
131 1.5 itohy enum maple_dma_stat {
132 1.5 itohy MAPLE_DMA_IDLE, /* not in queue */
133 1.5 itohy MAPLE_DMA_RETRY, /* retrying last command (sc_retryq) */
134 1.5 itohy MAPLE_DMA_PERIODIC, /* periodic GETCOND */
135 1.5 itohy MAPLE_DMA_ACMD, /* asynchronous command */
136 1.5 itohy MAPLE_DMA_PCMD, /* command on periodic timing */
137 1.5 itohy MAPLE_DMA_PROBE, /* checking for insertion */
138 1.5 itohy MAPLE_DMA_PING /* checking for removal */
139 1.5 itohy } u_dma_stat;
140 1.5 itohy int u_dma_func;
141 1.5 itohy
142 1.5 itohy SIMPLEQ_ENTRY(maple_unit) u_dmaq;
143 1.5 itohy
144 1.5 itohy /* start of each receive buffer */
145 1.8 tsutsui uint32_t *u_rxbuf;
146 1.8 tsutsui uint32_t u_rxbuf_phys;
147 1.5 itohy
148 1.5 itohy /* for restarting command */
149 1.5 itohy int u_command;
150 1.5 itohy int u_datalen;
151 1.7 itohy const void *u_dataaddr;
152 1.5 itohy enum maple_dma_stat u_saved_dma_stat;
153 1.5 itohy int u_retrycnt;
154 1.5 itohy #define MAPLE_RETRY_MAX 100 /* ~2s */
155 1.5 itohy /*
156 1.5 itohy * The 2s retry is rather too long, but required to avoid
157 1.5 itohy * unwanted detach/attach.
158 1.5 itohy * If a Visual Memory (without cells) is inserted to a controller,
159 1.5 itohy * the controller (including the base device and the other unit
160 1.5 itohy * in the slot) stops responding for near 1 second. If two VM are
161 1.5 itohy * inserted in succession, the period becomes near 2s.
162 1.5 itohy */
163 1.5 itohy
164 1.5 itohy /* queue for probe/ping */
165 1.5 itohy enum maple_queue_stat {
166 1.5 itohy MAPLE_QUEUE_NONE, /* not in queue */
167 1.5 itohy MAPLE_QUEUE_PROBE, /* checking for insertion */
168 1.5 itohy MAPLE_QUEUE_PING /* checking for removal */
169 1.5 itohy } u_queuestat;
170 1.5 itohy TAILQ_ENTRY(maple_unit) u_q;
171 1.5 itohy int u_proberetry; /* retry count (subunit != 0) */
172 1.5 itohy #define MAPLE_PROBERETRY_MAX 5
173 1.5 itohy };
174 1.1 marcus
175 1.1 marcus struct maple_softc {
176 1.5 itohy struct device sc_dev;
177 1.1 marcus
178 1.5 itohy struct callout maple_callout_ch;
179 1.5 itohy struct proc *event_thread;
180 1.3 marcus
181 1.5 itohy int8_t sc_port_unit_map[MAPLE_PORTS];
182 1.5 itohy int sc_port_units[MAPLE_PORTS];
183 1.5 itohy int sc_port_units_open[MAPLE_PORTS];
184 1.1 marcus
185 1.1 marcus struct maple_unit sc_unit[MAPLE_PORTS][MAPLE_SUBUNITS];
186 1.1 marcus
187 1.8 tsutsui uint32_t *sc_txbuf; /* start of allocated transmit buffer */
188 1.8 tsutsui uint32_t *sc_txpos; /* current write position in tx buffer */
189 1.8 tsutsui uint32_t *sc_txlink; /* start of last written frame */
190 1.1 marcus
191 1.8 tsutsui uint32_t sc_txbuf_phys; /* 29-bit physical address */
192 1.5 itohy
193 1.5 itohy void *sc_intrhand;
194 1.5 itohy int sc_dmadone; /* wchan */
195 1.5 itohy
196 1.5 itohy int sc_event; /* periodic event is active / wchan */
197 1.1 marcus
198 1.5 itohy SIMPLEQ_HEAD(maple_dmaq_head, maple_unit) sc_dmaq, sc_retryq;
199 1.5 itohy TAILQ_HEAD(maple_unitq_head, maple_unit) sc_probeq, sc_pingq;
200 1.5 itohy TAILQ_HEAD(maple_fnq_head, maple_func) sc_periodicq, sc_periodicdeferq;
201 1.5 itohy TAILQ_HEAD(maple_cmdq_head, maple_func) sc_acmdq, sc_pcmdq;
202 1.1 marcus };
203