1/* 2 * Copyright (c) 1999 M. Warner Losh <imp@village.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 */ 26 27#include <sys/cdefs.h>
| 1/* 2 * Copyright (c) 1999 M. Warner Losh <imp@village.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 */ 26 27#include <sys/cdefs.h>
|
28__FBSDID("$FreeBSD: head/sys/dev/cs/if_cs_pccard.c 119418 2003-08-24 17:55:58Z obrien $");
| 28__FBSDID("$FreeBSD: head/sys/dev/cs/if_cs_pccard.c 121816 2003-10-31 18:32:15Z brooks $");
|
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/kernel.h> 33#include <sys/socket.h> 34 35#include <sys/module.h> 36#include <sys/bus.h> 37 38#include <machine/bus.h> 39#include <machine/resource.h> 40 41#include <net/ethernet.h> 42#include <net/if.h> 43#include <net/if_arp.h> 44 45#include <dev/cs/if_csvar.h> 46#include <dev/cs/if_csreg.h> 47#include <dev/pccard/pccardvar.h> 48#include <dev/pccard/pccarddevs.h> 49 50#include "card_if.h" 51 52static const struct pccard_product cs_pccard_products[] = { 53 PCMCIA_CARD(IBM, ETHERJET, 0), 54 { NULL } 55}; 56static int 57cs_pccard_match(device_t dev) 58{ 59 const struct pccard_product *pp; 60 61 if ((pp = pccard_product_lookup(dev, cs_pccard_products, 62 sizeof(cs_pccard_products[0]), NULL)) != NULL) { 63 if (pp->pp_name != NULL) 64 device_set_desc(dev, pp->pp_name); 65 return 0; 66 } 67 return EIO; 68} 69 70static int 71cs_pccard_probe(device_t dev) 72{ 73 int error; 74 75 error = cs_cs89x0_probe(dev); 76 cs_release_resources(dev); 77 return (error); 78} 79 80static int 81cs_pccard_attach(device_t dev) 82{ 83 struct cs_softc *sc = device_get_softc(dev);
| 29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/kernel.h> 33#include <sys/socket.h> 34 35#include <sys/module.h> 36#include <sys/bus.h> 37 38#include <machine/bus.h> 39#include <machine/resource.h> 40 41#include <net/ethernet.h> 42#include <net/if.h> 43#include <net/if_arp.h> 44 45#include <dev/cs/if_csvar.h> 46#include <dev/cs/if_csreg.h> 47#include <dev/pccard/pccardvar.h> 48#include <dev/pccard/pccarddevs.h> 49 50#include "card_if.h" 51 52static const struct pccard_product cs_pccard_products[] = { 53 PCMCIA_CARD(IBM, ETHERJET, 0), 54 { NULL } 55}; 56static int 57cs_pccard_match(device_t dev) 58{ 59 const struct pccard_product *pp; 60 61 if ((pp = pccard_product_lookup(dev, cs_pccard_products, 62 sizeof(cs_pccard_products[0]), NULL)) != NULL) { 63 if (pp->pp_name != NULL) 64 device_set_desc(dev, pp->pp_name); 65 return 0; 66 } 67 return EIO; 68} 69 70static int 71cs_pccard_probe(device_t dev) 72{ 73 int error; 74 75 error = cs_cs89x0_probe(dev); 76 cs_release_resources(dev); 77 return (error); 78} 79 80static int 81cs_pccard_attach(device_t dev) 82{ 83 struct cs_softc *sc = device_get_softc(dev);
|
84 int flags = device_get_flags(dev);
| |
85 int error; 86 87 error = cs_alloc_port(dev, sc->port_rid, CS_89x0_IO_PORTS); 88 if (error != 0) 89 goto bad; 90 error = cs_alloc_irq(dev, sc->irq_rid, 0); 91 if (error != 0) 92 goto bad; 93 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, 94 csintr, sc, &sc->irq_handle); 95 if (error != 0) 96 goto bad; 97
| 84 int error; 85 86 error = cs_alloc_port(dev, sc->port_rid, CS_89x0_IO_PORTS); 87 if (error != 0) 88 goto bad; 89 error = cs_alloc_irq(dev, sc->irq_rid, 0); 90 if (error != 0) 91 goto bad; 92 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, 93 csintr, sc, &sc->irq_handle); 94 if (error != 0) 95 goto bad; 96
|
98 return (cs_attach(sc, device_get_unit(dev), flags));
| 97 return (cs_attach(dev));
|
99bad: 100 cs_release_resources(dev); 101 return (error); 102} 103 104static device_method_t cs_pccard_methods[] = { 105 /* Device interface */ 106 DEVMETHOD(device_probe, pccard_compat_probe), 107 DEVMETHOD(device_attach, pccard_compat_attach), 108#ifdef CS_HAS_DETACH 109 DEVMETHOD(device_detach, cs_detach), 110#endif 111 112 /* Card interface */ 113 DEVMETHOD(card_compat_match, cs_pccard_match), 114 DEVMETHOD(card_compat_probe, cs_pccard_probe), 115 DEVMETHOD(card_compat_attach, cs_pccard_attach), 116 117 { 0, 0 } 118}; 119 120static driver_t cs_pccard_driver = { 121 "cs", 122 cs_pccard_methods, 123 sizeof(struct cs_softc), 124}; 125 126extern devclass_t cs_devclass; 127 128DRIVER_MODULE(cs, pccard, cs_pccard_driver, cs_devclass, 0, 0); 129MODULE_DEPEND(cs, pccard, 1, 1, 1); 130MODULE_DEPEND(cs, ether, 1, 1, 1);
| 98bad: 99 cs_release_resources(dev); 100 return (error); 101} 102 103static device_method_t cs_pccard_methods[] = { 104 /* Device interface */ 105 DEVMETHOD(device_probe, pccard_compat_probe), 106 DEVMETHOD(device_attach, pccard_compat_attach), 107#ifdef CS_HAS_DETACH 108 DEVMETHOD(device_detach, cs_detach), 109#endif 110 111 /* Card interface */ 112 DEVMETHOD(card_compat_match, cs_pccard_match), 113 DEVMETHOD(card_compat_probe, cs_pccard_probe), 114 DEVMETHOD(card_compat_attach, cs_pccard_attach), 115 116 { 0, 0 } 117}; 118 119static driver_t cs_pccard_driver = { 120 "cs", 121 cs_pccard_methods, 122 sizeof(struct cs_softc), 123}; 124 125extern devclass_t cs_devclass; 126 127DRIVER_MODULE(cs, pccard, cs_pccard_driver, cs_devclass, 0, 0); 128MODULE_DEPEND(cs, pccard, 1, 1, 1); 129MODULE_DEPEND(cs, ether, 1, 1, 1);
|