2000-05-19 17:42:29 +04:00
|
|
|
/* $NetBSD: if_rtk_cardbus.c,v 1.3 2000/05/19 13:42:30 tsutsui Exp $ */
|
2000-05-15 05:55:12 +04:00
|
|
|
|
2000-04-10 11:42:55 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2000 Masanori Kanaoka
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2000-04-28 07:48:56 +04:00
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
2000-04-10 11:42:55 +04:00
|
|
|
*
|
2000-04-28 07:48:56 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2000-04-10 11:42:55 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2000-05-10 04:24:14 +04:00
|
|
|
* if_rtk_cardbus.c:
|
2000-04-10 11:42:55 +04:00
|
|
|
* Cardbus specific routines for RealTek 8139 ethernet adapter.
|
|
|
|
* Tested for
|
|
|
|
* - elecom-Laneed LD-10/100CBA (Accton MPX5030)
|
2000-05-15 05:55:12 +04:00
|
|
|
* - MELCO LPC3-TX-CB (RealTek 8139)
|
2000-04-10 11:42:55 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "opt_inet.h"
|
|
|
|
#include "opt_ns.h"
|
|
|
|
#include "bpfilter.h"
|
|
|
|
#include "rnd.h"
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/callout.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_arp.h>
|
|
|
|
#include <net/if_ether.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
#ifdef INET
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/if_inarp.h>
|
|
|
|
#endif
|
|
|
|
#ifdef NS
|
|
|
|
#include <netns/ns.h>
|
|
|
|
#include <netns/ns_if.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NBPFILTER > 0
|
|
|
|
#include <net/bpf.h>
|
|
|
|
#endif
|
|
|
|
#if NRND > 0
|
|
|
|
#include <sys/rnd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcidevs.h>
|
|
|
|
|
|
|
|
#include <dev/cardbus/cardbusvar.h>
|
|
|
|
#include <dev/cardbus/cardbusdevs.h>
|
|
|
|
|
|
|
|
#include <dev/mii/mii.h>
|
|
|
|
#include <dev/mii/miivar.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Default to using PIO access for this driver. On SMP systems,
|
|
|
|
* there appear to be problems with memory mapped mode: it looks like
|
|
|
|
* doing too many memory mapped access back to back in rapid succession
|
|
|
|
* can hang the bus. I'm inclined to blame this on crummy design/construction
|
|
|
|
* on the part of RealTek. Memory mapped mode does appear to work on
|
|
|
|
* uniprocessor systems though.
|
|
|
|
*/
|
2000-05-19 17:42:29 +04:00
|
|
|
#define RTK_USEIOSPACE
|
2000-04-10 11:42:55 +04:00
|
|
|
|
|
|
|
#include <dev/ic/rtl81x9reg.h>
|
2000-04-26 18:02:34 +04:00
|
|
|
#include <dev/ic/rtl81x9var.h>
|
2000-04-10 11:42:55 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Various supported device vendors/types and their names.
|
|
|
|
*/
|
2000-05-15 05:55:12 +04:00
|
|
|
static const struct rtk_type rtk_cardbus_devs[] = {
|
2000-04-10 11:42:55 +04:00
|
|
|
{ CARDBUS_VENDOR_ACCTON, CARDBUS_PRODUCT_ACCTON_MPX5030,
|
2000-05-15 05:55:12 +04:00
|
|
|
"Accton MPX 5030/5038 10/100BaseTX",
|
2000-05-19 17:42:29 +04:00
|
|
|
RTK_8139 },
|
2000-04-10 11:42:55 +04:00
|
|
|
{ CARDBUS_VENDOR_REALTEK, CARDBUS_PRODUCT_REALTEK_RT8138,
|
2000-05-19 17:42:29 +04:00
|
|
|
"RealTek 8138 10/100BaseTX", RTK_8139 },
|
2000-05-15 05:55:12 +04:00
|
|
|
{ 0, 0, NULL, 0 }
|
2000-04-10 11:42:55 +04:00
|
|
|
};
|
|
|
|
|
2000-05-19 17:42:29 +04:00
|
|
|
static int rtk_cardbus_match __P((struct device *, struct cfdata *, void *));
|
|
|
|
static void rtk_cardbus_attach __P((struct device *, struct device *, void *));
|
|
|
|
static int rtk_cardbus_detach __P((struct device *, int));
|
2000-04-10 11:42:55 +04:00
|
|
|
|
2000-05-15 05:55:12 +04:00
|
|
|
struct rtk_cardbus_softc {
|
|
|
|
struct rtk_softc sc_rtk; /* real rtk softc */
|
2000-04-10 11:42:55 +04:00
|
|
|
|
|
|
|
/* CardBus-specific goo. */
|
|
|
|
void *sc_ih;
|
|
|
|
cardbus_devfunc_t sc_ct;
|
|
|
|
cardbustag_t sc_tag;
|
|
|
|
int sc_csr;
|
|
|
|
int sc_cben;
|
|
|
|
int sc_bar_reg;
|
|
|
|
pcireg_t sc_bar_val;
|
|
|
|
bus_size_t sc_mapsize;
|
|
|
|
int sc_intrline;
|
|
|
|
};
|
|
|
|
|
2000-04-19 12:44:31 +04:00
|
|
|
struct cfattach rtk_cardbus_ca = {
|
2000-05-19 17:42:29 +04:00
|
|
|
sizeof(struct rtk_cardbus_softc),
|
|
|
|
rtk_cardbus_match, rtk_cardbus_attach,
|
|
|
|
rtk_cardbus_detach, rtk_activate,
|
2000-04-10 11:42:55 +04:00
|
|
|
};
|
|
|
|
|
2000-05-19 17:42:29 +04:00
|
|
|
const struct rtk_type *rtk_cardbus_lookup
|
|
|
|
__P((const struct cardbus_attach_args *));
|
|
|
|
|
|
|
|
void rtk_cardbus_setup __P((struct rtk_cardbus_softc *));
|
|
|
|
|
|
|
|
int rtk_cardbus_enable __P((struct rtk_softc *));
|
|
|
|
void rtk_cardbus_disable __P((struct rtk_softc *));
|
|
|
|
void rtk_cardbus_power __P((struct rtk_softc *, int));
|
2000-05-15 05:55:12 +04:00
|
|
|
const struct rtk_type *
|
|
|
|
rtk_cardbus_lookup(ca)
|
2000-04-10 11:42:55 +04:00
|
|
|
const struct cardbus_attach_args *ca;
|
|
|
|
{
|
2000-05-15 05:55:12 +04:00
|
|
|
const struct rtk_type *t;
|
2000-04-10 11:42:55 +04:00
|
|
|
|
2000-05-15 05:55:12 +04:00
|
|
|
for (t = rtk_cardbus_devs; t->rtk_name != NULL; t++){
|
|
|
|
if (CARDBUS_VENDOR(ca->ca_id) == t->rtk_vid &&
|
|
|
|
CARDBUS_PRODUCT(ca->ca_id) == t->rtk_did) {
|
2000-04-10 11:42:55 +04:00
|
|
|
return (t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2000-05-15 05:55:12 +04:00
|
|
|
rtk_cardbus_match(parent, match, aux)
|
2000-04-10 11:42:55 +04:00
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct cardbus_attach_args *ca = aux;
|
|
|
|
|
2000-05-15 05:55:12 +04:00
|
|
|
if (rtk_cardbus_lookup(ca) != NULL)
|
2000-04-10 11:42:55 +04:00
|
|
|
return (1);
|
2000-05-15 05:55:12 +04:00
|
|
|
|
2000-04-10 11:42:55 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2000-05-15 05:55:12 +04:00
|
|
|
rtk_cardbus_attach(parent, self, aux)
|
2000-04-10 11:42:55 +04:00
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
2000-05-15 05:55:12 +04:00
|
|
|
struct rtk_cardbus_softc *csc = (struct rtk_cardbus_softc *)self;
|
|
|
|
struct rtk_softc *sc = &csc->sc_rtk;
|
2000-04-10 11:42:55 +04:00
|
|
|
struct cardbus_attach_args *ca = aux;
|
|
|
|
cardbus_devfunc_t ct = ca->ca_ct;
|
2000-05-15 05:55:12 +04:00
|
|
|
const struct rtk_type *t;
|
2000-04-10 11:42:55 +04:00
|
|
|
bus_addr_t adr;
|
|
|
|
|
|
|
|
sc->sc_dmat = ca->ca_dmat;
|
|
|
|
csc->sc_ct = ct;
|
|
|
|
csc->sc_tag = ca->ca_tag;
|
|
|
|
csc->sc_intrline = ca->ca_intrline;
|
|
|
|
|
2000-05-15 05:55:12 +04:00
|
|
|
t = rtk_cardbus_lookup(ca);
|
2000-04-10 11:42:55 +04:00
|
|
|
if (t == NULL) {
|
|
|
|
printf("\n");
|
2000-05-15 05:55:12 +04:00
|
|
|
panic("rtk_cardbus_attach: impossible");
|
2000-04-10 11:42:55 +04:00
|
|
|
}
|
2000-05-15 05:55:12 +04:00
|
|
|
printf(": %s\n", t->rtk_name);
|
2000-05-19 17:42:29 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Power management hooks.
|
|
|
|
*/
|
|
|
|
sc->sc_enable = rtk_cardbus_enable;
|
|
|
|
sc->sc_disable = rtk_cardbus_disable;
|
|
|
|
sc->sc_power = rtk_cardbus_power;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Map control/status registers.
|
|
|
|
*/
|
|
|
|
csc->sc_csr = CARDBUS_COMMAND_MASTER_ENABLE;
|
|
|
|
#ifdef RTK_USEIOSPACE
|
|
|
|
if (Cardbus_mapreg_map(ct, RTK_PCI_LOIO, CARDBUS_MAPREG_TYPE_IO, 0,
|
|
|
|
&sc->rtk_btag, &sc->rtk_bhandle, &adr, &csc->sc_mapsize) == 0) {
|
|
|
|
#if rbus
|
|
|
|
#else
|
|
|
|
(*ct->ct_cf->cardbus_io_open)(cc, 0, adr, adr+csc->sc_mapsize);
|
|
|
|
#endif
|
|
|
|
csc->sc_cben = CARDBUS_IO_ENABLE;
|
|
|
|
csc->sc_csr |= CARDBUS_COMMAND_IO_ENABLE;
|
|
|
|
csc->sc_bar_reg = RTK_PCI_LOIO;
|
|
|
|
csc->sc_bar_val = adr | CARDBUS_MAPREG_TYPE_IO;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (Cardbus_mapreg_map(ct, RTK_PCI_LOMEM, CARDBUS_MAPREG_TYPE_MEM, 0,
|
|
|
|
&sc->rtk_btag, &sc->rtk_bhandle, &adr, &csc->sc_mapsize) == 0) {
|
|
|
|
#if rbus
|
|
|
|
#else
|
|
|
|
(*ct->ct_cf->cardbus_mem_open)(cc, 0, adr, adr+csc->sc_mapsize);
|
|
|
|
#endif
|
|
|
|
csc->sc_cben = CARDBUS_MEM_ENABLE;
|
|
|
|
csc->sc_csr |= CARDBUS_COMMAND_MEM_ENABLE;
|
|
|
|
csc->sc_bar_reg = RTK_PCI_LOMEM;
|
|
|
|
csc->sc_bar_val = adr | CARDBUS_MAPREG_TYPE_MEM;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
else {
|
|
|
|
printf("%s: unable to map deviceregisters\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Handle power management nonsense and initialize the
|
|
|
|
* configuration registers.
|
|
|
|
*/
|
|
|
|
rtk_cardbus_setup(csc);
|
|
|
|
sc->rtk_type = t->rtk_type;
|
|
|
|
|
|
|
|
rtk_attach(sc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Power down the socket.
|
|
|
|
*/
|
|
|
|
Cardbus_function_disable(csc->sc_ct);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rtk_cardbus_detach(self, flags)
|
|
|
|
struct device *self;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
struct rtk_cardbus_softc *csc = (void *) self;
|
|
|
|
struct rtk_softc *sc = &csc->sc_rtk;
|
|
|
|
struct cardbus_devfunc *ct = csc->sc_ct;
|
|
|
|
int rv;
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (ct == NULL)
|
|
|
|
panic("%s: data structure lacks\n", sc->sc_dev.dv_xname);
|
|
|
|
#endif
|
|
|
|
rv = rtk_detach(sc);
|
|
|
|
if (rv)
|
|
|
|
return (rv);
|
|
|
|
/*
|
|
|
|
* Unhook the interrut handler.
|
|
|
|
*/
|
|
|
|
if (csc->sc_ih != NULL)
|
|
|
|
cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, csc->sc_ih);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release bus space and close window.
|
|
|
|
*/
|
|
|
|
if (csc->sc_bar_reg != 0)
|
|
|
|
Cardbus_mapreg_unmap(ct, csc->sc_bar_reg,
|
|
|
|
sc->rtk_btag, sc->rtk_bhandle, csc->sc_mapsize);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rtk_cardbus_setup(csc)
|
|
|
|
struct rtk_cardbus_softc *csc;
|
|
|
|
{
|
|
|
|
struct rtk_softc *sc = &csc->sc_rtk;
|
|
|
|
cardbus_devfunc_t ct = csc->sc_ct;
|
|
|
|
cardbus_chipset_tag_t cc = ct->ct_cc;
|
|
|
|
cardbus_function_tag_t cf = ct->ct_cf;
|
|
|
|
pcireg_t reg,command;
|
|
|
|
int pmreg;
|
2000-04-10 11:42:55 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle power management nonsense.
|
|
|
|
*/
|
2000-05-01 19:08:50 +04:00
|
|
|
if (cardbus_get_capability(cc, cf, csc->sc_tag,
|
|
|
|
PCI_CAP_PWRMGMT, &pmreg, 0)) {
|
2000-04-24 19:25:00 +04:00
|
|
|
command = cardbus_conf_read(cc, cf, csc->sc_tag, pmreg + 4);
|
2000-05-19 17:42:29 +04:00
|
|
|
if (command & RTK_PSTATE_MASK) {
|
2000-04-24 19:25:00 +04:00
|
|
|
pcireg_t iobase, membase, irq;
|
2000-04-10 11:42:55 +04:00
|
|
|
|
|
|
|
/* Save important PCI config data. */
|
2000-05-01 19:08:50 +04:00
|
|
|
iobase = cardbus_conf_read(cc, cf, csc->sc_tag,
|
2000-05-19 17:42:29 +04:00
|
|
|
RTK_PCI_LOIO);
|
2000-05-01 19:08:50 +04:00
|
|
|
membase = cardbus_conf_read(cc, cf,csc->sc_tag,
|
2000-05-19 17:42:29 +04:00
|
|
|
RTK_PCI_LOMEM);
|
2000-05-01 19:08:50 +04:00
|
|
|
irq = cardbus_conf_read(cc, cf,csc->sc_tag,
|
|
|
|
PCI_PRODUCT_DELTA_8139);
|
2000-04-10 11:42:55 +04:00
|
|
|
|
|
|
|
/* Reset the power state. */
|
|
|
|
printf("%s: chip is is in D%d power mode "
|
2000-05-01 19:08:50 +04:00
|
|
|
"-- setting to D0\n", sc->sc_dev.dv_xname,
|
2000-05-19 17:42:29 +04:00
|
|
|
command & RTK_PSTATE_MASK);
|
2000-04-10 11:42:55 +04:00
|
|
|
command &= 0xFFFFFFFC;
|
2000-05-01 19:08:50 +04:00
|
|
|
cardbus_conf_write(cc, cf, csc->sc_tag,
|
|
|
|
pmreg + 4, command);
|
2000-04-10 11:42:55 +04:00
|
|
|
|
|
|
|
/* Restore PCI config data. */
|
2000-05-01 19:08:50 +04:00
|
|
|
cardbus_conf_write(cc, cf, csc->sc_tag,
|
2000-05-19 17:42:29 +04:00
|
|
|
RTK_PCI_LOIO, iobase);
|
2000-05-01 19:08:50 +04:00
|
|
|
cardbus_conf_write(cc, cf, csc->sc_tag,
|
2000-05-19 17:42:29 +04:00
|
|
|
RTK_PCI_LOMEM, membase);
|
2000-05-01 19:08:50 +04:00
|
|
|
cardbus_conf_write(cc, cf, csc->sc_tag,
|
|
|
|
PCI_PRODUCT_DELTA_8139, irq);
|
2000-04-10 11:42:55 +04:00
|
|
|
}
|
|
|
|
}
|
2000-05-19 17:42:29 +04:00
|
|
|
|
2000-04-10 11:42:55 +04:00
|
|
|
/* Make sure the right access type is on the CardBus bridge. */
|
2000-05-01 19:08:50 +04:00
|
|
|
(*ct->ct_cf->cardbus_ctrl)(cc, csc->sc_cben);
|
|
|
|
(*ct->ct_cf->cardbus_ctrl)(cc, CARDBUS_BM_ENABLE);
|
2000-04-10 11:42:55 +04:00
|
|
|
|
|
|
|
/* Program the BAR */
|
|
|
|
cardbus_conf_write(cc, cf, csc->sc_tag,
|
|
|
|
csc->sc_bar_reg, csc->sc_bar_val);
|
|
|
|
|
2000-05-01 19:08:50 +04:00
|
|
|
/* Enable the appropriate bits in the CARDBUS CSR. */
|
|
|
|
reg = cardbus_conf_read(cc, cf, csc->sc_tag,
|
|
|
|
CARDBUS_COMMAND_STATUS_REG);
|
|
|
|
reg &= ~(CARDBUS_COMMAND_IO_ENABLE|CARDBUS_COMMAND_MEM_ENABLE);
|
2000-04-10 11:42:55 +04:00
|
|
|
reg |= csc->sc_csr;
|
2000-05-01 19:08:50 +04:00
|
|
|
cardbus_conf_write(cc, cf, csc->sc_tag,
|
|
|
|
CARDBUS_COMMAND_STATUS_REG, reg);
|
2000-04-10 11:42:55 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure the latency timer is set to some reasonable
|
|
|
|
* value.
|
|
|
|
*/
|
2000-05-01 19:08:50 +04:00
|
|
|
reg = cardbus_conf_read(cc, cf, csc->sc_tag, CARDBUS_BHLC_REG);
|
|
|
|
if (CARDBUS_LATTIMER(reg) < 0x20) {
|
|
|
|
reg &= ~(CARDBUS_LATTIMER_MASK << CARDBUS_LATTIMER_SHIFT);
|
|
|
|
reg |= (0x20 << CARDBUS_LATTIMER_SHIFT);
|
|
|
|
cardbus_conf_write(cc, cf, csc->sc_tag, CARDBUS_BHLC_REG, reg);
|
2000-04-10 11:42:55 +04:00
|
|
|
}
|
2000-05-19 17:42:29 +04:00
|
|
|
}
|
2000-04-10 11:42:55 +04:00
|
|
|
|
2000-05-19 17:42:29 +04:00
|
|
|
int
|
|
|
|
rtk_cardbus_enable(sc)
|
|
|
|
struct rtk_softc *sc;
|
|
|
|
{
|
|
|
|
struct rtk_cardbus_softc *csc = (void *) sc;
|
|
|
|
cardbus_devfunc_t ct = csc->sc_ct;
|
|
|
|
cardbus_chipset_tag_t cc = ct->ct_cc;
|
|
|
|
cardbus_function_tag_t cf = ct->ct_cf;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Power on the socket.
|
|
|
|
*/
|
|
|
|
Cardbus_function_enable(ct);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up the PCI configuration registers.
|
|
|
|
*/
|
|
|
|
rtk_cardbus_setup(csc);
|
2000-04-10 11:42:55 +04:00
|
|
|
|
2000-05-19 17:42:29 +04:00
|
|
|
/*
|
|
|
|
* Map and establish the interrupt.
|
|
|
|
*/
|
|
|
|
csc->sc_ih = cardbus_intr_establish(cc, cf, csc->sc_intrline,
|
|
|
|
IPL_NET, rtk_intr, sc);
|
2000-04-10 11:42:55 +04:00
|
|
|
if (csc->sc_ih == NULL) {
|
|
|
|
printf("%s: unable to establish interrupt at %d\n",
|
2000-05-19 17:42:29 +04:00
|
|
|
sc->sc_dev.dv_xname, csc->sc_intrline);
|
|
|
|
Cardbus_function_disable(csc->sc_ct);
|
|
|
|
return (1);
|
2000-04-10 11:42:55 +04:00
|
|
|
}
|
2000-05-19 17:42:29 +04:00
|
|
|
printf("%s: interrupting at %d\n", sc->sc_dev.dv_xname,
|
|
|
|
csc->sc_intrline);
|
|
|
|
return (0);
|
|
|
|
}
|
2000-04-10 11:42:55 +04:00
|
|
|
|
2000-05-19 17:42:29 +04:00
|
|
|
void
|
|
|
|
rtk_cardbus_disable(sc)
|
|
|
|
struct rtk_softc *sc;
|
|
|
|
{
|
|
|
|
struct rtk_cardbus_softc *csc = (void *) sc;
|
|
|
|
cardbus_devfunc_t ct = csc->sc_ct;
|
|
|
|
cardbus_chipset_tag_t cc = ct->ct_cc;
|
|
|
|
cardbus_function_tag_t cf = ct->ct_cf;
|
|
|
|
|
|
|
|
/* Unhook the interrupt handler. */
|
|
|
|
cardbus_intr_disestablish(cc, cf, csc->sc_ih);
|
|
|
|
|
|
|
|
/* Power down the socket. */
|
|
|
|
Cardbus_function_disable(ct);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rtk_cardbus_power(sc, why)
|
|
|
|
struct rtk_softc *sc;
|
|
|
|
int why;
|
|
|
|
{
|
|
|
|
struct rtk_cardbus_softc *csc = (void *) sc;
|
|
|
|
|
|
|
|
if (why == PWR_RESUME) {
|
|
|
|
/*
|
|
|
|
* Give the PCI configuration registers a kick
|
|
|
|
* in the head.
|
|
|
|
*/
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (RTK_IS_ENABLED(sc) == 0)
|
|
|
|
panic("rtk_cardbus_power");
|
|
|
|
#endif
|
|
|
|
rtk_cardbus_setup(csc);
|
|
|
|
}
|
2000-04-10 11:42:55 +04:00
|
|
|
}
|