1139790Simp/*- 22268Sats * Copyright (c) 1994 Charles Hannum. All rights reserved. 32268Sats * 42268Sats * Redistribution and use in source and binary forms, with or without 52268Sats * modification, are permitted provided that the following conditions 62268Sats * are met: 72268Sats * 1. Redistributions of source code must retain the above copyright 82268Sats * notice, this list of conditions and the following disclaimer. 92268Sats * 2. Redistributions in binary form must reproduce the above copyright 102268Sats * notice, this list of conditions and the following disclaimer in the 112268Sats * documentation and/or other materials provided with the distribution. 122268Sats * 3. All advertising materials mentioning features or use of this software 132268Sats * must display the following acknowledgement: 142268Sats * This product includes software developed by Charles Hannum. 152268Sats * 4. The name of the author may not be used to endorse or promote products 162268Sats * derived from this software without specific prior written permission. 172268Sats * 182268Sats * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 192268Sats * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 202268Sats * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 212268Sats * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 222268Sats * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 232268Sats * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242268Sats * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252268Sats * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262268Sats * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 272268Sats * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282268Sats */ 292268Sats 30115703Sobrien#include <sys/cdefs.h> 31115703Sobrien__FBSDID("$FreeBSD$"); 32115703Sobrien 332268Sats/* 342268Sats * Common code for dealing with 3COM ethernet cards. 352268Sats */ 362268Sats 37112789Smdodd#include <sys/param.h> 38112789Smdodd#include <sys/systm.h> 39112789Smdodd#include <sys/kernel.h> 40112789Smdodd#include <sys/module.h> 416734Sbde 426734Sbde#include <machine/cpufunc.h> 436734Sbde 442268Sats#include <i386/isa/elink.h> 452268Sats 462268Sats/* 472268Sats * Issue a `global reset' to all cards. We have to be careful to do this only 482268Sats * once during autoconfig, to prevent resetting boards that have already been 492268Sats * configured. 502268Sats */ 512268Satsvoid 522268Satselink_reset() 538876Srgrimes{ 542268Sats static int x = 0; 552268Sats 562268Sats if (x == 0) { 572268Sats x = 1; 582268Sats outb(ELINK_ID_PORT, ELINK_RESET); 592268Sats } 60112789Smdodd outb(ELINK_ID_PORT, 0); 61112789Smdodd outb(ELINK_ID_PORT, 0); 62112789Smdodd 63112789Smdodd return; 642268Sats} 652268Sats 662268Sats/* 672268Sats * The `ID sequence' is really just snapshots of an 8-bit CRC register as 0 682268Sats * bits are shifted in. Different board types use different polynomials. 692268Sats */ 702268Satsvoid 7128752Sbdeelink_idseq(u_char p) 722268Sats{ 732268Sats register int i; 742268Sats register u_char c; 752268Sats 762268Sats c = 0xff; 772268Sats for (i = 255; i; i--) { 782268Sats outb(ELINK_ID_PORT, c); 792268Sats if (c & 0x80) { 802268Sats c <<= 1; 812268Sats c ^= p; 822268Sats } else 832268Sats c <<= 1; 842268Sats } 852268Sats} 86112789Smdodd 87112789Smdoddstatic moduledata_t elink_mod = { 88112789Smdodd "elink",/* module name */ 89112789Smdodd NULL, /* event handler */ 90241394Skevlo 0 /* extra data */ 91112789Smdodd}; 92112789Smdodd 93112789SmdoddDECLARE_MODULE(elink, elink_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); 94112789SmdoddMODULE_VERSION(elink, 1); 95