From Onno van der Linden:

Reorganise the driver some what.
Rename tr_reset() to the more appropriate tr_stop().
Create a common tropic reset routine and use it in the frontends.
Move the code in tr_config() which is only used in the card attachment
routines into a new tr_attach() function.
Take adapter off the ring through tr_shutdown() in a shutdown hook.
This simplifies the bus-specific frontend.
This commit is contained in:
bad 1999-04-29 15:47:02 +00:00
parent b74f892f6d
commit 8fb6c6124b
4 changed files with 218 additions and 212 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: tropic.c,v 1.2 1999/03/22 23:01:37 bad Exp $ */
/* $NetBSD: tropic.c,v 1.3 1999/04/29 15:47:02 bad Exp $ */
/*
* Ported to NetBSD by Onno van der Linden
@ -80,6 +80,8 @@
#include <dev/ic/tropicreg.h>
#include <dev/ic/tropicvar.h>
static void tr_shutdown __P((void *));
void tr_rint __P((struct tr_softc *));
void tr_xint __P((struct tr_softc *));
void tr_oldxint __P((struct tr_softc *));
@ -127,25 +129,25 @@ tropic_mediachange(sc)
case IFM_TOK_STP16:
case IFM_TOK_UTP16:
if ((sc->sc_init_status & RSP_16) == 0) {
tr_reset(sc);
if (tr_setspeed(sc, 16) == 0)
sc->sc_init_status |= RSP_16;
else
tr_stop(sc);
if (tr_setspeed(sc, 16))
return EINVAL;
if (tr_reset(sc))
return EINVAL;
if (tr_config(sc))
return EINVAL;
tr_init(sc);
tr_sleep(sc);
}
break;
case IFM_TOK_STP4:
case IFM_TOK_UTP4:
if ((sc->sc_init_status & RSP_16) != 0) {
tr_reset(sc);
if (tr_setspeed(sc, 4) == 0)
sc->sc_init_status &= ~RSP_16;
else
tr_stop(sc);
if (tr_setspeed(sc, 4))
return EINVAL;
if (tr_reset(sc))
return EINVAL;
if (tr_config(sc))
return EINVAL;
tr_init(sc);
tr_sleep(sc);
}
break;
}
@ -168,42 +170,76 @@ tropic_mediastatus(sc, ifmr)
int
tr_config(sc)
struct tr_softc *sc;
{
if (sc->sc_init_status & FAST_PATH_TRANSMIT) {
int i;
for (i=0; i < SRB_CFP_CMDSIZE; i++)
SRB_OUTB(sc, sc->sc_srb, i, 0);
SRB_OUTB(sc, sc->sc_srb, SRB_CMD, DIR_CONFIG_FAST_PATH_RAM);
SRB_OUTW(sc, sc->sc_srb, SRB_CFP_RAMSIZE,
(16 + (sc->sc_nbuf * FP_BUF_LEN) / 8));
SRB_OUTW(sc, sc->sc_srb, SRB_CFP_BUFSIZE, FP_BUF_LEN);
/* tell adapter: command in SRB */
ACA_SETB(sc, ACA_ISRA_o, CMD_IN_SRB);
for (i = 0; i < 30000; i++) {
if (ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT)
break;
delay(100);
}
if ((ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT) == 0) {
printf("No response for fast path cfg\n");
return 1;
}
ACA_RSTB(sc, ACA_ISRP_o, ~(SRB_RESP_INT));
if ((SRB_INB(sc, sc->sc_srb, SRB_RETCODE) != 0)) {
printf("cfg fast path returned: %02x\n",
SRB_INB(sc, sc->sc_srb, SRB_RETCODE));
return 1;
}
sc->sc_txca = SRB_INW(sc, sc->sc_srb, SRB_CFPRESP_FPXMIT);
sc->sc_srb = SRB_INW(sc, sc->sc_srb, SRB_CFPRESP_SRBADDR);
}
else {
if (sc->sc_init_status & RSP_16)
sc->sc_maxmtu = sc->sc_dhb16maxsz;
else
sc->sc_maxmtu = sc->sc_dhb4maxsz;
/*
* XXX Not completely true because Fast Path Transmit has 514 byte buffers
* XXX and TR_MAX_LINK_HDR is only correct when source-routing is used.
* XXX depending on wether source routing is used change the calculation
* XXX use IFM_TOK_SRCRT (IFF_LINK0)
* XXX recompute sc_minbuf !!
*/
sc->sc_maxmtu -= TR_MAX_LINK_HDR;
}
return 0;
}
int
tr_attach(sc)
struct tr_softc *sc;
{
int nmedia, *mediaptr, *defmediaptr;
int i, temp;
u_int8_t myaddr[ISO88025_ADDR_LEN];
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
for (i = 0, temp = 0; i < ISO88025_ADDR_LEN; i++, temp += 4) {
myaddr[i] = (MM_INB(sc, (TR_MAC_OFFSET + temp)) & 0xf) << 4;
myaddr[i] |= MM_INB(sc, (TR_MAC_OFFSET + temp + 2)) & 0xf;
}
sc->sc_init_status = SRB_INB(sc, sc->sc_srb, SRB_INIT_STATUS);
/*
* MAX_MACFRAME_SIZE = DHB_SIZE - 6
* IPMTU = MAX_MACFRAME_SIZE - (14 + 18 + 8)
* (14 = header, 18 = sroute, 8 = llcsnap)
*/
/* XXX should depend on sc_resvdmem. */
if (MM_INB(sc, TR_RAM_OFFSET) == 0xB && sc->sc_memsize == 65536)
for (i = 0; i < 512; i++)
SR_OUTB(sc, 0xfe00 + i, 0);
if (sc->sc_init_status & FAST_PATH_TRANSMIT) {
bus_size_t cfg_resp;
bus_size_t srb;
int nbuf = 0;
srb = sc->sc_srb;
cfg_resp = sc->sc_srb;
for (i=0; i < SRB_CFP_CMDSIZE; i++)
SRB_OUTB(sc, sc->sc_srb, i, 0);
SRB_OUTB(sc, srb, SRB_CMD, DIR_CONFIG_FAST_PATH_RAM);
switch (sc->sc_memsize) {
case 65536:
@ -225,41 +261,18 @@ tr_config(sc)
sc->sc_minbuf = ((sc->sc_maxmtu + 511) / 512) + 1;
sc->sc_nbuf = nbuf;
sc->sc_xmit_head = sc->sc_xmit_tail = 0;
SRB_OUTW(sc, srb, SRB_CFP_RAMSIZE,
(16 + (nbuf * FP_BUF_LEN) / 8));
SRB_OUTW(sc, srb, SRB_CFP_BUFSIZE, FP_BUF_LEN);
/* tell adapter: command in SRB */
ACA_SETB(sc, ACA_ISRA_o, CMD_IN_SRB);
for (i = 0; i < 30000; i++) {
if (ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT)
break;
delay(100);
}
if ((ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT) == 0) {
printf("No response for fast path cfg\n");
return 1;
}
ACA_RSTB(sc, ACA_ISRP_o, ~(SRB_RESP_INT));
if ((SRB_INB(sc, cfg_resp, SRB_RETCODE) != 0)) {
printf("cfg fast path returned: %02x\n",
SRB_INB(sc, cfg_resp, SRB_RETCODE));
return 1;
}
sc->sc_txca = SRB_INW(sc, cfg_resp, SRB_CFPRESP_FPXMIT);
sc->sc_srb = SRB_INW(sc, cfg_resp, SRB_CFPRESP_SRBADDR);
/*
* Create circular queues caching the buffer pointers ?
*/
}
else {
/*
* MAX_MACFRAME_SIZE = DHB_SIZE - 6
* IPMTU = MAX_MACFRAME_SIZE - (14 + 18 + 8)
* (14 = header, 18 = sroute, 8 = llcsnap)
*/
switch (sc->sc_memsize) {
case 8192:
sc->sc_dhb4maxsz = 2048;
@ -315,20 +328,11 @@ tr_config(sc)
sc->sc_dhb16maxsz = 8192;
break;
}
if (sc->sc_init_status & RSP_16)
sc->sc_maxmtu = sc->sc_dhb16maxsz;
else
sc->sc_maxmtu = sc->sc_dhb4maxsz;
/*
* XXX Not completely true because Fast Path Transmit has 514 byte buffers
* XXX and TR_MAX_LINK_HDR is only correct when source-routing is used.
* XXX depending on wether source routing is used change the calculation
* XXX use IFM_TOK_SRCRT (IFF_LINK0)
* XXX recompute sc_minbuf !!
*/
sc->sc_maxmtu -= TR_MAX_LINK_HDR;
}
if (tr_config(sc))
return 1;
/*
* init network-visible interface
*/
@ -419,7 +423,14 @@ tr_config(sc)
ifmedia_add(&sc->sc_media, IFM_TOKEN | IFM_MANUAL, 0, NULL);
ifmedia_set(&sc->sc_media, IFM_TOKEN | IFM_MANUAL);
}
if_attach(ifp);
for (i = 0, temp = 0; i < ISO88025_ADDR_LEN; i++, temp += 4) {
myaddr[i] = (MM_INB(sc, (TR_MAC_OFFSET + temp)) & 0xf) << 4;
myaddr[i] |= MM_INB(sc, (TR_MAC_OFFSET + temp + 2)) & 0xf;
}
token_ifattach(ifp, myaddr);
printf("\n%s: address %s ring speed %d Mbps\n",
@ -429,6 +440,11 @@ tr_config(sc)
#if NBPFILTER > 0
bpfattach(&ifp->if_bpf, ifp, DLT_IEEE802, sizeof(struct token_header));
#endif
/*
* XXX rnd stuff
*/
shutdownhook_establish(tr_shutdown, sc);
return 0;
}
@ -477,26 +493,85 @@ tr_mediastatus(ifp, ifmr)
(*sc->sc_mediastatus)(sc, ifmr);
}
int
tr_reset(sc)
struct tr_softc *sc;
{
int i;
tr_stop(sc);
/*
* Reset the card.
*/
/* latch on an unconditional adapter reset */
bus_space_write_1(sc->sc_piot, sc->sc_pioh, TR_RESET, 0);
delay(50000); /* delay 50ms */
/*
* XXX set paging if we have the right type of card
*/
/* turn off adapter reset */
bus_space_write_1(sc->sc_piot, sc->sc_pioh, TR_RELEASE, 0);
/* Enable interrupts. */
ACA_SETB(sc, ACA_ISRP_e, INT_ENABLE);
/* Wait for an answer from the adapter. */
for (i = 0; i < 35000; i++) {
if (ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT)
break;
delay(100);
}
if ((ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT) == 0) {
printf("No response from adapter after reset\n");
return 1;
}
ACA_RSTB(sc, ACA_ISRP_o, ~(SRB_RESP_INT));
ACA_OUTB(sc, ACA_RRR_e, (sc->sc_maddr >> 12));
sc->sc_srb = ACA_RDW(sc, ACA_WRBR);
if (SRB_INB(sc, sc->sc_srb, SRB_CMD) != 0x80) {
printf("Initialization incomplete, status: %02x\n",
SRB_INB(sc, sc->sc_srb, SRB_CMD));
return 1;
}
if (SRB_INB(sc, sc->sc_srb, SRB_INIT_BUC) != 0) {
printf("Bring Up Code %02x\n",
SRB_INB(sc, sc->sc_srb, SRB_INIT_BUC));
return 1;
}
sc->sc_init_status = SRB_INB(sc, sc->sc_srb, SRB_INIT_STATUS);
sc->sc_xmit_head = sc->sc_xmit_tail = 0;
/* XXX should depend on sc_resvdmem. */
if (MM_INB(sc, TR_RAM_OFFSET) == 0xB && sc->sc_memsize == 65536)
for (i = 0; i < 512; i++)
SR_OUTB(sc, 0xfe00 + i, 0);
return 0;
}
/*
* tr_reset - reset interface (issue a DIR CLOSE ADAPTER command)
* tr_stop - stop interface (issue a DIR CLOSE ADAPTER command)
*/
void
tr_reset(sc)
tr_stop(sc)
struct tr_softc *sc;
{
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
if ((ifp->if_flags & IFF_RUNNING) != 0) {
bus_size_t srb;
srb = sc->sc_srb;
/*
* XXX transmitter cannot be used from now on
* transmitter cannot be used from now on
*/
ifp->if_flags |= IFF_OACTIVE;
/* Close command. */
SRB_OUTB(sc, srb, SRB_CMD, DIR_CLOSE);
SRB_OUTB(sc, sc->sc_srb, SRB_CMD, DIR_CLOSE);
/* Tell adapter: command in SRB. */
ACA_SETB(sc, ACA_ISRA_o, CMD_IN_SRB);
@ -506,15 +581,24 @@ struct tr_softc *sc;
}
}
static void
tr_shutdown(arg)
void *arg;
{
struct tr_softc *sc = arg;
tr_stop(sc);
}
/*
* tr_init - initialize network interface, open adapter for packet
* reception and start any pending output
*/
void
tr_init(v)
void *v;
tr_init(arg)
void *arg;
{
struct tr_softc *sc = v;
struct tr_softc *sc = arg;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
bus_size_t open_srb;
int s, num_dhb;
@ -526,7 +610,7 @@ tr_init(v)
s = splimp();
ifp->if_flags &= ~IFF_OACTIVE;
sc->sc_xmit_head = sc->sc_xmit_tail = 0;
sc->sc_xmit_head = sc->sc_xmit_tail = 0; /* XXX tr_reset() */
open_srb = sc->sc_srb;
@ -789,7 +873,7 @@ tr_intr(arg)
#endif
sc->sc_xmit_correlator = 0;
untimeout(tr_timeout, sc);
wakeup(&sc->trsleep_event);
wakeup(&sc->tr_sleepevent);
}
else
tr_opensap(sc, LLC_SNAP_LSAP);
@ -818,12 +902,12 @@ tr_intr(arg)
ifp->if_flags &= ~IFF_UP;
ifp->if_flags &= ~IFF_OACTIVE;
untimeout(tr_timeout, sc);
wakeup(&sc->trsleep_event);
wakeup(&sc->tr_sleepevent);
}
break;
case DIR_SET_DEFAULT_RING_SPEED:
untimeout(tr_timeout, sc);
wakeup(&sc->trsleep_event);
wakeup(&sc->tr_sleepevent);
break;
case DLC_OPEN_SAP: /* Response to open sap cmd */
@ -836,7 +920,7 @@ tr_intr(arg)
printf("%s: Token Ring opened\n",
sc->sc_dev.dv_xname);
untimeout(tr_timeout, sc);
wakeup(&sc->trsleep_event);
wakeup(&sc->tr_sleepevent);
break;
/* XXX DLC_CLOSE_SAP not needed ? */
case DLC_CLOSE_SAP: /* Response to close sap cmd */
@ -1481,7 +1565,7 @@ caddr_t data;
* ie. adapter up but not running yet
*/
if ((ifp->if_flags & (IFF_RUNNING | IFF_UP)) == IFF_RUNNING) {
tr_reset(sc);
tr_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
}
else if ((ifp->if_flags & (IFF_RUNNING | IFF_UP)) == IFF_UP) {
@ -1622,7 +1706,7 @@ tr_sleep(sc)
struct tr_softc *sc;
{
timeout(tr_timeout, sc, hz*30);
sleep(&sc->trsleep_event, 1);
sleep(&sc->tr_sleepevent, 1);
}
void
@ -1641,11 +1725,11 @@ struct ifnet *ifp;
* tr_timeout - timeout routine if adapter does not open in 30 seconds
*/
void
tr_timeout(v)
void *v;
tr_timeout(arg)
void *arg;
{
struct tr_softc *sc = v;
struct tr_softc *sc = arg;
printf("Token Ring timeout\n");
wakeup(&sc->trsleep_event);
wakeup(&sc->tr_sleepevent);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: tropicvar.h,v 1.2 1999/03/22 23:01:36 bad Exp $ */
/* $NetBSD: tropicvar.h,v 1.3 1999/04/29 15:47:02 bad Exp $ */
/*
* Mach Operating System
@ -33,6 +33,16 @@
/*
* HISTORY
* $Log: tropicvar.h,v $
* Revision 1.3 1999/04/29 15:47:02 bad
* From Onno van der Linden:
* Reorganise the driver some what.
* Rename tr_reset() to the more appropriate tr_stop().
* Create a common tropic reset routine and use it in the frontends.
* Move the code in tr_config() which is only used in the card attachment
* routines into a new tr_attach() function.
* Take adapter off the ring through tr_shutdown() in a shutdown hook.
* This simplifies the bus-specific frontend.
*
* Revision 1.2 1999/03/22 23:01:36 bad
* Oops. RcsID police.
*
@ -48,11 +58,11 @@
*
*/
/* $Header: /cvsroot/src/sys/dev/ic/Attic/tropicvar.h,v 1.2 1999/03/22 23:01:36 bad Exp $ */
/* $Header: /cvsroot/src/sys/dev/ic/Attic/tropicvar.h,v 1.3 1999/04/29 15:47:02 bad Exp $ */
/* $ACIS:if_lanvar.h 12.0$ */
#if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS)
static char *rcsidif_lanvar = "$Header: /cvsroot/src/sys/dev/ic/Attic/tropicvar.h,v 1.2 1999/03/22 23:01:36 bad Exp $";
static char *rcsidif_lanvar = "$Header: /cvsroot/src/sys/dev/ic/Attic/tropicvar.h,v 1.3 1999/04/29 15:47:02 bad Exp $";
#endif
/*
@ -100,6 +110,7 @@ struct tr_softc {
bus_size_t sc_arb; /* offset of Adapter Request Block */
bus_size_t sc_srb; /* offset of System Request Block */
bus_size_t sc_asb; /* offset of Adapter Status Block */
u_int sc_maddr; /* mapped shared memory address */
u_int sc_memwinsz; /* mapped shared memory window size */
u_int sc_memsize; /* memory installed on adapter */
u_int sc_memreserved; /* reserved memory on adapter */
@ -107,15 +118,17 @@ struct tr_softc {
int sc_dhb16maxsz; /* max. dbh size at 16MBIT ring speed */
int sc_maxmtu; /* max. MTU supported by adapter */
unsigned char sc_init_status;
caddr_t trsleep_event; /* tr event signalled on successful */
caddr_t tr_sleepevent; /* tr event signalled on successful */
/* open of adapter */
unsigned short exsap_station; /* station assigned by open sap cmd */
};
int tr_config __P((struct tr_softc *));
int tr_attach __P((struct tr_softc *));
int tr_intr __P((void *));
void tr_init __P((void *));
int tr_ioctl __P((struct ifnet *, u_long, caddr_t));
void tr_reset __P((struct tr_softc *));
void tr_stop __P((struct tr_softc *));
int tr_reset __P((struct tr_softc *));
void tr_sleep __P((struct tr_softc *));
int tr_setspeed __P((struct tr_softc *, u_int8_t));

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tr_isa.c,v 1.2 1999/03/22 23:01:37 bad Exp $ */
/* $NetBSD: if_tr_isa.c,v 1.3 1999/04/29 15:47:03 bad Exp $ */
#undef TRISADEBUG
/*
@ -55,6 +55,7 @@
#include <dev/ic/tropicreg.h>
#include <dev/ic/tropicvar.h>
int tr_isa_probe __P((struct device *, struct cfdata *, void *));
int trtcm_isa_probe __P((struct device *, struct cfdata *, void *));
int tribm_isa_probe __P((struct device *, struct cfdata *, void *));
@ -72,7 +73,7 @@ void tr_isa_dumpaip __P((bus_space_tag_t, bus_space_handle_t));
/*
* List of manufacturer specific probe routines. Order is important.
*/
int (*tr_isa_probe_list[])(struct device *, struct cfdata*, void *) = {
int (*tr_isa_probe_list[])(struct device *, struct cfdata *, void *) = {
trtcm_isa_probe,
tribm_isa_probe,
0
@ -178,88 +179,36 @@ tr_isa_probe(parent, match, aux)
return 1;
}
/*
* tr_isa_attach - Make this interface available to the system-network-software.
*/
int trtcm_setspeed(struct tr_softc *, int);
void
tr_isa_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct tr_softc *sc = (void *) self;
bus_size_t init_resp;
struct isa_attach_args *ia = aux;
int i;
sc->sc_piot = ia->ia_iot;
sc->sc_memt = ia->ia_memt;
if (tr_isa_map_io(ia, &sc->sc_pioh, &sc->sc_mmioh))
panic("tr_isa_attach: IO space vanished\n");
if (bus_space_map(sc->sc_memt, ia->ia_maddr, ia->ia_msize, 0,
&sc->sc_sramh))
panic("tr_isa_attach: shared ram space vanished\n");
/* set ACA offset */
sc->sc_aca = TR_ACA_OFFSET;
sc->sc_memwinsz = ia->ia_msize;
sc->sc_maddr = ia->ia_maddr;
/*
* Determine total RAM on adapter and decide how much to use.
* XXX Since we don't use RAM paging, use sc_memwinsz for now.
*/
sc->sc_memsize = sc->sc_memwinsz;
sc->sc_memreserved = 0;
/*
* Reset the card.
*/
/* latch on an unconditional adapter reset */
bus_space_write_1(sc->sc_piot, sc->sc_pioh, TR_RESET, 0);
delay(50000); /* delay 50ms */
/*
* XXX set paging if we have the right type of card
*/
/* turn off adapter reset */
bus_space_write_1(sc->sc_piot, sc->sc_pioh, TR_RELEASE, 0);
/* Enable interrupts. */
ACA_SETB(sc, ACA_ISRP_e, INT_ENABLE);
/* Wait for an answer from the adapter. */
for (i = 0; i < 35000; i++) {
if (ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT)
break;
delay(100);
}
if ((ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT) == 0) {
printf("\nNo response from adapter after reset\n");
if (tr_reset(sc) != 0)
return;
}
ACA_RSTB(sc, ACA_ISRP_o, ~(SRB_RESP_INT));
/*
* XXX just set it ?
* XXXchb size mismatch between ia_maddr and MM_INB!
*/
#if 0
if (ia->ia_maddr != MM_INB(sc, TR_ACA_OFFSET))
MM_OUTB(sc, TR_ACA_OFFSET, (ia->ia_maddr >> 12));
#else
/* XXXchb must be set after reset */
ACA_OUTB(sc, ACA_RRR_e, (ia->ia_maddr >> 12));
#endif
if (bus_space_map(sc->sc_memt, ia->ia_maddr, ia->ia_msize, 0,
&sc->sc_sramh))
panic("tr_isa_attach: shared ram space vanished\n");
sc->sc_srb = ACA_RDW(sc, ACA_WRBR);
init_resp = sc->sc_srb;
if (SRB_INB(sc, init_resp, SRB_CMD) != 0x80) {
printf("\nInitialization incomplete, status: %02x",
SRB_INB(sc, init_resp, SRB_CMD));
return;
}
if (SRB_INB(sc, init_resp, SRB_INIT_BUC) != 0) {
printf("\nBring Up Code %02x",
SRB_INB(sc, init_resp, SRB_INIT_BUC));
return;
}
if (ia->ia_aux != NULL) {
sc->sc_mediastatus = trtcm_isa_mediastatus;
@ -270,8 +219,9 @@ tr_isa_attach(parent, self, aux)
sc->sc_mediachange = NULL;
}
if (tr_config(sc) != 0)
if (tr_attach(sc) != 0)
return;
/*
* XXX 3Com 619 can use LEVEL intr
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tr_isapnp.c,v 1.2 1999/03/22 23:01:37 bad Exp $ */
/* $NetBSD: if_tr_isapnp.c,v 1.3 1999/04/29 15:47:03 bad Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -114,9 +114,7 @@ tr_isapnp_attach(parent, self, aux)
{
struct tr_softc *sc = (void *)self;
struct isapnp_attach_args *ipa = aux;
int i;
int mmioidx, sramidx;
bus_size_t init_resp;
printf("\n");
@ -151,56 +149,17 @@ tr_isapnp_attach(parent, self, aux)
sc->sc_memreserved = 0;
sc->sc_aca = TR_ACA_OFFSET;
sc->sc_maddr = ipa->ipa_mem[sramidx].base;
/*
* Reset the card.
*/
/* Latch on an unconditional adapter reset. */
bus_space_write_1(sc->sc_piot, sc->sc_pioh, TR_RESET, 0);
delay(50000); /* delay 50ms */
/*
* XXX Set paging if we have the right type of card.
*/
/* Turn off adapter reset. */
bus_space_write_1(sc->sc_piot, sc->sc_pioh, TR_RELEASE, 0);
/* Enable interrupts. */
ACA_SETB(sc, ACA_ISRP_e, INT_ENABLE);
/* Wait for an answer from the adapter. */
for (i = 0; i < 35000; i++) {
if (ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT)
break;
delay(100);
}
if ((ACA_RDB(sc, ACA_ISRP_o) & SRB_RESP_INT) == 0) {
printf("No response from adapter after reset\n");
if (tr_reset(sc))
return;
}
ACA_RSTB(sc, ACA_ISRP_o, ~(SRB_RESP_INT));
/* XXXchb Must be set after reset. */
ACA_OUTB(sc, ACA_RRR_e, (ipa->ipa_mem[sramidx].base >> 12));
sc->sc_srb = ACA_RDW(sc, ACA_WRBR);
init_resp = sc->sc_srb;
if (SRB_INB(sc, init_resp, SRB_CMD) != 0x80) {
printf("\nInitialization incomplete, status: %02x\n",
SRB_INB(sc, init_resp, SRB_CMD));
return;
}
if (SRB_INB(sc, init_resp, SRB_INIT_BUC) != 0) {
printf("\nBring Up Code %02x\n",
SRB_INB(sc, init_resp, SRB_INIT_BUC));
return;
}
sc->sc_mediastatus = NULL;
sc->sc_mediachange = NULL;
if (tr_config(sc))
if (tr_attach(sc))
return;
sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,