/*-
* 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; Jason R. Thorpe of the Numerical Aerospace
* Simulation Facility, NASA Ames Research Center; Paul Kranenburg.
*
* 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.
*/
#if defined(SUN4M)
/*
* We need to flush the Sbus->Mbus write buffers. This can most
* easily be accomplished by reading back the register that we
* just wrote (thanks to Chris Torek for this solution).
*/
(void)bus_space_read_2(t, h, LEREG1_RDP);
#endif
}
csr = L64854_GCSR(dma);
csr &= ~E_TP_AUI;
L64854_SCSR(dma, csr);
delay(20000); /* must not touch le for 20ms */
}
int
lemediachange(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, we don't really have to do anything. We'll
* switch to the other media when we detect loss of
* carrier.
*/
switch (IFM_SUBTYPE(ifm->ifm_media)) {
case IFM_10_T:
lesetutp(sc);
break;
/*
* Notify the world which media we're currently using.
*/
if (L64854_GCSR(dma) & E_TP_AUI)
ifmr->ifm_active = IFM_ETHER | IFM_10_T;
else
ifmr->ifm_active = IFM_ETHER | IFM_10_5;
}
/*
* Disable E-cache invalidates on chip writes.
* Retain previous cable selection bit.
*/
csr = L64854_GCSR(dma);
csr |= (E_DSBL_WR_INVAL | aui_bit);
L64854_SCSR(dma, csr);
delay(20000); /* must not touch le for 20ms */
}
static void
lehwinit(struct lance_softc *sc)
{
/*
* Make sure we're using the currently-enabled media type.
* XXX Actually, this is probably unnecessary, now.
*/
switch (IFM_SUBTYPE(sc->sc_media.ifm_cur->ifm_media)) {
case IFM_10_T:
lesetutp(sc);
break;
/* it may take a while for modern switches to set 10baseT media */
if (lesc->sc_lostcount++ < LE_LOSTTHRESH)
return;
lesc->sc_lostcount = 0;
/*
* Check if the user has requested a certain cable type, and
* if so, honor that request.
*/
printf("%s: lost carrier on ", device_xname(sc->sc_dev));
if (L64854_GCSR(lesc->sc_dma) & E_TP_AUI) {
printf("UTP port");
switch (IFM_SUBTYPE(sc->sc_media.ifm_media)) {
case IFM_10_5:
case IFM_AUTO:
printf(", switching to AUI port");
lesetaui(sc);
}
} else {
printf("AUI port");
switch (IFM_SUBTYPE(sc->sc_media.ifm_media)) {
case IFM_10_T:
case IFM_AUTO:
printf(", switching to UTP port");
lesetutp(sc);
}
}
printf("\n");
}