if_ec.c revision 1.2.2.3 1 1.2.2.3 cgd /* $NetBSD: if_ec.c,v 1.2.2.3 1998/10/29 02:40:39 cgd Exp $ */
2 1.2.2.2 thorpej
3 1.2.2.2 thorpej /*-
4 1.2.2.2 thorpej * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 1.2.2.2 thorpej * All rights reserved.
6 1.2.2.2 thorpej *
7 1.2.2.2 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.2.2.2 thorpej * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.2.2.2 thorpej * NASA Ames Research Center.
10 1.2.2.2 thorpej *
11 1.2.2.2 thorpej * Redistribution and use in source and binary forms, with or without
12 1.2.2.2 thorpej * modification, are permitted provided that the following conditions
13 1.2.2.2 thorpej * are met:
14 1.2.2.2 thorpej * 1. Redistributions of source code must retain the above copyright
15 1.2.2.2 thorpej * notice, this list of conditions and the following disclaimer.
16 1.2.2.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
17 1.2.2.2 thorpej * notice, this list of conditions and the following disclaimer in the
18 1.2.2.2 thorpej * documentation and/or other materials provided with the distribution.
19 1.2.2.2 thorpej * 3. All advertising materials mentioning features or use of this software
20 1.2.2.2 thorpej * must display the following acknowledgement:
21 1.2.2.2 thorpej * This product includes software developed by the NetBSD
22 1.2.2.2 thorpej * Foundation, Inc. and its contributors.
23 1.2.2.2 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.2.2.2 thorpej * contributors may be used to endorse or promote products derived
25 1.2.2.2 thorpej * from this software without specific prior written permission.
26 1.2.2.2 thorpej *
27 1.2.2.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.2.2.2 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.2.2.2 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.2.2.2 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.2.2.2 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.2.2.2 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.2.2.2 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.2.2.2 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.2.2.2 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.2.2.2 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.2.2.2 thorpej * POSSIBILITY OF SUCH DAMAGE.
38 1.2.2.2 thorpej */
39 1.2.2.2 thorpej
40 1.2.2.2 thorpej /*
41 1.2.2.2 thorpej * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
42 1.2.2.2 thorpej * adapters.
43 1.2.2.2 thorpej *
44 1.2.2.2 thorpej * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
45 1.2.2.2 thorpej *
46 1.2.2.2 thorpej * Copyright (C) 1993, David Greenman. This software may be used, modified,
47 1.2.2.2 thorpej * copied, distributed, and sold, in both source and binary form provided that
48 1.2.2.2 thorpej * the above copyright and these terms are retained. Under no circumstances is
49 1.2.2.2 thorpej * the author responsible for the proper functioning of this software, nor does
50 1.2.2.2 thorpej * the author assume any responsibility for damages incurred with its use.
51 1.2.2.2 thorpej */
52 1.2.2.2 thorpej
53 1.2.2.2 thorpej /*
54 1.2.2.2 thorpej * Device driver for the 3Com Etherlink II (3c503).
55 1.2.2.2 thorpej */
56 1.2.2.2 thorpej
57 1.2.2.2 thorpej #include "bpfilter.h"
58 1.2.2.2 thorpej #include "rnd.h"
59 1.2.2.2 thorpej
60 1.2.2.2 thorpej #include <sys/param.h>
61 1.2.2.2 thorpej #include <sys/systm.h>
62 1.2.2.2 thorpej #include <sys/device.h>
63 1.2.2.2 thorpej #include <sys/socket.h>
64 1.2.2.2 thorpej #include <sys/mbuf.h>
65 1.2.2.2 thorpej #include <sys/syslog.h>
66 1.2.2.2 thorpej
67 1.2.2.2 thorpej #include <net/if.h>
68 1.2.2.2 thorpej #include <net/if_dl.h>
69 1.2.2.2 thorpej #include <net/if_types.h>
70 1.2.2.2 thorpej #include <net/if_media.h>
71 1.2.2.2 thorpej
72 1.2.2.2 thorpej #include <net/if_ether.h>
73 1.2.2.2 thorpej
74 1.2.2.2 thorpej #ifdef INET
75 1.2.2.2 thorpej #include <netinet/in.h>
76 1.2.2.2 thorpej #include <netinet/in_systm.h>
77 1.2.2.2 thorpej #include <netinet/in_var.h>
78 1.2.2.2 thorpej #include <netinet/ip.h>
79 1.2.2.2 thorpej #include <netinet/if_inarp.h>
80 1.2.2.2 thorpej #endif
81 1.2.2.2 thorpej
82 1.2.2.2 thorpej #ifdef NS
83 1.2.2.2 thorpej #include <netns/ns.h>
84 1.2.2.2 thorpej #include <netns/ns_if.h>
85 1.2.2.2 thorpej #endif
86 1.2.2.2 thorpej
87 1.2.2.2 thorpej #if NBPFILTER > 0
88 1.2.2.2 thorpej #include <net/bpf.h>
89 1.2.2.2 thorpej #include <net/bpfdesc.h>
90 1.2.2.2 thorpej #endif
91 1.2.2.2 thorpej
92 1.2.2.2 thorpej #include <machine/bus.h>
93 1.2.2.2 thorpej #include <machine/intr.h>
94 1.2.2.2 thorpej
95 1.2.2.2 thorpej #include <dev/isa/isareg.h>
96 1.2.2.2 thorpej #include <dev/isa/isavar.h>
97 1.2.2.2 thorpej
98 1.2.2.2 thorpej #include <dev/ic/dp8390reg.h>
99 1.2.2.2 thorpej #include <dev/ic/dp8390var.h>
100 1.2.2.2 thorpej
101 1.2.2.2 thorpej #include <dev/isa/if_ecreg.h>
102 1.2.2.2 thorpej
103 1.2.2.2 thorpej struct ec_softc {
104 1.2.2.2 thorpej struct dp8390_softc sc_dp8390;
105 1.2.2.2 thorpej
106 1.2.2.2 thorpej bus_space_tag_t sc_asict; /* space tag for ASIC */
107 1.2.2.2 thorpej bus_space_handle_t sc_asich; /* space handle for ASIC */
108 1.2.2.2 thorpej
109 1.2.2.2 thorpej int sc_16bitp; /* are we 16 bit? */
110 1.2.2.2 thorpej
111 1.2.2.2 thorpej void *sc_ih; /* interrupt handle */
112 1.2.2.2 thorpej };
113 1.2.2.2 thorpej
114 1.2.2.2 thorpej #ifdef __BROKEN_INDIRECT_CONFIG
115 1.2.2.2 thorpej int ec_probe __P((struct device *, void *, void *));
116 1.2.2.2 thorpej #else
117 1.2.2.2 thorpej int ec_probe __P((struct device *, struct cfdata *, void *));
118 1.2.2.2 thorpej #endif
119 1.2.2.2 thorpej void ec_attach __P((struct device *, struct device *, void *));
120 1.2.2.2 thorpej
121 1.2.2.2 thorpej struct cfattach ec_ca = {
122 1.2.2.2 thorpej sizeof(struct ec_softc), ec_probe, ec_attach
123 1.2.2.2 thorpej };
124 1.2.2.2 thorpej
125 1.2.2.2 thorpej struct cfdriver ec_cd = {
126 1.2.2.2 thorpej NULL, "ec", DV_IFNET
127 1.2.2.2 thorpej };
128 1.2.2.2 thorpej
129 1.2.2.2 thorpej int ec_set_media __P((struct ec_softc *, int));
130 1.2.2.2 thorpej
131 1.2.2.2 thorpej int ec_mediachange __P((struct dp8390_softc *));
132 1.2.2.2 thorpej void ec_mediastatus __P((struct dp8390_softc *, struct ifmediareq *));
133 1.2.2.2 thorpej
134 1.2.2.2 thorpej void ec_init_card __P((struct dp8390_softc *));
135 1.2.2.2 thorpej int ec_write_mbuf __P((struct dp8390_softc *, struct mbuf *, int));
136 1.2.2.2 thorpej int ec_ring_copy __P((struct dp8390_softc *, int, caddr_t, u_short));
137 1.2.2.2 thorpej void ec_read_hdr __P((struct dp8390_softc *, int, struct dp8390_ring *));
138 1.2.2.2 thorpej int ec_fake_test_mem __P((struct dp8390_softc *));
139 1.2.2.2 thorpej int ec_test_mem __P((struct dp8390_softc *));
140 1.2.2.2 thorpej
141 1.2.2.2 thorpej __inline void ec_writemem __P((struct ec_softc *, u_int8_t *, int, int));
142 1.2.2.2 thorpej __inline void ec_readmem __P((struct ec_softc *, int, u_int8_t *, int));
143 1.2.2.2 thorpej
144 1.2.2.2 thorpej static const int ec_iobase[] = {
145 1.2.2.2 thorpej 0x2e0, 0x2a0, 0x280, 0x250, 0x350, 0x330, 0x310, 0x300,
146 1.2.2.2 thorpej };
147 1.2.2.2 thorpej #define NEC_IOBASE (sizeof(ec_iobase) / sizeof(ec_iobase[0]))
148 1.2.2.2 thorpej
149 1.2.2.2 thorpej static const int ec_membase[] = {
150 1.2.2.2 thorpej MADDRUNK, MADDRUNK, MADDRUNK, MADDRUNK, 0xc8000, 0xcc000,
151 1.2.2.2 thorpej 0xd8000, 0xdc000,
152 1.2.2.2 thorpej };
153 1.2.2.2 thorpej #define NEC_MEMBASE (sizeof(ec_membase) / sizeof(ec_membase[0]))
154 1.2.2.2 thorpej
155 1.2.2.2 thorpej int ec_media[] = {
156 1.2.2.2 thorpej IFM_ETHER|IFM_10_2,
157 1.2.2.2 thorpej IFM_ETHER|IFM_10_5,
158 1.2.2.2 thorpej };
159 1.2.2.2 thorpej #define NEC_MEDIA (sizeof(ec_media) / sizeof(ec_media[0]))
160 1.2.2.2 thorpej #define EC_DEFMEDIA (IFM_ETHER|IFM_10_2)
161 1.2.2.2 thorpej
162 1.2.2.2 thorpej int
163 1.2.2.2 thorpej ec_probe(parent, match, aux)
164 1.2.2.2 thorpej struct device *parent;
165 1.2.2.2 thorpej #ifdef __BROKEN_INDIRECT_CONFIG
166 1.2.2.2 thorpej void *match;
167 1.2.2.2 thorpej #else
168 1.2.2.2 thorpej struct cfdata *match;
169 1.2.2.2 thorpej #endif
170 1.2.2.2 thorpej void *aux;
171 1.2.2.2 thorpej {
172 1.2.2.2 thorpej struct isa_attach_args *ia = aux;
173 1.2.2.2 thorpej bus_space_tag_t nict, asict, memt;
174 1.2.2.2 thorpej bus_space_handle_t nich, asich, memh;
175 1.2.2.2 thorpej bus_size_t memsize;
176 1.2.2.2 thorpej int nich_valid, asich_valid, memh_valid;
177 1.2.2.2 thorpej int i, rv = 0;
178 1.2.2.2 thorpej u_int8_t x;
179 1.2.2.2 thorpej
180 1.2.2.2 thorpej nict = asict = ia->ia_iot;
181 1.2.2.2 thorpej memt = ia->ia_memt;
182 1.2.2.2 thorpej
183 1.2.2.2 thorpej nich_valid = asich_valid = memh_valid = 0;
184 1.2.2.2 thorpej
185 1.2.2.2 thorpej /*
186 1.2.2.2 thorpej * Hmm, a 16-bit card has 16k of memory, but only an 8k window
187 1.2.2.2 thorpej * to it.
188 1.2.2.2 thorpej */
189 1.2.2.2 thorpej memsize = 8192;
190 1.2.2.2 thorpej
191 1.2.2.2 thorpej /* Disallow wildcarded i/o addresses. */
192 1.2.2.2 thorpej if (ia->ia_iobase == ISACF_PORT_DEFAULT)
193 1.2.2.2 thorpej return (0);
194 1.2.2.2 thorpej
195 1.2.2.2 thorpej /* Disallow wildcarded mem address. */
196 1.2.2.2 thorpej if (ia->ia_maddr == ISACF_IOMEM_DEFAULT)
197 1.2.2.2 thorpej return (0);
198 1.2.2.2 thorpej
199 1.2.2.2 thorpej /* Validate the i/o base. */
200 1.2.2.2 thorpej for (i = 0; i < NEC_IOBASE; i++)
201 1.2.2.2 thorpej if (ia->ia_iobase == ec_iobase[i])
202 1.2.2.2 thorpej break;
203 1.2.2.2 thorpej if (i == NEC_IOBASE)
204 1.2.2.2 thorpej return (0);
205 1.2.2.2 thorpej
206 1.2.2.2 thorpej /* Validate the mem base. */
207 1.2.2.2 thorpej for (i = 0; i < NEC_MEMBASE; i++) {
208 1.2.2.2 thorpej if (ec_membase[i] == MADDRUNK)
209 1.2.2.2 thorpej continue;
210 1.2.2.2 thorpej if (ia->ia_maddr == ec_membase[i])
211 1.2.2.2 thorpej break;
212 1.2.2.2 thorpej }
213 1.2.2.2 thorpej if (i == NEC_MEMBASE)
214 1.2.2.2 thorpej return (0);
215 1.2.2.2 thorpej
216 1.2.2.2 thorpej /* Attempt to map the NIC space. */
217 1.2.2.2 thorpej if (bus_space_map(nict, ia->ia_iobase + ELINK2_NIC_OFFSET,
218 1.2.2.2 thorpej ELINK2_NIC_PORTS, 0, &nich))
219 1.2.2.2 thorpej goto out;
220 1.2.2.2 thorpej nich_valid = 1;
221 1.2.2.2 thorpej
222 1.2.2.2 thorpej /* Attempt to map the ASIC space. */
223 1.2.2.2 thorpej if (bus_space_map(asict, ia->ia_iobase + ELINK2_ASIC_OFFSET,
224 1.2.2.2 thorpej ELINK2_ASIC_PORTS, 0, &asich))
225 1.2.2.2 thorpej goto out;
226 1.2.2.2 thorpej asich_valid = 1;
227 1.2.2.2 thorpej
228 1.2.2.2 thorpej /* Attempt to map the memory space. */
229 1.2.2.2 thorpej if (bus_space_map(memt, ia->ia_maddr, memsize, 0, &memh))
230 1.2.2.2 thorpej goto out;
231 1.2.2.2 thorpej memh_valid = 1;
232 1.2.2.2 thorpej
233 1.2.2.2 thorpej /*
234 1.2.2.2 thorpej * Verify that the kernel configured I/O address matches the
235 1.2.2.2 thorpej * board configured I/O address.
236 1.2.2.2 thorpej *
237 1.2.2.2 thorpej * This is really only useful to see if something that looks like
238 1.2.2.2 thorpej * the board is there; after all, we're already talking to it at
239 1.2.2.2 thorpej * this point.
240 1.2.2.2 thorpej */
241 1.2.2.2 thorpej x = bus_space_read_1(asict, asich, ELINK2_BCFR);
242 1.2.2.2 thorpej if (x == 0 || (x & (x - 1)) != 0)
243 1.2.2.2 thorpej goto out;
244 1.2.2.2 thorpej i = ffs(x) - 1;
245 1.2.2.2 thorpej if (ia->ia_iobase != ec_iobase[i])
246 1.2.2.2 thorpej goto out;
247 1.2.2.2 thorpej
248 1.2.2.2 thorpej /*
249 1.2.2.2 thorpej * ...and for the memory address. Note we do not support
250 1.2.2.2 thorpej * cards configured with shared memory disabled.
251 1.2.2.2 thorpej */
252 1.2.2.2 thorpej x = bus_space_read_1(asict, asich, ELINK2_PCFR);
253 1.2.2.2 thorpej if (x == 0 || (x & (x - 1)) != 0)
254 1.2.2.2 thorpej goto out;
255 1.2.2.2 thorpej i = ffs(x) - 1;
256 1.2.2.2 thorpej if (ia->ia_maddr != ec_membase[i])
257 1.2.2.2 thorpej goto out;
258 1.2.2.2 thorpej
259 1.2.2.2 thorpej /* So, we say we've found it! */
260 1.2.2.2 thorpej ia->ia_iosize = ELINK2_NIC_PORTS;
261 1.2.2.2 thorpej ia->ia_msize = memsize;
262 1.2.2.2 thorpej rv = 1;
263 1.2.2.2 thorpej
264 1.2.2.2 thorpej out:
265 1.2.2.2 thorpej if (nich_valid)
266 1.2.2.2 thorpej bus_space_unmap(nict, nich, ELINK2_NIC_PORTS);
267 1.2.2.2 thorpej if (asich_valid)
268 1.2.2.2 thorpej bus_space_unmap(asict, asich, ELINK2_ASIC_PORTS);
269 1.2.2.2 thorpej if (memh_valid)
270 1.2.2.2 thorpej bus_space_unmap(memt, memh, memsize);
271 1.2.2.2 thorpej return (rv);
272 1.2.2.2 thorpej }
273 1.2.2.2 thorpej
274 1.2.2.2 thorpej void
275 1.2.2.2 thorpej ec_attach(parent, self, aux)
276 1.2.2.2 thorpej struct device *parent, *self;
277 1.2.2.2 thorpej void *aux;
278 1.2.2.2 thorpej {
279 1.2.2.2 thorpej struct ec_softc *esc = (struct ec_softc *)self;
280 1.2.2.2 thorpej struct dp8390_softc *sc = &esc->sc_dp8390;
281 1.2.2.2 thorpej struct isa_attach_args *ia = aux;
282 1.2.2.2 thorpej bus_space_tag_t nict, asict, memt;
283 1.2.2.2 thorpej bus_space_handle_t nich, asich, memh;
284 1.2.2.2 thorpej bus_size_t memsize;
285 1.2.2.2 thorpej u_int8_t tmp;
286 1.2.2.2 thorpej int i;
287 1.2.2.2 thorpej
288 1.2.2.2 thorpej printf("\n");
289 1.2.2.2 thorpej
290 1.2.2.2 thorpej nict = asict = ia->ia_iot;
291 1.2.2.2 thorpej memt = ia->ia_memt;
292 1.2.2.2 thorpej
293 1.2.2.2 thorpej /*
294 1.2.2.2 thorpej * Hmm, a 16-bit card has 16k of memory, but only an 8k window
295 1.2.2.2 thorpej * to it.
296 1.2.2.2 thorpej */
297 1.2.2.2 thorpej memsize = 8192;
298 1.2.2.2 thorpej
299 1.2.2.2 thorpej /* Map the NIC space. */
300 1.2.2.2 thorpej if (bus_space_map(nict, ia->ia_iobase + ELINK2_NIC_OFFSET,
301 1.2.2.2 thorpej ELINK2_NIC_PORTS, 0, &nich)) {
302 1.2.2.2 thorpej printf("%s: can't map nic i/o space\n",
303 1.2.2.2 thorpej sc->sc_dev.dv_xname);
304 1.2.2.2 thorpej return;
305 1.2.2.2 thorpej }
306 1.2.2.2 thorpej
307 1.2.2.2 thorpej /* Map the ASIC space. */
308 1.2.2.2 thorpej if (bus_space_map(asict, ia->ia_iobase + ELINK2_ASIC_OFFSET,
309 1.2.2.2 thorpej ELINK2_ASIC_PORTS, 0, &asich)) {
310 1.2.2.2 thorpej printf("%s: can't map asic i/o space\n",
311 1.2.2.2 thorpej sc->sc_dev.dv_xname);
312 1.2.2.2 thorpej return;
313 1.2.2.2 thorpej }
314 1.2.2.2 thorpej
315 1.2.2.2 thorpej /* Map the memory space. */
316 1.2.2.2 thorpej if (bus_space_map(memt, ia->ia_maddr, memsize, 0, &memh)) {
317 1.2.2.2 thorpej printf("%s: can't map shared memory\n",
318 1.2.2.2 thorpej sc->sc_dev.dv_xname);
319 1.2.2.2 thorpej return;
320 1.2.2.2 thorpej }
321 1.2.2.2 thorpej
322 1.2.2.2 thorpej esc->sc_asict = asict;
323 1.2.2.2 thorpej esc->sc_asich = asich;
324 1.2.2.2 thorpej
325 1.2.2.2 thorpej sc->sc_regt = nict;
326 1.2.2.2 thorpej sc->sc_regh = nich;
327 1.2.2.2 thorpej
328 1.2.2.2 thorpej sc->sc_buft = memt;
329 1.2.2.2 thorpej sc->sc_bufh = memh;
330 1.2.2.2 thorpej
331 1.2.2.2 thorpej /* Interface is always enabled. */
332 1.2.2.2 thorpej sc->sc_enabled = 1;
333 1.2.2.2 thorpej
334 1.2.2.2 thorpej /* Registers are linear. */
335 1.2.2.2 thorpej for (i = 0; i < 16; i++)
336 1.2.2.2 thorpej sc->sc_reg_map[i] = i;
337 1.2.2.2 thorpej
338 1.2.2.2 thorpej /* Now we can use the NIC_{GET,PUT}() macros. */
339 1.2.2.2 thorpej
340 1.2.2.2 thorpej /*
341 1.2.2.2 thorpej * Reset NIC and ASIC. Enable on-board transeiver throughout
342 1.2.2.2 thorpej * reset sequence since it will lock up if the cable isn't
343 1.2.2.2 thorpej * connected if we don't.
344 1.2.2.2 thorpej */
345 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_CR,
346 1.2.2.2 thorpej ELINK2_CR_RST | ELINK2_CR_XSEL);
347 1.2.2.2 thorpej
348 1.2.2.2 thorpej /* Wait for a while, then un-reset it. */
349 1.2.2.2 thorpej delay(50);
350 1.2.2.2 thorpej
351 1.2.2.2 thorpej /*
352 1.2.2.2 thorpej * The 3Com ASIC defaults to rather strange settings for the CR
353 1.2.2.2 thorpej * after a reset. It's important to set it again after the
354 1.2.2.2 thorpej * following write (this is done when we map the PROM below).
355 1.2.2.2 thorpej */
356 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_CR, ELINK2_CR_XSEL);
357 1.2.2.2 thorpej
358 1.2.2.2 thorpej /* Wait a bit for the NIC to recover from the reset. */
359 1.2.2.2 thorpej delay(5000);
360 1.2.2.2 thorpej
361 1.2.2.2 thorpej /*
362 1.2.2.2 thorpej * Get the station address from on-board ROM.
363 1.2.2.2 thorpej *
364 1.2.2.2 thorpej * First, map Ethernet address PROM over the top of where the NIC
365 1.2.2.2 thorpej * registers normally appear.
366 1.2.2.2 thorpej */
367 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_CR,
368 1.2.2.2 thorpej ELINK2_CR_XSEL | ELINK2_CR_EALO);
369 1.2.2.2 thorpej
370 1.2.2.2 thorpej for (i = 0; i < ETHER_ADDR_LEN; i++)
371 1.2.2.2 thorpej sc->sc_enaddr[i] = NIC_GET(nict, nich, i);
372 1.2.2.2 thorpej
373 1.2.2.2 thorpej /*
374 1.2.2.2 thorpej * Unmap PROM - select NIC registers. The proper setting of the
375 1.2.2.2 thorpej * transciever is set in later in ec_init_card() via dp8390_init().
376 1.2.2.2 thorpej */
377 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_CR, ELINK2_CR_XSEL);
378 1.2.2.2 thorpej
379 1.2.2.2 thorpej /* Determine if this is an 8-bit or 16-bit board. */
380 1.2.2.2 thorpej
381 1.2.2.2 thorpej /* Select page 0 registers. */
382 1.2.2.2 thorpej NIC_PUT(nict, nich, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
383 1.2.2.2 thorpej
384 1.2.2.2 thorpej /*
385 1.2.2.2 thorpej * Attempt to clear WTS. If it doesn't clear, then this is a
386 1.2.2.2 thorpej * 16-bit board.
387 1.2.2.2 thorpej */
388 1.2.2.2 thorpej NIC_PUT(nict, nich, ED_P0_DCR, 0);
389 1.2.2.2 thorpej
390 1.2.2.2 thorpej /* Select page 2 registers. */
391 1.2.2.2 thorpej NIC_PUT(nict, nich, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_2 | ED_CR_STP);
392 1.2.2.2 thorpej
393 1.2.2.2 thorpej /* The 3c503 forces the WTS bit to a one if this is a 16-bit board. */
394 1.2.2.2 thorpej if (NIC_GET(nict, nich, ED_P2_DCR) & ED_DCR_WTS)
395 1.2.2.2 thorpej esc->sc_16bitp = 1;
396 1.2.2.2 thorpej else
397 1.2.2.2 thorpej esc->sc_16bitp = 0;
398 1.2.2.2 thorpej
399 1.2.2.2 thorpej printf("%s: 3Com 3c503 Ethernet (%s-bit)\n",
400 1.2.2.2 thorpej sc->sc_dev.dv_xname, esc->sc_16bitp ? "16" : "8");
401 1.2.2.2 thorpej
402 1.2.2.2 thorpej /* Select page 0 registers. */
403 1.2.2.2 thorpej NIC_PUT(nict, nich, ED_P2_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
404 1.2.2.2 thorpej
405 1.2.2.2 thorpej sc->cr_proto = ED_CR_RD2;
406 1.2.2.2 thorpej
407 1.2.2.2 thorpej /*
408 1.2.2.2 thorpej * DCR gets:
409 1.2.2.2 thorpej *
410 1.2.2.2 thorpej * FIFO threshold to 8, No auto-init Remote DMA,
411 1.2.2.2 thorpej * byte order=80x86.
412 1.2.2.2 thorpej *
413 1.2.2.2 thorpej * 16-bit cards also get word-wide DMA transfers.
414 1.2.2.2 thorpej */
415 1.2.2.2 thorpej sc->dcr_reg = ED_DCR_FT1 | ED_DCR_LS |
416 1.2.2.2 thorpej (esc->sc_16bitp ? ED_DCR_WTS : 0);
417 1.2.2.2 thorpej
418 1.2.2.2 thorpej sc->test_mem = ec_fake_test_mem;
419 1.2.2.2 thorpej sc->ring_copy = ec_ring_copy;
420 1.2.2.2 thorpej sc->write_mbuf = ec_write_mbuf;
421 1.2.2.2 thorpej sc->read_hdr = ec_read_hdr;
422 1.2.2.3 cgd sc->init_card = ec_init_card;
423 1.2.2.2 thorpej
424 1.2.2.2 thorpej sc->sc_mediachange = ec_mediachange;
425 1.2.2.2 thorpej sc->sc_mediastatus = ec_mediastatus;
426 1.2.2.2 thorpej
427 1.2.2.2 thorpej sc->mem_start = 0;
428 1.2.2.2 thorpej sc->mem_size = memsize;
429 1.2.2.2 thorpej
430 1.2.2.2 thorpej /* Do generic parts of attach. */
431 1.2.2.2 thorpej if (dp8390_config(sc, ec_media, NEC_MEDIA, EC_DEFMEDIA)) {
432 1.2.2.2 thorpej printf("%s: configuration failed\n", sc->sc_dev.dv_xname);
433 1.2.2.2 thorpej return;
434 1.2.2.2 thorpej }
435 1.2.2.2 thorpej
436 1.2.2.2 thorpej /*
437 1.2.2.2 thorpej * We need to override the way dp8390_config() set up our
438 1.2.2.2 thorpej * shared memory.
439 1.2.2.2 thorpej *
440 1.2.2.2 thorpej * We have an entire 8k window to put the transmit buffers on the
441 1.2.2.2 thorpej * 16-bit boards. But since the 16bit 3c503's shared memory is only
442 1.2.2.2 thorpej * fast enough to overlap the loading of one full-size packet, trying
443 1.2.2.2 thorpej * to load more than 2 buffers can actually leave the transmitter idle
444 1.2.2.2 thorpej * during the load. So 2 seems the best value. (Although a mix of
445 1.2.2.2 thorpej * variable-sized packets might change this assumption. Nonetheless,
446 1.2.2.2 thorpej * we optimize for linear transfers of same-size packets.)
447 1.2.2.2 thorpej */
448 1.2.2.2 thorpej if (esc->sc_16bitp) {
449 1.2.2.2 thorpej if (sc->sc_dev.dv_cfdata->cf_flags & DP8390_NO_MULTI_BUFFERING)
450 1.2.2.2 thorpej sc->txb_cnt = 1;
451 1.2.2.2 thorpej else
452 1.2.2.2 thorpej sc->txb_cnt = 2;
453 1.2.2.2 thorpej
454 1.2.2.2 thorpej sc->tx_page_start = ELINK2_TX_PAGE_OFFSET_16BIT;
455 1.2.2.2 thorpej sc->rec_page_start = ELINK2_RX_PAGE_OFFSET_16BIT;
456 1.2.2.2 thorpej sc->rec_page_stop = (memsize >> ED_PAGE_SHIFT) +
457 1.2.2.2 thorpej sc->rec_page_start;
458 1.2.2.2 thorpej sc->mem_ring = sc->mem_start;
459 1.2.2.2 thorpej } else {
460 1.2.2.2 thorpej sc->txb_cnt = 1;
461 1.2.2.2 thorpej sc->tx_page_start = ELINK2_TX_PAGE_OFFSET_8BIT;
462 1.2.2.2 thorpej sc->rec_page_start = sc->tx_page_start + ED_TXBUF_SIZE;
463 1.2.2.2 thorpej sc->rec_page_stop = (memsize >> ED_PAGE_SHIFT) +
464 1.2.2.2 thorpej sc->tx_page_start;
465 1.2.2.2 thorpej sc->mem_ring = sc->mem_start +
466 1.2.2.2 thorpej (ED_TXBUF_SIZE << ED_PAGE_SHIFT);
467 1.2.2.2 thorpej }
468 1.2.2.2 thorpej
469 1.2.2.2 thorpej /*
470 1.2.2.2 thorpej * Initialize CA page start/stop registers. Probably only needed
471 1.2.2.2 thorpej * if doing DMA, but what the Hell.
472 1.2.2.2 thorpej */
473 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_PSTR, sc->rec_page_start);
474 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_PSPR, sc->rec_page_stop);
475 1.2.2.2 thorpej
476 1.2.2.2 thorpej /*
477 1.2.2.2 thorpej * Program the IRQ.
478 1.2.2.2 thorpej */
479 1.2.2.2 thorpej switch (ia->ia_irq) {
480 1.2.2.2 thorpej case 9: tmp = ELINK2_IDCFR_IRQ2; break;
481 1.2.2.2 thorpej case 3: tmp = ELINK2_IDCFR_IRQ3; break;
482 1.2.2.2 thorpej case 4: tmp = ELINK2_IDCFR_IRQ4; break;
483 1.2.2.2 thorpej case 5: tmp = ELINK2_IDCFR_IRQ5; break;
484 1.2.2.2 thorpej break;
485 1.2.2.2 thorpej
486 1.2.2.2 thorpej case IRQUNK:
487 1.2.2.2 thorpej printf("%s: wildcarded IRQ is not allowed\n",
488 1.2.2.2 thorpej sc->sc_dev.dv_xname);
489 1.2.2.2 thorpej return;
490 1.2.2.2 thorpej
491 1.2.2.2 thorpej default:
492 1.2.2.2 thorpej printf("%s: invalid IRQ %d, must be 3, 4, 5, or 9\n",
493 1.2.2.2 thorpej sc->sc_dev.dv_xname, ia->ia_irq);
494 1.2.2.2 thorpej return;
495 1.2.2.2 thorpej }
496 1.2.2.2 thorpej
497 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_IDCFR, tmp);
498 1.2.2.2 thorpej
499 1.2.2.2 thorpej /*
500 1.2.2.2 thorpej * Initialize the GA configuration register. Set bank and enable
501 1.2.2.2 thorpej * shared memory.
502 1.2.2.2 thorpej */
503 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_GACFR,
504 1.2.2.2 thorpej ELINK2_GACFR_RSEL | ELINK2_GACFR_MBS0);
505 1.2.2.2 thorpej
506 1.2.2.2 thorpej /*
507 1.2.2.2 thorpej * Intialize "Vector Pointer" registers. These gawd-awful things
508 1.2.2.2 thorpej * are compared to 20 bits of the address on the ISA, and if they
509 1.2.2.2 thorpej * match, the shared memory is disabled. We se them to 0xffff0...
510 1.2.2.2 thorpej * allegedly the reset vector.
511 1.2.2.2 thorpej */
512 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_VPTR2, 0xff);
513 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_VPTR1, 0xff);
514 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_VPTR0, 0x00);
515 1.2.2.2 thorpej
516 1.2.2.2 thorpej /*
517 1.2.2.2 thorpej * Now run the real memory test.
518 1.2.2.2 thorpej */
519 1.2.2.2 thorpej if (ec_test_mem(sc)) {
520 1.2.2.2 thorpej printf("%s: memory test failed\n", sc->sc_dev.dv_xname);
521 1.2.2.2 thorpej return;
522 1.2.2.2 thorpej }
523 1.2.2.2 thorpej
524 1.2.2.2 thorpej /* Establish interrupt handler. */
525 1.2.2.2 thorpej esc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
526 1.2.2.2 thorpej IPL_NET, dp8390_intr, sc);
527 1.2.2.2 thorpej if (esc->sc_ih == NULL)
528 1.2.2.2 thorpej printf("%s: can't establish interrupt\n", sc->sc_dev.dv_xname);
529 1.2.2.2 thorpej }
530 1.2.2.2 thorpej
531 1.2.2.2 thorpej int
532 1.2.2.2 thorpej ec_fake_test_mem(sc)
533 1.2.2.2 thorpej struct dp8390_softc *sc;
534 1.2.2.2 thorpej {
535 1.2.2.2 thorpej
536 1.2.2.2 thorpej /*
537 1.2.2.2 thorpej * We have to do this after we initialize the GA, but we
538 1.2.2.2 thorpej * have to do that after calling dp8390_config(), which
539 1.2.2.2 thorpej * wants to test memory. Put this noop here, and then
540 1.2.2.2 thorpej * actually test memory later.
541 1.2.2.2 thorpej */
542 1.2.2.2 thorpej return (0);
543 1.2.2.2 thorpej }
544 1.2.2.2 thorpej
545 1.2.2.2 thorpej int
546 1.2.2.2 thorpej ec_test_mem(sc)
547 1.2.2.2 thorpej struct dp8390_softc *sc;
548 1.2.2.2 thorpej {
549 1.2.2.2 thorpej struct ec_softc *esc = (struct ec_softc *)sc;
550 1.2.2.2 thorpej bus_space_tag_t memt = sc->sc_buft;
551 1.2.2.2 thorpej bus_space_handle_t memh = sc->sc_bufh;
552 1.2.2.2 thorpej bus_size_t memsize = sc->mem_size;
553 1.2.2.2 thorpej int i;
554 1.2.2.2 thorpej
555 1.2.2.2 thorpej if (esc->sc_16bitp)
556 1.2.2.2 thorpej bus_space_set_region_2(memt, memh, 0, 0, memsize >> 1);
557 1.2.2.2 thorpej else
558 1.2.2.2 thorpej bus_space_set_region_1(memt, memh, 0, 0, memsize);
559 1.2.2.2 thorpej
560 1.2.2.2 thorpej if (esc->sc_16bitp) {
561 1.2.2.2 thorpej for (i = 0; i < memsize; i += 2) {
562 1.2.2.2 thorpej if (bus_space_read_2(memt, memh, i) != 0)
563 1.2.2.2 thorpej goto fail;
564 1.2.2.2 thorpej }
565 1.2.2.2 thorpej } else {
566 1.2.2.2 thorpej for (i = 0; i < memsize; i++) {
567 1.2.2.2 thorpej if (bus_space_read_1(memt, memh, i) != 0)
568 1.2.2.2 thorpej goto fail;
569 1.2.2.2 thorpej }
570 1.2.2.2 thorpej }
571 1.2.2.2 thorpej
572 1.2.2.2 thorpej return (0);
573 1.2.2.2 thorpej
574 1.2.2.2 thorpej fail:
575 1.2.2.2 thorpej printf("%s: failed to clear shared memory at offset 0x%x\n",
576 1.2.2.2 thorpej sc->sc_dev.dv_xname, i);
577 1.2.2.2 thorpej return (1);
578 1.2.2.2 thorpej }
579 1.2.2.2 thorpej
580 1.2.2.2 thorpej __inline void
581 1.2.2.2 thorpej ec_writemem(esc, from, to, len)
582 1.2.2.2 thorpej struct ec_softc *esc;
583 1.2.2.2 thorpej u_int8_t *from;
584 1.2.2.2 thorpej int to, len;
585 1.2.2.2 thorpej {
586 1.2.2.2 thorpej bus_space_tag_t memt = esc->sc_dp8390.sc_buft;
587 1.2.2.2 thorpej bus_space_handle_t memh = esc->sc_dp8390.sc_bufh;
588 1.2.2.2 thorpej
589 1.2.2.2 thorpej if (esc->sc_16bitp) {
590 1.2.2.2 thorpej bus_space_write_region_2(memt, memh, to, (u_int16_t *)from,
591 1.2.2.2 thorpej len >> 1);
592 1.2.2.2 thorpej if (len & 1)
593 1.2.2.2 thorpej bus_space_write_2(memt, memh, to + (len & ~1),
594 1.2.2.2 thorpej (u_int16_t)(*(from + (len & ~1))));
595 1.2.2.2 thorpej } else
596 1.2.2.2 thorpej bus_space_write_region_1(memt, memh, to, from, len);
597 1.2.2.2 thorpej }
598 1.2.2.2 thorpej
599 1.2.2.2 thorpej __inline void
600 1.2.2.2 thorpej ec_readmem(esc, from, to, len)
601 1.2.2.2 thorpej struct ec_softc *esc;
602 1.2.2.2 thorpej int from;
603 1.2.2.2 thorpej u_int8_t *to;
604 1.2.2.2 thorpej int len;
605 1.2.2.2 thorpej {
606 1.2.2.2 thorpej bus_space_tag_t memt = esc->sc_dp8390.sc_buft;
607 1.2.2.2 thorpej bus_space_handle_t memh = esc->sc_dp8390.sc_bufh;
608 1.2.2.2 thorpej
609 1.2.2.2 thorpej if (esc->sc_16bitp) {
610 1.2.2.2 thorpej bus_space_read_region_2(memt, memh, from, (u_int16_t *)to,
611 1.2.2.2 thorpej len >> 1);
612 1.2.2.2 thorpej if (len & 1)
613 1.2.2.2 thorpej *(to + (len & ~1)) = bus_space_read_2(memt,
614 1.2.2.2 thorpej memh, from + (len & ~1)) & 0xff;
615 1.2.2.2 thorpej } else
616 1.2.2.2 thorpej bus_space_read_region_1(memt, memh, from, to, len);
617 1.2.2.2 thorpej }
618 1.2.2.2 thorpej
619 1.2.2.2 thorpej int
620 1.2.2.2 thorpej ec_write_mbuf(sc, m, buf)
621 1.2.2.2 thorpej struct dp8390_softc *sc;
622 1.2.2.2 thorpej struct mbuf *m;
623 1.2.2.2 thorpej int buf;
624 1.2.2.2 thorpej {
625 1.2.2.2 thorpej struct ec_softc *esc = (struct ec_softc *)sc;
626 1.2.2.2 thorpej bus_space_tag_t asict = esc->sc_asict;
627 1.2.2.2 thorpej bus_space_handle_t asich = esc->sc_asich;
628 1.2.2.2 thorpej int savelen;
629 1.2.2.2 thorpej
630 1.2.2.2 thorpej savelen = m->m_pkthdr.len;
631 1.2.2.2 thorpej
632 1.2.2.2 thorpej /*
633 1.2.2.2 thorpej * If it's a 16-bit board, we have transmit buffers
634 1.2.2.2 thorpej * in a different page; switch to it.
635 1.2.2.2 thorpej */
636 1.2.2.2 thorpej if (esc->sc_16bitp)
637 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_GACFR,
638 1.2.2.2 thorpej ELINK2_GACFR_RSEL);
639 1.2.2.2 thorpej
640 1.2.2.2 thorpej for (; m != NULL; buf += m->m_len, m = m->m_next)
641 1.2.2.2 thorpej ec_writemem(esc, mtod(m, u_int8_t *), buf, m->m_len);
642 1.2.2.2 thorpej
643 1.2.2.2 thorpej /*
644 1.2.2.2 thorpej * Switch back to receive page.
645 1.2.2.2 thorpej */
646 1.2.2.2 thorpej if (esc->sc_16bitp)
647 1.2.2.2 thorpej bus_space_write_1(asict, asich, ELINK2_GACFR,
648 1.2.2.2 thorpej ELINK2_GACFR_RSEL | ELINK2_GACFR_MBS0);
649 1.2.2.2 thorpej
650 1.2.2.2 thorpej return (savelen);
651 1.2.2.2 thorpej }
652 1.2.2.2 thorpej
653 1.2.2.2 thorpej int
654 1.2.2.2 thorpej ec_ring_copy(sc, src, dst, amount)
655 1.2.2.2 thorpej struct dp8390_softc *sc;
656 1.2.2.2 thorpej int src;
657 1.2.2.2 thorpej caddr_t dst;
658 1.2.2.2 thorpej u_short amount;
659 1.2.2.2 thorpej {
660 1.2.2.2 thorpej struct ec_softc *esc = (struct ec_softc *)sc;
661 1.2.2.2 thorpej u_short tmp_amount;
662 1.2.2.2 thorpej
663 1.2.2.2 thorpej /* Does copy wrap to lower addr in ring buffer? */
664 1.2.2.2 thorpej if (src + amount > sc->mem_end) {
665 1.2.2.2 thorpej tmp_amount = sc->mem_end - src;
666 1.2.2.2 thorpej
667 1.2.2.2 thorpej /* Copy amount up to end of NIC memory. */
668 1.2.2.2 thorpej ec_readmem(esc, src, dst, tmp_amount);
669 1.2.2.2 thorpej
670 1.2.2.2 thorpej amount -= tmp_amount;
671 1.2.2.2 thorpej src = sc->mem_ring;
672 1.2.2.2 thorpej dst += tmp_amount;
673 1.2.2.2 thorpej }
674 1.2.2.2 thorpej
675 1.2.2.2 thorpej ec_readmem(esc, src, dst, amount);
676 1.2.2.2 thorpej
677 1.2.2.2 thorpej return (src + amount);
678 1.2.2.2 thorpej }
679 1.2.2.2 thorpej
680 1.2.2.2 thorpej void
681 1.2.2.2 thorpej ec_read_hdr(sc, packet_ptr, packet_hdrp)
682 1.2.2.2 thorpej struct dp8390_softc *sc;
683 1.2.2.2 thorpej int packet_ptr;
684 1.2.2.2 thorpej struct dp8390_ring *packet_hdrp;
685 1.2.2.2 thorpej {
686 1.2.2.2 thorpej struct ec_softc *esc = (struct ec_softc *)sc;
687 1.2.2.2 thorpej
688 1.2.2.2 thorpej ec_readmem(esc, packet_ptr, (u_int8_t *)packet_hdrp,
689 1.2.2.2 thorpej sizeof(struct dp8390_ring));
690 1.2.2.2 thorpej }
691 1.2.2.2 thorpej
692 1.2.2.2 thorpej int
693 1.2.2.2 thorpej ec_mediachange(sc)
694 1.2.2.2 thorpej struct dp8390_softc *sc;
695 1.2.2.2 thorpej {
696 1.2.2.2 thorpej struct ec_softc *esc = (struct ec_softc *)sc;
697 1.2.2.2 thorpej struct ifmedia *ifm = &sc->sc_media;
698 1.2.2.2 thorpej
699 1.2.2.2 thorpej return (ec_set_media(esc, ifm->ifm_media));
700 1.2.2.2 thorpej }
701 1.2.2.2 thorpej
702 1.2.2.2 thorpej void
703 1.2.2.2 thorpej ec_mediastatus(sc, ifmr)
704 1.2.2.2 thorpej struct dp8390_softc *sc;
705 1.2.2.2 thorpej struct ifmediareq *ifmr;
706 1.2.2.2 thorpej {
707 1.2.2.2 thorpej struct ifmedia *ifm = &sc->sc_media;
708 1.2.2.2 thorpej
709 1.2.2.2 thorpej /*
710 1.2.2.2 thorpej * The currently selected media is always the active media.
711 1.2.2.2 thorpej */
712 1.2.2.2 thorpej ifmr->ifm_active = ifm->ifm_cur->ifm_media;
713 1.2.2.2 thorpej }
714 1.2.2.2 thorpej
715 1.2.2.2 thorpej void
716 1.2.2.2 thorpej ec_init_card(sc)
717 1.2.2.2 thorpej struct dp8390_softc *sc;
718 1.2.2.2 thorpej {
719 1.2.2.2 thorpej struct ec_softc *esc = (struct ec_softc *)sc;
720 1.2.2.2 thorpej struct ifmedia *ifm = &sc->sc_media;
721 1.2.2.2 thorpej
722 1.2.2.2 thorpej (void) ec_set_media(esc, ifm->ifm_cur->ifm_media);
723 1.2.2.2 thorpej }
724 1.2.2.2 thorpej
725 1.2.2.2 thorpej int
726 1.2.2.2 thorpej ec_set_media(esc, media)
727 1.2.2.2 thorpej struct ec_softc *esc;
728 1.2.2.2 thorpej int media;
729 1.2.2.2 thorpej {
730 1.2.2.2 thorpej u_int8_t new;
731 1.2.2.2 thorpej
732 1.2.2.2 thorpej if (IFM_TYPE(media) != IFM_ETHER)
733 1.2.2.2 thorpej return (EINVAL);
734 1.2.2.2 thorpej
735 1.2.2.2 thorpej switch (IFM_SUBTYPE(media)) {
736 1.2.2.2 thorpej case IFM_10_2:
737 1.2.2.2 thorpej new = ELINK2_CR_XSEL;
738 1.2.2.2 thorpej break;
739 1.2.2.2 thorpej
740 1.2.2.2 thorpej case IFM_10_5:
741 1.2.2.2 thorpej new = 0;
742 1.2.2.2 thorpej break;
743 1.2.2.2 thorpej
744 1.2.2.2 thorpej default:
745 1.2.2.2 thorpej return (EINVAL);
746 1.2.2.2 thorpej }
747 1.2.2.2 thorpej
748 1.2.2.2 thorpej bus_space_write_1(esc->sc_asict, esc->sc_asich, ELINK2_CR, new);
749 1.2.2.2 thorpej return (0);
750 1.2.2.2 thorpej }
751