1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #ifndef __MUSYCCVAR_H__
20 #define __MUSYCCVAR_H__
21
22 #include <sys/queue.h>
23
24 #define PPP_HEADER_LEN 4
25
26
27 #define MUSYCC_NUMCHAN 32
28 #define MUSYCC_NUMPORT 8
29 #define MUSYCC_SREQNUM 16
30 #define MUSYCC_SREQMASK (MUSYCC_SREQNUM - 1)
31 #define MUSYCC_SREQTIMEOUT 2
32
33
34 #define MUSYCC_DMA_CNT 256
35 #define MUSYCC_DMA_MAPSIZE (MUSYCC_DMA_CNT * sizeof(struct dma_desc))
36 #define MUSYCC_DMA_SIZE 32
37
38 struct musycc_softc;
39 struct ebus_softc;
40
41
42 struct dma_desc {
43 u_int32_t status;
44 u_int32_t data;
45 u_int32_t next;
46
47 struct mbuf *mbuf;
48 struct dma_desc *nextdesc;
49 bus_dmamap_t map;
50 };
51
52 #define MUSYCC_INTLEN 512
53 struct musycc_intdesc {
54 u_int32_t md_intrq[MUSYCC_INTLEN];
55 };
56
57 struct musycc_dma_data {
58
59
60
61
62 struct dma_desc *rx_prod;
63 int rx_cnt;
64
65 struct dma_desc *tx_pend;
66 struct dma_desc *tx_cur;
67 int tx_cnt;
68 int tx_use;
69 int tx_pkts;
70 };
71
72 enum musycc_state {
73 CHAN_FLOAT,
74 CHAN_IDLE,
75 CHAN_RUNNING,
76 CHAN_FAULT,
77 CHAN_TRANSIENT
78 };
79
80 enum musycc_event {
81 EV_NULL,
82 EV_ACTIVATE,
83 EV_STOP,
84 EV_IDLE,
85 EV_WATCHDOG
86 };
87
88
89 struct musycc_group {
90 struct musycc_softc *mg_hdlc;
91 struct musycc_grpdesc *mg_group;
92 u_int8_t mg_gnum;
93 u_int8_t mg_port;
94 u_int8_t mg_loaded;
95 u_int64_t mg_fifomask;
96
97 struct channel_softc *mg_channels[MUSYCC_NUMCHAN];
98 struct musycc_dma_data mg_dma_d[MUSYCC_NUMCHAN];
99 struct dma_desc *mg_freelist;
100 int mg_freecnt;
101
102 struct {
103 long timeout;
104 u_int32_t sreq;
105 enum musycc_event event;
106 } mg_sreq[MUSYCC_SREQNUM];
107 int mg_sreqpend;
108 int mg_sreqprod;
109
110 struct dma_desc *mg_dma_pool;
111 bus_dma_tag_t mg_dmat;
112 caddr_t mg_listkva;
113 bus_dmamap_t mg_listmap;
114 bus_dma_segment_t mg_listseg[1];
115 int mg_listnseg;
116 bus_dmamap_t mg_tx_sparemap;
117 bus_dmamap_t mg_rx_sparemap;
118 };
119
120
121 struct musycc_attach_args {
122 char ma_product[64];
123 bus_size_t ma_base;
124 bus_size_t ma_size;
125 u_int32_t ma_type;
126 u_int8_t ma_gnum;
127 u_int8_t ma_port;
128 u_int8_t ma_flags;
129 char ma_slot;
130 };
131
132
133 struct ebus_dev {
134 bus_size_t base;
135 bus_size_t size;
136 bus_space_tag_t st;
137 bus_space_handle_t sh;
138 };
139
140
141 struct channel_softc {
142 struct sppp cc_ppp;
143 struct ifnet *cc_ifp;
144 struct musycc_group *cc_group;
145 struct device *cc_parent;
146
147 u_int32_t cc_tslots;
148 int cc_unit;
149 enum musycc_state cc_state;
150 u_int8_t cc_channel;
151 u_int8_t cc_locked;
152 };
153
154
155 struct musycc_softc {
156 struct device mc_dev;
157 void *mc_ih;
158 bus_space_tag_t mc_st;
159 bus_space_handle_t mc_sh;
160 bus_dma_tag_t mc_dmat;
161 bus_size_t mc_iosize;
162
163 caddr_t mc_groupkva;
164 bus_dmamap_t mc_cfgmap;
165 bus_dma_segment_t mc_cfgseg[1];
166 bus_dmamap_t mc_intrmap;
167 bus_dma_segment_t mc_intrseg[1];
168 int mc_cfgnseg;
169 int mc_intrnseg;
170
171 struct musycc_group *mc_groups;
172 struct musycc_intdesc *mc_intrd;
173 u_int32_t mc_global_conf;
174 u_int32_t mc_intrqptr;
175 int mc_ngroups;
176 int mc_nports;
177
178 struct musycc_softc *mc_other;
179 bus_size_t mc_ledbase;
180 u_int8_t mc_ledmask;
181 u_int8_t mc_ledstate;
182 int bus, device;
183 SLIST_ENTRY(musycc_softc) list;
184 };
185
186 int musycc_attach_common(struct musycc_softc *, u_int32_t, u_int32_t);
187 void musycc_set_port(struct musycc_group *, int);
188 int musycc_init_channel(struct channel_softc *, char);
189 void musycc_stop_channel(struct channel_softc *);
190 void musycc_free_channel(struct musycc_group *, int);
191 void musycc_start(struct ifnet *);
192 void musycc_watchdog(struct ifnet *);
193 void musycc_tick(struct channel_softc *);
194
195 int musycc_intr(void *);
196 int ebus_intr(void *);
197
198
199 int ebus_attach_device(struct ebus_dev *, struct musycc_softc *,
200 bus_size_t, bus_size_t);
201 u_int8_t ebus_read(struct ebus_dev *, bus_size_t);
202 void ebus_write(struct ebus_dev *, bus_size_t, u_int8_t);
203 void ebus_read_buf(struct ebus_dev *, bus_size_t, void *, size_t);
204 void ebus_set_led(struct channel_softc *, int, u_int8_t);
205
206 #define MUSYCC_LED_GREEN 0x1
207 #define MUSYCC_LED_RED 0x2
208 #define MUSYCC_LED_MASK 0x3
209
210
211 struct channel_softc *musycc_channel_create(const char *, u_int8_t);
212 void musycc_attach_sppp(struct channel_softc *,
213 int (*)(struct ifnet *, u_long, caddr_t));
214 int musycc_channel_attach(struct musycc_softc *,
215 struct channel_softc *, struct device *, u_int8_t);
216 void musycc_channel_detach(struct ifnet *);
217
218
219 #ifndef ACCOOM_DEBUG
220 #define ACCOOM_PRINTF(n, x)
221 #else
222 extern int accoom_debug;
223
224 #define ACCOOM_PRINTF(n, x) \
225 do { \
226 if (accoom_debug >= n) \
227 printf x; \
228 } while (0)
229 #endif
230
231 #endif