elink.c revision 1.7 1 1.7 cgd /* $NetBSD: elink.c,v 1.7 1995/01/29 07:36:56 cgd Exp $ */
2 1.3 cgd
3 1.2 mycroft /*
4 1.6 mycroft * Copyright (c) 1994, 1995 Charles Hannum. All rights reserved.
5 1.2 mycroft *
6 1.2 mycroft * Redistribution and use in source and binary forms, with or without
7 1.2 mycroft * modification, are permitted provided that the following conditions
8 1.2 mycroft * are met:
9 1.2 mycroft * 1. Redistributions of source code must retain the above copyright
10 1.2 mycroft * notice, this list of conditions and the following disclaimer.
11 1.2 mycroft * 2. Redistributions in binary form must reproduce the above copyright
12 1.2 mycroft * notice, this list of conditions and the following disclaimer in the
13 1.2 mycroft * documentation and/or other materials provided with the distribution.
14 1.2 mycroft * 3. All advertising materials mentioning features or use of this software
15 1.2 mycroft * must display the following acknowledgement:
16 1.2 mycroft * This product includes software developed by Charles Hannum.
17 1.2 mycroft * 4. The name of the author may not be used to endorse or promote products
18 1.2 mycroft * derived from this software without specific prior written permission.
19 1.2 mycroft *
20 1.2 mycroft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.2 mycroft * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.2 mycroft * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.2 mycroft * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.2 mycroft * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.2 mycroft * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.2 mycroft * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.2 mycroft * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.2 mycroft * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.2 mycroft * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.2 mycroft */
31 1.2 mycroft
32 1.2 mycroft /*
33 1.2 mycroft * Common code for dealing with 3COM ethernet cards.
34 1.2 mycroft */
35 1.2 mycroft
36 1.1 mycroft #include <sys/types.h>
37 1.1 mycroft #include <machine/pio.h>
38 1.7 cgd #include <dev/isa/elink.h>
39 1.1 mycroft
40 1.1 mycroft /*
41 1.6 mycroft * Issue a `global reset' to all cards, and reset the ID state machines. We
42 1.6 mycroft * have to be careful to do the global reset only once during autoconfig, to
43 1.6 mycroft * prevent resetting boards that have already been configured.
44 1.1 mycroft */
45 1.1 mycroft void
46 1.1 mycroft elink_reset()
47 1.1 mycroft {
48 1.1 mycroft static int x = 0;
49 1.1 mycroft
50 1.2 mycroft if (x == 0) {
51 1.2 mycroft x = 1;
52 1.1 mycroft outb(ELINK_ID_PORT, ELINK_RESET);
53 1.2 mycroft }
54 1.6 mycroft outb(ELINK_ID_PORT, 0x00);
55 1.6 mycroft outb(ELINK_ID_PORT, 0x00);
56 1.1 mycroft }
57 1.1 mycroft
58 1.1 mycroft /*
59 1.1 mycroft * The `ID sequence' is really just snapshots of an 8-bit CRC register as 0
60 1.2 mycroft * bits are shifted in. Different board types use different polynomials.
61 1.1 mycroft */
62 1.1 mycroft void
63 1.1 mycroft elink_idseq(p)
64 1.1 mycroft register u_char p;
65 1.1 mycroft {
66 1.1 mycroft register int i;
67 1.1 mycroft register u_char c;
68 1.1 mycroft
69 1.1 mycroft c = 0xff;
70 1.1 mycroft for (i = 255; i; i--) {
71 1.1 mycroft outb(ELINK_ID_PORT, c);
72 1.1 mycroft if (c & 0x80) {
73 1.1 mycroft c <<= 1;
74 1.1 mycroft c ^= p;
75 1.1 mycroft } else
76 1.1 mycroft c <<= 1;
77 1.1 mycroft }
78 1.1 mycroft }
79