/*
* Copyright (c) 2000 Masanori Kanaoka
* All rights reserved.
*
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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_rtk_cardbus.c:
* Cardbus specific routines for Realtek 8139 ethernet adapter.
* Tested for
* - elecom-Laneed LD-10/100CBA (Accton MPX5030)
* - MELCO LPC3-TX-CB (Realtek 8139)
*/
/*
* Default to using PIO access for this driver. On SMP systems,
* there appear to be problems with memory mapped mode: it looks like
* doing too many memory mapped access back to back in rapid succession
* can hang the bus. I'm inclined to blame this on crummy design/construction
* on the part of Realtek. Memory mapped mode does appear to work on
* uniprocessor systems though.
*/
#define RTK_USEIOSPACE
if (pmf_device_register(self, NULL, NULL))
pmf_class_network_register(self, &sc->ethercom.ec_if);
else
aprint_error_dev(self, "couldn't establish power handler\n");
/*
* Power down the socket.
*/
Cardbus_function_disable(csc->sc_ct);
}
int
rtk_cardbus_detach(device_t self, int flags)
{
struct rtk_cardbus_softc *csc = device_private(self);
struct rtk_softc *sc = &csc->sc_rtk;
struct cardbus_devfunc *ct = csc->sc_ct;
int rv;
#ifdef DIAGNOSTIC
if (ct == NULL)
panic("%s: data structure lacks", device_xname(self));
#endif
rv = rtk_detach(sc);
if (rv)
return rv;
/*
* Unhook the interrupt handler.
*/
if (csc->sc_ih != NULL)
Cardbus_intr_disestablish(ct, csc->sc_ih);
/*
* Release bus space and close window.
*/
if (csc->sc_bar_reg != 0)
Cardbus_mapreg_unmap(ct, csc->sc_bar_reg,
sc->rtk_btag, sc->rtk_bhandle, sc->rtk_bsize);
/* Reset the power state. */
aprint_normal_dev(sc->sc_dev,
"chip is in D%d power mode -- setting to D0\n",
command & PCI_PMCSR_STATE_MASK);
command &= ~PCI_PMCSR_STATE_MASK;
Cardbus_conf_write(ct, csc->sc_tag,
pmreg + PCI_PMCSR, command);