fwohcivar.h revision 1.2 1 /*-
2 * Copyright (c) 2000 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Matt Thomas of the 3am Software Foundry.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the NetBSD
19 * Foundation, Inc. and its contributors.
20 * 4. Neither the name of The NetBSD Foundation nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #ifndef _DEV_IEEE1394_FWOHCIVAR_H_
38 #define _DEV_IEEE1394_FWOHCIVAR_H_
39
40
41 #define OHCI_PAGE_SIZE 0x0800
42 #define OHCI_BUF_ARRQ_CNT 16
43 #define OHCI_BUF_ARRS_CNT 8
44 #define OHCI_BUF_ATRQ_CNT (8*8)
45 #define OHCI_BUF_ATRS_CNT (8*8)
46 #define OHCI_BUF_IR_CNT 16
47 #define OHCI_BUF_CNT (OHCI_BUF_ARRQ_CNT + OHCI_BUF_ARRS_CNT + OHCI_BUF_ATRQ_CNT + OHCI_BUF_ATRS_CNT + OHCI_BUF_IR_CNT + 1 + 1)
48
49 #define OHCI_LOOP 1000
50
51 struct fwohci_softc;
52
53 struct fwohci_buf {
54 TAILQ_ENTRY(fwohci_buf) fb_list;
55 bus_dma_segment_t fb_seg;
56 int fb_nseg;
57 bus_dmamap_t fb_dmamap;
58 caddr_t fb_buf;
59 struct fwohci_desc *fb_desc;
60 bus_addr_t fb_daddr;
61 int fb_off;
62 struct mbuf *fb_m;
63 void (*fb_callback)(struct device *, struct mbuf *);
64 };
65
66 struct fwohci_pkt {
67 int fp_tcode;
68 int fp_hlen;
69 int fp_dlen;
70 u_int32_t fp_hdr[4];
71 int fp_iovcnt;
72 struct iovec fp_iov[8];
73 u_int32_t *fp_trail;
74 struct mbuf *fp_m;
75 void (*fp_callback)(struct device *, struct mbuf *);
76 };
77
78 struct fwohci_handler {
79 LIST_ENTRY(fwohci_handler) fh_list;
80 u_int32_t fh_tcode; /* ARRQ / ARRS / IR */
81 u_int32_t fh_key1; /* addrhi / srcid / chan */
82 u_int32_t fh_key2; /* addrlo / tlabel / tag */
83 int (*fh_handler)(struct fwohci_softc *, void *,
84 struct fwohci_pkt *);
85 void *fh_handarg;
86 };
87
88 struct fwohci_ctx {
89 int fc_ctx;
90 int fc_ppbmode; /* packet per buffer */
91 int fc_bufcnt;
92 u_int32_t *fc_branch;
93 TAILQ_HEAD(fwohci_buf_s, fwohci_buf) fc_buf, fc_busy;
94 LIST_HEAD(, fwohci_handler) fc_handler;
95 };
96
97 struct fwohci_uidtbl {
98 struct fwohci_uident {
99 u_int8_t fu_uid[4];
100 u_int8_t fu_valid;
101 } fu_hi, fu_lo;
102 };
103
104 struct fwohci_softc {
105 struct ieee1394_softc sc_sc1394;
106
107 bus_space_tag_t sc_memt;
108 bus_space_handle_t sc_memh;
109 bus_dma_tag_t sc_dmat;
110 bus_size_t sc_memsize;
111
112 bus_dma_segment_t sc_dseg;
113 int sc_dnseg;
114 bus_dmamap_t sc_ddmamap;
115 caddr_t sc_desc;
116 int sc_descsize;
117 int sc_descfree;
118
119 int sc_isoctx;
120 int sc_tlabel;
121
122 struct fwohci_ctx *sc_ctx_arrq;
123 struct fwohci_ctx *sc_ctx_arrs;
124 struct fwohci_ctx *sc_ctx_atrq;
125 struct fwohci_ctx *sc_ctx_atrs;
126 struct fwohci_ctx **sc_ctx_ir;
127 struct fwohci_buf sc_buf_cnfrom;
128 struct fwohci_buf sc_buf_selfid;
129
130 u_int8_t sc_csr[CSR_SB_END];
131
132 struct fwohci_uidtbl *sc_uidtbl;
133 u_int16_t sc_nodeid;
134 u_int8_t sc_irmid;
135 u_int8_t sc_rootid;
136 };
137
138 int fwohci_init __P((struct fwohci_softc *));
139 int fwohci_intr __P((void *));
140 int fwohci_print __P((void *, const char *));
141
142 /* Macros to read and write the OHCI registers
143 */
144 #define OHCI_CSR_WRITE(sc, reg, val) bus_space_write_4((sc)->sc_memt, (sc)->sc_memh, reg, val)
145 #define OHCI_CSR_READ(sc, reg) bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, reg)
146
147 #endif /* _DEV_IEEE1394_FWOHCIVAR_H_ */
148