elink.c revision 112789
155430Srwatson/* 255430Srwatson * Copyright (c) 1994 Charles Hannum. All rights reserved. 355430Srwatson * 455430Srwatson * Redistribution and use in source and binary forms, with or without 555430Srwatson * modification, are permitted provided that the following conditions 655430Srwatson * are met: 755430Srwatson * 1. Redistributions of source code must retain the above copyright 855430Srwatson * notice, this list of conditions and the following disclaimer. 955430Srwatson * 2. Redistributions in binary form must reproduce the above copyright 1055430Srwatson * notice, this list of conditions and the following disclaimer in the 1155430Srwatson * documentation and/or other materials provided with the distribution. 1255430Srwatson * 3. All advertising materials mentioning features or use of this software 1355430Srwatson * must display the following acknowledgement: 1455430Srwatson * This product includes software developed by Charles Hannum. 1555430Srwatson * 4. The name of the author may not be used to endorse or promote products 1655430Srwatson * derived from this software without specific prior written permission. 1755430Srwatson * 1855430Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1955430Srwatson * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2055430Srwatson * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2155430Srwatson * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2255430Srwatson * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2355430Srwatson * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2455430Srwatson * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2555430Srwatson * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26141580Sru * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2755430Srwatson * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2855430Srwatson * 29206622Suqs * $FreeBSD: head/sys/i386/isa/elink.c 112789 2003-03-29 13:18:20Z mdodd $ 3055430Srwatson */ 3155430Srwatson 3255430Srwatson/* 3375670Sru * Common code for dealing with 3COM ethernet cards. 3455430Srwatson */ 3584306Sru 3684306Sru#include <sys/param.h> 3784306Sru#include <sys/systm.h> 3855430Srwatson#include <sys/kernel.h> 3986691Sarr#include <sys/module.h> 4055430Srwatson 4155430Srwatson#include <machine/cpufunc.h> 4255430Srwatson 4355430Srwatson#include <i386/isa/elink.h> 4455430Srwatson 4555430Srwatson/* 46115440Shmp * Issue a `global reset' to all cards. We have to be careful to do this only 47140931Sru * once during autoconfig, to prevent resetting boards that have already been 48115440Shmp * configured. 49140931Sru */ 50115440Shmpvoid 51140931Sruelink_reset() 52115440Shmp{ 53140931Sru static int x = 0; 54115440Shmp 55140931Sru if (x == 0) { 5655430Srwatson x = 1; 5755430Srwatson outb(ELINK_ID_PORT, ELINK_RESET); 5855430Srwatson } 5955430Srwatson outb(ELINK_ID_PORT, 0); 6055430Srwatson outb(ELINK_ID_PORT, 0); 61121382Shmp 62121382Shmp return; 6355430Srwatson} 6455430Srwatson 6555430Srwatson/* 6655430Srwatson * The `ID sequence' is really just snapshots of an 8-bit CRC register as 0 67121382Shmp * bits are shifted in. Different board types use different polynomials. 68121382Shmp */ 6955430Srwatsonvoid 7055430Srwatsonelink_idseq(u_char p) 7155430Srwatson{ 7255430Srwatson register int i; 7355430Srwatson register u_char c; 7455430Srwatson 7555430Srwatson c = 0xff; 7655430Srwatson for (i = 255; i; i--) { 7755430Srwatson outb(ELINK_ID_PORT, c); 7855430Srwatson if (c & 0x80) { 7955430Srwatson c <<= 1; 8055430Srwatson c ^= p; 81121382Shmp } else 82121382Shmp c <<= 1; 8355430Srwatson } 8455430Srwatson} 8555430Srwatson 86103534Struckmanstatic moduledata_t elink_mod = { 8755430Srwatson "elink",/* module name */ 88103566Struckman NULL, /* event handler */ 8955430Srwatson 0 /* extra data */ 90103566Struckman}; 9155430Srwatson 92107788SruDECLARE_MODULE(elink, elink_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); 93103534StruckmanMODULE_VERSION(elink, 1); 9455430Srwatson