Home | History | Annotate | Line # | Download | only in pci
if_rtw_pci.c revision 1.20.12.1
      1  1.20.12.1      tls /* $NetBSD: if_rtw_pci.c,v 1.20.12.1 2012/11/20 03:02:17 tls Exp $ */
      2        1.1   dyoung 
      3        1.1   dyoung /*-
      4       1.19   dyoung  * Copyright (c) 2004, 2005, 2010 David Young.  All rights reserved.
      5       1.19   dyoung  *
      6       1.19   dyoung  * Adapted for the RTL8180 by David Young.
      7       1.19   dyoung  *
      8       1.19   dyoung  * Redistribution and use in source and binary forms, with or without
      9       1.19   dyoung  * modification, are permitted provided that the following conditions
     10       1.19   dyoung  * are met:
     11       1.19   dyoung  * 1. Redistributions of source code must retain the above copyright
     12       1.19   dyoung  *    notice, this list of conditions and the following disclaimer.
     13       1.19   dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.19   dyoung  *    notice, this list of conditions and the following disclaimer in the
     15       1.19   dyoung  *    documentation and/or other materials provided with the distribution.
     16       1.19   dyoung  *
     17       1.19   dyoung  * THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY
     18       1.19   dyoung  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     19       1.19   dyoung  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
     20       1.19   dyoung  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL David
     21       1.19   dyoung  * Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     22       1.19   dyoung  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
     23       1.19   dyoung  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24       1.19   dyoung  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     25       1.19   dyoung  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     26       1.19   dyoung  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27       1.19   dyoung  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
     28       1.19   dyoung  * OF SUCH DAMAGE.
     29       1.19   dyoung  */
     30       1.19   dyoung /*-
     31        1.1   dyoung  * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
     32        1.1   dyoung  * All rights reserved.
     33        1.1   dyoung  *
     34        1.1   dyoung  * This code is derived from software contributed to The NetBSD Foundation
     35        1.1   dyoung  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
     36        1.1   dyoung  * NASA Ames Research Center; Charles M. Hannum; and David Young.
     37        1.1   dyoung  *
     38        1.1   dyoung  * Redistribution and use in source and binary forms, with or without
     39        1.1   dyoung  * modification, are permitted provided that the following conditions
     40        1.1   dyoung  * are met:
     41        1.1   dyoung  * 1. Redistributions of source code must retain the above copyright
     42        1.1   dyoung  *    notice, this list of conditions and the following disclaimer.
     43        1.1   dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     44        1.1   dyoung  *    notice, this list of conditions and the following disclaimer in the
     45        1.1   dyoung  *    documentation and/or other materials provided with the distribution.
     46        1.1   dyoung  *
     47        1.1   dyoung  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     48        1.1   dyoung  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     49        1.1   dyoung  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     50        1.1   dyoung  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     51        1.1   dyoung  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     52        1.1   dyoung  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     53        1.1   dyoung  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     54        1.1   dyoung  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     55        1.1   dyoung  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     56        1.1   dyoung  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     57        1.1   dyoung  * POSSIBILITY OF SUCH DAMAGE.
     58        1.1   dyoung  */
     59        1.1   dyoung 
     60        1.1   dyoung /*
     61        1.1   dyoung  * PCI bus front-end for the Realtek RTL8180 802.11 MAC/BBP chip.
     62        1.1   dyoung  *
     63        1.1   dyoung  * Derived from the ADMtek ADM8211 PCI bus front-end.
     64        1.1   dyoung  *
     65        1.1   dyoung  * Derived from the ``Tulip'' PCI bus front-end.
     66        1.1   dyoung  */
     67        1.1   dyoung 
     68        1.1   dyoung #include <sys/cdefs.h>
     69  1.20.12.1      tls __KERNEL_RCSID(0, "$NetBSD: if_rtw_pci.c,v 1.20.12.1 2012/11/20 03:02:17 tls Exp $");
     70        1.1   dyoung 
     71        1.1   dyoung #include <sys/param.h>
     72        1.2    perry #include <sys/systm.h>
     73        1.2    perry #include <sys/mbuf.h>
     74        1.1   dyoung #include <sys/malloc.h>
     75        1.1   dyoung #include <sys/kernel.h>
     76        1.1   dyoung #include <sys/socket.h>
     77        1.1   dyoung #include <sys/ioctl.h>
     78        1.1   dyoung #include <sys/errno.h>
     79        1.1   dyoung #include <sys/device.h>
     80        1.1   dyoung 
     81        1.1   dyoung #include <machine/endian.h>
     82        1.2    perry 
     83        1.1   dyoung #include <net/if.h>
     84        1.1   dyoung #include <net/if_dl.h>
     85        1.1   dyoung #include <net/if_media.h>
     86        1.1   dyoung #include <net/if_ether.h>
     87        1.1   dyoung 
     88        1.3   dyoung #include <net80211/ieee80211_netbsd.h>
     89        1.1   dyoung #include <net80211/ieee80211_radiotap.h>
     90        1.1   dyoung #include <net80211/ieee80211_var.h>
     91        1.1   dyoung 
     92        1.8       ad #include <sys/bus.h>
     93        1.8       ad #include <sys/intr.h>
     94        1.1   dyoung 
     95        1.1   dyoung #include <dev/ic/rtwreg.h>
     96        1.1   dyoung #include <dev/ic/rtwvar.h>
     97        1.1   dyoung 
     98        1.1   dyoung #include <dev/pci/pcivar.h>
     99        1.1   dyoung #include <dev/pci/pcireg.h>
    100        1.1   dyoung #include <dev/pci/pcidevs.h>
    101        1.1   dyoung 
    102        1.1   dyoung /*
    103       1.18   dyoung  * PCI configuration space registers used by the RTL8180.
    104        1.1   dyoung  */
    105       1.20   dyoung #define RTW_PCI_IOBA PCI_BAR(0)	/* i/o mapped base */
    106       1.20   dyoung #define RTW_PCI_MMBA PCI_BAR(1)	/* memory mapped base */
    107        1.1   dyoung 
    108        1.1   dyoung struct rtw_pci_softc {
    109       1.19   dyoung 	struct rtw_softc	psc_rtw;
    110        1.1   dyoung 
    111       1.19   dyoung 	pcireg_t		psc_csr;
    112       1.19   dyoung 	void			*psc_ih;
    113       1.19   dyoung 	pci_chipset_tag_t	psc_pc;
    114       1.19   dyoung 	pci_intr_handle_t	psc_pih;
    115       1.19   dyoung 	pcitag_t		psc_tag;
    116        1.1   dyoung };
    117        1.1   dyoung 
    118        1.9   dyoung static void	rtw_pci_attach(device_t, device_t, void *);
    119       1.10   dyoung static int	rtw_pci_detach(device_t, int);
    120       1.19   dyoung #if 0
    121       1.19   dyoung static void	rtw_pci_funcregen(struct rtw_regs *, int);
    122       1.19   dyoung #endif
    123       1.19   dyoung static const struct rtw_pci_product *
    124       1.19   dyoung 		rtw_pci_lookup(const struct pci_attach_args *);
    125       1.19   dyoung static int	rtw_pci_match(device_t, cfdata_t, void *);
    126       1.19   dyoung static bool	rtw_pci_resume(device_t, const pmf_qual_t *);
    127       1.19   dyoung static int	rtw_pci_setup(struct rtw_pci_softc *);
    128       1.19   dyoung static bool	rtw_pci_suspend(device_t, const pmf_qual_t *);
    129       1.19   dyoung 
    130       1.19   dyoung CFATTACH_DECL3_NEW(rtw_pci, sizeof(struct rtw_pci_softc),
    131       1.19   dyoung     rtw_pci_match, rtw_pci_attach, rtw_pci_detach, NULL, NULL, NULL,
    132       1.19   dyoung     DVF_DETACH_SHUTDOWN);
    133       1.18   dyoung 
    134        1.1   dyoung static const struct rtw_pci_product {
    135       1.19   dyoung 	u_int32_t	rpp_vendor;	/* PCI vendor ID */
    136       1.19   dyoung 	u_int32_t	rpp_product;	/* PCI product ID */
    137       1.19   dyoung 	const char	*rpp_product_name;
    138        1.1   dyoung } rtw_pci_products[] = {
    139  1.20.12.1      tls 	{ PCI_VENDOR_REALTEK,		PCI_PRODUCT_REALTEK_RT8180,
    140  1.20.12.1      tls 	  "Realtek RTL8180 802.11 MAC/BBP" },
    141  1.20.12.1      tls #ifdef RTW_DEBUG
    142  1.20.12.1      tls #if 0   /* These came from openbsd, netbsd doesn't have the definitions. */
    143  1.20.12.1      tls 	{ PCI_VENDOR_REALTEK,		PCI_PRODUCT_REALTEK_RT8185,
    144  1.20.12.1      tls 	  "Realtek RTL8185 802.11 MAC/BBP" },
    145  1.20.12.1      tls 	{ PCI_VENDOR_BELKIN2,		PCI_PRODUCT_BELKIN2_F5D7010,
    146  1.20.12.1      tls 	  "Belkin F5D7010" },
    147  1.20.12.1      tls #endif
    148  1.20.12.1      tls #endif
    149  1.20.12.1      tls 	{ PCI_VENDOR_BELKIN,		PCI_PRODUCT_BELKIN_F5D6001,
    150  1.20.12.1      tls 	  "Belkin F5D6001" },
    151  1.20.12.1      tls 	{ PCI_VENDOR_BELKIN,		PCI_PRODUCT_BELKIN_F5D6020V3,
    152  1.20.12.1      tls 	  "Belkin F5D6020v3" },
    153  1.20.12.1      tls 	{PCI_VENDOR_DLINK,		PCI_PRODUCT_DLINK_DWL610,
    154  1.20.12.1      tls 	  "DWL-610 D-Link Air 802.11b (RTL8180 MAC/BBP)"},
    155  1.20.12.1      tls 	{ 0,				0,				NULL },
    156        1.1   dyoung };
    157        1.1   dyoung 
    158        1.1   dyoung static const struct rtw_pci_product *
    159        1.1   dyoung rtw_pci_lookup(const struct pci_attach_args *pa)
    160        1.1   dyoung {
    161       1.19   dyoung 	const struct rtw_pci_product *rpp;
    162        1.1   dyoung 
    163       1.19   dyoung 	for (rpp = rtw_pci_products; rpp->rpp_product_name != NULL; rpp++) {
    164       1.19   dyoung 		if (PCI_VENDOR(pa->pa_id) == rpp->rpp_vendor &&
    165       1.19   dyoung 		    PCI_PRODUCT(pa->pa_id) == rpp->rpp_product)
    166       1.19   dyoung 			return rpp;
    167        1.1   dyoung 	}
    168       1.19   dyoung 	return NULL;
    169        1.1   dyoung }
    170        1.1   dyoung 
    171        1.1   dyoung static int
    172       1.13   cegger rtw_pci_match(device_t parent, cfdata_t match, void *aux)
    173        1.1   dyoung {
    174        1.1   dyoung 	struct pci_attach_args *pa = aux;
    175        1.1   dyoung 
    176        1.1   dyoung 	if (rtw_pci_lookup(pa) != NULL)
    177       1.19   dyoung 		return 1;
    178        1.1   dyoung 
    179       1.19   dyoung 	return 0;
    180        1.1   dyoung }
    181        1.1   dyoung 
    182        1.1   dyoung static void
    183        1.9   dyoung rtw_pci_attach(device_t parent, device_t self, void *aux)
    184        1.1   dyoung {
    185        1.9   dyoung 	struct rtw_pci_softc *psc = device_private(self);
    186        1.1   dyoung 	struct rtw_softc *sc = &psc->psc_rtw;
    187        1.1   dyoung 	struct rtw_regs *regs = &sc->sc_regs;
    188        1.1   dyoung 	struct pci_attach_args *pa = aux;
    189        1.1   dyoung 	const char *intrstr = NULL;
    190       1.19   dyoung 	const struct rtw_pci_product *rpp;
    191        1.1   dyoung 
    192        1.9   dyoung 	sc->sc_dev = self;
    193       1.19   dyoung 	sc->sc_dmat = pa->pa_dmat;
    194        1.1   dyoung 	psc->psc_pc = pa->pa_pc;
    195       1.19   dyoung 	psc->psc_tag = pa->pa_tag;
    196        1.1   dyoung 
    197       1.19   dyoung 	rpp = rtw_pci_lookup(pa);
    198       1.19   dyoung 	if (rpp == NULL) {
    199        1.1   dyoung 		printf("\n");
    200        1.1   dyoung 		panic("rtw_pci_attach: impossible");
    201        1.1   dyoung 	}
    202        1.1   dyoung 
    203        1.1   dyoung 	/*
    204        1.1   dyoung 	 * Get revision info, and set some chip-specific variables.
    205        1.1   dyoung 	 */
    206        1.1   dyoung 	sc->sc_rev = PCI_REVISION(pa->pa_class);
    207       1.19   dyoung 	aprint_normal(": %s, revision %d.%d signature %08x\n",
    208       1.19   dyoung 	    rpp->rpp_product_name,
    209       1.19   dyoung 	    (sc->sc_rev >> 4) & 0xf, sc->sc_rev & 0xf,
    210       1.19   dyoung 	    pci_conf_read(psc->psc_pc, psc->psc_tag, 0x80));
    211        1.1   dyoung 
    212        1.1   dyoung 	/*
    213        1.1   dyoung 	 * Map the device.
    214        1.1   dyoung 	 */
    215       1.19   dyoung 	psc->psc_csr = PCI_COMMAND_MASTER_ENABLE |
    216       1.19   dyoung 	              PCI_COMMAND_PARITY_ENABLE |
    217       1.19   dyoung 		      PCI_COMMAND_SERR_ENABLE;
    218       1.19   dyoung 	if (pci_mapreg_map(pa, RTW_PCI_MMBA, PCI_MAPREG_TYPE_MEM, 0,
    219       1.19   dyoung 	    &regs->r_bt, &regs->r_bh, NULL, &regs->r_sz) == 0) {
    220       1.19   dyoung 		RTW_DPRINTF(RTW_DEBUG_ATTACH,
    221       1.19   dyoung 		    ("%s: %s mapped %" PRIuMAX " bytes mem space\n",
    222       1.19   dyoung 		     device_xname(self), __func__, (uintmax_t)regs->r_sz));
    223       1.19   dyoung 		psc->psc_csr |= PCI_COMMAND_MEM_ENABLE;
    224       1.19   dyoung 	} else if (pci_mapreg_map(pa, RTW_PCI_IOBA, PCI_MAPREG_TYPE_IO, 0,
    225       1.19   dyoung 	    &regs->r_bt, &regs->r_bh, NULL, &regs->r_sz) == 0) {
    226       1.19   dyoung 		RTW_DPRINTF(RTW_DEBUG_ATTACH,
    227       1.19   dyoung 		    ("%s: %s mapped %" PRIuMAX " bytes I/O space\n",
    228       1.19   dyoung 		     device_xname(self), __func__, (uintmax_t)regs->r_sz));
    229       1.19   dyoung 		psc->psc_csr |= PCI_COMMAND_IO_ENABLE;
    230       1.19   dyoung 	} else {
    231       1.10   dyoung 		aprint_error_dev(self, "unable to map device registers\n");
    232        1.1   dyoung 		return;
    233        1.1   dyoung 	}
    234        1.1   dyoung 
    235        1.1   dyoung 	/*
    236       1.19   dyoung 	 * Bring the chip out of powersave mode and initialize the
    237       1.19   dyoung 	 * configuration registers.
    238        1.1   dyoung 	 */
    239       1.19   dyoung 	if (rtw_pci_setup(psc) != 0)
    240       1.19   dyoung 		return;
    241        1.1   dyoung 
    242        1.1   dyoung 	/*
    243        1.1   dyoung 	 * Map and establish our interrupt.
    244        1.1   dyoung 	 */
    245       1.19   dyoung 	if (pci_intr_map(pa, &psc->psc_pih)) {
    246        1.9   dyoung 		aprint_error_dev(self, "unable to map interrupt\n");
    247        1.1   dyoung 		return;
    248        1.1   dyoung 	}
    249       1.19   dyoung 	intrstr = pci_intr_string(psc->psc_pc, psc->psc_pih);
    250       1.19   dyoung 	psc->psc_ih = pci_intr_establish(psc->psc_pc, psc->psc_pih, IPL_NET,
    251        1.1   dyoung 	    rtw_intr, sc);
    252       1.19   dyoung 	if (psc->psc_ih == NULL) {
    253        1.9   dyoung 		aprint_error_dev(self, "unable to establish interrupt");
    254        1.1   dyoung 		if (intrstr != NULL)
    255        1.5   rpaulo 			aprint_error(" at %s", intrstr);
    256        1.9   dyoung 		aprint_error("\n");
    257        1.1   dyoung 		return;
    258        1.1   dyoung 	}
    259        1.1   dyoung 
    260        1.9   dyoung 	aprint_normal_dev(self, "interrupting at %s\n", intrstr);
    261        1.1   dyoung 
    262        1.1   dyoung 	/*
    263        1.1   dyoung 	 * Finish off the attach.
    264        1.1   dyoung 	 */
    265        1.1   dyoung 	rtw_attach(sc);
    266       1.10   dyoung 
    267       1.19   dyoung 	if (pmf_device_register(self, rtw_pci_suspend, rtw_pci_resume)) {
    268       1.10   dyoung 		pmf_class_network_register(self, &sc->sc_if);
    269       1.10   dyoung 		/*
    270       1.10   dyoung 		 * Power down the socket.
    271       1.10   dyoung 		 */
    272       1.19   dyoung 		pmf_device_suspend(self, &sc->sc_qual);
    273       1.14  tsutsui 	} else
    274       1.19   dyoung 		aprint_error_dev(self, "couldn't establish power handler\n");
    275       1.10   dyoung }
    276       1.10   dyoung 
    277       1.10   dyoung static int
    278       1.10   dyoung rtw_pci_detach(device_t self, int flags)
    279       1.10   dyoung {
    280       1.10   dyoung 	struct rtw_pci_softc *psc = device_private(self);
    281       1.10   dyoung 	struct rtw_softc *sc = &psc->psc_rtw;
    282       1.10   dyoung 	struct rtw_regs *regs = &sc->sc_regs;
    283       1.10   dyoung 	int rc;
    284       1.10   dyoung 
    285       1.10   dyoung 	if ((rc = rtw_detach(sc)) != 0)
    286       1.10   dyoung 		return rc;
    287       1.19   dyoung 	if (psc->psc_ih != NULL)
    288       1.19   dyoung 		pci_intr_disestablish(psc->psc_pc, psc->psc_ih);
    289       1.10   dyoung 	bus_space_unmap(regs->r_bt, regs->r_bh, regs->r_sz);
    290       1.10   dyoung 
    291       1.10   dyoung 	return 0;
    292        1.1   dyoung }
    293       1.18   dyoung 
    294       1.18   dyoung static bool
    295       1.18   dyoung rtw_pci_resume(device_t self, const pmf_qual_t *qual)
    296       1.18   dyoung {
    297       1.18   dyoung 	struct rtw_pci_softc *psc = device_private(self);
    298       1.18   dyoung 	struct rtw_softc *sc = &psc->psc_rtw;
    299       1.18   dyoung 
    300       1.18   dyoung 	/* Establish the interrupt. */
    301       1.19   dyoung 	psc->psc_ih = pci_intr_establish(psc->psc_pc, psc->psc_pih, IPL_NET,
    302       1.19   dyoung 	    rtw_intr, sc);
    303       1.19   dyoung 	if (psc->psc_ih == NULL) {
    304       1.18   dyoung 		aprint_error_dev(sc->sc_dev, "unable to establish interrupt\n");
    305       1.18   dyoung 		return false;
    306       1.18   dyoung 	}
    307       1.18   dyoung 
    308       1.18   dyoung 	return rtw_resume(self, qual);
    309       1.18   dyoung }
    310       1.18   dyoung 
    311       1.18   dyoung static bool
    312       1.18   dyoung rtw_pci_suspend(device_t self, const pmf_qual_t *qual)
    313       1.18   dyoung {
    314       1.18   dyoung 	struct rtw_pci_softc *psc = device_private(self);
    315       1.18   dyoung 
    316       1.18   dyoung 	if (!rtw_suspend(self, qual))
    317       1.18   dyoung 		return false;
    318       1.18   dyoung 
    319       1.18   dyoung 	/* Unhook the interrupt handler. */
    320       1.19   dyoung 	pci_intr_disestablish(psc->psc_pc, psc->psc_ih);
    321       1.19   dyoung 	psc->psc_ih = NULL;
    322       1.18   dyoung 	return true;
    323       1.18   dyoung }
    324       1.19   dyoung 
    325       1.19   dyoung static int
    326       1.19   dyoung rtw_pci_setup(struct rtw_pci_softc *psc)
    327       1.19   dyoung {
    328       1.19   dyoung 	pcitag_t tag = psc->psc_tag;
    329       1.19   dyoung 	pcireg_t bhlc, csr, lattimer;
    330       1.19   dyoung 	device_t self = psc->psc_rtw.sc_dev;
    331       1.19   dyoung 	int rc;
    332       1.19   dyoung 
    333       1.19   dyoung 	/* power up chip */
    334       1.19   dyoung 	rc = pci_activate(psc->psc_pc, psc->psc_tag, self, NULL);
    335       1.19   dyoung 
    336       1.19   dyoung 	if (rc != 0 && rc != EOPNOTSUPP) {
    337       1.19   dyoung 		aprint_error_dev(self, "cannot activate (%d)\n", rc);
    338       1.19   dyoung 		return rc;
    339       1.19   dyoung 	}
    340       1.19   dyoung 
    341       1.19   dyoung 	/* I believe the datasheet tries to warn us that the RTL8180
    342       1.19   dyoung 	 * wants for 16 (0x10) to divide the latency timer.
    343       1.19   dyoung 	 */
    344       1.19   dyoung 	bhlc = pci_conf_read(psc->psc_pc, tag, PCI_BHLC_REG);
    345       1.19   dyoung 	lattimer = rounddown(PCI_LATTIMER(bhlc), 0x10);
    346       1.19   dyoung 	if (PCI_LATTIMER(bhlc) != lattimer) {
    347       1.19   dyoung 		bhlc &= ~(PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT);
    348       1.19   dyoung 		bhlc |= (lattimer << PCI_LATTIMER_SHIFT);
    349       1.19   dyoung 		pci_conf_write(psc->psc_pc, tag, PCI_BHLC_REG, bhlc);
    350       1.19   dyoung 	}
    351       1.19   dyoung 
    352       1.19   dyoung 	/* Enable the appropriate bits in the PCI CSR. */
    353       1.19   dyoung 	csr = pci_conf_read(psc->psc_pc, tag, PCI_COMMAND_STATUS_REG);
    354       1.19   dyoung 	csr &= ~(PCI_COMMAND_IO_ENABLE|PCI_COMMAND_MEM_ENABLE);
    355       1.19   dyoung 	csr |= psc->psc_csr;
    356       1.19   dyoung 	pci_conf_write(psc->psc_pc, tag, PCI_COMMAND_STATUS_REG, csr);
    357       1.19   dyoung 
    358       1.19   dyoung 	return 0;
    359       1.19   dyoung }
    360