Home | History | Annotate | Line # | Download | only in cardbus
if_re_cardbus.c revision 1.14
      1  1.14        ad /*	$NetBSD: if_re_cardbus.c,v 1.14 2007/10/19 11:59:39 ad Exp $	*/
      2   1.1  jonathan 
      3   1.1  jonathan /*
      4   1.1  jonathan  * Copyright (c) 2004 Jonathan Stone
      5   1.1  jonathan  * All rights reserved.
      6   1.1  jonathan  *
      7   1.1  jonathan  * Redistribution and use in source and binary forms, with or without
      8   1.1  jonathan  * modification, are permitted provided that the following conditions
      9   1.1  jonathan  * are met:
     10   1.1  jonathan  * 1. Redistributions of source code must retain the above copyright
     11   1.1  jonathan  *    notice, this list of conditions and the following disclaimer.
     12   1.1  jonathan  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1  jonathan  *    notice, this list of conditions and the following disclaimer in the
     14   1.1  jonathan  *    documentation and/or other materials provided with the distribution.
     15   1.1  jonathan  * 3. The name of the author may not be used to endorse or promote products
     16   1.1  jonathan  *    derived from this software without specific prior written permission.
     17   1.1  jonathan  *
     18   1.1  jonathan  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19   1.1  jonathan  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20   1.1  jonathan  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21   1.1  jonathan  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22   1.1  jonathan  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23   1.1  jonathan  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24   1.1  jonathan  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25   1.1  jonathan  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26   1.1  jonathan  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     27   1.1  jonathan  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28   1.1  jonathan  */
     29   1.1  jonathan 
     30   1.1  jonathan /*
     31   1.1  jonathan  * if_re_cardbus.c:
     32   1.1  jonathan  *	Cardbus specific routines for Realtek 8169 ethernet adapter.
     33   1.1  jonathan  *	Tested for :
     34   1.1  jonathan  *		Netgear GA-511 (8169S)
     35   1.3   kanaoka  *		Buffalo LPC-CB-CLGT
     36   1.1  jonathan  */
     37   1.1  jonathan 
     38   1.1  jonathan #include <sys/cdefs.h>
     39  1.14        ad __KERNEL_RCSID(0, "$NetBSD: if_re_cardbus.c,v 1.14 2007/10/19 11:59:39 ad Exp $");
     40   1.1  jonathan 
     41   1.1  jonathan #include "opt_inet.h"
     42   1.1  jonathan #include "bpfilter.h"
     43   1.1  jonathan #include "rnd.h"
     44   1.1  jonathan 
     45   1.1  jonathan #include <sys/param.h>
     46   1.1  jonathan #include <sys/systm.h>
     47   1.1  jonathan #include <sys/callout.h>
     48   1.1  jonathan #include <sys/device.h>
     49   1.1  jonathan #include <sys/sockio.h>
     50   1.1  jonathan #include <sys/mbuf.h>
     51   1.1  jonathan #include <sys/malloc.h>
     52   1.1  jonathan #include <sys/kernel.h>
     53   1.1  jonathan #include <sys/socket.h>
     54   1.1  jonathan 
     55   1.1  jonathan #include <net/if.h>
     56   1.1  jonathan #include <net/if_arp.h>
     57   1.1  jonathan #include <net/if_ether.h>
     58   1.1  jonathan #include <net/if_dl.h>
     59   1.1  jonathan #include <net/if_media.h>
     60   1.1  jonathan #ifdef INET
     61   1.1  jonathan #include <netinet/in.h>
     62   1.1  jonathan #include <netinet/if_inarp.h>
     63   1.1  jonathan #endif
     64   1.1  jonathan 
     65   1.1  jonathan #if NBPFILTER > 0
     66   1.1  jonathan #include <net/bpf.h>
     67   1.1  jonathan #endif
     68   1.1  jonathan #if NRND > 0
     69   1.1  jonathan #include <sys/rnd.h>
     70   1.1  jonathan #endif
     71   1.1  jonathan 
     72  1.14        ad #include <sys/bus.h>
     73   1.1  jonathan 
     74   1.1  jonathan #include <dev/pci/pcireg.h>
     75   1.1  jonathan #include <dev/pci/pcivar.h>
     76   1.1  jonathan #include <dev/pci/pcidevs.h>
     77   1.1  jonathan 
     78   1.1  jonathan #include <dev/cardbus/cardbusvar.h>
     79   1.1  jonathan #include <dev/pci/pcidevs.h>
     80   1.1  jonathan 
     81   1.1  jonathan #include <dev/mii/mii.h>
     82   1.1  jonathan #include <dev/mii/miivar.h>
     83   1.1  jonathan 
     84   1.1  jonathan /*
     85   1.1  jonathan  * Default to using PIO access for this driver. On SMP systems,
     86   1.1  jonathan  * there appear to be problems with memory mapped mode: it looks like
     87   1.1  jonathan  * doing too many memory mapped access back to back in rapid succession
     88   1.1  jonathan  * can hang the bus. I'm inclined to blame this on crummy design/construction
     89   1.1  jonathan  * on the part of Realtek. Memory mapped mode does appear to work on
     90   1.1  jonathan  * uniprocessor systems though.
     91   1.1  jonathan  */
     92   1.5     perry #define RTK_USEIOSPACE
     93   1.1  jonathan 
     94   1.1  jonathan #include <dev/ic/rtl81x9reg.h>
     95   1.1  jonathan #include <dev/ic/rtl81x9var.h>
     96   1.1  jonathan 
     97   1.1  jonathan #include <dev/ic/rtl8169var.h>
     98   1.1  jonathan 
     99   1.1  jonathan /*
    100   1.1  jonathan  * Various supported device vendors/types and their names.
    101   1.1  jonathan  */
    102   1.1  jonathan static const struct rtk_type re_cardbus_devs[] = {
    103   1.1  jonathan 	{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8169,
    104   1.1  jonathan 		RTK_8169, "Realtek 10/100/1000baseT" },
    105   1.1  jonathan 	{ 0, 0, 0, NULL }
    106   1.1  jonathan };
    107   1.1  jonathan 
    108   1.1  jonathan static int  re_cardbus_match(struct device *, struct cfdata *, void *);
    109   1.1  jonathan static void re_cardbus_attach(struct device *, struct device *, void *);
    110   1.1  jonathan static int  re_cardbus_detach(struct device *, int);
    111   1.1  jonathan 
    112   1.1  jonathan struct re_cardbus_softc {
    113   1.5     perry 	struct rtk_softc sc_rtk;	/* real rtk softc */
    114   1.1  jonathan 
    115   1.1  jonathan 	/* CardBus-specific goo. */
    116   1.1  jonathan 	void *sc_ih;
    117   1.1  jonathan 	cardbus_devfunc_t sc_ct;
    118   1.1  jonathan 	cardbustag_t sc_tag;
    119   1.1  jonathan 	int sc_csr;
    120   1.1  jonathan 	int sc_cben;
    121   1.1  jonathan 	int sc_bar_reg;
    122   1.1  jonathan 	pcireg_t sc_bar_val;
    123   1.1  jonathan 	bus_size_t sc_mapsize;
    124   1.1  jonathan 	int sc_intrline;
    125   1.1  jonathan };
    126   1.1  jonathan 
    127   1.1  jonathan CFATTACH_DECL(re_cardbus, sizeof(struct re_cardbus_softc),
    128   1.1  jonathan     re_cardbus_match, re_cardbus_attach, re_cardbus_detach, re_activate);
    129   1.1  jonathan 
    130   1.4   kanaoka const struct rtk_type *re_cardbus_lookup(const struct cardbus_attach_args *);
    131   1.1  jonathan 
    132   1.4   kanaoka void re_cardbus_setup(struct re_cardbus_softc *);
    133   1.1  jonathan 
    134   1.4   kanaoka int re_cardbus_enable(struct rtk_softc *);
    135   1.4   kanaoka void re_cardbus_disable(struct rtk_softc *);
    136   1.4   kanaoka void re_cardbus_power(struct rtk_softc *, int);
    137   1.1  jonathan 
    138   1.1  jonathan const struct rtk_type *
    139   1.4   kanaoka re_cardbus_lookup(const struct cardbus_attach_args *ca)
    140   1.1  jonathan {
    141   1.1  jonathan 	const struct rtk_type *t;
    142   1.1  jonathan 
    143   1.1  jonathan 	for (t = re_cardbus_devs; t->rtk_name != NULL; t++) {
    144   1.1  jonathan 		if (CARDBUS_VENDOR(ca->ca_id) == t->rtk_vid &&
    145   1.1  jonathan 		    CARDBUS_PRODUCT(ca->ca_id) == t->rtk_did) {
    146   1.4   kanaoka 			return t;
    147   1.1  jonathan 		}
    148   1.1  jonathan 	}
    149   1.4   kanaoka 	return NULL;
    150   1.1  jonathan }
    151   1.1  jonathan 
    152   1.1  jonathan int
    153  1.12   tsutsui re_cardbus_match(struct device *parent, struct cfdata *match, void *aux)
    154   1.1  jonathan {
    155   1.1  jonathan 	struct cardbus_attach_args *ca = aux;
    156   1.1  jonathan 
    157   1.1  jonathan 	if (re_cardbus_lookup(ca) != NULL)
    158   1.4   kanaoka 		return 1;
    159   1.1  jonathan 
    160   1.4   kanaoka 	return 0;
    161   1.1  jonathan }
    162   1.1  jonathan 
    163   1.1  jonathan 
    164   1.1  jonathan void
    165  1.12   tsutsui re_cardbus_attach(struct device *parent, struct device *self, void *aux)
    166   1.1  jonathan {
    167   1.7   thorpej 	struct re_cardbus_softc *csc = device_private(self);
    168   1.1  jonathan 	struct rtk_softc *sc = &csc->sc_rtk;
    169   1.1  jonathan 	struct cardbus_attach_args *ca = aux;
    170   1.1  jonathan 	cardbus_devfunc_t ct = ca->ca_ct;
    171   1.1  jonathan 	const struct rtk_type *t;
    172   1.1  jonathan 	bus_addr_t adr;
    173   1.1  jonathan 
    174   1.1  jonathan 	sc->sc_dmat = ca->ca_dmat;
    175   1.1  jonathan 	csc->sc_ct = ct;
    176   1.1  jonathan 	csc->sc_tag = ca->ca_tag;
    177   1.1  jonathan 	csc->sc_intrline = ca->ca_intrline;
    178   1.1  jonathan 
    179   1.5     perry 	t = re_cardbus_lookup(ca);
    180   1.5     perry 	if (t == NULL) {
    181   1.5     perry 		aprint_error("\n");
    182   1.1  jonathan 		panic("re_cardbus_attach: impossible");
    183   1.5     perry 	 }
    184   1.5     perry 	aprint_normal(": %s\n", t->rtk_name);
    185   1.5     perry 
    186   1.1  jonathan 	/*
    187   1.1  jonathan 	 * Power management hooks.
    188   1.1  jonathan 	 */
    189   1.1  jonathan 	sc->sc_enable = re_cardbus_enable;
    190   1.1  jonathan 	sc->sc_disable = re_cardbus_disable;
    191   1.1  jonathan 	sc->sc_power = re_cardbus_power;
    192   1.1  jonathan 
    193   1.1  jonathan 	/*
    194   1.1  jonathan 	 * Map control/status registers.
    195   1.1  jonathan 	 */
    196   1.1  jonathan 	csc->sc_csr = CARDBUS_COMMAND_MASTER_ENABLE;
    197   1.1  jonathan #ifdef RTK_USEIOSPACE
    198   1.1  jonathan 	if (Cardbus_mapreg_map(ct, RTK_PCI_LOIO, CARDBUS_MAPREG_TYPE_IO, 0,
    199   1.1  jonathan 	    &sc->rtk_btag, &sc->rtk_bhandle, &adr, &csc->sc_mapsize) == 0) {
    200   1.1  jonathan #if rbus
    201   1.1  jonathan #else
    202   1.1  jonathan 		(*ct->ct_cf->cardbus_io_open)(cc, 0, adr, adr+csc->sc_mapsize);
    203   1.1  jonathan #endif
    204   1.1  jonathan 		csc->sc_cben = CARDBUS_IO_ENABLE;
    205   1.1  jonathan 		csc->sc_csr |= CARDBUS_COMMAND_IO_ENABLE;
    206   1.1  jonathan 		csc->sc_bar_reg = RTK_PCI_LOIO;
    207   1.1  jonathan 		csc->sc_bar_val = adr | CARDBUS_MAPREG_TYPE_IO;
    208   1.1  jonathan 	}
    209   1.1  jonathan #else
    210   1.1  jonathan 	if (Cardbus_mapreg_map(ct, RTK_PCI_LOMEM, CARDBUS_MAPREG_TYPE_MEM, 0,
    211   1.1  jonathan 	    &sc->rtk_btag, &sc->rtk_bhandle, &adr, &csc->sc_mapsize) == 0) {
    212   1.1  jonathan #if rbus
    213   1.1  jonathan #else
    214   1.1  jonathan 		(*ct->ct_cf->cardbus_mem_open)(cc, 0, adr, adr+csc->sc_mapsize);
    215   1.1  jonathan #endif
    216   1.1  jonathan 		csc->sc_cben = CARDBUS_MEM_ENABLE;
    217   1.1  jonathan 		csc->sc_csr |= CARDBUS_COMMAND_MEM_ENABLE;
    218   1.1  jonathan 		csc->sc_bar_reg = RTK_PCI_LOMEM;
    219   1.1  jonathan 		csc->sc_bar_val = adr | CARDBUS_MAPREG_TYPE_MEM;
    220   1.1  jonathan 	}
    221   1.1  jonathan #endif
    222   1.1  jonathan 	else {
    223   1.4   kanaoka 		aprint_error("%s: unable to map deviceregisters\n",
    224   1.1  jonathan 			 sc->sc_dev.dv_xname);
    225   1.1  jonathan 		return;
    226   1.1  jonathan 	}
    227   1.1  jonathan 	/*
    228   1.1  jonathan 	 * Handle power management nonsense and initialize the
    229   1.1  jonathan 	 * configuration registers.
    230   1.1  jonathan 	 */
    231   1.1  jonathan 	re_cardbus_setup(csc);
    232   1.1  jonathan 
    233   1.1  jonathan 	sc->sc_dmat = ca->ca_dmat;
    234   1.1  jonathan 	re_attach(sc);
    235   1.1  jonathan 
    236   1.1  jonathan 	/*
    237   1.1  jonathan 	 * Power down the socket.
    238   1.1  jonathan 	 */
    239   1.1  jonathan 	Cardbus_function_disable(csc->sc_ct);
    240   1.1  jonathan }
    241   1.1  jonathan 
    242   1.5     perry int
    243  1.11  christos re_cardbus_detach(struct device *self, int flags)
    244   1.1  jonathan {
    245   1.7   thorpej 	struct re_cardbus_softc *csc = device_private(self);
    246   1.1  jonathan 	struct rtk_softc *sc = &csc->sc_rtk;
    247   1.1  jonathan 	struct cardbus_devfunc *ct = csc->sc_ct;
    248   1.1  jonathan 	int	rv;
    249   1.1  jonathan 
    250   1.1  jonathan #ifdef DIAGNOSTIC
    251   1.1  jonathan 	if (ct == NULL)
    252   1.1  jonathan 		panic("%s: cardbus softc, cardbus_devfunc NULL",
    253   1.1  jonathan 		      sc->sc_dev.dv_xname);
    254   1.1  jonathan #endif
    255   1.1  jonathan 	rv = re_detach(sc);
    256   1.1  jonathan 	if (rv)
    257   1.4   kanaoka 		return rv;
    258   1.1  jonathan 	/*
    259   1.1  jonathan 	 * Unhook the interrupt handler.
    260   1.1  jonathan 	 */
    261   1.1  jonathan 	if (csc->sc_ih != NULL)
    262   1.1  jonathan 		cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, csc->sc_ih);
    263   1.5     perry 
    264   1.1  jonathan 	/*
    265   1.1  jonathan 	 * Release bus space and close window.
    266   1.1  jonathan 	 */
    267   1.1  jonathan 	if (csc->sc_bar_reg != 0)
    268   1.1  jonathan 		Cardbus_mapreg_unmap(ct, csc->sc_bar_reg,
    269   1.1  jonathan 			sc->rtk_btag, sc->rtk_bhandle, csc->sc_mapsize);
    270   1.1  jonathan 
    271   1.4   kanaoka 	return 0;
    272   1.1  jonathan }
    273   1.1  jonathan 
    274   1.5     perry void
    275   1.1  jonathan re_cardbus_setup(struct re_cardbus_softc *csc)
    276   1.1  jonathan {
    277   1.1  jonathan 	struct rtk_softc *sc = &csc->sc_rtk;
    278   1.1  jonathan 	cardbus_devfunc_t ct = csc->sc_ct;
    279   1.1  jonathan 	cardbus_chipset_tag_t cc = ct->ct_cc;
    280   1.1  jonathan 	cardbus_function_tag_t cf = ct->ct_cf;
    281   1.1  jonathan 	pcireg_t	reg,command;
    282   1.1  jonathan 	int		pmreg;
    283   1.1  jonathan 
    284   1.1  jonathan 	/*
    285   1.1  jonathan 	 * Handle power management nonsense.
    286   1.1  jonathan 	 */
    287   1.1  jonathan 	if (cardbus_get_capability(cc, cf, csc->sc_tag,
    288   1.1  jonathan 	    PCI_CAP_PWRMGMT, &pmreg, 0)) {
    289   1.1  jonathan 		command = cardbus_conf_read(cc, cf, csc->sc_tag,
    290   1.1  jonathan 		    pmreg + PCI_PMCSR);
    291  1.10    dogcow 		if (command & PCI_PMCSR_STATE_MASK) {
    292   1.1  jonathan 			pcireg_t		iobase, membase, irq;
    293   1.1  jonathan 
    294   1.1  jonathan 			/* Save important PCI config data. */
    295   1.1  jonathan 			iobase = cardbus_conf_read(cc, cf, csc->sc_tag,
    296   1.1  jonathan 			    RTK_PCI_LOIO);
    297   1.1  jonathan 			membase = cardbus_conf_read(cc, cf,csc->sc_tag,
    298   1.1  jonathan 			    RTK_PCI_LOMEM);
    299   1.1  jonathan 			irq = cardbus_conf_read(cc, cf,csc->sc_tag,
    300   1.1  jonathan 			    CARDBUS_INTERRUPT_REG);
    301   1.1  jonathan 
    302   1.1  jonathan 			/* Reset the power state. */
    303   1.4   kanaoka 			aprint_normal("%s: chip is in D%d power mode "
    304   1.1  jonathan 			    "-- setting to D0\n", sc->sc_dev.dv_xname,
    305  1.10    dogcow 			    command & PCI_PMCSR_STATE_MASK);
    306  1.10    dogcow 			command &= ~PCI_PMCSR_STATE_MASK;
    307   1.1  jonathan 			cardbus_conf_write(cc, cf, csc->sc_tag,
    308   1.1  jonathan 			    pmreg + PCI_PMCSR, command);
    309   1.1  jonathan 
    310   1.1  jonathan 			/* Restore PCI config data. */
    311   1.1  jonathan 			cardbus_conf_write(cc, cf, csc->sc_tag,
    312   1.1  jonathan 			    RTK_PCI_LOIO, iobase);
    313   1.1  jonathan 			cardbus_conf_write(cc, cf, csc->sc_tag,
    314   1.1  jonathan 			    RTK_PCI_LOMEM, membase);
    315   1.1  jonathan 			cardbus_conf_write(cc, cf, csc->sc_tag,
    316   1.1  jonathan 			    CARDBUS_INTERRUPT_REG, irq);
    317   1.1  jonathan 		}
    318   1.1  jonathan 	}
    319   1.1  jonathan 
    320   1.1  jonathan 	/* Program the BAR */
    321   1.1  jonathan 	cardbus_conf_write(cc, cf, csc->sc_tag,
    322   1.1  jonathan 		csc->sc_bar_reg, csc->sc_bar_val);
    323   1.1  jonathan 
    324   1.1  jonathan 	/* Make sure the right access type is on the CardBus bridge. */
    325   1.1  jonathan 	(*ct->ct_cf->cardbus_ctrl)(cc, csc->sc_cben);
    326   1.1  jonathan 	(*ct->ct_cf->cardbus_ctrl)(cc, CARDBUS_BM_ENABLE);
    327   1.1  jonathan 
    328   1.1  jonathan 	/* Enable the appropriate bits in the CARDBUS CSR. */
    329   1.5     perry 	reg = cardbus_conf_read(cc, cf, csc->sc_tag,
    330   1.1  jonathan 	    CARDBUS_COMMAND_STATUS_REG);
    331   1.1  jonathan 	reg &= ~(CARDBUS_COMMAND_IO_ENABLE|CARDBUS_COMMAND_MEM_ENABLE);
    332   1.1  jonathan 	reg |= csc->sc_csr;
    333   1.5     perry 	cardbus_conf_write(cc, cf, csc->sc_tag,
    334   1.1  jonathan 	    CARDBUS_COMMAND_STATUS_REG, reg);
    335   1.1  jonathan 
    336   1.1  jonathan 	/*
    337   1.1  jonathan 	 * Make sure the latency timer is set to some reasonable
    338   1.1  jonathan 	 * value.
    339   1.1  jonathan 	 */
    340   1.1  jonathan 	reg = cardbus_conf_read(cc, cf, csc->sc_tag, CARDBUS_BHLC_REG);
    341   1.3   kanaoka 	if (CARDBUS_LATTIMER(reg) < 0x40) {
    342   1.1  jonathan 		reg &= ~(CARDBUS_LATTIMER_MASK << CARDBUS_LATTIMER_SHIFT);
    343   1.3   kanaoka 		reg |= (0x40 << CARDBUS_LATTIMER_SHIFT);
    344   1.1  jonathan 		cardbus_conf_write(cc, cf, csc->sc_tag, CARDBUS_BHLC_REG, reg);
    345   1.1  jonathan 	}
    346   1.1  jonathan }
    347   1.1  jonathan 
    348   1.5     perry int
    349   1.1  jonathan re_cardbus_enable(struct rtk_softc *sc)
    350   1.1  jonathan {
    351   1.1  jonathan 	struct re_cardbus_softc *csc = (void *) sc;
    352   1.1  jonathan 	cardbus_devfunc_t ct = csc->sc_ct;
    353   1.1  jonathan 	cardbus_chipset_tag_t cc = ct->ct_cc;
    354   1.1  jonathan 	cardbus_function_tag_t cf = ct->ct_cf;
    355   1.1  jonathan 
    356   1.1  jonathan 	/*
    357   1.1  jonathan 	 * Power on the socket.
    358   1.1  jonathan 	 */
    359   1.1  jonathan 	Cardbus_function_enable(ct);
    360   1.1  jonathan 
    361   1.1  jonathan 	/*
    362   1.1  jonathan 	 * Set up the PCI configuration registers.
    363   1.1  jonathan 	 */
    364   1.1  jonathan 	re_cardbus_setup(csc);
    365   1.1  jonathan 
    366   1.1  jonathan 	/*
    367   1.1  jonathan 	 * Map and establish the interrupt.
    368   1.1  jonathan 	 */
    369   1.1  jonathan 	csc->sc_ih = cardbus_intr_establish(cc, cf, csc->sc_intrline,
    370   1.1  jonathan 		IPL_NET, re_intr, sc);
    371   1.1  jonathan 	if (csc->sc_ih == NULL) {
    372   1.4   kanaoka 		aprint_error("%s: unable to establish interrupt at %d\n",
    373   1.1  jonathan 			sc->sc_dev.dv_xname, csc->sc_intrline);
    374   1.1  jonathan 		Cardbus_function_disable(csc->sc_ct);
    375   1.4   kanaoka 		return 1;
    376   1.1  jonathan 	}
    377   1.4   kanaoka 	aprint_normal("%s: interrupting at %d\n", sc->sc_dev.dv_xname,
    378   1.1  jonathan 		csc->sc_intrline);
    379   1.4   kanaoka 	return 0;
    380   1.1  jonathan }
    381   1.1  jonathan 
    382   1.5     perry void
    383   1.1  jonathan re_cardbus_disable(struct rtk_softc *sc)
    384   1.1  jonathan {
    385   1.1  jonathan 	struct re_cardbus_softc *csc = (void *) sc;
    386   1.1  jonathan 	cardbus_devfunc_t ct = csc->sc_ct;
    387   1.1  jonathan 	cardbus_chipset_tag_t cc = ct->ct_cc;
    388   1.1  jonathan 	cardbus_function_tag_t cf = ct->ct_cf;
    389   1.1  jonathan 
    390   1.1  jonathan 	/* Unhook the interrupt handler. */
    391   1.1  jonathan 	cardbus_intr_disestablish(cc, cf, csc->sc_ih);
    392   1.1  jonathan 	csc->sc_ih = NULL;
    393   1.1  jonathan 
    394   1.1  jonathan 	/* Power down the socket. */
    395   1.1  jonathan 	Cardbus_function_disable(ct);
    396   1.1  jonathan }
    397   1.1  jonathan 
    398   1.5     perry void
    399  1.12   tsutsui re_cardbus_power(struct rtk_softc *sc, int why)
    400   1.1  jonathan {
    401   1.1  jonathan 	struct re_cardbus_softc *csc = (void *) sc;
    402   1.1  jonathan 
    403   1.1  jonathan 	if (why == PWR_RESUME) {
    404   1.1  jonathan 		/*
    405   1.1  jonathan 		 * Give the PCI configuration registers a kick
    406   1.1  jonathan 		 * in the head.
    407   1.1  jonathan 		 */
    408   1.1  jonathan #ifdef DIAGNOSTIC
    409   1.1  jonathan 		if (RTK_IS_ENABLED(sc) == 0)
    410   1.1  jonathan 			panic("re_cardbus_power");
    411   1.1  jonathan #endif
    412   1.1  jonathan 		re_cardbus_setup(csc);
    413   1.1  jonathan 	}
    414   1.1  jonathan }
    415