Home | History | Annotate | Line # | Download | only in cardbus
if_rtk_cardbus.c revision 1.47
      1  1.47       tls /*	$NetBSD: if_rtk_cardbus.c,v 1.47 2012/02/02 19:43:02 tls Exp $	*/
      2   1.2   thorpej 
      3   1.1      haya /*
      4   1.1      haya  * Copyright (c) 2000 Masanori Kanaoka
      5   1.1      haya  * All rights reserved.
      6   1.1      haya  *
      7   1.1      haya  * Redistribution and use in source and binary forms, with or without
      8   1.1      haya  * modification, are permitted provided that the following conditions
      9   1.1      haya  * are met:
     10   1.1      haya  * 1. Redistributions of source code must retain the above copyright
     11   1.1      haya  *    notice, this list of conditions and the following disclaimer.
     12   1.1      haya  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1      haya  *    notice, this list of conditions and the following disclaimer in the
     14   1.1      haya  *    documentation and/or other materials provided with the distribution.
     15   1.1      haya  * 3. The name of the author may not be used to endorse or promote products
     16   1.1      haya  *    derived from this software without specific prior written permission.
     17   1.1      haya  *
     18   1.1      haya  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19   1.1      haya  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20   1.1      haya  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21   1.1      haya  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22   1.1      haya  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23   1.1      haya  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24   1.1      haya  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25   1.1      haya  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26   1.1      haya  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     27   1.1      haya  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28   1.1      haya  */
     29   1.1      haya 
     30   1.1      haya /*
     31   1.1      haya  * if_rtk_cardbus.c:
     32  1.18       wiz  *	Cardbus specific routines for Realtek 8139 ethernet adapter.
     33  1.25     perry  *	Tested for
     34   1.1      haya  *		- elecom-Laneed	LD-10/100CBA (Accton MPX5030)
     35  1.18       wiz  *		- MELCO		LPC3-TX-CB   (Realtek 8139)
     36   1.1      haya  */
     37   1.6     lukem 
     38   1.6     lukem #include <sys/cdefs.h>
     39  1.47       tls __KERNEL_RCSID(0, "$NetBSD: if_rtk_cardbus.c,v 1.47 2012/02/02 19:43:02 tls Exp $");
     40   1.1      haya 
     41   1.1      haya #include "opt_inet.h"
     42   1.1      haya 
     43   1.1      haya #include <sys/param.h>
     44   1.1      haya #include <sys/systm.h>
     45   1.1      haya #include <sys/callout.h>
     46   1.1      haya #include <sys/device.h>
     47   1.1      haya #include <sys/sockio.h>
     48   1.1      haya #include <sys/mbuf.h>
     49   1.1      haya #include <sys/malloc.h>
     50   1.1      haya #include <sys/kernel.h>
     51   1.1      haya #include <sys/socket.h>
     52   1.1      haya 
     53   1.1      haya #include <net/if.h>
     54   1.1      haya #include <net/if_arp.h>
     55   1.1      haya #include <net/if_ether.h>
     56   1.1      haya #include <net/if_dl.h>
     57   1.1      haya #include <net/if_media.h>
     58   1.1      haya #ifdef INET
     59   1.1      haya #include <netinet/in.h>
     60   1.1      haya #include <netinet/if_inarp.h>
     61   1.1      haya #endif
     62   1.1      haya 
     63   1.1      haya #include <sys/rnd.h>
     64   1.1      haya 
     65  1.33        ad #include <sys/bus.h>
     66   1.1      haya 
     67   1.1      haya #include <dev/pci/pcireg.h>
     68   1.1      haya #include <dev/pci/pcivar.h>
     69   1.1      haya #include <dev/pci/pcidevs.h>
     70   1.1      haya 
     71   1.1      haya #include <dev/cardbus/cardbusvar.h>
     72  1.22   mycroft #include <dev/pci/pcidevs.h>
     73   1.1      haya 
     74   1.1      haya #include <dev/mii/mii.h>
     75   1.1      haya #include <dev/mii/miivar.h>
     76   1.1      haya 
     77   1.1      haya /*
     78   1.1      haya  * Default to using PIO access for this driver. On SMP systems,
     79   1.1      haya  * there appear to be problems with memory mapped mode: it looks like
     80   1.1      haya  * doing too many memory mapped access back to back in rapid succession
     81   1.1      haya  * can hang the bus. I'm inclined to blame this on crummy design/construction
     82  1.18       wiz  * on the part of Realtek. Memory mapped mode does appear to work on
     83   1.1      haya  * uniprocessor systems though.
     84   1.1      haya  */
     85  1.25     perry #define RTK_USEIOSPACE
     86   1.1      haya 
     87   1.1      haya #include <dev/ic/rtl81x9reg.h>
     88   1.1      haya #include <dev/ic/rtl81x9var.h>
     89   1.1      haya 
     90   1.1      haya /*
     91   1.1      haya  * Various supported device vendors/types and their names.
     92   1.1      haya  */
     93   1.2   thorpej static const struct rtk_type rtk_cardbus_devs[] = {
     94  1.22   mycroft 	{ PCI_VENDOR_ACCTON, PCI_PRODUCT_ACCTON_MPX5030,
     95  1.16      fvdl 		RTK_8139, "Accton MPX 5030/5038 10/100BaseTX" },
     96  1.23   mycroft 	{ PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DFE690TXD,
     97  1.16      fvdl 		RTK_8139, "D-Link DFE-690TXD 10/100BaseTX" },
     98  1.22   mycroft 	{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8138,
     99  1.18       wiz 		RTK_8139, "Realtek 8138 10/100BaseTX" },
    100  1.22   mycroft 	{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8139,
    101  1.18       wiz 		RTK_8139, "Realtek 8139 10/100BaseTX" },
    102  1.22   mycroft 	{ PCI_VENDOR_COREGA, PCI_PRODUCT_COREGA_CB_TXD,
    103  1.16      fvdl 		RTK_8139, "Corega FEther CB-TXD 10/100BaseTX" },
    104  1.22   mycroft 	{ PCI_VENDOR_COREGA, PCI_PRODUCT_COREGA_2CB_TXD,
    105  1.16      fvdl 		RTK_8139, "Corega FEther II CB-TXD 10/100BaseTX" },
    106  1.22   mycroft 	{ PCI_VENDOR_PLANEX, PCI_PRODUCT_PLANEX_FNW_3603_TX,
    107  1.16      fvdl 		RTK_8139, "Planex FNW-3603 10/100BaseTX" },
    108  1.22   mycroft 	{ PCI_VENDOR_PLANEX, PCI_PRODUCT_PLANEX_FNW_3800_TX,
    109  1.16      fvdl 		RTK_8139, "Planex 10/100BaseTX FNW-3800-TX" },
    110  1.22   mycroft 	{ PCI_VENDOR_ABOCOM, PCI_PRODUCT_ABOCOM_FE2000VX,
    111  1.16      fvdl 		RTK_8139, "AboCom FE2000VX 10/100BaseTX" },
    112  1.14    ichiro 
    113  1.16      fvdl 	{ 0, 0, 0, NULL }
    114   1.1      haya };
    115   1.1      haya 
    116  1.36   tsutsui static int rtk_cardbus_match(device_t, cfdata_t, void *);
    117  1.36   tsutsui static void rtk_cardbus_attach(device_t, device_t, void *);
    118  1.36   tsutsui static int rtk_cardbus_detach(device_t, int);
    119   1.1      haya 
    120   1.2   thorpej struct rtk_cardbus_softc {
    121  1.25     perry 	struct rtk_softc sc_rtk;	/* real rtk softc */
    122   1.1      haya 
    123   1.1      haya 	/* CardBus-specific goo. */
    124   1.1      haya 	void *sc_ih;
    125   1.1      haya 	cardbus_devfunc_t sc_ct;
    126  1.40    dyoung 	pcitag_t sc_tag;
    127  1.42    dyoung 	pcireg_t sc_csr;
    128   1.1      haya 	int sc_bar_reg;
    129   1.1      haya 	pcireg_t sc_bar_val;
    130   1.1      haya };
    131   1.1      haya 
    132  1.36   tsutsui CFATTACH_DECL_NEW(rtk_cardbus, sizeof(struct rtk_cardbus_softc),
    133  1.11   thorpej     rtk_cardbus_match, rtk_cardbus_attach, rtk_cardbus_detach, rtk_activate);
    134   1.1      haya 
    135  1.36   tsutsui const struct rtk_type *rtk_cardbus_lookup(const struct cardbus_attach_args *);
    136   1.3   tsutsui 
    137  1.36   tsutsui void rtk_cardbus_setup(struct rtk_cardbus_softc *);
    138   1.3   tsutsui 
    139  1.36   tsutsui int rtk_cardbus_enable(struct rtk_softc *);
    140  1.24     perry void rtk_cardbus_disable(struct rtk_softc *);
    141  1.36   tsutsui void rtk_cardbus_power(struct rtk_softc *, int);
    142  1.36   tsutsui 
    143   1.2   thorpej const struct rtk_type *
    144  1.36   tsutsui rtk_cardbus_lookup(const struct cardbus_attach_args *ca)
    145   1.1      haya {
    146   1.2   thorpej 	const struct rtk_type *t;
    147   1.1      haya 
    148  1.25     perry 	for (t = rtk_cardbus_devs; t->rtk_name != NULL; t++){
    149  1.43    dyoung 		if (PCI_VENDOR(ca->ca_id) == t->rtk_vid &&
    150  1.43    dyoung 		    PCI_PRODUCT(ca->ca_id) == t->rtk_did) {
    151  1.36   tsutsui 			return t;
    152   1.1      haya 		}
    153   1.1      haya 	}
    154  1.36   tsutsui 	return NULL;
    155   1.1      haya }
    156   1.1      haya 
    157   1.1      haya int
    158  1.36   tsutsui rtk_cardbus_match(device_t parent, cfdata_t cf, void *aux)
    159   1.1      haya {
    160   1.1      haya 	struct cardbus_attach_args *ca = aux;
    161   1.1      haya 
    162   1.2   thorpej 	if (rtk_cardbus_lookup(ca) != NULL)
    163  1.36   tsutsui 		return 1;
    164   1.2   thorpej 
    165  1.36   tsutsui 	return 0;
    166   1.1      haya }
    167   1.1      haya 
    168   1.1      haya 
    169   1.1      haya void
    170  1.36   tsutsui rtk_cardbus_attach(device_t parent, device_t self, void *aux)
    171   1.1      haya {
    172  1.27   thorpej 	struct rtk_cardbus_softc *csc = device_private(self);
    173   1.2   thorpej 	struct rtk_softc *sc = &csc->sc_rtk;
    174   1.1      haya 	struct cardbus_attach_args *ca = aux;
    175   1.1      haya 	cardbus_devfunc_t ct = ca->ca_ct;
    176   1.2   thorpej 	const struct rtk_type *t;
    177   1.1      haya 	bus_addr_t adr;
    178   1.1      haya 
    179  1.36   tsutsui 	sc->sc_dev = self;
    180   1.1      haya 	sc->sc_dmat = ca->ca_dmat;
    181   1.1      haya 	csc->sc_ct = ct;
    182   1.1      haya 	csc->sc_tag = ca->ca_tag;
    183   1.1      haya 
    184  1.25     perry 	t = rtk_cardbus_lookup(ca);
    185  1.25     perry 	if (t == NULL) {
    186  1.36   tsutsui 		aprint_error("\n");
    187  1.36   tsutsui 		panic("%s: impossible", __func__);
    188  1.25     perry 	 }
    189  1.36   tsutsui 	aprint_normal(": %s\n", t->rtk_name);
    190  1.25     perry 
    191   1.3   tsutsui 	/*
    192   1.3   tsutsui 	 * Power management hooks.
    193   1.3   tsutsui 	 */
    194   1.3   tsutsui 	sc->sc_enable = rtk_cardbus_enable;
    195   1.3   tsutsui 	sc->sc_disable = rtk_cardbus_disable;
    196   1.3   tsutsui 
    197   1.3   tsutsui 	/*
    198   1.3   tsutsui 	 * Map control/status registers.
    199   1.3   tsutsui 	 */
    200  1.43    dyoung 	csc->sc_csr = PCI_COMMAND_MASTER_ENABLE;
    201   1.3   tsutsui #ifdef RTK_USEIOSPACE
    202  1.43    dyoung 	if (Cardbus_mapreg_map(ct, RTK_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0,
    203  1.45  jakllsch 	    &sc->rtk_btag, &sc->rtk_bhandle, &adr, &sc->rtk_bsize) == 0) {
    204  1.43    dyoung 		csc->sc_csr |= PCI_COMMAND_IO_ENABLE;
    205   1.3   tsutsui 		csc->sc_bar_reg = RTK_PCI_LOIO;
    206  1.43    dyoung 		csc->sc_bar_val = adr | PCI_MAPREG_TYPE_IO;
    207   1.3   tsutsui 	}
    208   1.3   tsutsui #else
    209  1.43    dyoung 	if (Cardbus_mapreg_map(ct, RTK_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0,
    210  1.45  jakllsch 	    &sc->rtk_btag, &sc->rtk_bhandle, &adr, &sc->rtk_bsize) == 0) {
    211  1.43    dyoung 		csc->sc_csr |= PCI_COMMAND_MEM_ENABLE;
    212   1.3   tsutsui 		csc->sc_bar_reg = RTK_PCI_LOMEM;
    213  1.43    dyoung 		csc->sc_bar_val = adr | PCI_MAPREG_TYPE_MEM;
    214   1.3   tsutsui 	}
    215   1.3   tsutsui #endif
    216   1.3   tsutsui 	else {
    217  1.36   tsutsui 		aprint_error_dev(self, " unable to map deviceregisters\n");
    218   1.3   tsutsui 		return;
    219   1.3   tsutsui 	}
    220   1.3   tsutsui 	/*
    221   1.3   tsutsui 	 * Handle power management nonsense and initialize the
    222   1.3   tsutsui 	 * configuration registers.
    223   1.3   tsutsui 	 */
    224   1.3   tsutsui 	rtk_cardbus_setup(csc);
    225   1.3   tsutsui 
    226   1.3   tsutsui 	rtk_attach(sc);
    227   1.3   tsutsui 
    228  1.38   tsutsui 	if (pmf_device_register(self, NULL, NULL))
    229  1.38   tsutsui 		pmf_class_network_register(self, &sc->ethercom.ec_if);
    230  1.38   tsutsui 	else
    231  1.34  jmcneill 		aprint_error_dev(self, "couldn't establish power handler\n");
    232  1.34  jmcneill 
    233   1.3   tsutsui 	/*
    234   1.3   tsutsui 	 * Power down the socket.
    235   1.3   tsutsui 	 */
    236   1.3   tsutsui 	Cardbus_function_disable(csc->sc_ct);
    237   1.3   tsutsui }
    238   1.3   tsutsui 
    239  1.25     perry int
    240  1.36   tsutsui rtk_cardbus_detach(device_t self, int flags)
    241   1.3   tsutsui {
    242  1.27   thorpej 	struct rtk_cardbus_softc *csc = device_private(self);
    243   1.3   tsutsui 	struct rtk_softc *sc = &csc->sc_rtk;
    244   1.3   tsutsui 	struct cardbus_devfunc *ct = csc->sc_ct;
    245  1.36   tsutsui 	int rv;
    246   1.3   tsutsui 
    247   1.3   tsutsui #ifdef DIAGNOSTIC
    248   1.3   tsutsui 	if (ct == NULL)
    249  1.36   tsutsui 		panic("%s: data structure lacks", device_xname(self));
    250   1.3   tsutsui #endif
    251   1.3   tsutsui 	rv = rtk_detach(sc);
    252   1.3   tsutsui 	if (rv)
    253  1.36   tsutsui 		return rv;
    254   1.3   tsutsui 	/*
    255  1.17       wiz 	 * Unhook the interrupt handler.
    256   1.3   tsutsui 	 */
    257   1.3   tsutsui 	if (csc->sc_ih != NULL)
    258  1.44    dyoung 		Cardbus_intr_disestablish(ct, csc->sc_ih);
    259  1.25     perry 
    260   1.3   tsutsui 	/*
    261   1.3   tsutsui 	 * Release bus space and close window.
    262   1.3   tsutsui 	 */
    263   1.3   tsutsui 	if (csc->sc_bar_reg != 0)
    264   1.3   tsutsui 		Cardbus_mapreg_unmap(ct, csc->sc_bar_reg,
    265  1.45  jakllsch 		    sc->rtk_btag, sc->rtk_bhandle, sc->rtk_bsize);
    266   1.3   tsutsui 
    267  1.36   tsutsui 	return 0;
    268   1.3   tsutsui }
    269   1.3   tsutsui 
    270  1.25     perry void
    271  1.36   tsutsui rtk_cardbus_setup(struct rtk_cardbus_softc *csc)
    272   1.3   tsutsui {
    273   1.3   tsutsui 	struct rtk_softc *sc = &csc->sc_rtk;
    274   1.3   tsutsui 	cardbus_devfunc_t ct = csc->sc_ct;
    275   1.3   tsutsui 	cardbus_chipset_tag_t cc = ct->ct_cc;
    276   1.3   tsutsui 	cardbus_function_tag_t cf = ct->ct_cf;
    277  1.36   tsutsui 	pcireg_t reg, command;
    278  1.36   tsutsui 	int pmreg;
    279   1.1      haya 
    280   1.1      haya 	/*
    281   1.1      haya 	 * Handle power management nonsense.
    282   1.1      haya 	 */
    283   1.1      haya 	if (cardbus_get_capability(cc, cf, csc->sc_tag,
    284   1.1      haya 	    PCI_CAP_PWRMGMT, &pmreg, 0)) {
    285  1.43    dyoung 		command = Cardbus_conf_read(ct, csc->sc_tag,
    286  1.20    dyoung 		    pmreg + PCI_PMCSR);
    287  1.30    dogcow 		if (command & PCI_PMCSR_STATE_MASK) {
    288  1.36   tsutsui 			pcireg_t iobase, membase, irq;
    289   1.1      haya 
    290   1.1      haya 			/* Save important PCI config data. */
    291  1.43    dyoung 			iobase = Cardbus_conf_read(ct, csc->sc_tag,
    292   1.3   tsutsui 			    RTK_PCI_LOIO);
    293  1.43    dyoung 			membase = Cardbus_conf_read(ct, csc->sc_tag,
    294   1.3   tsutsui 			    RTK_PCI_LOMEM);
    295  1.43    dyoung 			irq = Cardbus_conf_read(ct, csc->sc_tag,
    296  1.43    dyoung 			    PCI_INTERRUPT_REG);
    297   1.1      haya 
    298   1.1      haya 			/* Reset the power state. */
    299  1.36   tsutsui 			aprint_normal_dev(sc->sc_dev,
    300  1.36   tsutsui 			    "chip is in D%d power mode -- setting to D0\n",
    301  1.30    dogcow 			    command & PCI_PMCSR_STATE_MASK);
    302  1.30    dogcow 			command &= ~PCI_PMCSR_STATE_MASK;
    303  1.43    dyoung 			Cardbus_conf_write(ct, csc->sc_tag,
    304  1.20    dyoung 			    pmreg + PCI_PMCSR, command);
    305   1.1      haya 
    306   1.1      haya 			/* Restore PCI config data. */
    307  1.43    dyoung 			Cardbus_conf_write(ct, csc->sc_tag,
    308   1.3   tsutsui 			    RTK_PCI_LOIO, iobase);
    309  1.43    dyoung 			Cardbus_conf_write(ct, csc->sc_tag,
    310   1.3   tsutsui 			    RTK_PCI_LOMEM, membase);
    311  1.43    dyoung 			Cardbus_conf_write(ct, csc->sc_tag,
    312  1.43    dyoung 			    PCI_INTERRUPT_REG, irq);
    313   1.1      haya 		}
    314   1.1      haya 	}
    315   1.3   tsutsui 
    316  1.21   mycroft 	/* Program the BAR */
    317  1.43    dyoung 	Cardbus_conf_write(ct, csc->sc_tag, csc->sc_bar_reg, csc->sc_bar_val);
    318  1.21   mycroft 
    319   1.1      haya 	/* Enable the appropriate bits in the CARDBUS CSR. */
    320  1.43    dyoung 	reg = Cardbus_conf_read(ct, csc->sc_tag, PCI_COMMAND_STATUS_REG);
    321  1.43    dyoung 	reg &= ~(PCI_COMMAND_IO_ENABLE|PCI_COMMAND_MEM_ENABLE);
    322   1.1      haya 	reg |= csc->sc_csr;
    323  1.43    dyoung 	Cardbus_conf_write(ct, csc->sc_tag, PCI_COMMAND_STATUS_REG, reg);
    324   1.1      haya 
    325   1.1      haya 	/*
    326   1.1      haya 	 * Make sure the latency timer is set to some reasonable
    327   1.1      haya 	 * value.
    328   1.1      haya 	 */
    329  1.43    dyoung 	reg = Cardbus_conf_read(ct, csc->sc_tag, PCI_BHLC_REG);
    330  1.43    dyoung 	if (PCI_LATTIMER(reg) < 0x20) {
    331  1.43    dyoung 		reg &= ~(PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT);
    332  1.43    dyoung 		reg |= (0x20 << PCI_LATTIMER_SHIFT);
    333  1.43    dyoung 		Cardbus_conf_write(ct, csc->sc_tag, PCI_BHLC_REG, reg);
    334   1.1      haya 	}
    335   1.3   tsutsui }
    336   1.1      haya 
    337  1.25     perry int
    338  1.36   tsutsui rtk_cardbus_enable(struct rtk_softc *sc)
    339   1.3   tsutsui {
    340  1.36   tsutsui 	struct rtk_cardbus_softc *csc = (struct rtk_cardbus_softc *)sc;
    341   1.3   tsutsui 	cardbus_devfunc_t ct = csc->sc_ct;
    342   1.3   tsutsui 
    343   1.3   tsutsui 	/*
    344   1.3   tsutsui 	 * Power on the socket.
    345   1.3   tsutsui 	 */
    346   1.3   tsutsui 	Cardbus_function_enable(ct);
    347   1.3   tsutsui 
    348   1.3   tsutsui 	/*
    349   1.3   tsutsui 	 * Set up the PCI configuration registers.
    350   1.3   tsutsui 	 */
    351   1.3   tsutsui 	rtk_cardbus_setup(csc);
    352   1.1      haya 
    353   1.3   tsutsui 	/*
    354   1.3   tsutsui 	 * Map and establish the interrupt.
    355   1.3   tsutsui 	 */
    356  1.46  drochner 	csc->sc_ih = Cardbus_intr_establish(ct, IPL_NET, rtk_intr, sc);
    357   1.1      haya 	if (csc->sc_ih == NULL) {
    358  1.36   tsutsui 		aprint_error_dev(sc->sc_dev,
    359  1.37  drochner 		    "unable to establish interrupt\n");
    360   1.3   tsutsui 		Cardbus_function_disable(csc->sc_ct);
    361  1.36   tsutsui 		return 1;
    362   1.1      haya 	}
    363  1.36   tsutsui 	return 0;
    364   1.3   tsutsui }
    365   1.3   tsutsui 
    366  1.25     perry void
    367  1.36   tsutsui rtk_cardbus_disable(struct rtk_softc *sc)
    368   1.3   tsutsui {
    369  1.36   tsutsui 	struct rtk_cardbus_softc *csc = (struct rtk_cardbus_softc *)sc;
    370   1.3   tsutsui 	cardbus_devfunc_t ct = csc->sc_ct;
    371   1.3   tsutsui 
    372   1.3   tsutsui 	/* Unhook the interrupt handler. */
    373  1.44    dyoung 	Cardbus_intr_disestablish(ct, csc->sc_ih);
    374  1.19   kanaoka 	csc->sc_ih = NULL;
    375   1.1      haya 
    376   1.3   tsutsui 	/* Power down the socket. */
    377   1.3   tsutsui 	Cardbus_function_disable(ct);
    378   1.3   tsutsui }
    379