/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jaromir Dolecek.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Driver for SKNET Personal and MC2+ cards, which are AMD Lance 7990 based
* cards made by Syskonnect, former Schneider & Koch Datensysteme GmbH.
*
* Syskonnect was very helpful and provided docs for these cards promptly.
* I wish all vendors would be like that!
* I'd like to thank to Alfred Arnold, author of the Linux driver, for
* giving me contact to The Right Syskonnect person, too :-)
*
* Sources:
* SKNET MC+ Technical Manual, version 1.1, July 21 1993
* SKNET personal Technisches Manual, version 1.2, April 14 1988
* SKNET junior Technisches Manual, version 1.0, July 14 1987
*/
/*
* SKNET MC+ needs the driver to clear 0, 1 bits of pos4
* and explicitly set the enable bit. Somebody at Syskonnect
* was obviously misguided when the card was designed ...
*/
pos3 = mca_conf_read(ma->ma_mc, ma->ma_slot, 3);
pos4 = mca_conf_read(ma->ma_mc, ma->ma_slot, 4);
if ((pos4 & 0x03) != 0) {
/* clear the bits 0, 1 */
mca_conf_write(ma->ma_mc, ma->ma_slot, 4,
pos4 & ~0x03);
}
/*
* Extract the physical MAC address from the ROM.
*/
for (i = 0; i < ETHER_ADDR_LEN; i++)
sc->sc_enaddr[i] = bus_space_read_1(lesc->sc_memt,
lesc->sc_memh, LE_PROMOFF + i * 2);
/*
* This is merely cosmetic since it's not possible to switch
* the media anyway, even for MC2+.
*/
if (supmedia != NULL) {
sc->sc_supmedia = supmedia;
sc->sc_nsupmedia = 1;
sc->sc_defaultmedia = *supmedia;
}
/*
* Controller interrupt.
*/
int
le_mca_intredge(void *arg)
{
/*
* We could check the IRQ bit of LE_PORT, but it seems to be unset
* at this time anyway.
*/
if (am7990_intr(arg) == 0)
return 0;
for(;;)
if (am7990_intr(arg) == 0)
return 1;
}
/*
* Push a value to LANCE controller.
*/
static inline void
le_mca_wrreg(struct le_mca_softc *sc, int val, int type)
{
/*
* This follows steps in SKNET Personal/MC2+ docs:
* 1. write reg. number to LANCE register
* 2. write value RESET | type to port
* 3. flag REGDO
* 4. wait until REGREQ is cleared
*/
if ((type & REGREAD) == 0)
bus_space_write_2(sc->sc_memt, sc->sc_memh, LE_LANCEREG, val);
bus_space_write_1(sc->sc_memt, sc->sc_memh, LE_PORT,
RESET | type);
bus_space_write_1(sc->sc_memt, sc->sc_memh, LE_REGIO,
REGDO);
/* Delay here doesn't seem to be necessary */
/* delay(1); */
while (bus_space_read_1(sc->sc_memt, sc->sc_memh, LE_PORT) & REGREQ)
;
}