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