firewirereg.h revision 106810
1/* 2 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 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: 15 * 16 * This product includes software developed by K. Kobayashi and H. Shimokawa 17 * 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. 20 * 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. 32 * 33 * $FreeBSD: head/sys/dev/firewire/firewirereg.h 106810 2002-11-12 13:49:17Z simokawa $ 34 * 35 */ 36 37#if __FreeBSD_version >= 500000 38typedef struct thread fw_proc; 39#include <sys/selinfo.h> 40#else 41typedef struct proc fw_proc; 42#include <sys/select.h> 43#endif 44 45#define splfw splimp 46 47struct fw_device{ 48 u_int16_t dst; 49 struct fw_eui64 eui; 50 u_int32_t spec; 51 u_int32_t ver; 52 u_int8_t speed; 53 u_int8_t maxrec; 54 u_int8_t nport; 55 u_int8_t power; 56#define CSRROMOFF 0x400 57#define CSRROMSIZE 0x400 58 int rommax; /* offset from 0xffff f000 0000 */ 59 u_int32_t csrrom[CSRROMSIZE/4]; 60 int rcnt; 61 struct firewire_comm *fc; 62 u_int32_t status; 63#define FWDEVINIT 1 64#define FWDEVATTACHED 2 65#define FWDEVINVAL 3 66 TAILQ_ENTRY(fw_device) link; 67#if 0 68 LIST_HEAD(, fw_xfer) txqueue; 69 LIST_HEAD(, fw_xfer) rxqueue; 70#endif 71}; 72struct firewire_softc { 73#if __FreeBSD_version >= 500000 74 dev_t dev; 75#else 76 dev_t dev[FWMAXNDMA+1]; 77#endif 78 struct firewire_comm *fc; 79}; 80#define FW_MAX_DMACH 0x20 81#define FW_MAX_DEVCH FW_MAX_DMACH 82#define FW_XFERTIMEOUT 1 83struct firewire_dev_comm { 84 device_t dev; 85 struct firewire_comm *fc; 86 void (*post_explore) __P((void *)); 87}; 88 89struct tcode_info { 90 u_char hdr_len; /* IEEE1394 header length */ 91 u_char flag; 92#define FWTI_REQ (1 << 0) 93#define FWTI_RES (1 << 1) 94#define FWTI_TLABEL (1 << 2) 95#define FWTI_BLOCK_STR (1 << 3) 96#define FWTI_BLOCK_ASY (1 << 4) 97}; 98 99struct firewire_comm{ 100 device_t dev; 101 device_t bdev; 102 u_int16_t busid:10, 103 nodeid:6; 104 u_int mode; 105 u_int nport; 106 u_int speed; 107 u_int maxrec; 108 u_int irm; 109 u_int max_node; 110 u_int max_hop; 111 u_int max_asyretry; 112#define FWPHYASYST (1 << 0) 113 u_int retry_count; 114 u_int32_t ongobus:10, 115 ongonode:6, 116 ongoaddr:16; 117 struct fw_device *ongodev; 118 struct fw_eui64 ongoeui; 119#define FWMAXCSRDIR 16 120 SLIST_HEAD(, csrdir) ongocsr; 121 SLIST_HEAD(, csrdir) csrfree; 122 struct csrdir{ 123 u_int32_t ongoaddr; 124 u_int32_t off; 125 SLIST_ENTRY(csrdir) link; 126 }; 127 u_int32_t status; 128#define FWBUSRESET 0 129#define FWBUSINIT 1 130#define FWBUSCYMELECT 2 131#define FWBUSMGRELECT 3 132#define FWBUSMGRDONE 4 133#define FWBUSEXPLORE 5 134#define FWBUSPHYCONF 6 135#define FWBUSEXPDONE 7 136#define FWBUSCOMPLETION 10 137 int nisodma; 138 u_int8_t eui[8]; 139 STAILQ_HEAD(fw_queue, fw_xfer); 140 struct fw_xferq { 141 int flag; 142#define FWXFERQ_CHTAGMASK 0xff 143#define FWXFERQ_RUNNING (1 << 8) 144#define FWXFERQ_STREAM (1 << 9) 145 146#define FWXFERQ_PACKET (1 << 10) 147#define FWXFERQ_BULK (1 << 11) 148#define FWXFERQ_DV (1 << 12) 149#define FWXFERQ_MODEMASK (7 << 10) 150 151#define FWXFERQ_EXTBUF (1 << 13) 152#define FWXFERQ_OPEN (1 << 14) 153 154#define FWXFERQ_HANDLER (1 << 16) 155#define FWXFERQ_WAKEUP (1 << 17) 156 157 void (*start) __P((struct firewire_comm*)); 158 void (*drain) __P((struct firewire_comm*, struct fw_xfer*)); 159 struct fw_queue q; 160 u_int queued; 161 u_int maxq; 162 u_int psize; 163 u_int packets; 164 u_int error; 165 STAILQ_HEAD(, fw_bind) binds; 166 caddr_t buf; 167 u_int bnchunk; 168 u_int bnpacket; 169 u_int btpacket; 170 struct fw_bulkxfer *bulkxfer; 171 STAILQ_HEAD(, fw_bulkxfer) stvalid; 172 STAILQ_HEAD(, fw_bulkxfer) stfree; 173 struct fw_bulkxfer *stdma; 174 struct fw_bulkxfer *stdma2; 175 struct fw_bulkxfer *stproc; 176 u_int procptr; 177 int dvdbc, dvdiff, dvsync; 178 struct fw_dvbuf *dvbuf; 179 STAILQ_HEAD(, fw_dvbuf) dvvalid; 180 STAILQ_HEAD(, fw_dvbuf) dvfree; 181 struct fw_dvbuf *dvdma; 182 struct fw_dvbuf *dvproc; 183 u_int dvptr; 184 u_int dvpacket; 185 u_int need_wakeup; 186 struct selinfo rsel; 187 caddr_t sc; 188 void (*hand) __P((struct fw_xferq *)); 189 }; 190 struct fw_xferq 191 *arq, *atq, *ars, *ats, *it[FW_MAX_DMACH],*ir[FW_MAX_DMACH]; 192 struct fw_bulkxfer{ 193 u_int32_t flag; 194 caddr_t buf; 195 STAILQ_ENTRY(fw_bulkxfer) link; 196 caddr_t start; 197 caddr_t end; 198 u_int npacket; 199 }; 200 struct fw_dvbuf{ 201 caddr_t buf; 202 STAILQ_ENTRY(fw_dvbuf) link; 203 }; 204 struct tlabel{ 205 struct fw_xfer *xfer; 206 STAILQ_ENTRY(tlabel) link; 207 }; 208 STAILQ_HEAD(, tlabel) tlabels[0x40]; 209 struct fw_bind{ 210 u_int32_t start_hi, start_lo, addrlen; 211 struct fw_xfer* xfer; 212 STAILQ_ENTRY(fw_bind) fclist; 213 STAILQ_ENTRY(fw_bind) chlist; 214 }; 215 STAILQ_HEAD(, fw_bind) binds; 216 TAILQ_HEAD(, fw_device) devices; 217 STAILQ_HEAD(, fw_xfer) pending; 218 volatile u_int32_t *sid_buf; 219 u_int sid_cnt; 220#define CSRSIZE 0x4000 221 u_int32_t csr_arc[CSRSIZE/4]; 222#define CROMSIZE 0x400 223 u_int32_t *config_rom; 224 struct fw_topology_map *topology_map; 225 struct fw_speed_map *speed_map; 226 struct callout_handle tlhandle; 227 struct callout_handle bmrhandle; 228 struct callout_handle timeouthandle; 229 struct callout_handle retry_probe_handle; 230 u_int32_t (*cyctimer) __P((struct firewire_comm *)); 231 void (*ibr) __P((struct firewire_comm *)); 232 u_int32_t (*set_bmr) __P((struct firewire_comm *, u_int32_t)); 233 int (*ioctl) __P((dev_t, u_long, caddr_t, int, fw_proc *)); 234 int (*irx_enable) __P((struct firewire_comm *, int)); 235 int (*irx_disable) __P((struct firewire_comm *, int)); 236 int (*itx_enable) __P((struct firewire_comm *, int)); 237 int (*itx_disable) __P((struct firewire_comm *, int)); 238 void (*timeout) __P((void *)); 239 void (*poll) __P((struct firewire_comm *, int, int)); 240 void (*set_intr) __P((struct firewire_comm *, int)); 241 void (*irx_post) __P((struct firewire_comm *, u_int32_t *)); 242 void (*itx_post) __P((struct firewire_comm *, u_int32_t *)); 243 struct tcode_info *tcode; 244}; 245#define CSRARC(sc, offset) ((sc)->csr_arc[(offset)/4]) 246 247 248struct fw_xfer{ 249 caddr_t sc; 250 struct firewire_comm *fc; 251 struct fw_xferq *q; 252 struct callout_handle ch; 253 time_t time; 254 struct fw_tlabel *tlabel; 255 u_int8_t spd; 256 u_int8_t tcode; 257 int resp; 258#define FWXF_INIT 0 259#define FWXF_INQ 1 260#define FWXF_START 2 261#define FWXF_SENT 3 262#define FWXF_SENTERR 4 263#define FWXF_BUSY 8 264#define FWXF_RCVD 10 265 int state; 266 u_int8_t retry; 267 u_int8_t tl; 268 int sub; 269 int32_t dst; 270 u_int8_t act_type; 271#define FWACT_NULL 0 272#define FWACT_XFER 2 273#define FWACT_CH 3 274 void (*retry_req) __P((struct fw_xfer *)); 275 union{ 276 void (*hand) __P((struct fw_xfer *)); 277 278 } act; 279 union{ 280 struct { 281 struct fw_device *device; 282 } req; 283 struct { 284 struct stch *channel; 285 } stream; 286 } mode; 287 struct { 288 u_int16_t len, off; 289 caddr_t buf; 290 } send, recv; 291 struct mbuf *mbuf; 292 STAILQ_ENTRY(fw_xfer) link; 293}; 294void fw_sidrcv __P((struct firewire_comm *, caddr_t, u_int, u_int)); 295void fw_rcv __P((struct firewire_comm *, caddr_t, u_int, u_int, u_int, u_int)); 296void fw_xfer_free __P(( struct fw_xfer*)); 297struct fw_xfer *fw_xfer_alloc __P((void)); 298void fw_init __P((struct firewire_comm *)); 299int fw_tbuf_update __P((struct firewire_comm *, int, int)); 300int fw_rbuf_update __P((struct firewire_comm *, int, int)); 301int fw_readreqq __P((struct firewire_comm *, u_int32_t, u_int32_t, u_int32_t *)); 302int fw_writereqb __P((struct firewire_comm *, u_int32_t, u_int32_t, u_int32_t, u_int32_t *)); 303int fw_readresb __P((struct firewire_comm *, u_int32_t, u_int32_t, u_int32_t, u_int32_t*)); 304int fw_writeres __P((struct firewire_comm *, u_int32_t, u_int32_t)); 305u_int32_t getcsrdata __P((struct fw_device *, u_int8_t)); 306void fw_asybusy __P((struct fw_xfer *)); 307int fw_bindadd __P((struct firewire_comm *, struct fw_bind *)); 308int fw_bindremove __P((struct firewire_comm *, struct fw_bind *)); 309int fw_asyreq __P((struct firewire_comm *, int, struct fw_xfer*)); 310void fw_busreset __P((struct firewire_comm *)); 311u_int16_t fw_crc16 __P((u_int32_t *, u_int32_t)); 312void fw_xfer_timeout __P((void *)); 313void fw_xfer_done __P((struct fw_xfer *)); 314void fw_asy_callback __P((struct fw_xfer *)); 315struct fw_device *fw_noderesolve __P((struct firewire_comm *, struct fw_eui64)); 316 317extern int firewire_debug; 318extern devclass_t firewire_devclass; 319 320#define DV_BROADCAST_ON (1<<30) 321#define IP_CHANNELS 0x0234 322 323#define STATE_CLEAR 0x0000 324#define STATE_SET 0x0004 325#define NODE_IDS 0x0008 326#define RESET_START 0x000c 327#define SPLIT_TIMEOUT_HI 0x0018 328#define SPLIT_TIMEOUT_LO 0x001c 329#define CYCLE_TIME 0x0200 330#define BUS_TIME 0x0210 331#define BUS_MGR_ID 0x021c 332#define BANDWIDTH_AV 0x0220 333#define CHANNELS_AV_HI 0x0224 334#define CHANNELS_AV_LO 0x0228 335 336#define CONF_ROM 0x0400 337 338#define TOPO_MAP 0x1000 339#define SPED_MAP 0x2000 340 341#define oMPR 0x900 342#define oPCR 0x904 343 344#define iMPR 0x980 345#define iPCR 0x984 346 347#define FWPRI ((PZERO+8)|PCATCH) 348 349#ifdef __alpha__ 350#undef vtophys 351#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)(va)) 352#endif /* __alpha__ */ 353