Home | History | Annotate | Line # | Download | only in cardbus
if_ex_cardbus.c revision 1.15
      1  1.15      haya /*	$NetBSD: if_ex_cardbus.c,v 1.15 2000/08/29 08:54:51 haya Exp $	*/
      2   1.1      haya 
      3   1.1      haya /*
      4   1.1      haya  * CardBus specific routines for 3Com 3C575-family CardBus ethernet adapter
      5   1.1      haya  *
      6   1.1      haya  * Copyright (c) 1998 and 1999
      7   1.1      haya  *       HAYAKAWA Koichi.  All rights reserved.
      8   1.1      haya  *
      9   1.1      haya  * Redistribution and use in source and binary forms, with or without
     10   1.1      haya  * modification, are permitted provided that the following conditions
     11   1.1      haya  * are met:
     12   1.1      haya  * 1. Redistributions of source code must retain the above copyright
     13   1.1      haya  *    notice, this list of conditions and the following disclaimer.
     14   1.1      haya  * 2. Redistributions in binary form must reproduce the above copyright
     15   1.1      haya  *    notice, this list of conditions and the following disclaimer in the
     16   1.1      haya  *    documentation and/or other materials provided with the distribution.
     17   1.1      haya  * 3. All advertising materials mentioning features or use of this software
     18   1.1      haya  *    must display the following acknowledgement:
     19   1.1      haya  *      This product includes software developed by the author.
     20   1.1      haya  * 4. Neither the name of the author nor the names of any co-contributors
     21   1.1      haya  *    may be used to endorse or promote products derived from this software
     22   1.1      haya  *    without specific prior written permission.
     23   1.1      haya  *
     24   1.1      haya  * THIS SOFTWARE IS PROVIDED BY HAYAKAWA KOICHI ``AS IS'' AND
     25   1.1      haya  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26   1.1      haya  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27   1.1      haya  * ARE DISCLAIMED.  IN NO EVENT SHALL TAKESHI OHASHI OR CONTRIBUTORS BE LIABLE
     28   1.1      haya  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29   1.1      haya  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30   1.1      haya  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31   1.1      haya  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32   1.1      haya  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33   1.1      haya  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34   1.1      haya  * SUCH DAMAGE.
     35   1.1      haya  *
     36   1.1      haya  *
     37   1.1      haya  */
     38   1.1      haya 
     39   1.3  augustss /* #define EX_DEBUG 4 */	/* define to report infomation for debugging */
     40   1.1      haya 
     41   1.1      haya #define EX_POWER_STATIC		/* do not use enable/disable functions */
     42   1.1      haya 				/* I'm waiting elinkxl.c uses
     43   1.1      haya                                    sc->enable and sc->disable
     44   1.1      haya                                    functions. */
     45   1.1      haya 
     46   1.1      haya #include <sys/param.h>
     47   1.1      haya #include <sys/systm.h>
     48   1.9   thorpej #include <sys/mbuf.h>
     49   1.9   thorpej #include <sys/socket.h>
     50   1.1      haya #include <sys/ioctl.h>
     51   1.1      haya #include <sys/errno.h>
     52   1.1      haya #include <sys/syslog.h>
     53   1.9   thorpej #include <sys/select.h>
     54   1.9   thorpej #include <sys/device.h>
     55   1.1      haya 
     56   1.1      haya #include <net/if.h>
     57   1.1      haya #include <net/if_dl.h>
     58   1.9   thorpej #include <net/if_ether.h>
     59   1.1      haya #include <net/if_media.h>
     60   1.1      haya 
     61   1.1      haya #include <machine/cpu.h>
     62   1.1      haya #include <machine/bus.h>
     63   1.5      haya 
     64   1.1      haya #include <dev/cardbus/cardbusvar.h>
     65   1.1      haya #include <dev/cardbus/cardbusdevs.h>
     66   1.1      haya 
     67   1.1      haya #include <dev/mii/miivar.h>
     68   1.1      haya 
     69   1.1      haya #include <dev/ic/elink3var.h>
     70   1.1      haya #include <dev/ic/elink3reg.h>
     71   1.1      haya #include <dev/ic/elinkxlreg.h>
     72   1.1      haya #include <dev/ic/elinkxlvar.h>
     73   1.1      haya 
     74   1.1      haya #if defined DEBUG && !defined EX_DEBUG
     75   1.1      haya #define EX_DEBUG
     76   1.1      haya #endif
     77   1.1      haya 
     78   1.1      haya #if defined EX_DEBUG
     79   1.1      haya #define DPRINTF(a) printf a
     80   1.1      haya #else
     81   1.1      haya #define DPRINTF(a)
     82   1.1      haya #endif
     83   1.1      haya 
     84   1.1      haya #define CARDBUS_3C575BTX_FUNCSTAT_PCIREG  CARDBUS_BASE2_REG  /* means 0x18 */
     85   1.1      haya #define EX_CB_INTR 4		/* intr acknowledge reg. CardBus only */
     86   1.1      haya #define EX_CB_INTR_ACK 0x8000 /* intr acknowledge bit */
     87   1.1      haya 
     88   1.9   thorpej int ex_cardbus_match __P((struct device *, struct cfdata *, void *));
     89   1.9   thorpej void ex_cardbus_attach __P((struct device *, struct device *,void *));
     90   1.9   thorpej int ex_cardbus_detach __P((struct device *, int));
     91   1.9   thorpej void ex_cardbus_intr_ack __P((struct ex_softc *));
     92   1.1      haya 
     93   1.1      haya #if !defined EX_POWER_STATIC
     94   1.9   thorpej int ex_cardbus_enable __P((struct ex_softc *sc));
     95   1.9   thorpej void ex_cardbus_disable __P((struct ex_softc *sc));
     96   1.1      haya #endif /* !defined EX_POWER_STATIC */
     97   1.1      haya 
     98   1.1      haya struct ex_cardbus_softc {
     99   1.9   thorpej 	struct ex_softc sc_softc;
    100   1.1      haya 
    101   1.9   thorpej 	cardbus_devfunc_t sc_ct;
    102   1.9   thorpej 	int sc_intrline;
    103   1.9   thorpej 	u_int8_t sc_cardbus_flags;
    104   1.1      haya #define EX_REATTACH		0x01
    105   1.1      haya #define EX_ABSENT		0x02
    106   1.9   thorpej 	u_int8_t sc_cardtype;
    107   1.1      haya #define EX_3C575		1
    108   1.1      haya #define EX_3C575B		2
    109  1.15      haya #define EX_3C575C		3
    110   1.1      haya 
    111   1.9   thorpej 	/* CardBus function status space.  575B requests it. */
    112   1.9   thorpej 	bus_space_tag_t sc_funct;
    113   1.9   thorpej 	bus_space_handle_t sc_funch;
    114  1.11  augustss 	bus_size_t sc_funcsize;
    115  1.11  augustss 
    116  1.11  augustss 	bus_size_t sc_mapsize;		/* the size of mapped bus space region */
    117   1.1      haya };
    118   1.1      haya 
    119   1.1      haya struct cfattach ex_cardbus_ca = {
    120   1.9   thorpej 	sizeof(struct ex_cardbus_softc), ex_cardbus_match,
    121  1.11  augustss 	    ex_cardbus_attach, ex_cardbus_detach, ex_activate
    122   1.9   thorpej };
    123   1.9   thorpej 
    124   1.9   thorpej const struct ex_cardbus_product {
    125   1.9   thorpej 	u_int32_t	ecp_prodid;	/* CardBus product ID */
    126   1.9   thorpej 	int		ecp_flags;	/* initial softc flags */
    127   1.9   thorpej 	pcireg_t	ecp_csr;	/* PCI CSR flags */
    128   1.9   thorpej 	int		ecp_cardtype;	/* card type */
    129   1.9   thorpej 	const char	*ecp_name;	/* device name */
    130   1.9   thorpej } ex_cardbus_products[] = {
    131   1.9   thorpej 	{ CARDBUS_PRODUCT_3COM_3C575TX,
    132   1.9   thorpej 	  EX_CONF_MII,
    133   1.9   thorpej 	  CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE,
    134   1.9   thorpej 	  EX_3C575,
    135   1.9   thorpej 	  "3c575-TX Ethernet" },
    136   1.9   thorpej 
    137   1.9   thorpej 	{ CARDBUS_PRODUCT_3COM_3C575BTX,
    138  1.15      haya 	  EX_CONF_90XB|EX_CONF_MII|EX_CONF_INV_LED_POLARITY,
    139   1.9   thorpej 	  CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MEM_ENABLE |
    140   1.9   thorpej 	      CARDBUS_COMMAND_MASTER_ENABLE,
    141   1.9   thorpej 	  EX_3C575B,
    142   1.9   thorpej 	  "3c575B-TX Ethernet" },
    143   1.9   thorpej 
    144  1.15      haya 	{ CARDBUS_PRODUCT_3COM_3C575CTX,
    145  1.15      haya 	  EX_CONF_90XB|EX_CONF_PHY_POWER,
    146  1.15      haya 	  CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MEM_ENABLE |
    147  1.15      haya 	      CARDBUS_COMMAND_MASTER_ENABLE,
    148  1.15      haya 	  EX_3C575C,
    149  1.15      haya 	  "3c575CT Ethernet" },
    150  1.15      haya 
    151   1.9   thorpej 	{ 0,
    152  1.14   thorpej 	  0,
    153   1.9   thorpej 	  0,
    154   1.9   thorpej 	  0,
    155   1.9   thorpej 	  NULL },
    156   1.1      haya };
    157   1.1      haya 
    158   1.9   thorpej const struct ex_cardbus_product *ex_cardbus_lookup
    159   1.9   thorpej     __P((const struct cardbus_attach_args *));
    160   1.9   thorpej 
    161   1.9   thorpej const struct ex_cardbus_product *
    162   1.9   thorpej ex_cardbus_lookup(ca)
    163   1.9   thorpej 	const struct cardbus_attach_args *ca;
    164   1.9   thorpej {
    165   1.9   thorpej 	const struct ex_cardbus_product *ecp;
    166   1.9   thorpej 
    167   1.9   thorpej 	if (CARDBUS_VENDOR(ca->ca_id) != CARDBUS_VENDOR_3COM)
    168   1.9   thorpej 		return (NULL);
    169   1.1      haya 
    170   1.9   thorpej 	for (ecp = ex_cardbus_products; ecp->ecp_name != NULL; ecp++)
    171   1.9   thorpej 		if (CARDBUS_PRODUCT(ca->ca_id) == ecp->ecp_prodid)
    172   1.9   thorpej 			return (ecp);
    173   1.9   thorpej 	return (NULL);
    174   1.9   thorpej }
    175   1.1      haya 
    176   1.9   thorpej int
    177   1.1      haya ex_cardbus_match(parent, cf, aux)
    178   1.9   thorpej 	struct device *parent;
    179   1.9   thorpej 	struct cfdata *cf;
    180   1.9   thorpej 	void *aux;
    181   1.1      haya {
    182   1.9   thorpej 	struct cardbus_attach_args *ca = aux;
    183   1.9   thorpej 
    184   1.9   thorpej 	if (ex_cardbus_lookup(ca) != NULL)
    185   1.9   thorpej 		return (1);
    186   1.1      haya 
    187   1.9   thorpej 	return (0);
    188   1.1      haya }
    189   1.1      haya 
    190   1.9   thorpej void
    191   1.9   thorpej ex_cardbus_attach(parent, self, aux)
    192   1.9   thorpej 	struct device *parent;
    193   1.9   thorpej 	struct device *self;
    194   1.9   thorpej 	void *aux;
    195   1.9   thorpej {
    196   1.9   thorpej 	struct ex_cardbus_softc *psc = (void *)self;
    197   1.9   thorpej 	struct ex_softc *sc = &psc->sc_softc;
    198   1.9   thorpej 	struct cardbus_attach_args *ca = aux;
    199   1.9   thorpej 	cardbus_devfunc_t ct = ca->ca_ct;
    200   1.9   thorpej 	cardbus_chipset_tag_t cc = ct->ct_cc;
    201   1.9   thorpej 	cardbus_function_tag_t cf = ct->ct_cf;
    202   1.9   thorpej 	cardbusreg_t iob, command, bhlc;
    203   1.9   thorpej 	const struct ex_cardbus_product *ecp;
    204   1.9   thorpej 	bus_space_handle_t ioh;
    205   1.9   thorpej 	bus_addr_t adr;
    206   1.9   thorpej 
    207   1.9   thorpej 	if (Cardbus_mapreg_map(ct, CARDBUS_BASE0_REG, CARDBUS_MAPREG_TYPE_IO, 0,
    208  1.11  augustss 	    &sc->sc_iot, &ioh, &adr, &psc->sc_mapsize)) {
    209   1.9   thorpej 		printf(": can't map i/o space\n");
    210   1.9   thorpej 		return;
    211   1.9   thorpej 	}
    212   1.9   thorpej 
    213   1.9   thorpej 	ecp = ex_cardbus_lookup(ca);
    214   1.9   thorpej 	if (ecp == NULL) {
    215   1.9   thorpej 		printf("\n");
    216   1.9   thorpej 		panic("ex_cardbus_attach: impossible");
    217   1.9   thorpej 	}
    218   1.1      haya 
    219   1.9   thorpej 	printf(": 3Com %s\n", ecp->ecp_name);
    220   1.1      haya 
    221   1.9   thorpej #if !defined EX_POWER_STATIC
    222   1.9   thorpej 	sc->enable = ex_cardbus_enable;
    223   1.9   thorpej 	sc->disable = ex_cardbus_disable;
    224   1.9   thorpej #else
    225   1.9   thorpej 	sc->enable = NULL;
    226   1.9   thorpej 	sc->disable = NULL;
    227   1.9   thorpej #endif
    228   1.9   thorpej 	sc->enabled = 1;
    229   1.1      haya 
    230   1.9   thorpej 	sc->sc_dmat = ca->ca_dmat;
    231   1.1      haya 
    232   1.9   thorpej 	sc->ex_bustype = EX_BUS_CARDBUS;
    233   1.9   thorpej 	sc->ex_conf = ecp->ecp_flags;
    234   1.1      haya 
    235   1.9   thorpej 	iob = adr;
    236   1.9   thorpej 	sc->sc_ioh = ioh;
    237   1.1      haya 
    238   1.1      haya #if rbus
    239   1.1      haya #else
    240   1.9   thorpej 	(ct->ct_cf->cardbus_io_open)(cc, 0, iob, iob + 0x40);
    241   1.1      haya #endif
    242   1.9   thorpej 	(ct->ct_cf->cardbus_ctrl)(cc, CARDBUS_IO_ENABLE);
    243   1.1      haya 
    244   1.9   thorpej 	command = cardbus_conf_read(cc, cf, ca->ca_tag,
    245   1.9   thorpej 	    CARDBUS_COMMAND_STATUS_REG);
    246   1.9   thorpej 	command |= ecp->ecp_csr;
    247   1.9   thorpej 	psc->sc_cardtype = ecp->ecp_cardtype;
    248   1.9   thorpej 
    249  1.15      haya 	if ((psc->sc_cardtype == EX_3C575B) ||
    250  1.15      haya 	    (psc->sc_cardtype == EX_3C575C)) {
    251   1.9   thorpej 		/* Map CardBus function status window. */
    252   1.9   thorpej 		if (Cardbus_mapreg_map(ct, CARDBUS_3C575BTX_FUNCSTAT_PCIREG,
    253   1.9   thorpej 		    CARDBUS_MAPREG_TYPE_MEM, 0, &psc->sc_funct,
    254  1.11  augustss 		    &psc->sc_funch, 0, &psc->sc_funcsize)) {
    255   1.9   thorpej 			printf("%s: unable to map function status window\n",
    256   1.9   thorpej 			    self->dv_xname);
    257   1.9   thorpej 			return;
    258   1.9   thorpej 		}
    259   1.9   thorpej 
    260   1.9   thorpej 		/*
    261   1.9   thorpej 		 * Make sure CardBus brigde can access memory space.  Usually
    262   1.9   thorpej 		 * memory access is enabled by BIOS, but some BIOSes do not
    263   1.9   thorpej 		 * enable it.
    264   1.9   thorpej 		 */
    265   1.9   thorpej 		(ct->ct_cf->cardbus_ctrl)(cc, CARDBUS_MEM_ENABLE);
    266   1.9   thorpej 
    267   1.9   thorpej 		/* Setup interrupt acknowledge hook */
    268   1.9   thorpej 		sc->intr_ack = ex_cardbus_intr_ack;
    269   1.9   thorpej 	}
    270   1.1      haya 
    271  1.13   mycroft 	(ct->ct_cf->cardbus_ctrl)(cc, CARDBUS_BM_ENABLE);
    272   1.9   thorpej 	cardbus_conf_write(cc, cf, ca->ca_tag, CARDBUS_COMMAND_STATUS_REG,
    273   1.9   thorpej 	    command);
    274   1.1      haya 
    275   1.9   thorpej  	/*
    276   1.9   thorpej 	 * set latency timmer
    277   1.9   thorpej 	 */
    278   1.9   thorpej 	bhlc = cardbus_conf_read(cc, cf, ca->ca_tag, CARDBUS_BHLC_REG);
    279   1.9   thorpej 	if (CARDBUS_LATTIMER(bhlc) < 0x20) {
    280   1.9   thorpej 		/* at least the value of latency timer should 0x20. */
    281   1.9   thorpej 		DPRINTF(("if_ex_cardbus: lattimer 0x%x -> 0x20\n",
    282   1.9   thorpej 		    CARDBUS_LATTIMER(bhlc)));
    283   1.9   thorpej 		bhlc &= ~(CARDBUS_LATTIMER_MASK << CARDBUS_LATTIMER_SHIFT);
    284   1.9   thorpej 		bhlc |= (0x20 << CARDBUS_LATTIMER_SHIFT);
    285   1.9   thorpej 		cardbus_conf_write(cc, cf, ca->ca_tag, CARDBUS_BHLC_REG, bhlc);
    286   1.9   thorpej 	}
    287   1.1      haya 
    288   1.9   thorpej 	psc->sc_ct = ca->ca_ct;
    289   1.9   thorpej 	psc->sc_intrline = ca->ca_intrline;
    290   1.1      haya 
    291   1.1      haya #if defined EX_POWER_STATIC
    292   1.9   thorpej 	/* Map and establish the interrupt. */
    293   1.1      haya 
    294   1.9   thorpej 	sc->sc_ih = cardbus_intr_establish(cc, cf, ca->ca_intrline, IPL_NET,
    295   1.9   thorpej 	    ex_intr, psc);
    296   1.9   thorpej 	if (sc->sc_ih == NULL) {
    297   1.9   thorpej 		printf("%s: couldn't establish interrupt",
    298   1.9   thorpej 		    sc->sc_dev.dv_xname);
    299   1.9   thorpej 		printf(" at %d", ca->ca_intrline);
    300   1.9   thorpej 		printf("\n");
    301   1.9   thorpej 		return;
    302   1.9   thorpej 	}
    303   1.9   thorpej 	printf("%s: interrupting at %d\n", sc->sc_dev.dv_xname,
    304   1.9   thorpej 	    ca->ca_intrline);
    305   1.1      haya #endif
    306   1.1      haya 
    307   1.9   thorpej 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, ELINK_COMMAND, GLOBAL_RESET);
    308   1.9   thorpej 	delay(400);
    309   1.9   thorpej 	{
    310   1.9   thorpej 		int i = 0;
    311   1.9   thorpej 		while (bus_space_read_2(sc->sc_iot, sc->sc_ioh, ELINK_STATUS) &
    312   1.9   thorpej 		    S_COMMAND_IN_PROGRESS) {
    313   1.9   thorpej 			if (++i > 10000) {
    314   1.9   thorpej 				printf("ex: timeout %x\n",
    315   1.9   thorpej 				    bus_space_read_2(sc->sc_iot, sc->sc_ioh,
    316   1.9   thorpej 				        ELINK_STATUS));
    317   1.9   thorpej 				printf("ex: addr %x\n",
    318   1.9   thorpej 				    cardbus_conf_read(cc, cf, ca->ca_tag,
    319   1.9   thorpej 				    CARDBUS_BASE0_REG));
    320   1.9   thorpej 				return;		/* emergency exit */
    321   1.9   thorpej 			}
    322   1.9   thorpej 		}
    323   1.9   thorpej 	}
    324   1.9   thorpej 
    325   1.9   thorpej 	ex_config(sc);
    326   1.9   thorpej 
    327  1.15      haya 	if ((psc->sc_cardtype == EX_3C575B) ||
    328  1.15      haya 	    (psc->sc_cardtype == EX_3C575C))
    329   1.9   thorpej 		bus_space_write_4(psc->sc_funct, psc->sc_funch,
    330   1.9   thorpej 		    EX_CB_INTR, EX_CB_INTR_ACK);
    331   1.1      haya 
    332  1.15      haya 	if (psc->sc_cardtype == EX_3C575C) {
    333  1.15      haya 		u_int16_t cbcard_config;
    334  1.15      haya 
    335  1.15      haya 		GO_WINDOW(2);
    336  1.15      haya 		cbcard_config = bus_space_read_2(sc->sc_iot, sc->sc_ioh, 0x0c);
    337  1.15      haya 		cbcard_config |= 0x4000; /* turn on MII power */
    338  1.15      haya 		bus_space_write_2(sc->sc_iot, sc->sc_ioh, 0x0c, cbcard_config);
    339  1.15      haya 	}
    340  1.15      haya 
    341   1.1      haya #if !defined EX_POWER_STATIC
    342   1.9   thorpej 	cardbus_function_disable(psc->sc_ct);
    343   1.9   thorpej 	sc->enabled = 0;
    344   1.1      haya #endif
    345   1.1      haya }
    346   1.1      haya 
    347   1.9   thorpej void
    348   1.1      haya ex_cardbus_intr_ack(sc)
    349   1.9   thorpej 	struct ex_softc *sc;
    350   1.1      haya {
    351   1.9   thorpej 	struct ex_cardbus_softc *psc = (struct ex_cardbus_softc *)sc;
    352   1.9   thorpej 
    353   1.9   thorpej 	bus_space_write_4(psc->sc_funct, psc->sc_funch, EX_CB_INTR,
    354   1.9   thorpej 	    EX_CB_INTR_ACK);
    355   1.1      haya }
    356   1.1      haya 
    357   1.9   thorpej int
    358   1.1      haya ex_cardbus_detach(self, arg)
    359   1.9   thorpej 	struct device *self;
    360   1.9   thorpej 	int arg;
    361   1.1      haya {
    362   1.9   thorpej 	struct ex_cardbus_softc *psc = (void *)self;
    363   1.9   thorpej 	struct ex_softc *sc = &psc->sc_softc;
    364  1.11  augustss 	struct cardbus_devfunc *ct = psc->sc_ct;
    365  1.11  augustss 	int rv;
    366   1.1      haya 
    367  1.11  augustss #if defined(DIAGNOSTIC)
    368  1.11  augustss 	if (ct == NULL) {
    369  1.11  augustss 		panic("%s: data structure lacks\n", sc->sc_dev.dv_xname);
    370  1.11  augustss 	}
    371  1.11  augustss #endif
    372  1.10      haya 
    373  1.11  augustss 	rv = ex_detach(sc);
    374  1.11  augustss 	if (rv == 0) {
    375  1.11  augustss 		/*
    376  1.11  augustss 		 * Unhook the interrupt handler.
    377  1.11  augustss 		 */
    378  1.11  augustss 		cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, sc->sc_ih);
    379   1.1      haya 
    380  1.15      haya 		if ((psc->sc_cardtype == EX_3C575B) ||
    381  1.15      haya 		    (psc->sc_cardtype == EX_3C575C)) {
    382  1.12   thorpej 			Cardbus_mapreg_unmap(ct,
    383  1.12   thorpej 			    CARDBUS_3C575BTX_FUNCSTAT_PCIREG,
    384  1.11  augustss 			    psc->sc_funct, psc->sc_funch, psc->sc_funcsize);
    385  1.11  augustss 		}
    386   1.1      haya 
    387  1.12   thorpej 		Cardbus_mapreg_unmap(ct, CARDBUS_BASE0_REG, sc->sc_iot,
    388  1.11  augustss 		    sc->sc_ioh, psc->sc_mapsize);
    389  1.11  augustss 	}
    390  1.11  augustss 	return (rv);
    391   1.1      haya }
    392   1.1      haya 
    393   1.1      haya #if !defined EX_POWER_STATIC
    394   1.9   thorpej int
    395   1.1      haya ex_cardbus_enable(sc)
    396   1.9   thorpej 	struct ex_softc *sc;
    397   1.1      haya {
    398   1.9   thorpej 	struct ex_cardbus_softc *csc = (struct ex_cardbus_softc *)sc;
    399   1.9   thorpej 	cardbus_function_tag_t cf = csc->sc_ct->ct_cf;
    400   1.9   thorpej 	cardbus_chipset_tag_t cc = csc->sc_ct->ct_cc;
    401   1.9   thorpej 
    402   1.9   thorpej 	Cardbus_function_enable(csc->sc_ct);
    403   1.9   thorpej 	cardbus_restore_bar(csc->sc_ct);
    404   1.9   thorpej 
    405   1.9   thorpej 	sc->sc_ih = cardbus_intr_establish(cc, cf, csc->sc_intrline,
    406   1.9   thorpej 	    IPL_NET, ex_intr, sc);
    407   1.9   thorpej 	if (NULL == sc->sc_ih) {
    408   1.9   thorpej 		printf("%s: couldn't establish interrupt\n",
    409   1.9   thorpej 		    sc->sc_dev.dv_xname);
    410   1.9   thorpej 		return (1);
    411   1.9   thorpej 	}
    412   1.1      haya 
    413   1.9   thorpej 	return (0);
    414   1.1      haya }
    415   1.1      haya 
    416   1.9   thorpej void
    417   1.1      haya ex_cardbus_disable(sc)
    418   1.9   thorpej 	struct ex_softc *sc;
    419   1.1      haya {
    420   1.9   thorpej 	struct ex_cardbus_softc *csc = (struct ex_cardbus_softc *)sc;
    421   1.9   thorpej 	cardbus_function_tag_t cf = csc->sc_ct->ct_cf;
    422   1.9   thorpej 	cardbus_chipset_tag_t cc = csc->sc_ct->ct_cc;
    423   1.1      haya 
    424   1.9   thorpej 	cardbus_save_bar(csc->sc_ct);
    425   1.1      haya 
    426   1.9   thorpej  	Cardbus_function_disable(csc->sc_ct);
    427   1.1      haya 
    428   1.9   thorpej 	cardbus_intr_disestablish(cc, cf, sc->sc_ih);
    429   1.1      haya }
    430   1.1      haya #endif /* EX_POWER_STATIC */
    431