2 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the acknowledgement as bellow:
16 * This product includes software developed by K. Kobayashi and H. Shimokawa
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
37 #if __FreeBSD_version >= 500000
38 typedef struct thread fw_proc;
39 #include <sys/selinfo.h>
41 typedef struct proc fw_proc;
42 #include <sys/select.h>
56 #define CSRROMOFF 0x400
57 #define CSRROMSIZE 0x400
58 int rommax; /* offset from 0xffff f000 0000 */
59 u_int32_t csrrom[CSRROMSIZE/4];
64 #define FWDEVATTACHED 2
66 TAILQ_ENTRY(fw_device) link;
67 LIST_HEAD(, fw_xfer) txqueue;
68 LIST_HEAD(, fw_xfer) rxqueue;
70 struct firewire_softc {
71 #if __FreeBSD_version >= 500000
74 dev_t dev[FWMAXNDMA+1];
76 struct firewire_comm *fc;
78 #define FW_MAX_DMACH 0x20
79 #define FW_MAX_DEVCH FW_MAX_DMACH
80 #define FW_XFERTIMEOUT 1
81 struct firewire_dev_comm {
83 struct firewire_comm *fc;
84 void (*post_explore) __P((void *));
88 u_char hdr_len; /* IEEE1394 header length */
90 #define FWTI_REQ (1 << 0)
91 #define FWTI_RES (1 << 1)
92 #define FWTI_TLABEL (1 << 2)
93 #define FWTI_BLOCK_STR (1 << 3)
94 #define FWTI_BLOCK_ASY (1 << 4)
110 #define FWPHYASYST (1 << 0)
112 u_int32_t ongobus:10,
115 struct fw_device *ongodev;
116 struct fw_eui64 ongoeui;
117 #define FWMAXCSRDIR 16
118 SLIST_HEAD(, csrdir) ongocsr;
119 SLIST_HEAD(, csrdir) csrfree;
123 SLIST_ENTRY(csrdir) link;
128 #define FWBUSCYMELECT 2
129 #define FWBUSMGRELECT 3
130 #define FWBUSMGRDONE 4
131 #define FWBUSEXPLORE 5
132 #define FWBUSPHYCONF 6
133 #define FWBUSEXPDONE 7
134 #define FWBUSCOMPLETION 10
137 STAILQ_HEAD(fw_queue, fw_xfer);
140 #define FWXFERQ_CHTAGMASK 0xff
141 #define FWXFERQ_RUNNING (1 << 8)
142 #define FWXFERQ_STREAM (1 << 9)
144 #define FWXFERQ_PACKET (1 << 10)
145 #define FWXFERQ_BULK (1 << 11)
146 #define FWXFERQ_DV (1 << 12)
147 #define FWXFERQ_MODEMASK (7 << 10)
149 #define FWXFERQ_EXTBUF (1 << 13)
150 #define FWXFERQ_OPEN (1 << 14)
152 #define FWXFERQ_HANDLER (1 << 16)
153 #define FWXFERQ_WAKEUP (1 << 17)
155 void (*start) __P((struct firewire_comm*));
156 void (*drain) __P((struct firewire_comm*, struct fw_xfer*));
163 STAILQ_HEAD(, fw_bind) binds;
168 struct fw_bulkxfer *bulkxfer;
169 STAILQ_HEAD(, fw_bulkxfer) stvalid;
170 STAILQ_HEAD(, fw_bulkxfer) stfree;
171 struct fw_bulkxfer *stdma;
172 struct fw_bulkxfer *stdma2;
173 struct fw_bulkxfer *stproc;
175 int dvdbc, dvdiff, dvsync;
176 struct fw_dvbuf *dvbuf;
177 STAILQ_HEAD(, fw_dvbuf) dvvalid;
178 STAILQ_HEAD(, fw_dvbuf) dvfree;
179 struct fw_dvbuf *dvdma;
180 struct fw_dvbuf *dvproc;
186 void (*hand) __P((struct fw_xferq *));
189 *arq, *atq, *ars, *ats, *it[FW_MAX_DMACH],*ir[FW_MAX_DMACH];
193 STAILQ_ENTRY(fw_bulkxfer) link;
200 STAILQ_ENTRY(fw_dvbuf) link;
203 struct fw_xfer *xfer;
204 STAILQ_ENTRY(tlabel) link;
206 STAILQ_HEAD(, tlabel) tlabels[0x40];
208 u_int32_t start_hi, start_lo, addrlen;
209 struct fw_xfer* xfer;
210 STAILQ_ENTRY(fw_bind) fclist;
211 STAILQ_ENTRY(fw_bind) chlist;
213 STAILQ_HEAD(, fw_bind) binds;
214 TAILQ_HEAD(, fw_device) devices;
215 STAILQ_HEAD(, fw_xfer) pending;
216 volatile u_int32_t *sid_buf;
218 #define CSRSIZE 0x4000
219 u_int32_t csr_arc[CSRSIZE/4];
220 #define CROMSIZE 0x400
221 u_int32_t *config_rom;
222 struct fw_topology_map *topology_map;
223 struct fw_speed_map *speed_map;
224 struct callout_handle tlhandle;
225 struct callout_handle bmrhandle;
226 struct callout_handle timeouthandle;
227 struct callout_handle retry_probe_handle;
228 u_int32_t (*cyctimer) __P((struct firewire_comm *));
229 void (*ibr) __P((struct firewire_comm *));
230 u_int32_t (*set_bmr) __P((struct firewire_comm *, u_int32_t));
231 int (*ioctl) __P((dev_t, u_long, caddr_t, int, fw_proc *));
232 int (*irx_enable) __P((struct firewire_comm *, int));
233 int (*irx_disable) __P((struct firewire_comm *, int));
234 int (*itx_enable) __P((struct firewire_comm *, int));
235 int (*itx_disable) __P((struct firewire_comm *, int));
236 void (*timeout) __P((void *));
237 void (*poll) __P((struct firewire_comm *, int, int));
238 void (*set_intr) __P((struct firewire_comm *, int));
239 void (*irx_post) __P((struct firewire_comm *, u_int32_t *));
240 void (*itx_post) __P((struct firewire_comm *, u_int32_t *));
241 struct tcode_info *tcode;
243 #define CSRARC(sc, offset) ((sc)->csr_arc[(offset)/4])
248 struct firewire_comm *fc;
250 struct callout_handle ch;
252 struct fw_tlabel *tlabel;
260 #define FWXF_SENTERR 4
272 void (*retry_req) __P((struct fw_xfer *));
274 void (*hand) __P((struct fw_xfer *));
279 struct fw_device *device;
282 struct stch *channel;
290 STAILQ_ENTRY(fw_xfer) link;
292 void fw_sidrcv __P((struct firewire_comm *, caddr_t, u_int, u_int));
293 void fw_rcv __P((struct firewire_comm *, caddr_t, u_int, u_int, u_int, u_int));
294 void fw_xfer_free __P(( struct fw_xfer*));
295 struct fw_xfer *fw_xfer_alloc __P((void));
296 void fw_init __P((struct firewire_comm *));
297 int fw_tbuf_update __P((struct firewire_comm *, int, int));
298 int fw_rbuf_update __P((struct firewire_comm *, int, int));
299 int fw_readreqq __P((struct firewire_comm *, u_int32_t, u_int32_t, u_int32_t *));
300 int fw_writereqb __P((struct firewire_comm *, u_int32_t, u_int32_t, u_int32_t, u_int32_t *));
301 int fw_readresb __P((struct firewire_comm *, u_int32_t, u_int32_t, u_int32_t, u_int32_t*));
302 int fw_writeres __P((struct firewire_comm *, u_int32_t, u_int32_t));
303 u_int32_t getcsrdata __P((struct fw_device *, u_int8_t));
304 void fw_asybusy __P((struct fw_xfer *));
305 int fw_bindadd __P((struct firewire_comm *, struct fw_bind *));
306 int fw_bindremove __P((struct firewire_comm *, struct fw_bind *));
307 int fw_asyreq __P((struct firewire_comm *, int, struct fw_xfer*));
308 void fw_busreset __P((struct firewire_comm *));
309 u_int16_t fw_crc16 __P((u_int32_t *, u_int32_t));
310 void fw_xfer_timeout __P((void *));
311 void fw_xfer_done __P((struct fw_xfer *));
312 void fw_asy_callback __P((struct fw_xfer *));
314 extern int firewire_debug;
315 extern devclass_t firewire_devclass;
317 #define DV_BROADCAST_ON (1<<30)
318 #define IP_CHANNELS 0x0234
320 #define STATE_CLEAR 0x0000
321 #define STATE_SET 0x0004
322 #define NODE_IDS 0x0008
323 #define RESET_START 0x000c
324 #define SPLIT_TIMEOUT_HI 0x0018
325 #define SPLIT_TIMEOUT_LO 0x001c
326 #define CYCLE_TIME 0x0200
327 #define BUS_TIME 0x0210
328 #define BUS_MGR_ID 0x021c
329 #define BANDWIDTH_AV 0x0220
330 #define CHANNELS_AV_HI 0x0224
331 #define CHANNELS_AV_LO 0x0228
333 #define CONF_ROM 0x0400
335 #define TOPO_MAP 0x1000
336 #define SPED_MAP 0x2000
344 #define FWPRI ((PZERO+8)|PCATCH)
348 #define vtophys(va) alpha_XXX_dmamap((vm_offset_t)(va))
349 #endif /* __alpha__ */