firewirereg.h revision 103285
1228753Smm/* 2228753Smm * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 3228753Smm * All rights reserved. 4228753Smm * 5228753Smm * Redistribution and use in source and binary forms, with or without 6228753Smm * modification, are permitted provided that the following conditions 7228753Smm * are met: 8228753Smm * 1. Redistributions of source code must retain the above copyright 9228753Smm * notice, this list of conditions and the following disclaimer. 10228753Smm * 2. Redistributions in binary form must reproduce the above copyright 11228753Smm * notice, this list of conditions and the following disclaimer in the 12228753Smm * documentation and/or other materials provided with the distribution. 13228753Smm * 3. All advertising materials mentioning features or use of this software 14228753Smm * must display the acknowledgement as bellow: 15228753Smm * 16228753Smm * This product includes software developed by K. Kobayashi and H. Shimokawa 17228753Smm * 18228753Smm * 4. The name of the author may not be used to endorse or promote products 19228753Smm * derived from this software without specific prior written permission. 20228753Smm * 21228753Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22228753Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23228753Smm * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24228753Smm * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25228753Smm * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26228763Smm * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27228753Smm * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28228753Smm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29228753Smm * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30228753Smm * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31228753Smm * POSSIBILITY OF SUCH DAMAGE. 32228753Smm * 33228753Smm * $FreeBSD: head/sys/dev/firewire/firewirereg.h 103285 2002-09-13 12:31:56Z ikob $ 34228753Smm * 35228753Smm */ 36228753Smm 37228753Smm#if __FreeBSD_version >= 500000 38228753Smmtypedef struct thread fw_proc; 39228753Smm#include <sys/selinfo.h> 40228753Smm#else 41228753Smmtypedef struct proc fw_proc; 42228753Smm#include <sys/select.h> 43228753Smm#endif 44228753Smm 45228753Smm#define splfw splimp 46228753Smm 47228753Smmstruct fw_device{ 48228753Smm u_int16_t dst; 49228753Smm struct fw_eui64 eui; 50228753Smm u_int32_t spec; 51228753Smm u_int32_t ver; 52228753Smm u_int8_t speed; 53228753Smm u_int8_t maxrec; 54228753Smm u_int8_t nport; 55228753Smm u_int8_t power; 56228753Smm#define CSRROMOFF 0x400 57228753Smm#define CSRROMSIZE 0x400 58228753Smm int rommax; /* offset from 0xffff f000 0000 */ 59228753Smm u_int32_t csrrom[CSRROMSIZE/4]; 60228753Smm int rcnt; 61228753Smm device_t dev; 62228753Smm u_int32_t status; 63228753Smm#define FWDEVINIT 1 64228753Smm#define FWDEVATTACHED 2 65228753Smm#define FWDEVINVAL 3 66228753Smm TAILQ_ENTRY(fw_device) link; 67228753Smm LIST_HEAD(, fw_xfer) txqueue; 68228753Smm LIST_HEAD(, fw_xfer) rxqueue; 69228753Smm}; 70228753Smmstruct firewire_softc { 71228753Smm#if __FreeBSD_version >= 500000 72 dev_t dev; 73#else 74 dev_t dev[FWMAXNDMA+1]; 75#endif 76 struct firewire_comm *fc; 77}; 78#define FW_MAX_DMACH 0x20 79#define FW_MAX_DEVCH FW_MAX_DMACH 80#define FW_XFERTIMEOUT 1 81struct firewire_dev_comm { 82 device_t dev; 83 struct firewire_comm *fc; 84 void (*post_explore) __P((void *)); 85}; 86 87struct tcode_info { 88 u_char hdr_len; /* IEEE1394 header length */ 89 u_char flag; 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) 95}; 96 97struct firewire_comm{ 98 device_t dev; 99 device_t bdev; 100 u_int16_t busid:10, 101 nodeid:6; 102 u_int mode; 103 u_int nport; 104 u_int speed; 105 u_int maxrec; 106 u_int irm; 107 u_int max_node; 108 u_int max_hop; 109 u_int max_asyretry; 110#define FWPHYASYST (1 << 0) 111 u_int retry_count; 112 u_int32_t ongobus:10, 113 ongonode:6, 114 ongoaddr:16; 115 struct fw_device *ongodev; 116 struct fw_eui64 ongoeui; 117#define FWMAXCSRDIR 16 118 SLIST_HEAD(, csrdir) ongocsr; 119 SLIST_HEAD(, csrdir) csrfree; 120 struct csrdir{ 121 u_int32_t ongoaddr; 122 u_int32_t off; 123 SLIST_ENTRY(csrdir) link; 124 }; 125 u_int32_t status; 126#define FWBUSRESET 0 127#define FWBUSINIT 1 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 135 int nisodma; 136 u_int8_t eui[8]; 137 STAILQ_HEAD(fw_queue, fw_xfer); 138 struct fw_xferq { 139 int flag; 140#define FWXFERQ_CHTAGMASK 0xff 141#define FWXFERQ_RUNNING (1 << 8) 142#define FWXFERQ_STREAM (1 << 9) 143 144#define FWXFERQ_PACKET (1 << 10) 145#define FWXFERQ_BULK (1 << 11) 146#define FWXFERQ_DV (1 << 12) 147#define FWXFERQ_MODEMASK (7 << 10) 148 149#define FWXFERQ_EXTBUF (1 << 13) 150#define FWXFERQ_OPEN (1 << 14) 151 152#define FWXFERQ_HANDLER (1 << 16) 153#define FWXFERQ_WAKEUP (1 << 17) 154 155 void (*start) __P((struct firewire_comm*)); 156 void (*drain) __P((struct firewire_comm*, struct fw_xfer*)); 157 struct fw_queue q; 158 u_int queued; 159 u_int maxq; 160 u_int psize; 161 u_int packets; 162 u_int error; 163 STAILQ_HEAD(, fw_bind) binds; 164 caddr_t buf; 165 u_int bnchunk; 166 u_int bnpacket; 167 u_int btpacket; 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; 174 u_int procptr; 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; 181 u_int dvptr; 182 u_int dvpacket; 183 u_int need_wakeup; 184 struct selinfo rsel; 185 caddr_t sc; 186 void (*hand) __P((struct fw_xferq *)); 187 }; 188 struct fw_xferq 189 *arq, *atq, *ars, *ats, *it[FW_MAX_DMACH],*ir[FW_MAX_DMACH]; 190 struct fw_bulkxfer{ 191 u_int32_t flag; 192 caddr_t buf; 193 STAILQ_ENTRY(fw_bulkxfer) link; 194 caddr_t start; 195 caddr_t end; 196 u_int npacket; 197 }; 198 struct fw_dvbuf{ 199 caddr_t buf; 200 STAILQ_ENTRY(fw_dvbuf) link; 201 }; 202 struct tlabel{ 203 struct fw_xfer *xfer; 204 STAILQ_ENTRY(tlabel) link; 205 }; 206 STAILQ_HEAD(, tlabel) tlabels[0x40]; 207 struct fw_bind{ 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; 212 }; 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; 217 u_int sid_cnt; 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; 242}; 243#define CSRARC(sc, offset) ((sc)->csr_arc[(offset)/4]) 244 245 246struct fw_xfer{ 247 caddr_t sc; 248 struct firewire_comm *fc; 249 struct fw_xferq *q; 250 struct callout_handle ch; 251 time_t time; 252 struct fw_tlabel *tlabel; 253 u_int8_t spd; 254 u_int8_t tcode; 255 int resp; 256#define FWXF_INIT 0 257#define FWXF_INQ 1 258#define FWXF_START 2 259#define FWXF_SENT 3 260#define FWXF_SENTERR 4 261#define FWXF_BUSY 8 262#define FWXF_RCVD 10 263 int state; 264 u_int8_t retry; 265 u_int8_t tl; 266 int sub; 267 int32_t dst; 268 u_int8_t act_type; 269#define FWACT_NULL 0 270#define FWACT_XFER 2 271#define FWACT_CH 3 272 void (*retry_req) __P((struct fw_xfer *)); 273 union{ 274 void (*hand) __P((struct fw_xfer *)); 275 276 } act; 277 union{ 278 struct { 279 struct fw_device *device; 280 } req; 281 struct { 282 struct stch *channel; 283 } stream; 284 } mode; 285 struct { 286 u_int16_t len, off; 287 caddr_t buf; 288 } send, recv; 289 struct mbuf *mbuf; 290 STAILQ_ENTRY(fw_xfer) link; 291}; 292void fw_sidrcv __P((struct firewire_comm *, caddr_t, u_int, u_int)); 293void fw_rcv __P((struct firewire_comm *, caddr_t, u_int, u_int, u_int, u_int)); 294void fw_xfer_free __P(( struct fw_xfer*)); 295struct fw_xfer *fw_xfer_alloc __P((void)); 296void fw_init __P((struct firewire_comm *)); 297int fw_tbuf_update __P((struct firewire_comm *, int, int)); 298int fw_rbuf_update __P((struct firewire_comm *, int, int)); 299int fw_readreqq __P((struct firewire_comm *, u_int32_t, u_int32_t, u_int32_t *)); 300int fw_writereqb __P((struct firewire_comm *, u_int32_t, u_int32_t, u_int32_t, u_int32_t *)); 301int fw_readresb __P((struct firewire_comm *, u_int32_t, u_int32_t, u_int32_t, u_int32_t*)); 302int fw_writeres __P((struct firewire_comm *, u_int32_t, u_int32_t)); 303u_int32_t getcsrdata __P((struct fw_device *, u_int8_t)); 304void fw_asybusy __P((struct fw_xfer *)); 305int fw_bindadd __P((struct firewire_comm *, struct fw_bind *)); 306int fw_bindremove __P((struct firewire_comm *, struct fw_bind *)); 307int fw_asyreq __P((struct firewire_comm *, int, struct fw_xfer*)); 308void fw_busreset __P((struct firewire_comm *)); 309u_int16_t fw_crc16 __P((u_int32_t *, u_int32_t)); 310void fw_xfer_timeout __P((void *)); 311void fw_xfer_done __P((struct fw_xfer *)); 312void fw_asy_callback __P((struct fw_xfer *)); 313 314extern int firewire_debug; 315extern devclass_t firewire_devclass; 316 317#define DV_BROADCAST_ON (1<<30) 318#define IP_CHANNELS 0x0234 319 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 332 333#define CONF_ROM 0x0400 334 335#define TOPO_MAP 0x1000 336#define SPED_MAP 0x2000 337 338#define oMPR 0x900 339#define oPCR 0x904 340 341#define iMPR 0x980 342#define iPCR 0x984 343 344#define FWPRI ((PZERO+8)|PCATCH) 345 346#ifdef __alpha__ 347#undef vtophys 348#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)(va)) 349#endif /* __alpha__ */ 350