/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
* Simulation Facility, NASA Ames Research Center.
*
* 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.
*/
/*-
* Copyright (c) 1997 Bernd Ernesti. All rights reserved.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell and Rick Macklem.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project
* by Bernd Ernesti.
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)if_le.c 8.2 (Berkeley) 11/16/93
*/
void
ariadne_autoselect(struct lance_softc *sc, int on)
{
/*
* on = 0: autoselect disabled
* on = 1: autoselect enabled
*/
if (on == 0)
ariadne_wribcr(sc, LE_BCR_MC, 0x0000);
else
ariadne_wribcr(sc, LE_BCR_MC, LE_MC_ASEL);
}
int
ariadne_mediachange(struct lance_softc *sc)
{
struct ifmedia *ifm = &sc->sc_media;
if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
return (EINVAL);
/*
* Switch to the selected media. If autoselect is
* set, switch it on otherwise disable it. We'll
* switch to the other media when we detect loss of
* carrier.
*/
switch (IFM_SUBTYPE(ifm->ifm_media)) {
case IFM_10_T:
sc->sc_initmodemedia = 1;
lance_init(&sc->sc_ethercom.ec_if);
break;
case IFM_10_2:
sc->sc_initmodemedia = 0;
lance_init(&sc->sc_ethercom.ec_if);
break;
case IFM_AUTO:
sc->sc_initmodemedia = 2;
ariadne_hwinit(sc);
break;
default:
return (EINVAL);
}
return (0);
}
void
ariadne_hwinit(struct lance_softc *sc)
{
/*
* Re-program LEDs to match meaning used on the Ariadne board.
*/
ariadne_wribcr(sc, LE_BCR_LED1, 0x0090);
ariadne_wribcr(sc, LE_BCR_LED2, 0x0081);
ariadne_wribcr(sc, LE_BCR_LED3, 0x0084);
/*
* Enable/Disable auto selection
*/
if (sc->sc_initmodemedia == 2)
ariadne_autoselect(sc, 1);
else
ariadne_autoselect(sc, 0);
}
/*
* Serial number for board is used as host ID.
*/
ser = (u_long)zap->serno;
sc->sc_enaddr[3] = (ser >> 16) & 0xff;
sc->sc_enaddr[4] = (ser >> 8) & 0xff;
sc->sc_enaddr[5] = (ser ) & 0xff;