if_re_pci.c revision 1.50.2.1       1  1.50.2.1        ad /*	$NetBSD: if_re_pci.c,v 1.50.2.1 2020/02/29 20:19:10 ad Exp $	*/
      2       1.4      yamt 
      3       1.4      yamt /*
      4       1.4      yamt  * Copyright (c) 1997, 1998-2003
      5       1.4      yamt  *	Bill Paul <wpaul (at) windriver.com>.  All rights reserved.
      6       1.4      yamt  *
      7       1.4      yamt  * Redistribution and use in source and binary forms, with or without
      8       1.4      yamt  * modification, are permitted provided that the following conditions
      9       1.4      yamt  * are met:
     10       1.4      yamt  * 1. Redistributions of source code must retain the above copyright
     11       1.4      yamt  *    notice, this list of conditions and the following disclaimer.
     12       1.4      yamt  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.4      yamt  *    notice, this list of conditions and the following disclaimer in the
     14       1.4      yamt  *    documentation and/or other materials provided with the distribution.
     15       1.4      yamt  * 3. All advertising materials mentioning features or use of this software
     16       1.4      yamt  *    must display the following acknowledgement:
     17       1.4      yamt  *	This product includes software developed by Bill Paul.
     18       1.4      yamt  * 4. Neither the name of the author nor the names of any co-contributors
     19       1.4      yamt  *    may be used to endorse or promote products derived from this software
     20       1.4      yamt  *    without specific prior written permission.
     21       1.4      yamt  *
     22       1.4      yamt  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
     23       1.4      yamt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24       1.4      yamt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25       1.4      yamt  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
     26       1.4      yamt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     27       1.4      yamt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     28       1.4      yamt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     29       1.4      yamt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     30       1.4      yamt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     31       1.4      yamt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     32       1.4      yamt  * THE POSSIBILITY OF SUCH DAMAGE.
     33       1.4      yamt  */
     34       1.4      yamt 
     35       1.4      yamt /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
     36       1.4      yamt 
     37       1.1  jonathan /*
     38       1.1  jonathan  * RealTek 8139C+/8169/8169S/8110S PCI NIC driver
     39       1.1  jonathan  *
     40       1.1  jonathan  * Written by Bill Paul <wpaul (at) windriver.com>
     41       1.1  jonathan  * Senior Networking Software Engineer
     42       1.1  jonathan  * Wind River Systems
     43       1.1  jonathan  *
     44      1.21  christos  * NetBSD bus-specific frontends for written by
     45       1.1  jonathan  * Jonathan Stone <jonathan (at) netbsd.org>
     46       1.1  jonathan  */
     47       1.1  jonathan 
     48      1.28       dsl #include <sys/cdefs.h>
     49  1.50.2.1        ad __KERNEL_RCSID(0, "$NetBSD: if_re_pci.c,v 1.50.2.1 2020/02/29 20:19:10 ad Exp $");
     50       1.1  jonathan 
     51       1.1  jonathan #include <sys/types.h>
     52       1.1  jonathan 
     53       1.1  jonathan #include <sys/param.h>
     54       1.1  jonathan #include <sys/systm.h>
     55       1.1  jonathan #include <sys/device.h>
     56       1.1  jonathan 
     57       1.1  jonathan #include <net/if.h>
     58       1.1  jonathan #include <net/if_ether.h>
     59       1.1  jonathan #include <net/if_media.h>
     60       1.1  jonathan 
     61      1.30        ad #include <sys/bus.h>
     62       1.5    briggs 
     63       1.1  jonathan #include <dev/mii/mii.h>
     64       1.1  jonathan #include <dev/mii/miivar.h>
     65       1.1  jonathan 
     66       1.5    briggs #include <dev/pci/pcireg.h>
     67       1.5    briggs #include <dev/pci/pcivar.h>
     68       1.5    briggs #include <dev/pci/pcidevs.h>
     69       1.5    briggs 
     70       1.1  jonathan #include <dev/ic/rtl81x9reg.h>
     71       1.1  jonathan #include <dev/ic/rtl81x9var.h>
     72       1.1  jonathan #include <dev/ic/rtl8169var.h>
     73       1.1  jonathan 
     74       1.1  jonathan struct re_pci_softc {
     75       1.1  jonathan 	struct rtk_softc sc_rtk;
     76       1.1  jonathan 
     77       1.1  jonathan 	void *sc_ih;
     78      1.45  jakllsch 	pci_intr_handle_t *sc_pihp;
     79       1.1  jonathan 	pci_chipset_tag_t sc_pc;
     80       1.1  jonathan };
     81       1.1  jonathan 
     82      1.34   tsutsui static int	re_pci_match(device_t, cfdata_t, void *);
     83      1.34   tsutsui static void	re_pci_attach(device_t, device_t, void *);
     84      1.39  jakllsch static int	re_pci_detach(device_t, int);
     85      1.34   tsutsui 
     86      1.34   tsutsui CFATTACH_DECL_NEW(re_pci, sizeof(struct re_pci_softc),
     87      1.39  jakllsch     re_pci_match, re_pci_attach, re_pci_detach, NULL);
     88       1.1  jonathan 
     89       1.1  jonathan /*
     90       1.1  jonathan  * Various supported device vendors/types and their names.
     91       1.1  jonathan  */
     92       1.6  jdolecek static const struct rtk_type re_devs[] = {
     93      1.19   tsutsui 	{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8139,
     94      1.27   tsutsui 	    RTK_8139CPLUS,
     95      1.19   tsutsui 	    "RealTek 8139C+ 10/100BaseTX" },
     96      1.19   tsutsui 	{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8101E,
     97      1.27   tsutsui 	    RTK_8101E,
     98      1.35       tnn 	    "RealTek 8100E/8101E/8102E/8102EL PCIe 10/100BaseTX" },
     99      1.19   tsutsui 	{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8168,
    100      1.27   tsutsui 	    RTK_8168,
    101      1.36   tsutsui 	    "RealTek 8168/8111 PCIe Gigabit Ethernet" },
    102      1.50   msaitoh 	{ PCI_VENDOR_NCUBE, PCI_PRODUCT_NCUBE_TG3648,
    103      1.50   msaitoh 	    RTK_8168,
    104      1.50   msaitoh 	    "TP-Link TG-3468 v2 (RTL8168) Gigabit Ethernet" },
    105      1.19   tsutsui 	{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8169,
    106      1.27   tsutsui 	    RTK_8169,
    107      1.27   tsutsui 	    "RealTek 8169/8110 Gigabit Ethernet" },
    108      1.19   tsutsui 	{ PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RT8169SC,
    109      1.27   tsutsui 	    RTK_8169,
    110      1.19   tsutsui 	    "RealTek 8169SC/8110SC Single-chip Gigabit Ethernet" },
    111      1.19   tsutsui 	{ PCI_VENDOR_COREGA, PCI_PRODUCT_COREGA_LAPCIGT,
    112      1.27   tsutsui 	    RTK_8169,
    113      1.19   tsutsui 	    "Corega CG-LAPCIGT Gigabit Ethernet" },
    114      1.19   tsutsui 	{ PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE528T,
    115      1.27   tsutsui 	    RTK_8169,
    116      1.19   tsutsui 	    "D-Link DGE-528T Gigabit Ethernet" },
    117      1.50   msaitoh 	{ PCI_VENDOR_DLINK, PCI_PRODUCT_DLINK_DGE530T_C1,
    118      1.50   msaitoh 	    RTK_8169,
    119      1.50   msaitoh 	    "D-Link DGE-530T C1 Gigabit Ethernet" },
    120      1.19   tsutsui 	{ PCI_VENDOR_USR2, PCI_PRODUCT_USR2_USR997902,
    121      1.27   tsutsui 	    RTK_8169,
    122      1.19   tsutsui 	    "US Robotics (3Com) USR997902 Gigabit Ethernet" },
    123      1.19   tsutsui 	{ PCI_VENDOR_LINKSYS, PCI_PRODUCT_LINKSYS_EG1032,
    124      1.27   tsutsui 	    RTK_8169,
    125      1.19   tsutsui 	    "Linksys EG1032 rev. 3 Gigabit Ethernet" },
    126       1.1  jonathan };
    127       1.1  jonathan 
    128      1.39  jakllsch static const struct rtk_type *
    129      1.39  jakllsch re_pci_lookup(const struct pci_attach_args * pa)
    130      1.39  jakllsch {
    131      1.39  jakllsch 	int i;
    132      1.39  jakllsch 
    133  1.50.2.1        ad 	for (i = 0; i < __arraycount(re_devs); i++) {
    134      1.39  jakllsch 		if (PCI_VENDOR(pa->pa_id) != re_devs[i].rtk_vid)
    135      1.39  jakllsch 			continue;
    136      1.39  jakllsch 		if (PCI_PRODUCT(pa->pa_id) == re_devs[i].rtk_did)
    137      1.39  jakllsch 			return &re_devs[i];
    138      1.39  jakllsch 	}
    139      1.39  jakllsch 
    140      1.39  jakllsch 	return NULL;
    141      1.39  jakllsch }
    142      1.39  jakllsch 
    143      1.11       riz #define RE_LINKSYS_EG1032_SUBID	0x00241737
    144      1.11       riz 
    145       1.1  jonathan /*
    146       1.1  jonathan  * Probe for a RealTek 8139C+/8169/8110 chip. Check the PCI vendor and device
    147       1.1  jonathan  * IDs against our list and return a device name if we find a match.
    148       1.1  jonathan  */
    149       1.1  jonathan static int
    150      1.34   tsutsui re_pci_match(device_t parent, cfdata_t cf, void *aux)
    151       1.1  jonathan {
    152      1.34   tsutsui 	struct pci_attach_args *pa = aux;
    153      1.11       riz 	pcireg_t subid;
    154      1.11       riz 
    155      1.11       riz 	subid = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG);
    156      1.11       riz 
    157      1.11       riz 	/* special-case Linksys EG1032, since rev 2 uses sk(4) */
    158      1.11       riz 	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_LINKSYS &&
    159      1.27   tsutsui 	    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_LINKSYS_EG1032) {
    160      1.27   tsutsui 		if (subid != RE_LINKSYS_EG1032_SUBID)
    161      1.27   tsutsui 			return 0;
    162      1.27   tsutsui 	}
    163      1.39  jakllsch 
    164      1.27   tsutsui 	/* Don't match 8139 other than C-PLUS */
    165      1.27   tsutsui 	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_REALTEK &&
    166      1.27   tsutsui 	    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_REALTEK_RT8139) {
    167      1.27   tsutsui 		if (PCI_REVISION(pa->pa_class) != 0x20)
    168      1.27   tsutsui 			return 0;
    169      1.27   tsutsui 	}
    170       1.1  jonathan 
    171      1.39  jakllsch 	if (re_pci_lookup(pa) != NULL)
    172      1.39  jakllsch 		return 2;	/* defeat rtk(4) */
    173       1.1  jonathan 
    174       1.1  jonathan 	return 0;
    175       1.1  jonathan }
    176       1.1  jonathan 
    177       1.1  jonathan static void
    178      1.34   tsutsui re_pci_attach(device_t parent, device_t self, void *aux)
    179       1.1  jonathan {
    180      1.34   tsutsui 	struct re_pci_softc *psc = device_private(self);
    181      1.34   tsutsui 	struct rtk_softc *sc = &psc->sc_rtk;
    182      1.34   tsutsui 	struct pci_attach_args *pa = aux;
    183       1.1  jonathan 	pci_chipset_tag_t pc = pa->pa_pc;
    184       1.1  jonathan 	const char *intrstr = NULL;
    185      1.34   tsutsui 	const struct rtk_type *t;
    186      1.34   tsutsui 	uint32_t hwrev;
    187      1.34   tsutsui 	pcireg_t command, memtype;
    188      1.34   tsutsui 	bool ioh_valid, memh_valid;
    189      1.34   tsutsui 	bus_space_tag_t iot, memt;
    190      1.34   tsutsui 	bus_space_handle_t ioh, memh;
    191      1.39  jakllsch 	bus_size_t iosize, memsize;
    192      1.43  christos 	char intrbuf[PCI_INTRSTR_LEN];
    193  1.50.2.1        ad 	bool prefer_io = false;
    194      1.34   tsutsui 
    195      1.34   tsutsui 	sc->sc_dev = self;
    196      1.39  jakllsch 	psc->sc_pc = pa->pa_pc;
    197       1.1  jonathan 
    198       1.1  jonathan 	command = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
    199       1.1  jonathan 	command |= PCI_COMMAND_MASTER_ENABLE;
    200       1.1  jonathan 	pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, command);
    201       1.1  jonathan 
    202      1.39  jakllsch 	/*
    203      1.39  jakllsch 	 * Map control/status registers.
    204      1.39  jakllsch 	 */
    205      1.22   tsutsui 	ioh_valid = (pci_mapreg_map(pa, RTK_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0,
    206      1.22   tsutsui 	    &iot, &ioh, NULL, &iosize) == 0);
    207      1.27   tsutsui 	memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, RTK_PCI_LOMEM);
    208      1.27   tsutsui 	switch (memtype) {
    209      1.27   tsutsui 	case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT:
    210      1.27   tsutsui 	case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT:
    211      1.44      matt 		memh_valid =
    212      1.44      matt 		    (pci_mapreg_map(pa, RTK_PCI_LOMEM,
    213  1.50.2.1        ad 			memtype, 0, &memt, &memh, NULL, &memsize) == 0) ||
    214      1.44      matt 		    (pci_mapreg_map(pa, RTK_PCI_LOMEM + 4,
    215      1.44      matt 			PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT,
    216      1.44      matt 			0, &memt, &memh, NULL, &memsize) == 0);
    217      1.27   tsutsui 		break;
    218      1.27   tsutsui 	default:
    219      1.27   tsutsui 		memh_valid = 0;
    220      1.27   tsutsui 		break;
    221      1.27   tsutsui 	}
    222      1.27   tsutsui 
    223  1.50.2.1        ad 	switch (PCI_VENDOR(pa->pa_id)) {
    224  1.50.2.1        ad 	case PCI_VENDOR_REALTEK:
    225  1.50.2.1        ad 		switch (PCI_PRODUCT(pa->pa_id)) {
    226  1.50.2.1        ad 		case PCI_PRODUCT_REALTEK_RT8169SC:
    227  1.50.2.1        ad 			prefer_io = true;
    228  1.50.2.1        ad 			break;
    229  1.50.2.1        ad 		}
    230  1.50.2.1        ad 		break;
    231  1.50.2.1        ad 	}
    232  1.50.2.1        ad 	if (!memh_valid)
    233  1.50.2.1        ad 		prefer_io = true;
    234  1.50.2.1        ad 
    235  1.50.2.1        ad 	if (ioh_valid && prefer_io) {
    236      1.22   tsutsui 		sc->rtk_btag = iot;
    237      1.22   tsutsui 		sc->rtk_bhandle = ioh;
    238      1.39  jakllsch 		sc->rtk_bsize = iosize;
    239      1.39  jakllsch 		if (memh_valid)
    240      1.39  jakllsch 			bus_space_unmap(memt, memh, memsize);
    241  1.50.2.1        ad 
    242  1.50.2.1        ad 		command = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
    243  1.50.2.1        ad 		command |= PCI_COMMAND_IO_ENABLE;
    244  1.50.2.1        ad 		pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, command);
    245      1.22   tsutsui 	} else if (memh_valid) {
    246      1.22   tsutsui 		sc->rtk_btag = memt;
    247      1.22   tsutsui 		sc->rtk_bhandle = memh;
    248      1.39  jakllsch 		sc->rtk_bsize = memsize;
    249  1.50.2.1        ad 		if (ioh_valid)
    250  1.50.2.1        ad 			bus_space_unmap(iot, ioh, iosize);
    251  1.50.2.1        ad 
    252  1.50.2.1        ad 		command = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
    253  1.50.2.1        ad 		command |= PCI_COMMAND_MEM_ENABLE;
    254  1.50.2.1        ad 		pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, command);
    255      1.22   tsutsui 	} else {
    256      1.34   tsutsui 		aprint_error(": can't map registers\n");
    257       1.2   kanaoka 		return;
    258       1.1  jonathan 	}
    259      1.22   tsutsui 
    260      1.39  jakllsch 	t = re_pci_lookup(pa);
    261      1.39  jakllsch 	KASSERT(t != NULL);
    262       1.1  jonathan 
    263      1.41  drochner 	pci_aprint_devinfo_fancy(pa, NULL, t->rtk_name, 1);
    264      1.34   tsutsui 
    265      1.27   tsutsui 	if (t->rtk_basetype == RTK_8139CPLUS)
    266      1.27   tsutsui 		sc->sc_quirk |= RTKQ_8139CPLUS;
    267      1.27   tsutsui 
    268      1.27   tsutsui 	if (t->rtk_basetype == RTK_8168 ||
    269      1.27   tsutsui 	    t->rtk_basetype == RTK_8101E)
    270      1.27   tsutsui 		sc->sc_quirk |= RTKQ_PCIE;
    271      1.27   tsutsui 
    272      1.46  jmcneill 	if (t->rtk_basetype == RTK_8168)
    273      1.46  jmcneill 		sc->sc_quirk |= RTKQ_IM_HW;
    274      1.46  jmcneill 
    275      1.40  jakllsch 	if (pci_dma64_available(pa) && (sc->sc_quirk & RTKQ_PCIE))
    276      1.40  jakllsch 		sc->sc_dmat = pa->pa_dmat64;
    277      1.40  jakllsch 	else
    278      1.40  jakllsch 		sc->sc_dmat = pa->pa_dmat;
    279       1.1  jonathan 
    280       1.1  jonathan 	/*
    281      1.29    simonb 	 * No power/enable/disable machinery for PCI attach;
    282       1.1  jonathan 	 * mark the card enabled now.
    283       1.1  jonathan 	 */
    284       1.1  jonathan 	sc->sc_flags |= RTK_ENABLED;
    285       1.8     perry 
    286       1.1  jonathan 	/* Hook interrupt last to avoid having to lock softc */
    287       1.1  jonathan 	/* Allocate interrupt */
    288      1.45  jakllsch 	if (pci_intr_alloc(pa, &psc->sc_pihp, NULL, 0)) {
    289      1.34   tsutsui 		aprint_error_dev(self, "couldn't map interrupt\n");
    290       1.2   kanaoka 		return;
    291       1.1  jonathan 	}
    292      1.45  jakllsch 	intrstr = pci_intr_string(pc, psc->sc_pihp[0], intrbuf,
    293      1.45  jakllsch 	    sizeof(intrbuf));
    294      1.49  jdolecek 	psc->sc_ih = pci_intr_establish_xname(pc, psc->sc_pihp[0], IPL_NET,
    295      1.49  jdolecek 	    re_intr, sc, device_xname(sc->sc_dev));
    296       1.1  jonathan 	if (psc->sc_ih == NULL) {
    297      1.34   tsutsui 		aprint_error_dev(self, "couldn't establish interrupt");
    298       1.1  jonathan 		if (intrstr != NULL)
    299       1.3   kanaoka 			aprint_error(" at %s", intrstr);
    300       1.3   kanaoka 		aprint_error("\n");
    301       1.1  jonathan 		return;
    302       1.1  jonathan 	}
    303      1.34   tsutsui 	aprint_normal_dev(self, "interrupting at %s\n", intrstr);
    304       1.1  jonathan 
    305       1.2   kanaoka 	re_attach(sc);
    306       1.2   kanaoka 
    307      1.39  jakllsch 	hwrev = CSR_READ_4(sc, RTK_TXCFG) & RTK_TXCFG_HWREV;
    308      1.39  jakllsch 
    309       1.2   kanaoka 	/*
    310      1.17   tsutsui 	 * Perform hardware diagnostic on the original RTL8169.
    311      1.17   tsutsui 	 * Some 32-bit cards were incorrectly wired and would
    312      1.17   tsutsui 	 * malfunction if plugged into a 64-bit slot.
    313       1.2   kanaoka 	 */
    314      1.17   tsutsui 	if (hwrev == RTK_HWREV_8169) {
    315      1.39  jakllsch 		if (re_diag(sc)) {
    316      1.39  jakllsch 			re_pci_detach(self, 0);
    317      1.39  jakllsch 			aprint_error_dev(self, "disabled\n");
    318       1.2   kanaoka 		}
    319       1.2   kanaoka 	}
    320       1.1  jonathan }
    321      1.39  jakllsch 
    322      1.39  jakllsch static int
    323      1.39  jakllsch re_pci_detach(device_t self, int flags)
    324      1.39  jakllsch {
    325      1.39  jakllsch 	struct re_pci_softc *psc = device_private(self);
    326      1.39  jakllsch 	struct rtk_softc *sc = &psc->sc_rtk;
    327      1.39  jakllsch 	int rv;
    328      1.39  jakllsch 
    329      1.39  jakllsch 	if ((sc->sc_flags & RTK_ATTACHED) != 0)
    330      1.39  jakllsch 		/* re_stop() */
    331      1.39  jakllsch 		sc->ethercom.ec_if.if_stop(&sc->ethercom.ec_if, 0);
    332      1.39  jakllsch 
    333      1.39  jakllsch 	rv = re_detach(sc);
    334      1.39  jakllsch 	if (rv)
    335      1.39  jakllsch 		return rv;
    336      1.39  jakllsch 
    337      1.39  jakllsch 	if (psc->sc_ih != NULL) {
    338      1.39  jakllsch 		pci_intr_disestablish(psc->sc_pc, psc->sc_ih);
    339      1.39  jakllsch 		psc->sc_ih = NULL;
    340      1.39  jakllsch 	}
    341      1.39  jakllsch 
    342      1.45  jakllsch 	if (psc->sc_pihp != NULL) {
    343      1.45  jakllsch 		pci_intr_release(psc->sc_pc, psc->sc_pihp, 1);
    344      1.45  jakllsch 		psc->sc_pihp = NULL;
    345      1.45  jakllsch 	}
    346      1.45  jakllsch 
    347      1.39  jakllsch 	if (sc->rtk_bsize != 0) {
    348      1.39  jakllsch 		bus_space_unmap(sc->rtk_btag, sc->rtk_bhandle, sc->rtk_bsize);
    349      1.39  jakllsch 		sc->rtk_bsize = 0;
    350      1.39  jakllsch 	}
    351      1.42  christos 
    352      1.39  jakllsch 	return 0;
    353      1.39  jakllsch }
    354