diff options
| author | jdolecek <jdolecek@NetBSD.org> | 2005-04-03 10:56:59 +0000 |
|---|---|---|
| committer | jdolecek <jdolecek@NetBSD.org> | 2005-04-03 10:56:59 +0000 |
| commit | fc38d3f3acd4d6bdb869db3d2123ddfe64588f97 (patch) | |
| tree | bb236b4a27e0a229a84f589316e17bff3c9a0d35 /sys/dev | |
| parent | cc3c0f2c9cfdfcfe1089d1589bb22d932b645e92 (diff) | |
Make it possible for attachment to specify that the 16bit access shouldn't
be toggled in WE_MEM_{ENABLE|DISABLE} when receiving or transmitting packets.
Use this to switch the toggle off for MCA cards, since it causes NIC resets
there.
Fixes PR kern/26895 by Dave Barnes.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ic/we.c | 58 | ||||
| -rw-r--r-- | sys/dev/ic/wevar.h | 6 | ||||
| -rw-r--r-- | sys/dev/isa/if_we_isa.c | 18 | ||||
| -rw-r--r-- | sys/dev/mca/if_we_mca.c | 7 |
4 files changed, 46 insertions, 43 deletions
diff --git a/sys/dev/ic/we.c b/sys/dev/ic/we.c index bb62b8c319d..82a7b7c448d 100644 --- a/sys/dev/ic/we.c +++ b/sys/dev/ic/we.c @@ -1,4 +1,4 @@ -/* $NetBSD: we.c,v 1.6 2005/02/04 02:10:37 perry Exp $ */ +/* $NetBSD: we.c,v 1.7 2005/04/03 10:56:59 jdolecek Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -56,7 +56,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: we.c,v 1.6 2005/02/04 02:10:37 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: we.c,v 1.7 2005/04/03 10:56:59 jdolecek Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -115,27 +115,27 @@ static __inline void we_readmem(struct we_softc *, int, u_int8_t *, int); * Enable card RAM, and 16-bit access. */ #define WE_MEM_ENABLE(wsc) \ -do { \ - if ((wsc)->sc_16bitp) \ - bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \ - WE_LAAR, (wsc)->sc_laar_proto | WE_LAAR_M16EN); \ - bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \ - WE_MSR, wsc->sc_msr_proto | WE_MSR_MENB); \ - WE_DELAY((wsc)); \ -} while (0) +if (((wsc)->sc_flags & WE_16BIT_NOTOGGLE) == 0) { \ + if ((wsc)->sc_flags & WE_16BIT_ENABLE) \ + bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \ + WE_LAAR, (wsc)->sc_laar_proto | WE_LAAR_M16EN); \ + bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \ + WE_MSR, wsc->sc_msr_proto | WE_MSR_MENB); \ + WE_DELAY((wsc)); \ +} /* * Disable card RAM, and 16-bit access. */ #define WE_MEM_DISABLE(wsc) \ -do { \ - bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \ - WE_MSR, (wsc)->sc_msr_proto); \ - if ((wsc)->sc_16bitp) \ - bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \ - WE_LAAR, (wsc)->sc_laar_proto); \ - WE_DELAY((wsc)); \ -} while (0) +if (((wsc)->sc_flags & WE_16BIT_NOTOGGLE) == 0) { \ + bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \ + WE_MSR, (wsc)->sc_msr_proto); \ + if ((wsc)->sc_flags & WE_16BIT_ENABLE) \ + bus_space_write_1((wsc)->sc_asict, (wsc)->sc_asich, \ + WE_LAAR, (wsc)->sc_laar_proto); \ + WE_DELAY((wsc)); \ +} int we_config(self, wsc, typestr) @@ -151,11 +151,11 @@ we_config(self, wsc, typestr) * Allow user to override 16-bit mode. 8-bit takes precedence. */ if (self->dv_cfdata->cf_flags & DP8390_FORCE_16BIT_MODE) { - wsc->sc_16bitp = 1; + wsc->sc_flags |= WE_16BIT_ENABLE; forced_16bit = 1; } if (self->dv_cfdata->cf_flags & DP8390_FORCE_8BIT_MODE) - wsc->sc_16bitp = 0; + wsc->sc_flags &= ~WE_16BIT_ENABLE; /* Registers are linear. */ for (i = 0; i < 16; i++) @@ -164,7 +164,7 @@ we_config(self, wsc, typestr) /* Now we can use the NIC_{GET,PUT}() macros. */ printf("%s: %s Ethernet (%s-bit)\n", sc->sc_dev.dv_xname, - typestr, wsc->sc_16bitp ? "16" : "8"); + typestr, wsc->sc_flags & WE_16BIT_ENABLE ? "16" : "8"); /* Get station address from EEPROM. */ for (i = 0; i < ETHER_ADDR_LEN; i++) @@ -179,7 +179,7 @@ we_config(self, wsc, typestr) bus_space_read_1(wsc->sc_asict, wsc->sc_asich, WE_LAAR) & ~WE_LAAR_M16EN; bus_space_write_1(wsc->sc_asict, wsc->sc_asich, WE_LAAR, - wsc->sc_laar_proto | (wsc->sc_16bitp ? WE_LAAR_M16EN : 0)); + wsc->sc_laar_proto | (wsc->sc_flags & WE_16BIT_ENABLE ? WE_LAAR_M16EN : 0)); } else if ((wsc->sc_type & WE_SOFTCONFIG) || #ifdef TOSH_ETHER (wsc->sc_type == WE_TYPE_TOSHIBA1) || @@ -188,10 +188,10 @@ we_config(self, wsc, typestr) (forced_16bit) || (wsc->sc_type == WE_TYPE_WD8013EBT)) { wsc->sc_laar_proto = (wsc->sc_maddr >> 19) & WE_LAAR_ADDRHI; - if (wsc->sc_16bitp) + if (wsc->sc_flags & WE_16BIT_ENABLE) wsc->sc_laar_proto |= WE_LAAR_L16EN; bus_space_write_1(wsc->sc_asict, wsc->sc_asich, WE_LAAR, - wsc->sc_laar_proto | (wsc->sc_16bitp ? WE_LAAR_M16EN : 0)); + wsc->sc_laar_proto | (wsc->sc_flags & WE_16BIT_ENABLE ? WE_LAAR_M16EN : 0)); } /* @@ -240,7 +240,7 @@ we_config(self, wsc, typestr) * 16-bit cards also get word-wide DMA transfers. */ sc->dcr_reg = ED_DCR_FT1 | ED_DCR_LS | - (wsc->sc_16bitp ? ED_DCR_WTS : 0); + (wsc->sc_flags & WE_16BIT_ENABLE ? ED_DCR_WTS : 0); sc->test_mem = we_test_mem; sc->ring_copy = we_ring_copy; @@ -294,12 +294,12 @@ we_test_mem(sc) bus_size_t memsize = sc->mem_size; int i; - if (wsc->sc_16bitp) + if (wsc->sc_flags & WE_16BIT_ENABLE) bus_space_set_region_2(memt, memh, 0, 0, memsize >> 1); else bus_space_set_region_1(memt, memh, 0, 0, memsize); - if (wsc->sc_16bitp) { + if (wsc->sc_flags & WE_16BIT_ENABLE) { for (i = 0; i < memsize; i += 2) { if (bus_space_read_2(memt, memh, i) != 0) goto fail; @@ -338,7 +338,7 @@ we_readmem(wsc, from, to, len) if (len & 1) ++len; - if (wsc->sc_16bitp) + if (wsc->sc_flags & WE_16BIT_ENABLE) bus_space_read_region_stream_2(memt, memh, from, (u_int16_t *)to, len >> 1); else @@ -368,7 +368,7 @@ we_write_mbuf(sc, m, buf) /* * 8-bit boards are simple; no alignment tricks are necessary. */ - if (wsc->sc_16bitp == 0) { + if ((wsc->sc_flags & WE_16BIT_ENABLE) == 0) { for (; m != NULL; buf += m->m_len, m = m->m_next) bus_space_write_region_1(memt, memh, buf, mtod(m, u_int8_t *), m->m_len); diff --git a/sys/dev/ic/wevar.h b/sys/dev/ic/wevar.h index ab4aeb394f6..09459dc1986 100644 --- a/sys/dev/ic/wevar.h +++ b/sys/dev/ic/wevar.h @@ -1,4 +1,4 @@ -/* $NetBSD: wevar.h,v 1.2 2005/02/04 02:10:37 perry Exp $ */ +/* $NetBSD: wevar.h,v 1.3 2005/04/03 10:56:59 jdolecek Exp $ */ /* * National Semiconductor DS8390 NIC register definitions. @@ -21,7 +21,9 @@ struct we_softc { u_int8_t sc_type; /* our type */ - int sc_16bitp; /* are we 16 bit? */ + u_int8_t sc_flags; /* attachment flags */ +#define WE_16BIT_ENABLE 1 /* are we 16 bit? */ +#define WE_16BIT_NOTOGGLE 2 /* avoid explicit 16bit reset/enable? */ int sc_iobase; /* i/o address */ int sc_maddr; /* physical i/o mem addr */ diff --git a/sys/dev/isa/if_we_isa.c b/sys/dev/isa/if_we_isa.c index 30ea62c3242..e33cc0cd6dc 100644 --- a/sys/dev/isa/if_we_isa.c +++ b/sys/dev/isa/if_we_isa.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_we_isa.c,v 1.11 2005/02/27 00:27:17 perry Exp $ */ +/* $NetBSD: if_we_isa.c,v 1.12 2005/04/03 10:56:59 jdolecek Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -56,7 +56,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_we_isa.c,v 1.11 2005/02/27 00:27:17 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_we_isa.c,v 1.12 2005/04/03 10:56:59 jdolecek Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -99,7 +99,7 @@ CFATTACH_DECL(we_isa, sizeof(struct we_softc), extern struct cfdriver we_cd; static const char *we_params(bus_space_tag_t, bus_space_handle_t, - u_int8_t *, bus_size_t *, int *, int *); + u_int8_t *, bus_size_t *, u_int8_t *, int *); static const int we_584_irq[] = { 9, 3, 5, 7, 10, 11, 15, 4, @@ -331,7 +331,7 @@ we_isa_attach(parent, self, aux) } typestr = we_params(asict, asich, &wsc->sc_type, NULL, - &wsc->sc_16bitp, &sc->is790); + &wsc->sc_flags, &sc->is790); if (typestr == NULL) { printf("%s: where did the card go?\n", sc->sc_dev.dv_xname); return; @@ -390,12 +390,12 @@ we_isa_attach(parent, self, aux) } static const char * -we_params(asict, asich, typep, memsizep, is16bitp, is790p) +we_params(asict, asich, typep, memsizep, flagp, is790p) bus_space_tag_t asict; bus_space_handle_t asich; - u_int8_t *typep; + u_int8_t *typep, *flagp; bus_size_t *memsizep; - int *is16bitp, *is790p; + int *is790p; { const char *typestr; bus_size_t memsize; @@ -533,8 +533,8 @@ we_params(asict, asich, typep, memsizep, is16bitp, is790p) *typep = type; if (memsizep != NULL) *memsizep = memsize; - if (is16bitp != NULL) - *is16bitp = is16bit; + if (flagp != NULL && is16bit) + *flagp |= WE_16BIT_ENABLE; if (is790p != NULL) *is790p = is790; return (typestr); diff --git a/sys/dev/mca/if_we_mca.c b/sys/dev/mca/if_we_mca.c index ab46dede1d0..f1f850c7bd7 100644 --- a/sys/dev/mca/if_we_mca.c +++ b/sys/dev/mca/if_we_mca.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_we_mca.c,v 1.12 2005/02/04 02:10:43 perry Exp $ */ +/* $NetBSD: if_we_mca.c,v 1.13 2005/04/03 10:56:59 jdolecek Exp $ */ /*- * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_we_mca.c,v 1.12 2005/02/04 02:10:43 perry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_we_mca.c,v 1.13 2005/04/03 10:56:59 jdolecek Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -267,7 +267,8 @@ we_mca_attach(parent, self, aux) } wsc->sc_type = wep->we_type; - wsc->sc_16bitp = 1; /* all cards we support are 16bit */ + /* all cards we support are 16bit native (no need for reset) */ + wsc->sc_flags = WE_16BIT_ENABLE|WE_16BIT_NOTOGGLE; sc->is790 = 0; typestr = wep->we_typestr; |
