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