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