From 1f18ea8c9e03fa628f7da64080514aa3f9b0e708 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Fri, 13 Feb 2004 21:15:12 +0000 Subject: [PATCH] Sync if_ed with FreeBSD current --- sys/conf/files | 4 +- sys/conf/files.i386 | 4 +- sys/conf/options | 5 +- sys/dev/netif/Makefile | 4 +- sys/dev/netif/ed/Makefile | 11 + sys/dev/netif/ed/if_ed.c | 148 ++++++++----- sys/dev/netif/ed/if_ed98.h | 4 +- sys/dev/netif/ed/if_ed_cbus.c | 59 +++--- sys/dev/netif/ed/if_ed_isa.c | 14 +- sys/dev/netif/ed/if_ed_pccard.c | 353 ++++++++++++++++++++------------ sys/dev/netif/ed/if_ed_pci.c | 10 +- sys/dev/netif/ed/if_edreg.h | 4 +- sys/dev/netif/ed/if_edvar.h | 13 +- 13 files changed, 385 insertions(+), 248 deletions(-) create mode 100644 sys/dev/netif/ed/Makefile diff --git a/sys/conf/files b/sys/conf/files index 2435ecefa5..943c935e06 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,5 +1,5 @@ # $FreeBSD: src/sys/conf/files,v 1.340.2.137 2003/06/04 17:10:30 sam Exp $ -# $DragonFly: src/sys/conf/files,v 1.46 2004/02/10 07:55:46 joerg Exp $ +# $DragonFly: src/sys/conf/files,v 1.47 2004/02/13 21:15:12 joerg Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -325,6 +325,8 @@ dev/netif/cs/if_cs_pccard.c optional cs pccard dev/raid/dpt/dpt_scsi.c optional dpt dev/raid/dpt/dpt_eisa.c optional dpt eisa dev/raid/dpt/dpt_pci.c optional dpt pci +dev/netif/ed/if_ed.c optional ed +dev/netif/ed/if_ed_pccard.c optional ed pccard dev/netif/ed/if_ed_pci.c optional ed pci dev/netif/ep/if_ep.c optional ep dev/netif/ep/if_ep_isa.c optional ep isa diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index ef01574516..af9e721675 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -2,7 +2,7 @@ # files marked standard are always included. # # $FreeBSD: src/sys/conf/files.i386,v 1.307.2.38 2003/01/02 20:41:33 kan Exp $ -# $DragonFly: src/sys/conf/Attic/files.i386,v 1.10 2004/01/11 16:45:16 joerg Exp $ +# $DragonFly: src/sys/conf/Attic/files.i386,v 1.11 2004/02/13 21:15:12 joerg Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -104,9 +104,7 @@ acpi_wakecode.h optional acpica \ # dev/netif/cm/if_cm_isa.c optional cm isa -dev/netif/ed/if_ed.c optional ed dev/netif/ed/if_ed_isa.c optional ed isa -dev/netif/ed/if_ed_pccard.c optional ed card bus/eisa/eisaconf.c optional eisa dev/netif/em/if_em.c optional em dev/netif/em/if_em_hw.c optional em diff --git a/sys/conf/options b/sys/conf/options index 2e50f747d4..23e921365e 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -1,5 +1,5 @@ # $FreeBSD: src/sys/conf/options,v 1.191.2.53 2003/06/04 17:56:58 sam Exp $ -# $DragonFly: src/sys/conf/options,v 1.12 2004/01/07 18:13:19 joerg Exp $ +# $DragonFly: src/sys/conf/options,v 1.13 2004/02/13 21:15:12 joerg Exp $ # # On the handling of kernel options # @@ -517,3 +517,6 @@ UBSEC_NO_RNG opt_ubsec.h HIFN_DEBUG opt_hifn.h HIFN_RNDTEST opt_hifn.h HIFN_NO_RNG opt_hifn.h + +# ed driver +ED_NO_MIIBUS opt_ed.h diff --git a/sys/dev/netif/Makefile b/sys/dev/netif/Makefile index 4f517f059e..e478506183 100644 --- a/sys/dev/netif/Makefile +++ b/sys/dev/netif/Makefile @@ -1,7 +1,7 @@ -# $DragonFly: src/sys/dev/netif/Makefile,v 1.2 2003/12/07 19:23:37 dillon Exp $ +# $DragonFly: src/sys/dev/netif/Makefile,v 1.3 2004/02/13 21:15:12 joerg Exp $ # -SUBDIR= an ar aue bge cue dc em fwe fxp gx kue lge lnc mii_layer my \ +SUBDIR= an ar aue bge cue dc ed em fwe fxp gx kue lge lnc mii_layer my \ nge pcn ray rl sbni sbsh sf sis sk snc sr ste ti tl tx \ txp vr vx wb wi wx xe xl diff --git a/sys/dev/netif/ed/Makefile b/sys/dev/netif/ed/Makefile new file mode 100644 index 0000000000..e189681d44 --- /dev/null +++ b/sys/dev/netif/ed/Makefile @@ -0,0 +1,11 @@ +# $DragonFly: src/sys/dev/netif/ed/Makefile,v 1.1 2004/02/13 21:15:12 joerg Exp $ + +.PATH: ${.CURDIR}/../../dev/fxp +KMOD = if_ed +SRCS = if_ed.c if_ed_isa.c if_ed_pccard.c if_ed_pci.c \ + card_if.h device_if.h bus_if.h pci_if.h isa_if.h \ + miibus_if.h \ + opt_ed.h opt_bdg.h +KMODDEPS = miibus + +.include diff --git a/sys/dev/netif/ed/if_ed.c b/sys/dev/netif/ed/if_ed.c index c8f6544063..043ca3c07b 100644 --- a/sys/dev/netif/ed/if_ed.c +++ b/sys/dev/netif/ed/if_ed.c @@ -24,8 +24,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/ed/if_ed.c,v 1.173.2.14 2003/12/24 17:02:00 shiba Exp $ - * $DragonFly: src/sys/dev/netif/ed/if_ed.c,v 1.9 2004/02/08 06:47:35 hmp Exp $ + * $FreeBSD: src/sys/dev/ed/if_ed.c,v 1.224 2003/12/08 07:54:12 obrien Exp $ + * $DragonFly: src/sys/dev/netif/ed/if_ed.c,v 1.10 2004/02/13 21:15:12 joerg Exp $ */ /* @@ -38,6 +38,8 @@ * */ +#include "opt_ed.h" + #include #include #include @@ -60,25 +62,30 @@ #include #include -#include "../mii_layer/mii.h" -#include "../mii_layer/miivar.h" +#ifndef ED_NO_MIIBUS +#include +#include +#endif #include #include "opt_bdg.h" #include -#include #include #include "if_edreg.h" #include "if_edvar.h" +devclass_t ed_devclass; + static void ed_init (void *); static int ed_ioctl (struct ifnet *, u_long, caddr_t); static void ed_start (struct ifnet *); static void ed_reset (struct ifnet *); static void ed_watchdog (struct ifnet *); +#ifndef ED_NO_MIIBUS static void ed_tick (void *); +#endif static void ds_getmcaf (struct ed_softc *, u_int32_t *); @@ -101,7 +108,7 @@ static u_short ed_pio_write_mbufs (struct ed_softc *, struct mbuf *, static void ed_setrcr (struct ed_softc *); -static u_int32_t ds_crc (u_char *ep); +static uint32_t ds_mchash (const uint8_t *); DECLARE_DUMMY_MODULE(if_ed); @@ -569,7 +576,7 @@ ed_probe_WD80x3_generic(dev, flags, intr_vals) for (i = 0; i < memsize; ++i) { if (sc->mem_start[i]) { device_printf(dev, "failed to clear shared memory at %llx - check configuration\n", - kvtop(sc->mem_start + i)); + (long long)kvtop(sc->mem_start + i)); /* * Disable 16 bit access to shared memory @@ -903,8 +910,8 @@ ed_probe_3Com(dev, port_rid, flags) for (i = 0; i < memsize; ++i) if (sc->mem_start[i]) { - device_printf(dev, "failed to clear shared memory at %lx - check configuration\n", - kvtop(sc->mem_start + i)); + device_printf(dev, "failed to clear shared memory at %llx - check configuration\n", + (unsigned long long)kvtop(sc->mem_start + i)); return (ENXIO); } return (0); @@ -997,7 +1004,7 @@ ed_probe_SIC(dev, port_rid, flags) if (sc->mem_start[i]) { device_printf(dev, "failed to clear shared memory " "at %llx - check configuration\n", - kvtop(sc->mem_start + i)); + (long long)kvtop(sc->mem_start + i)); return (ENXIO); } @@ -1050,7 +1057,7 @@ ed_probe_Novell_generic(dev, flags) /* * I don't know if this is necessary; probably cruft leftover from * Clarkson packet driver code. Doesn't do a thing on the boards I've - * tested. -DG [note that a outb(0x84, 0) seems to work here, and is + * tested. -DG [note that an outb(0x84, 0) seems to work here, and is * non-invasive...but some boards don't seem to reset and I don't have * complete documentation on what the 'right' thing to do is...so we * do the invasive thing for now. Yuck.] @@ -1545,7 +1552,7 @@ ed_probe_HP_pclanp(dev, port_rid, flags) * HP PC Lan+ : Set the physical link to use AUI or TP/TL. */ -void +static void ed_hpp_set_physical_link(struct ed_softc *sc) { struct ifnet *ifp = &sc->arpcom.ac_if; @@ -1674,16 +1681,22 @@ ed_release_resources(dev) struct ed_softc *sc = device_get_softc(dev); if (sc->port_res) { + bus_deactivate_resource(dev, SYS_RES_IOPORT, + sc->port_rid, sc->port_res); bus_release_resource(dev, SYS_RES_IOPORT, sc->port_rid, sc->port_res); sc->port_res = 0; } if (sc->mem_res) { + bus_deactivate_resource(dev, SYS_RES_MEMORY, + sc->mem_rid, sc->mem_res); bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem_res); sc->mem_res = 0; } if (sc->irq_res) { + bus_deactivate_resource(dev, SYS_RES_IRQ, + sc->irq_rid, sc->irq_res); bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, sc->irq_res); sc->irq_res = 0; @@ -1694,11 +1707,9 @@ ed_release_resources(dev) * Install interface into kernel networking data structures */ int -ed_attach(sc, unit, flags) - struct ed_softc *sc; - int unit; - int flags; +ed_attach(device_t dev) { + struct ed_softc *sc = device_get_softc(dev); struct ifnet *ifp = &sc->arpcom.ac_if; callout_handle_init(&sc->tick_ch); @@ -1711,8 +1722,9 @@ ed_attach(sc, unit, flags) * Initialize ifnet structure */ ifp->if_softc = sc; - if_initname(ifp, "ed", unit); + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_output = ether_output; + ifp->if_mtu = ETHERMTU; ifp->if_start = ed_start; ifp->if_ioctl = ed_ioctl; ifp->if_watchdog = ed_watchdog; @@ -1720,6 +1732,7 @@ ed_attach(sc, unit, flags) ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; ifp->if_linkmib = &sc->mibdata; ifp->if_linkmiblen = sizeof sc->mibdata; + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; /* * XXX - should do a better job. */ @@ -1738,12 +1751,8 @@ ed_attach(sc, unit, flags) * tranceiver for AUI operation), based on compile-time * config option. */ - if (flags & ED_FLAGS_DISABLE_TRANCEIVER) - ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | - IFF_MULTICAST | IFF_ALTPHYS); - else - ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | - IFF_MULTICAST); + if (device_get_flags(dev) & ED_FLAGS_DISABLE_TRANCEIVER) + ifp->if_flags |= IFF_ALTPHYS; /* * Attach the interface @@ -1755,8 +1764,7 @@ ed_attach(sc, unit, flags) /* * Print additional info when attached */ - printf("%s: address %6D, ", ifp->if_xname, - sc->arpcom.ac_enaddr, ":"); + if_printf(ifp, "address %6D, ", sc->arpcom.ac_enaddr, ":"); if (sc->type_str && (*sc->type_str != 0)) printf("type %s ", sc->type_str); @@ -1809,8 +1817,10 @@ ed_stop(sc) { int n = 5000; +#ifndef ED_NO_MIIBUS untimeout(ed_tick, sc, sc->tick_ch); callout_handle_init(&sc->tick_ch); +#endif if (sc->gone) return; /* @@ -1845,6 +1855,7 @@ ed_watchdog(ifp) ed_reset(ifp); } +#ifndef ED_NO_MIIBUS static void ed_tick(arg) void *arg; @@ -1865,6 +1876,7 @@ ed_tick(arg) sc->tick_ch = timeout(ed_tick, sc, hz); splx(s); } +#endif /* * Initialize device. @@ -2007,11 +2019,13 @@ ed_init(xsc) } } +#ifndef ED_NO_MIIBUS if (sc->miibus != NULL) { struct mii_data *mii; mii = device_get_softc(sc->miibus); mii_mediachg(mii); } +#endif /* * Set 'running' flag, and clear output active flag. */ @@ -2023,8 +2037,10 @@ ed_init(xsc) */ ed_start(ifp); +#ifndef ED_NO_MIIBUS untimeout(ed_tick, sc, sc->tick_ch); sc->tick_ch = timeout(ed_tick, sc, hz); +#endif (void) splx(s); } @@ -2203,8 +2219,10 @@ outloop: } } else { len = ed_pio_write_mbufs(sc, m, (int)buffer); - if (len == 0) + if (len == 0) { + m_freem(m0); goto outloop; + } } sc->txb_len[sc->txb_new] = max(len, (ETHER_MIN_LEN-ETHER_CRC_LEN)); @@ -2381,6 +2399,7 @@ edintr(arg) struct ed_softc *sc = (struct ed_softc*) arg; struct ifnet *ifp = (struct ifnet *)sc; u_char isr; + int count; if (sc->gone) return; @@ -2390,9 +2409,12 @@ edintr(arg) ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA); /* - * loop until there are no more new interrupts + * loop until there are no more new interrupts. When the card + * goes away, the hardware will read back 0xff. Looking at + * the interrupts, it would appear that 0xff is impossible, + * or at least extremely unlikely. */ - while ((isr = ed_nic_inb(sc, ED_P0_ISR)) != 0) { + while ((isr = ed_nic_inb(sc, ED_P0_ISR)) != 0 && isr != 0xff) { /* * reset all the bits that we are 'acknowledging' by writing a @@ -2401,12 +2423,21 @@ edintr(arg) */ ed_nic_outb(sc, ED_P0_ISR, isr); - /* XXX workaround for AX88190 */ + /* + * XXX workaround for AX88190 + * We limit this to 5000 iterations. At 1us per inb/outb, + * this translates to about 15ms, which should be plenty + * of time, and also gives protection in the card eject + * case. + */ if (sc->chip_type == ED_CHIP_TYPE_AX88190) { - while (ed_nic_inb(sc, ED_P0_ISR) & isr) { - ed_nic_outb(sc, ED_P0_ISR,0); - ed_nic_outb(sc, ED_P0_ISR,isr); - } + count = 5000; /* 15ms */ + while (count-- && (ed_nic_inb(sc, ED_P0_ISR) & isr)) { + ed_nic_outb(sc, ED_P0_ISR,0); + ed_nic_outb(sc, ED_P0_ISR,isr); + } + if (count == 0) + break; } /* @@ -2554,7 +2585,7 @@ edintr(arg) sc->mibdata.dot3StatsInternalMacReceiveErrors++; ifp->if_ierrors++; #ifdef ED_DEBUG - printf("%s: receive error %x\n", ifp->if_xname, + if_printf("receive error %x\n", ed_nic_inb(sc, ED_P0_RSR)); #endif } @@ -2636,8 +2667,10 @@ ed_ioctl(ifp, command, data) caddr_t data; { struct ed_softc *sc = ifp->if_softc; +#ifndef ED_NO_MIIBUS struct ifreq *ifr = (struct ifreq *)data; struct mii_data *mii; +#endif int s, error = 0; if (sc == NULL || sc->gone) { @@ -2700,6 +2733,7 @@ ed_ioctl(ifp, command, data) error = 0; break; +#ifndef ED_NO_MIIBUS case SIOCGIFMEDIA: case SIOCSIFMEDIA: if (sc->miibus == NULL) { @@ -2709,6 +2743,7 @@ ed_ioctl(ifp, command, data) mii = device_get_softc(sc->miibus); error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); break; +#endif default: error = EINVAL; @@ -2763,6 +2798,7 @@ ed_get_packet(sc, buf, len) char *buf; u_short len; { + struct ifnet *ifp = &sc->arpcom.ac_if; struct ether_header *eh; struct mbuf *m; @@ -2770,7 +2806,7 @@ ed_get_packet(sc, buf, len) MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) return; - m->m_pkthdr.rcvif = &sc->arpcom.ac_if; + m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = len; /* @@ -2801,11 +2837,11 @@ ed_get_packet(sc, buf, len) * Don't read in the entire packet if we know we're going to drop it * and no bpf is active. */ - if (!sc->arpcom.ac_if.if_bpf && BDG_ACTIVE( (&sc->arpcom.ac_if) ) ) { + if (!ifp->if_bpf && BDG_ACTIVE( (ifp) ) ) { struct ifnet *bif; ed_ring_copy(sc, buf, (char *)eh, ETHER_HDR_LEN); - bif = bridge_in_ptr(&sc->arpcom.ac_if, eh) ; + bif = bridge_in_ptr(ifp, eh) ; if (bif == BDG_DROP) { m_freem(m); return; @@ -2825,7 +2861,7 @@ ed_get_packet(sc, buf, len) m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header); m->m_data += sizeof(struct ether_header); - ether_input(&sc->arpcom.ac_if, eh, m); + ether_input(ifp, eh, m); } /* @@ -3157,7 +3193,7 @@ ed_hpp_readmem(sc, src, dst, amount) * Only used in the probe routine to test the memory. 'len' must * be even. */ -void +static void ed_hpp_writemem(sc, src, dst, len) struct ed_softc *sc; unsigned char *src; @@ -3245,7 +3281,7 @@ ed_hpp_write_mbufs(struct ed_softc *sc, struct mbuf *m, int dst) /* finish the last word of the previous mbuf */ if (wantbyte) { savebyte[1] = *data; - *d = *((ushort *) savebyte); + *d = *((u_short *) savebyte); data++; len--; wantbyte = 0; } /* output contiguous words */ @@ -3326,6 +3362,7 @@ ed_hpp_write_mbufs(struct ed_softc *sc, struct mbuf *m, int dst) return (total_len); } +#ifndef ED_NO_MIIBUS /* * MII bus support routines. */ @@ -3343,7 +3380,7 @@ ed_miibus_readreg(dev, phy, reg) splx(s); return (0); } - + (*sc->mii_writebits)(sc, 0xffffffff, 32); (*sc->mii_writebits)(sc, ED_MII_STARTDELIM, ED_MII_STARTDELIM_BITS); (*sc->mii_writebits)(sc, ED_MII_READOP, ED_MII_OP_BITS); @@ -3429,6 +3466,7 @@ ed_child_detached(dev, child) if (child == sc->miibus) sc->miibus = NULL; } +#endif static void ed_setrcr(sc) @@ -3510,23 +3548,21 @@ ed_setrcr(sc) /* * Compute crc for ethernet address */ -static u_int32_t -ds_crc(ep) - u_char *ep; +static uint32_t +ds_mchash(addr) + const uint8_t *addr; { -#define POLYNOMIAL 0x04c11db6 - u_int32_t crc = 0xffffffff; - int carry, i, j; - u_char b; - - for (i = 6; --i >= 0;) { - b = *ep++; - for (j = 8; --j >= 0;) { - carry = ((crc & 0x80000000) ? 1 : 0) ^ (b & 0x01); +#define ED_POLYNOMIAL 0x04c11db6 + register uint32_t crc = 0xffffffff; + register int carry, idx, bit; + register uint8_t data; + + for (idx = 6; --idx >= 0;) { + for (data = *addr++, bit = 8; --bit >= 0; data >>=1 ) { + carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); crc <<= 1; - b >>= 1; if (carry) - crc = (crc ^ POLYNOMIAL) | carry; + crc = (crc ^ ED_POLYNOMIAL) | carry; } } return crc; @@ -3553,7 +3589,7 @@ ds_getmcaf(sc, mcaf) ifma = ifma->ifma_link.le_next) { if (ifma->ifma_addr->sa_family != AF_LINK) continue; - index = ds_crc(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)) + index = ds_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)) >> 26; af[index >> 3] |= 1 << (index & 7); } diff --git a/sys/dev/netif/ed/if_ed98.h b/sys/dev/netif/ed/if_ed98.h index d99209df69..c002627648 100644 --- a/sys/dev/netif/ed/if_ed98.h +++ b/sys/dev/netif/ed/if_ed98.h @@ -24,8 +24,8 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/ed/if_ed98.h,v 1.1.2.1 2000/09/10 08:45:11 nyan Exp $ - * $DragonFly: src/sys/dev/netif/ed/Attic/if_ed98.h,v 1.2 2003/06/17 04:28:24 dillon Exp $ + * $FreeBSD: src/sys/dev/ed/if_ed98.h,v 1.1 2000/08/17 12:15:43 nyan Exp $ + * $DragonFly: src/sys/dev/netif/ed/Attic/if_ed98.h,v 1.3 2004/02/13 21:15:12 joerg Exp $ */ /* diff --git a/sys/dev/netif/ed/if_ed_cbus.c b/sys/dev/netif/ed/if_ed_cbus.c index bd2927e602..9536c662aa 100644 --- a/sys/dev/netif/ed/if_ed_cbus.c +++ b/sys/dev/netif/ed/if_ed_cbus.c @@ -24,8 +24,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/ed/if_ed_cbus.c,v 1.1.2.3 2003/12/24 17:02:00 shiba Exp $ - * $DragonFly: src/sys/dev/netif/ed/Attic/if_ed_cbus.c,v 1.6 2004/02/08 06:47:35 hmp Exp $ + * $FreeBSD: src/sys/dev/ed/if_ed_cbus.c,v 1.12 2003/10/31 18:31:58 brooks Exp $ + * $DragonFly: src/sys/dev/netif/ed/Attic/if_ed_cbus.c,v 1.7 2004/02/13 21:15:12 joerg Exp $ */ #include @@ -49,7 +49,6 @@ #include #include -#include #include "if_edvar.h" #ifdef PC98 @@ -279,27 +278,9 @@ ed_isa_attach(dev) return (error); } - return ed_attach(sc, device_get_unit(dev), flags); + return ed_attach(dev); } -static device_method_t ed_isa_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, ed_isa_probe), - DEVMETHOD(device_attach, ed_isa_attach), - - { 0, 0 } -}; - -static driver_t ed_isa_driver = { - "ed", - ed_isa_methods, - sizeof(struct ed_softc) -}; - -static devclass_t ed_isa_devclass; - -DRIVER_MODULE(if_ed, isa, ed_isa_driver, ed_isa_devclass, 0, 0); - #ifdef PC98 /* * Interrupt conversion table for EtherEZ98 @@ -774,7 +755,7 @@ ed98_probe_Novell(dev, port_rid, flags) /* * I don't know if this is necessary; probably cruft leftover from * Clarkson packet driver code. Doesn't do a thing on the boards I've - * tested. -DG [note that a outb(0x84, 0) seems to work here, and is + * tested. -DG [note that an outb(0x84, 0) seems to work here, and is * non-invasive...but some boards don't seem to reset and I don't have * complete documentation on what the 'right' thing to do is...so we * do the invasive thing for now. Yuck.] @@ -959,7 +940,7 @@ ed_probe_SIC98(dev, port_rid, flags) for (i = 0; i < sc->mem_size; i++) { if (sc->mem_start[i]) { device_printf(dev, "failed to clear shared memory " - "at %lx - check configuration\n", + "at %x - check configuration\n", kvtop(sc->mem_start + i)); return (ENXIO); @@ -995,7 +976,7 @@ ed_reset_CNET98(sc, flags) struct ed_softc *sc; int flags; { - u_short init_addr = ED_CNET98_INIT; + u_int init_addr = ED_CNET98_INIT; u_char tmp; /* Choose initial register address */ @@ -1121,7 +1102,7 @@ ed_probe_CNET98(dev, port_rid, flags) if (((rman_get_start(sc->port_res) & 0x0fff) != 0x03d0) || ((rman_get_start(sc->port_res) & 0xf000) < (u_short) 0xa000)) { #ifdef DIAGNOSTIC - device_printf(dev, "Invalid i/o port configuration (0x%x) " + device_printf(dev, "Invalid i/o port configuration (0x%lx) " "must be %s for %s\n", rman_get_start(sc->port_res), "0x[a-f]3d0", "CNET98"); #endif @@ -1140,7 +1121,7 @@ ed_probe_CNET98(dev, port_rid, flags) tmp_s &= 0x0f; tmp = rman_get_start(sc->port_res) >> 12; if ((tmp_s <= tmp) && (tmp < (tmp_s + 4))) { - device_printf(dev, "Please change iobase address(0x%x) " + device_printf(dev, "Please change iobase address(0x%lx) " "or window address(0x%x)\n", rman_get_start(sc->port_res), kvtop(sc->mem_start)); return (ENXIO); @@ -1193,7 +1174,7 @@ ed_probe_CNET98(dev, port_rid, flags) for (i = 0; i < sc->mem_size; i++) { if (sc->mem_start[i]) { device_printf(dev, "failed to clear shared memory " - "at %lx - check configuration\n", + "at %x - check configuration\n", kvtop(sc->mem_start + i)); return (ENXIO); @@ -1283,7 +1264,7 @@ ed_probe_CNET98EL(dev, port_rid, flags) /* Check I/O address. 0x[0-f]3d0 are allowed. */ if ((rman_get_start(sc->port_res) & 0x0fff) != 0x03d0) { #ifdef DIAGNOSTIC - device_printf(dev, "Invalid i/o port configuration (0x%x) " + device_printf(dev, "Invalid i/o port configuration (0x%lx) " "must be %s for %s\n", rman_get_start(sc->port_res), "0x?3d0", "CNET98E/L"); #endif @@ -1576,7 +1557,7 @@ ed_probe_SB98(dev, port_rid, flags) /* Check I/O address. 00d[02468ace] are allowed. */ if ((rman_get_start(sc->port_res) & ~0x000e) != 0x00d0) { #ifdef DIAGNOSTIC - device_printf(dev, "Invalid i/o port configuration (0x%x) " + device_printf(dev, "Invalid i/o port configuration (0x%lx) " "must be %s for %s\n", rman_get_start(sc->port_res), "0xd?", "SB9801"); #endif @@ -1758,3 +1739,21 @@ ed_pio_testmem(sc, page_offset, isa16bit, flags) return (1); } #endif /* PC98 */ + +static device_method_t ed_isa_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ed_isa_probe), + DEVMETHOD(device_attach, ed_isa_attach), + + { 0, 0 } +}; + +static driver_t ed_isa_driver = { + "ed", + ed_isa_methods, + sizeof(struct ed_softc) +}; + +DRIVER_MODULE(if_ed, isa, ed_isa_driver, ed_devclass, 0, 0); +MODULE_DEPEND(if_ed, isa, 1, 1, 1); +MODULE_DEPEND(if_ed, ether, 1, 1, 1); diff --git a/sys/dev/netif/ed/if_ed_isa.c b/sys/dev/netif/ed/if_ed_isa.c index 3a5493e394..c41b188bc3 100644 --- a/sys/dev/netif/ed/if_ed_isa.c +++ b/sys/dev/netif/ed/if_ed_isa.c @@ -24,8 +24,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/ed/if_ed_isa.c,v 1.5.2.4 2003/12/24 17:02:00 shiba Exp $ - * $DragonFly: src/sys/dev/netif/ed/if_ed_isa.c,v 1.6 2004/02/08 06:47:35 hmp Exp $ + * $FreeBSD: src/sys/dev/ed/if_ed_isa.c,v 1.15 2003/10/31 18:31:58 brooks Exp $ + * $DragonFly: src/sys/dev/netif/ed/if_ed_isa.c,v 1.7 2004/02/13 21:15:12 joerg Exp $ */ #include @@ -43,7 +43,6 @@ #include #include -#include #include "if_edvar.h" @@ -126,7 +125,6 @@ ed_isa_attach(dev) device_t dev; { struct ed_softc *sc = device_get_softc(dev); - int flags = device_get_flags(dev); int error; if (sc->port_used > 0) @@ -143,7 +141,7 @@ ed_isa_attach(dev) return (error); } - return ed_attach(sc, device_get_unit(dev), flags); + return ed_attach(dev); } static device_method_t ed_isa_methods[] = { @@ -160,6 +158,6 @@ static driver_t ed_isa_driver = { sizeof(struct ed_softc) }; -static devclass_t ed_isa_devclass; - -DRIVER_MODULE(if_ed, isa, ed_isa_driver, ed_isa_devclass, 0, 0); +DRIVER_MODULE(if_ed, isa, ed_isa_driver, ed_devclass, 0, 0); +MODULE_DEPEND(if_ed, isa, 1, 1, 1); +MODULE_DEPEND(if_ed, ether, 1, 1, 1); diff --git a/sys/dev/netif/ed/if_ed_pccard.c b/sys/dev/netif/ed/if_ed_pccard.c index 5b1b426bac..cd9e2c795c 100644 --- a/sys/dev/netif/ed/if_ed_pccard.c +++ b/sys/dev/netif/ed/if_ed_pccard.c @@ -24,23 +24,24 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/ed/if_ed_pccard.c,v 1.9.2.6 2001/07/25 18:06:01 iedowse Exp $ - * $DragonFly: src/sys/dev/netif/ed/if_ed_pccard.c,v 1.6 2003/11/20 22:07:27 dillon Exp $ + * $FreeBSD: src/sys/dev/ed/if_ed_pccard.c,v 1.55 2003/12/31 04:25:00 kato Exp $ + * $DragonFly: src/sys/dev/netif/ed/if_ed_pccard.c,v 1.7 2004/02/13 21:15:12 joerg Exp $ */ +#include "opt_ed.h" + #include #include #include #include #include #include -#include -#include -#include #include #include #include +#include +#include #include #include @@ -51,58 +52,41 @@ #include "if_edreg.h" #include "if_edvar.h" #include -#include -#include -#include "../mii_layer/mii.h" -#include "../mii_layer/miivar.h" - +#include +#ifndef ED_NO_MIIBUS +#include +#include +#endif + +#include "card_if.h" +#ifndef ED_NO_MIIBUS /* "device miibus" required. See GENERIC if you get errors here. */ #include "miibus_if.h" -#define CARD_MAJOR 50 +MODULE_DEPEND(ed, miibus, 1, 1, 1); +#endif +MODULE_DEPEND(ed, ether, 1, 1, 1); +MODULE_DEPEND(ed, pccard, 1, 1, 1); /* * PC-Card (PCMCIA) specific code. */ +static int ed_pccard_match(device_t); static int ed_pccard_probe(device_t); static int ed_pccard_attach(device_t); static int ed_pccard_detach(device_t); +static int ed_pccard_Linksys(device_t dev); +static int ed_pccard_ax88190(device_t dev); + static void ax88190_geteprom(struct ed_softc *); static int ed_pccard_memwrite(device_t dev, off_t offset, u_char byte); -static int ed_pccard_memread(device_t dev, off_t offset, u_char *buf, int size); -static int ed_pccard_Linksys(device_t dev); +#ifndef ED_NO_MIIBUS static void ed_pccard_dlink_mii_reset(struct ed_softc *sc); static u_int ed_pccard_dlink_mii_readbits(struct ed_softc *sc, int nbits); static void ed_pccard_dlink_mii_writebits(struct ed_softc *sc, u_int val, int nbits); -static int linksys; - -static device_method_t ed_pccard_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, ed_pccard_probe), - DEVMETHOD(device_attach, ed_pccard_attach), - DEVMETHOD(device_detach, ed_pccard_detach), - - /* Bus interface */ - DEVMETHOD(bus_child_detached, ed_child_detached), - - /* MII interface */ - DEVMETHOD(miibus_readreg, ed_miibus_readreg), - DEVMETHOD(miibus_writereg, ed_miibus_writereg), - { 0, 0 } -}; - -static driver_t ed_pccard_driver = { - "ed", - ed_pccard_methods, - sizeof(struct ed_softc) -}; - -static devclass_t ed_pccard_devclass; - -DRIVER_MODULE(if_ed, pccard, ed_pccard_driver, ed_pccard_devclass, 0, 0); -DRIVER_MODULE(miibus, ed, miibus_driver, miibus_devclass, 0, 0); +#endif /* * ed_pccard_detach - unload the driver and clear the table. @@ -132,6 +116,96 @@ ed_pccard_detach(device_t dev) return (0); } +static const struct ed_product { + struct pccard_product prod; + int flags; +#define NE2000DVF_DL10019 0x0001 /* chip is D-Link DL10019 */ +#define NE2000DVF_AX88190 0x0002 /* chip is ASIX AX88190 */ +} ed_pccard_products[] = { + { PCMCIA_CARD(ACCTON, EN2212, 0), 0}, + { PCMCIA_CARD(ALLIEDTELESIS, LA_PCM, 0), 0}, + { PCMCIA_CARD(AMBICOM, AMB8002T, 0), 0}, + { PCMCIA_CARD(BILLIONTON, LNT10TN, 0), 0}, + { PCMCIA_CARD(BILLIONTON, CFLT10N, 0), 0}, + { PCMCIA_CARD(BUFFALO, LPC3_CLT, 0), 0}, + { PCMCIA_CARD(BUFFALO, LPC3_CLX, 0), NE2000DVF_AX88190}, + { PCMCIA_CARD(BUFFALO, LPC_CF_CLT, 0), 0}, + { PCMCIA_CARD(CNET, NE2000, 0), 0}, + { PCMCIA_CARD(COMPEX, LINKPORT_ENET_B, 0), 0}, + { PCMCIA_CARD(COREGA, ETHER_II_PCC_T, 0), 0}, + { PCMCIA_CARD(COREGA, ETHER_II_PCC_TD, 0), 0}, + { PCMCIA_CARD(COREGA, ETHER_PCC_T, 0), 0}, + { PCMCIA_CARD(COREGA, ETHER_PCC_TD, 0), 0}, + { PCMCIA_CARD(COREGA, FAST_ETHER_PCC_TX, 0), NE2000DVF_DL10019 }, + { PCMCIA_CARD(COREGA, FETHER_PCC_TXD, 0), NE2000DVF_AX88190 }, + { PCMCIA_CARD(COREGA, FETHER_PCC_TXF, 0), NE2000DVF_DL10019 }, + { PCMCIA_CARD(DAYNA, COMMUNICARD_E_1, 0), 0}, + { PCMCIA_CARD(DAYNA, COMMUNICARD_E_2, 0), 0}, + { PCMCIA_CARD(DIGITAL, DEPCMXX, 0), 0 }, + { PCMCIA_CARD(DLINK, DE650, 0), 0}, + { PCMCIA_CARD(DLINK, DE660, 0), 0 }, + { PCMCIA_CARD(DLINK, DE660PLUS, 0), 0}, + { PCMCIA_CARD(DLINK, DFE670TXD, 0), NE2000DVF_DL10019}, + { PCMCIA_CARD(DYNALINK, L10C, 0), 0}, + { PCMCIA_CARD(EDIMAX, EP4000A, 0), 0}, + { PCMCIA_CARD(EPSON, EEN10B, 0), 0}, + { PCMCIA_CARD(EXP, THINLANCOMBO, 0), 0}, + { PCMCIA_CARD(IBM, INFOMOVER, 0), 0}, + { PCMCIA_CARD(IODATA, PCLAT, 0), 0}, + { PCMCIA_CARD(IODATA, PCLATE, 0), 0}, + { PCMCIA_CARD(KINGSTON, KNE2, 0), 0}, + { PCMCIA_CARD(LANTECH, FASTNETTX, 0),NE2000DVF_AX88190 }, + { PCMCIA_CARD(LINKSYS, COMBO_ECARD, 0), NE2000DVF_DL10019 }, + { PCMCIA_CARD(LINKSYS, ECARD_1, 0), 0}, + { PCMCIA_CARD(LINKSYS, ECARD_2, 0), 0}, + { PCMCIA_CARD(LINKSYS, ETHERFAST, 0), NE2000DVF_DL10019 }, + { PCMCIA_CARD(LINKSYS, PCM100, 0), 0}, + { PCMCIA_CARD(LINKSYS, TRUST_COMBO_ECARD, 0), 0}, + { PCMCIA_CARD(LINKSYS, ETHERFAST, 0), NE2000DVF_DL10019 }, + { PCMCIA_CARD(MACNICA, ME1_JEIDA, 0), 0}, + { PCMCIA_CARD(MELCO, LPC3_CLX, 0), NE2000DVF_AX88190}, + { PCMCIA_CARD(MELCO, LPC3_TX, 0), NE2000DVF_AX88190 }, + { PCMCIA_CARD(NDC, ND5100_E, 0), 0}, + { PCMCIA_CARD(NETGEAR, FA410TXC, 0), NE2000DVF_DL10019}, + { PCMCIA_CARD(NETGEAR, FA411, 0), NE2000DVF_AX88190}, + { PCMCIA_CARD(PLANET, SMARTCOM2000, 0), 0 }, + { PCMCIA_CARD(PREMAX, PE200, 0), 0}, + { PCMCIA_CARD(RPTI, EP400, 0), 0}, + { PCMCIA_CARD(RPTI, EP401, 0), 0}, + { PCMCIA_CARD(SMC, EZCARD, 0), 0}, + { PCMCIA_CARD(SOCKET, EA_ETHER, 0), 0}, + { PCMCIA_CARD(SOCKET, LP_ETHER, 0), 0}, + { PCMCIA_CARD(SOCKET, LP_ETHER_CF, 0), 0}, + { PCMCIA_CARD(SOCKET, LP_ETH_10_100_CF, 0), NE2000DVF_DL10019}, + { PCMCIA_CARD(SVEC, COMBOCARD, 0), 0}, + { PCMCIA_CARD(SVEC, LANCARD, 0), 0}, + { PCMCIA_CARD(SYNERGY21, S21810, 0), 0}, + { PCMCIA_CARD(TDK, LAK_CD031, 0), 0}, + { PCMCIA_CARD(TELECOMDEVICE, TCD_HPC100, 0), NE2000DVF_AX88190 }, + { PCMCIA_CARD(XIRCOM, CFE_10, 0), 0}, + { PCMCIA_CARD(ZONET, ZEN, 0), 0}, + { { NULL } } +}; + +static int +ed_pccard_match(device_t dev) +{ + const struct ed_product *pp; + + if ((pp = (const struct ed_product *) pccard_product_lookup(dev, + (const struct pccard_product *) ed_pccard_products, + sizeof(ed_pccard_products[0]), NULL)) != NULL) { + if (pp->prod.pp_name != NULL) + device_set_desc(dev, pp->prod.pp_name); + if (pp->flags & NE2000DVF_DL10019) + device_set_flags(dev, ED_FLAGS_LINKSYS); + else if (pp->flags & NE2000DVF_AX88190) + device_set_flags(dev, ED_FLAGS_AX88190); + return (0); + } + return (EIO); +} + /* * Probe framework for pccards. Replicates the standard framework, * minus the pccard driver registration and ignores the ether address @@ -140,44 +214,12 @@ ed_pccard_detach(device_t dev) static int ed_pccard_probe(device_t dev) { - struct ed_softc *sc = device_get_softc(dev); - int flags = device_get_flags(dev); int error; + int flags = device_get_flags(dev); if (ED_FLAGS_GETTYPE(flags) == ED_FLAGS_AX88190) { - /* Special setup for AX88190 */ - u_char rdbuf[4]; - int iobase; - int attr_ioport; - - /* XXX Allocate the port resource during setup. */ - error = ed_alloc_port(dev, 0, ED_NOVELL_IO_PORTS); - if (error) - return (error); - - sc->asic_offset = ED_NOVELL_ASIC_OFFSET; - sc->nic_offset = ED_NOVELL_NIC_OFFSET; - - sc->chip_type = ED_CHIP_TYPE_AX88190; - - /* - * Check & Set Attribute Memory IOBASE Register - */ - ed_pccard_memread(dev, ED_AX88190_IOBASE0, rdbuf, 4); - attr_ioport = rdbuf[2] << 8 | rdbuf[0]; - iobase = rman_get_start(sc->port_res); - if (attr_ioport != iobase) { -#if notdef - printf("AX88190 IOBASE MISMATCH %04x -> %04x Setting\n", attr_ioport, iobase); -#endif /* notdef */ - ed_pccard_memwrite(dev, ED_AX88190_IOBASE0, - iobase & 0xff); - ed_pccard_memwrite(dev, ED_AX88190_IOBASE1, - (iobase >> 8) & 0xff); - } - ax88190_geteprom(sc); - - ed_release_resources(dev); + error = ed_pccard_ax88190(dev); + goto end2; } error = ed_probe_Novell(dev, 0, flags); @@ -192,11 +234,8 @@ ed_pccard_probe(device_t dev) goto end2; end: - if (ED_FLAGS_GETTYPE(flags) & ED_FLAGS_LINKSYS) { - linksys = ed_pccard_Linksys(dev); - } else { - linksys = 0; - } + if (ED_FLAGS_GETTYPE(flags) & ED_FLAGS_LINKSYS) + ed_pccard_Linksys(dev); end2: if (error == 0) error = ed_alloc_irq(dev, 0, 0); @@ -209,7 +248,6 @@ static int ed_pccard_attach(device_t dev) { struct ed_softc *sc = device_get_softc(dev); - int flags = device_get_flags(dev); int error; int i; u_char sum; @@ -229,7 +267,7 @@ ed_pccard_attach(device_t dev) return (error); } - if (linksys == 0) { + if (sc->vendor != ED_VENDOR_LINKSYS) { pccard_get_ether(dev, ether_addr); for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++) sum |= ether_addr[i]; @@ -237,7 +275,8 @@ ed_pccard_attach(device_t dev) bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN); } - error = ed_attach(sc, device_get_unit(dev), flags); + error = ed_attach(dev); +#ifndef ED_NO_MIIBUS if (error == 0 && sc->vendor == ED_VENDOR_LINKSYS) { /* Probe for an MII bus, but ignore errors. */ ed_pccard_dlink_mii_reset(sc); @@ -246,6 +285,7 @@ ed_pccard_attach(device_t dev) mii_phy_probe(dev, &sc->miibus, ed_ifmedia_upd, ed_ifmedia_sts); } +#endif return (error); } @@ -260,12 +300,12 @@ ax88190_geteprom(struct ed_softc *sc) } pg_seq[] = { {ED_P0_CR, ED_CR_RD2|ED_CR_STP}, /* Select Page0 */ {ED_P0_DCR, 0x01}, - {ED_P0_RBCR0, 0x00}, /* Clear the count regs. */ + {ED_P0_RBCR0, 0x00}, /* Clear the count regs. */ {ED_P0_RBCR1, 0x00}, - {ED_P0_IMR, 0x00}, /* Mask completion irq. */ + {ED_P0_IMR, 0x00}, /* Mask completion irq. */ {ED_P0_ISR, 0xff}, {ED_P0_RCR, ED_RCR_MON | ED_RCR_INTT}, /* Set To Monitor */ - {ED_P0_TCR, ED_TCR_LB0}, /* loopback mode. */ + {ED_P0_TCR, ED_TCR_LB0}, /* loopback mode. */ {ED_P0_RBCR0, 32}, {ED_P0_RBCR1, 0x00}, {ED_P0_RSAR0, 0x00}, @@ -287,11 +327,6 @@ ax88190_geteprom(struct ed_softc *sc) /* Get Data */ for (i = 0; i < 16; i++) prom[i] = ed_asic_inb(sc, 0); -/* - for (i = 0; i < 16; i++) - printf("ax88190 eprom [%02d] %02x %02x\n", - i,prom[i] & 0xff,prom[i] >> 8); -*/ sc->arpcom.ac_enaddr[0] = prom[0] & 0xff; sc->arpcom.ac_enaddr[1] = prom[0] >> 8; sc->arpcom.ac_enaddr[2] = prom[1] & 0xff; @@ -300,55 +335,27 @@ ax88190_geteprom(struct ed_softc *sc) sc->arpcom.ac_enaddr[5] = prom[2] >> 8; } -/* XXX: Warner-san, any plan to provide access to the attribute memory? */ static int ed_pccard_memwrite(device_t dev, off_t offset, u_char byte) { - struct pccard_devinfo *devi; - dev_t d; - struct iovec iov; - struct uio uios; - - devi = device_get_ivars(dev); - - iov.iov_base = &byte; - iov.iov_len = sizeof(byte); - - uios.uio_iov = &iov; - uios.uio_iovcnt = 1; - uios.uio_offset = offset; - uios.uio_resid = sizeof(byte); - uios.uio_segflg = UIO_SYSSPACE; - uios.uio_rw = UIO_WRITE; - uios.uio_td = NULL; - - d = makedev(CARD_MAJOR, devi->slt->slotnum); - return (dev_dwrite(d, &uios, 0)); -} + int cis_rid; + struct resource *cis; + + cis_rid = 0; + cis = bus_alloc_resource(dev, SYS_RES_MEMORY, &cis_rid, 0, ~0, + 4 << 10, RF_ACTIVE | RF_SHAREABLE); + if (cis == NULL) + return (ENXIO); + CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, + cis_rid, PCCARD_A_MEM_ATTR); -static int -ed_pccard_memread(device_t dev, off_t offset, u_char *buf, int size) -{ - struct pccard_devinfo *devi; - dev_t d; - struct iovec iov; - struct uio uios; - - devi = device_get_ivars(dev); - - iov.iov_base = buf; - iov.iov_len = size; - - uios.uio_iov = &iov; - uios.uio_iovcnt = 1; - uios.uio_offset = offset; - uios.uio_resid = size; - uios.uio_segflg = UIO_SYSSPACE; - uios.uio_rw = UIO_READ; - uios.uio_td = NULL; - - d = makedev(CARD_MAJOR, devi->slt->slotnum); - return (dev_dread(d, &uios, 0)); + bus_space_write_1(rman_get_bustag(cis), rman_get_bushandle(cis), + offset, byte); + + bus_deactivate_resource(dev, SYS_RES_MEMORY, cis_rid, cis); + bus_release_resource(dev, SYS_RES_MEMORY, cis_rid, cis); + + return (0); } /* @@ -390,6 +397,45 @@ ed_pccard_Linksys(device_t dev) return (1); } +/* + * Special setup for AX88190 + */ +static int +ed_pccard_ax88190(device_t dev) +{ + int error; + int flags = device_get_flags(dev); + int iobase; + struct ed_softc *sc = device_get_softc(dev); + + /* Allocate the port resource during setup. */ + error = ed_alloc_port(dev, 0, ED_NOVELL_IO_PORTS); + if (error) + return (error); + + sc->asic_offset = ED_NOVELL_ASIC_OFFSET; + sc->nic_offset = ED_NOVELL_NIC_OFFSET; + sc->chip_type = ED_CHIP_TYPE_AX88190; + + /* + * Set Attribute Memory IOBASE Register. Is this a deficiency in + * the PC Card layer, or an ax88190 specific issue? xxx + */ + iobase = rman_get_start(sc->port_res); + ed_pccard_memwrite(dev, ED_AX88190_IOBASE0, iobase & 0xff); + ed_pccard_memwrite(dev, ED_AX88190_IOBASE1, (iobase >> 8) & 0xff); + ax88190_geteprom(sc); + ed_release_resources(dev); + error = ed_probe_Novell(dev, 0, flags); + if (error == 0) { + sc->vendor = ED_VENDOR_PCCARD; + sc->type = ED_TYPE_NE2000; + sc->type_str = "AX88190"; + } + return (error); +} + +#ifndef ED_NO_MIIBUS /* MII bit-twiddling routines for cards using Dlink chipset */ #define DLINK_MIISET(sc, x) ed_asic_outb(sc, ED_DLINK_MIIBUS, \ ed_asic_inb(sc, ED_DLINK_MIIBUS) | (x)) @@ -457,3 +503,38 @@ ed_pccard_dlink_mii_readbits(sc, nbits) return val; } +#endif + +static device_method_t ed_pccard_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pccard_compat_probe), + DEVMETHOD(device_attach, pccard_compat_attach), + DEVMETHOD(device_detach, ed_pccard_detach), + +#ifndef ED_NO_MIIBUS + /* Bus interface */ + DEVMETHOD(bus_child_detached, ed_child_detached), + + /* MII interface */ + DEVMETHOD(miibus_readreg, ed_miibus_readreg), + DEVMETHOD(miibus_writereg, ed_miibus_writereg), +#endif + + /* Card interface */ + DEVMETHOD(card_compat_match, ed_pccard_match), + DEVMETHOD(card_compat_probe, ed_pccard_probe), + DEVMETHOD(card_compat_attach, ed_pccard_attach), + { 0, 0 } +}; + +static driver_t ed_pccard_driver = { + "ed", + ed_pccard_methods, + sizeof(struct ed_softc) +}; + +DRIVER_MODULE(if_ed, pccard, ed_pccard_driver, ed_devclass, 0, 0); +#ifndef ED_NO_MIIBUS +MODULE_DEPEND(if_ed, miibus, 1, 1, 1); +DRIVER_MODULE(miibus, ed, miibus_driver, miibus_devclass, 0, 0); +#endif diff --git a/sys/dev/netif/ed/if_ed_pci.c b/sys/dev/netif/ed/if_ed_pci.c index 30b86de3bf..f8893037da 100644 --- a/sys/dev/netif/ed/if_ed_pci.c +++ b/sys/dev/netif/ed/if_ed_pci.c @@ -17,8 +17,8 @@ * 4. Modifications may be freely made to this file if the above conditions * are met. * - * $FreeBSD: src/sys/dev/ed/if_ed_pci.c,v 1.23.2.1 2000/09/10 08:45:11 nyan Exp $ - * $DragonFly: src/sys/dev/netif/ed/if_ed_pci.c,v 1.5 2003/11/20 22:07:27 dillon Exp $ + * $FreeBSD: src/sys/dev/ed/if_ed_pci.c,v 1.34 2003/10/31 18:31:58 brooks Exp $ + * $DragonFly: src/sys/dev/netif/ed/if_ed_pci.c,v 1.6 2004/02/13 21:15:12 joerg Exp $ */ #include @@ -102,7 +102,7 @@ ed_pci_attach(device_t dev) return (error); } - error = ed_attach(sc, device_get_unit(dev), flags); + error = ed_attach(dev); return (error); } @@ -123,4 +123,6 @@ static driver_t ed_pci_driver = { static devclass_t ed_devclass; -DRIVER_MODULE(if_ed, pci, ed_pci_driver, ed_devclass, 0, 0); +DRIVER_MODULE(ed, pci, ed_pci_driver, ed_devclass, 0, 0); +MODULE_DEPEND(ed, pci, 1, 1, 1); +MODULE_DEPEND(ed, ether, 1, 1, 1); diff --git a/sys/dev/netif/ed/if_edreg.h b/sys/dev/netif/ed/if_edreg.h index 4840380d1d..0dd2e6d9bd 100644 --- a/sys/dev/netif/ed/if_edreg.h +++ b/sys/dev/netif/ed/if_edreg.h @@ -6,8 +6,8 @@ * of this software, nor does the author assume any responsibility * for damages incurred with its use. * - * $FreeBSD: src/sys/dev/ed/if_edreg.h,v 1.27.2.4 2003/12/24 17:02:00 shiba Exp $ - * $DragonFly: src/sys/dev/netif/ed/if_edreg.h,v 1.3 2004/02/08 06:47:35 hmp Exp $ + * $FreeBSD: src/sys/dev/ed/if_edreg.h,v 1.32 2003/10/15 17:22:15 shiba Exp $ + * $DragonFly: src/sys/dev/netif/ed/if_edreg.h,v 1.4 2004/02/13 21:15:12 joerg Exp $ */ /* * National Semiconductor DS8390 NIC register definitions diff --git a/sys/dev/netif/ed/if_edvar.h b/sys/dev/netif/ed/if_edvar.h index 2951803850..199a5d35fd 100644 --- a/sys/dev/netif/ed/if_edvar.h +++ b/sys/dev/netif/ed/if_edvar.h @@ -24,10 +24,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/ed/if_edvar.h,v 1.4.2.5 2003/12/24 17:02:00 shiba Exp $ - * $DragonFly: src/sys/dev/netif/ed/if_edvar.h,v 1.4 2004/02/08 06:47:35 hmp Exp $ + * $FreeBSD: src/sys/dev/ed/if_edvar.h,v 1.16 2003/10/31 18:31:58 brooks Exp $ + * $DragonFly: src/sys/dev/netif/ed/if_edvar.h,v 1.5 2004/02/13 21:15:12 joerg Exp $ */ +#ifndef SYS_DEV_NETIF_ED_EDVAR_H +#define SYS_DEV_NETIF_ED_EDVAR_H + /* * ed_softc: per line info and status */ @@ -203,17 +206,21 @@ int ed_probe_Novell (device_t, int, int); int ed_probe_Novell_generic (device_t, int); int ed_probe_HP_pclanp (device_t, int, int); -int ed_attach (struct ed_softc *, int, int); +int ed_attach (device_t); void ed_stop (struct ed_softc *); void ed_pio_readmem (struct ed_softc *, int, unsigned char *, unsigned short); void ed_pio_writemem (struct ed_softc *, char *, unsigned short, unsigned short); +#ifndef ED_NO_MIIBUS int ed_miibus_readreg (device_t, int, int); void ed_miibus_writereg (device_t, int, int, int); int ed_ifmedia_upd (struct ifnet *); void ed_ifmedia_sts (struct ifnet *, struct ifmediareq *); void ed_child_detached (device_t, device_t); +#endif driver_intr_t edintr; +extern devclass_t ed_devclass; +#endif /* SYS_DEV_NETIF_ED_EDVAR_H */ -- 2.41.0