diff options
author | imp <imp@FreeBSD.org> | 2001-01-21 04:56:12 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2001-01-21 04:56:12 +0000 |
commit | 137b76e8468ffeda29434bad4703749720ef6ce3 (patch) | |
tree | a01f068ec330e28d32822fb2ffae73607120d026 /sys/dev | |
parent | 9dfe17139ab61253a8f0874fb7b6e542b4dcee8e (diff) | |
download | FreeBSD-src-137b76e8468ffeda29434bad4703749720ef6ce3.zip FreeBSD-src-137b76e8468ffeda29434bad4703749720ef6ce3.tar.gz |
Break the isa attachment of the Crystal Semiconductor 89x0 into two
parts: isa and pccard. The isa one is known to work with an IBM
EtherJet ISA card. The pccard one isn't known to work because the
EtherJet pccard I purchased recently arrived DOA :-(. I'll commit the
pccard.conf entry when the replacement card arrives.
I plan on MFC this in a week or two.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/cs/if_cs.c | 157 | ||||
-rw-r--r-- | sys/dev/cs/if_cs_isa.c | 127 | ||||
-rw-r--r-- | sys/dev/cs/if_cs_pccard.c | 126 | ||||
-rw-r--r-- | sys/dev/cs/if_csvar.h | 78 |
4 files changed, 344 insertions, 144 deletions
diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c index dfed343..05b021e 100644 --- a/sys/dev/cs/if_cs.c +++ b/sys/dev/cs/if_cs.c @@ -57,13 +57,10 @@ #include <net/if_arp.h> #include <net/if_media.h> #include <net/ethernet.h> - #include <net/bpf.h> -#include <isa/isavar.h> - - #include <dev/cs/if_csreg.h> +#include <dev/cs/if_csvar.h> #ifdef CS_USE_64K_DMA #define CS_DMA_BUFFER_SIZE 65536 @@ -71,69 +68,19 @@ #define CS_DMA_BUFFER_SIZE 16384 #endif -/* - * cs_softc: per line info and status - */ -struct cs_softc { - - /* Ethernet common code */ - struct arpcom arpcom; - - /* Configuration words from EEPROM */ - int auto_neg_cnf; /* AutoNegotitation configuration */ - int adapter_cnf; /* Adapter configuration */ - int isa_config; /* ISA configuration */ - int chip_type; /* Type of chip */ - - struct ifmedia media; /* Media information */ - - int port_rid; /* resource id for port range */ - int port_used; /* nonzero if ports used */ - struct resource* port_res; /* resource for port range */ - int mem_rid; /* resource id for memory range */ - int mem_used; /* nonzero if memory used */ - struct resource* mem_res; /* resource for memory range */ - int irq_rid; /* resource id for irq */ - struct resource* irq_res; /* resource for irq */ - void* irq_handle; /* handle for irq handler */ - - int nic_addr; /* Base IO address of card */ - int send_cmd; - int line_ctl; /* */ - int send_underrun; - void *recv_ring; - - unsigned char *buffer; - int buf_len; -}; - static int cs_recv_delay = 570; SYSCTL_INT(_machdep, OID_AUTO, cs_recv_delay, CTLFLAG_RW, &cs_recv_delay, 0, ""); -static int cs_isa_probe __P((device_t dev)); -static int cs_isa_attach __P((device_t dev)); - -static int cs_cs89x0_probe __P((device_t dev)); - -driver_intr_t csintr; - -static int cs_attach __P((struct cs_softc *, int, int)); - -static void cs_init __P((void *)); -static int cs_ioctl __P((struct ifnet *, u_long, caddr_t)); -static void cs_start __P((struct ifnet *)); -static void cs_stop __P((struct cs_softc *)); -static void cs_reset __P((struct cs_softc *)); -static void cs_watchdog __P((struct ifnet *)); +static void cs_init (void *); +static int cs_ioctl (struct ifnet *, u_long, caddr_t); +static void cs_start (struct ifnet *); +static void cs_stop (struct cs_softc *); +static void cs_reset (struct cs_softc *); +static void cs_watchdog (struct ifnet *); -static int cs_alloc_port(device_t dev, int rid, int size); -static int cs_alloc_memory(device_t dev, int rid, int size); -static int cs_alloc_irq(device_t dev, int rid, int flags); -static void cs_release_resources(device_t dev); - -static int cs_mediachange __P((struct ifnet *)); -static void cs_mediastatus __P((struct ifnet *, struct ifmediareq *)); -static int cs_mediaset __P((struct cs_softc *, int)); +static int cs_mediachange (struct ifnet *); +static void cs_mediastatus (struct ifnet *, struct ifmediareq *); +static int cs_mediaset (struct cs_softc *, int); static void cs_write_mbufs(struct cs_softc*, struct mbuf*); static void cs_xmit_buf(struct cs_softc*); @@ -150,22 +97,7 @@ static int enable_aui(struct cs_softc *); static int enable_bnc(struct cs_softc *); static int cs_duplex_auto(struct cs_softc *); -static device_method_t cs_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, cs_isa_probe), - DEVMETHOD(device_attach, cs_isa_attach), - { 0, 0 } -}; - -static driver_t cs_driver = { - "cs", - cs_methods, - sizeof(struct cs_softc) -}; - -static devclass_t cs_devclass; - -DRIVER_MODULE(cs, isa, cs_driver, cs_devclass, 0, 0); +devclass_t cs_devclass; static int get_eeprom_data( struct cs_softc *sc, int off, int len, int *buffer) @@ -358,7 +290,7 @@ enable_bnc(struct cs_softc *sc) return 0; } -static int +int cs_cs89x0_probe(device_t dev) { int i; @@ -643,73 +575,10 @@ void cs_release_resources(device_t dev) } } -static struct isa_pnp_id cs_ids[] = { - { 0x4060630e, NULL }, /* CSC6040 */ - { 0x10104d24, NULL }, /* IBM EtherJet */ - { 0, NULL } -}; - -/* - * Determine if the device is present - */ -static int -cs_isa_probe(device_t dev) -{ - int error = 0; - - struct cs_softc *sc = device_get_softc(dev); - - bzero(sc, sizeof(struct cs_softc)); - - /* Check isapnp ids */ - error = ISA_PNP_PROBE(device_get_parent(dev), dev, cs_ids); - - /* If the card had a PnP ID that didn't match any we know about */ - if (error == ENXIO) { - goto end; - } - - /* If we had some other problem. */ - if (!(error == 0 || error == ENOENT)) { - goto end; - } - - error=cs_cs89x0_probe(dev); - -end: - if (error == 0) - error = cs_alloc_irq(dev, 0, 0); - - cs_release_resources(dev); - return (error); -} - -static int cs_isa_attach(device_t dev) -{ - struct cs_softc *sc = device_get_softc(dev); - int flags = device_get_flags(dev); - int error; - - if (sc->port_used > 0) - cs_alloc_port(dev, sc->port_rid, sc->port_used); - if (sc->mem_used) - cs_alloc_memory(dev, sc->mem_rid, sc->mem_used); - cs_alloc_irq(dev, sc->irq_rid, 0); - - error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, - csintr, sc, &sc->irq_handle); - if (error) { - cs_release_resources(dev); - return (error); - } - - return cs_attach(sc, device_get_unit(dev), flags); -} - /* * Install the interface into kernel networking data structures */ -static int +int cs_attach(struct cs_softc *sc, int unit, int flags) { int media=0; diff --git a/sys/dev/cs/if_cs_isa.c b/sys/dev/cs/if_cs_isa.c new file mode 100644 index 0000000..a3364b9 --- /dev/null +++ b/sys/dev/cs/if_cs_isa.c @@ -0,0 +1,127 @@ +/* + * Copyright (c) 1997,1998 Maxim Bolotin and Oleg Sharoiko. + * 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 unmodified, 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. + * + * $FreeBSD$ + */ + +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/socket.h> + +#include <sys/module.h> +#include <sys/bus.h> + +#include <machine/bus.h> +#include <machine/resource.h> + +#include <net/ethernet.h> +#include <net/if.h> +#include <net/if_arp.h> + +#include <isa/isavar.h> + +#include <dev/cs/if_csvar.h> + +static int cs_isa_probe (device_t); +static int cs_isa_attach (device_t); + +static struct isa_pnp_id cs_ids[] = { + { 0x4060630e, NULL }, /* CSC6040 */ + { 0x10104d24, NULL }, /* IBM EtherJet */ + { 0, NULL } +}; + +/* + * Determine if the device is present + */ +static int +cs_isa_probe(device_t dev) +{ + int error = 0; + + /* Check isapnp ids */ + error = ISA_PNP_PROBE(device_get_parent(dev), dev, cs_ids); + + /* If the card had a PnP ID that didn't match any we know about */ + if (error == ENXIO) + goto end; + + /* If we had some other problem. */ + if (!(error == 0 || error == ENOENT)) + goto end; + + error = cs_cs89x0_probe(dev); +end: + if (error == 0) + error = cs_alloc_irq(dev, 0, 0); + + cs_release_resources(dev); + return (error); +} + +static int +cs_isa_attach(device_t dev) +{ + struct cs_softc *sc = device_get_softc(dev); + int flags = device_get_flags(dev); + int error; + + if (sc->port_used > 0) + cs_alloc_port(dev, sc->port_rid, sc->port_used); + if (sc->mem_used) + cs_alloc_memory(dev, sc->mem_rid, sc->mem_used); + cs_alloc_irq(dev, sc->irq_rid, 0); + + error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, + csintr, sc, &sc->irq_handle); + if (error) { + cs_release_resources(dev); + return (error); + } + + return (cs_attach(sc, device_get_unit(dev), flags)); +} + +static device_method_t cs_isa_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, cs_isa_probe), + DEVMETHOD(device_attach, cs_isa_attach), +#ifdef CS_HAS_DETACH + DEVMETHOD(device_detach, cs_detach), +#endif + + { 0, 0 } +}; + +static driver_t cs_isa_driver = { + "cs", + cs_isa_methods, + sizeof(struct cs_softc), +}; + +extern devclass_t cs_devclass; + +DRIVER_MODULE(if_cs, isa, cs_isa_driver, cs_devclass, 0, 0); diff --git a/sys/dev/cs/if_cs_pccard.c b/sys/dev/cs/if_cs_pccard.c new file mode 100644 index 0000000..6b6a03e --- /dev/null +++ b/sys/dev/cs/if_cs_pccard.c @@ -0,0 +1,126 @@ +/* + * Copyright (c) 1999 M. Warner Losh <imp@village.org> + * 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. + * + * 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. + * + * $FreeBSD$ + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/socket.h> + +#include <sys/module.h> +#include <sys/bus.h> + +#include <machine/bus.h> +#include <machine/resource.h> + +#include <net/ethernet.h> +#include <net/if.h> +#include <net/if_arp.h> + +#include <dev/cs/if_csvar.h> +#include <dev/pccard/pccardvar.h> +#include <dev/pccard/pccarddevs.h> + +#include "card_if.h" + +static const struct pccard_product cs_pccard_products[] = { + { NULL } +}; +static int +cs_pccard_match(device_t dev) +{ + const struct pccard_product *pp; + + if ((pp = pccard_product_lookup(dev, cs_pccard_products, + sizeof(cs_pccard_products[0]), NULL)) != NULL) { + device_set_desc(dev, pp->pp_name); + return 0; + } + return EIO; +} + +static int +cs_pccard_probe(device_t dev) +{ + int error; + + error = cs_cs89x0_probe(dev); + cs_release_resources(dev); + return (error); +} + +static int +cs_pccard_attach(device_t dev) +{ + struct cs_softc *sc = device_get_softc(dev); + int flags = device_get_flags(dev); + int error; + + if (sc->port_used > 0) + cs_alloc_port(dev, sc->port_rid, sc->port_used); + if (sc->mem_used) + cs_alloc_memory(dev, sc->mem_rid, sc->mem_used); + error = cs_alloc_irq(dev, sc->irq_rid, 0); + if (error != 0) + goto bad; + + error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, + csintr, sc, &sc->irq_handle); + if (error != 0) + goto bad; + + return (cs_attach(sc, device_get_unit(dev), flags)); +bad: + cs_release_resources(dev); + return (error); +} + +static device_method_t cs_pccard_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pccard_compat_probe), + DEVMETHOD(device_attach, pccard_compat_attach), +#ifdef CS_HAS_DETACH + DEVMETHOD(device_detach, cs_detach), +#endif + + /* Card interface */ + DEVMETHOD(card_compat_match, cs_pccard_match), + DEVMETHOD(card_compat_probe, cs_pccard_probe), + DEVMETHOD(card_compat_attach, cs_pccard_attach), + + { 0, 0 } +}; + +static driver_t cs_pccard_driver = { + "cs", + cs_pccard_methods, + sizeof(struct cs_softc), +}; + +extern devclass_t cs_devclass; + +DRIVER_MODULE(if_cs, pccard, cs_pccard_driver, cs_devclass, 0, 0); +MODULE_DEPEND(if_cs, pccard, 1, 1, 1); diff --git a/sys/dev/cs/if_csvar.h b/sys/dev/cs/if_csvar.h new file mode 100644 index 0000000..719a8db --- /dev/null +++ b/sys/dev/cs/if_csvar.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1999 M. Warner Losh <imp@village.org> + * 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. + * + * 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. + * + * $FreeBSD$ + */ + +#ifndef _IF_CSVAR_H +#define _IF_CSVAR_H + +#include <net/if_arp.h> +#include <net/if_media.h> + +/* + * cs_softc: per line info and status + */ +struct cs_softc { + + /* Ethernet common code */ + struct arpcom arpcom; + + /* Configuration words from EEPROM */ + int auto_neg_cnf; /* AutoNegotitation configuration */ + int adapter_cnf; /* Adapter configuration */ + int isa_config; /* ISA configuration */ + int chip_type; /* Type of chip */ + + struct ifmedia media; /* Media information */ + + int port_rid; /* resource id for port range */ + int port_used; /* nonzero if ports used */ + struct resource* port_res; /* resource for port range */ + int mem_rid; /* resource id for memory range */ + int mem_used; /* nonzero if memory used */ + struct resource* mem_res; /* resource for memory range */ + int irq_rid; /* resource id for irq */ + struct resource* irq_res; /* resource for irq */ + void* irq_handle; /* handle for irq handler */ + + int nic_addr; /* Base IO address of card */ + int send_cmd; + int line_ctl; /* */ + int send_underrun; + void *recv_ring; + + unsigned char *buffer; + int buf_len; +}; + +int cs_alloc_port(device_t dev, int rid, int size); +int cs_alloc_memory(device_t dev, int rid, int size); +int cs_alloc_irq(device_t dev, int rid, int flags); +int cs_attach(struct cs_softc *, int, int); +int cs_cs89x0_probe(device_t dev); +void cs_release_resources(device_t dev); +driver_intr_t csintr; + +#endif /* _IF_CSVAR_H */ |