if_cs_pccard.c revision 113315
171316Simp/* 271316Simp * Copyright (c) 1999 M. Warner Losh <imp@village.org> 371316Simp * All rights reserved. 471316Simp * 571316Simp * Redistribution and use in source and binary forms, with or without 671316Simp * modification, are permitted provided that the following conditions 771316Simp * are met: 871316Simp * 1. Redistributions of source code must retain the above copyright 971316Simp * notice, this list of conditions and the following disclaimer. 1071316Simp * 2. Redistributions in binary form must reproduce the above copyright 1171316Simp * notice, this list of conditions and the following disclaimer in the 1271316Simp * documentation and/or other materials provided with the distribution. 1371316Simp * 1471316Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1571316Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1671316Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1771316Simp * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1871316Simp * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1971316Simp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2071316Simp * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2171316Simp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2271316Simp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2371316Simp * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2471316Simp * 2571316Simp * $FreeBSD: head/sys/dev/cs/if_cs_pccard.c 113315 2003-04-10 04:36:02Z imp $ 2671316Simp */ 2771316Simp 2871316Simp#include <sys/param.h> 2971316Simp#include <sys/systm.h> 3071316Simp#include <sys/kernel.h> 3171316Simp#include <sys/socket.h> 3271316Simp 3371316Simp#include <sys/module.h> 3471316Simp#include <sys/bus.h> 3571316Simp 3671316Simp#include <machine/bus.h> 3771316Simp#include <machine/resource.h> 3871316Simp 3971316Simp#include <net/ethernet.h> 4071316Simp#include <net/if.h> 4171316Simp#include <net/if_arp.h> 4271316Simp 4371316Simp#include <dev/cs/if_csvar.h> 4472940Simp#include <dev/cs/if_csreg.h> 4571316Simp#include <dev/pccard/pccardvar.h> 4671316Simp#include <dev/pccard/pccarddevs.h> 4771316Simp 4871316Simp#include "card_if.h" 4971316Simp 5071316Simpstatic const struct pccard_product cs_pccard_products[] = { 5186394Simp PCMCIA_CARD(IBM, ETHERJET, 0), 5271316Simp { NULL } 5371316Simp}; 5471316Simpstatic int 5571316Simpcs_pccard_match(device_t dev) 5671316Simp{ 5771316Simp const struct pccard_product *pp; 5871316Simp 5971316Simp if ((pp = pccard_product_lookup(dev, cs_pccard_products, 6071316Simp sizeof(cs_pccard_products[0]), NULL)) != NULL) { 61113315Simp if (pp->pp_name != NULL) 62113315Simp device_set_desc(dev, pp->pp_name); 6371316Simp return 0; 6471316Simp } 6571316Simp return EIO; 6671316Simp} 6771316Simp 6871316Simpstatic int 6971316Simpcs_pccard_probe(device_t dev) 7071316Simp{ 7171316Simp int error; 7271316Simp 7371316Simp error = cs_cs89x0_probe(dev); 7471316Simp cs_release_resources(dev); 7571316Simp return (error); 7671316Simp} 7771316Simp 7871316Simpstatic int 7971316Simpcs_pccard_attach(device_t dev) 8071316Simp{ 8171316Simp struct cs_softc *sc = device_get_softc(dev); 8271316Simp int flags = device_get_flags(dev); 8371316Simp int error; 8471316Simp 8572940Simp error = cs_alloc_port(dev, sc->port_rid, CS_89x0_IO_PORTS); 8672940Simp if (error != 0) 8772940Simp goto bad; 8871316Simp error = cs_alloc_irq(dev, sc->irq_rid, 0); 8971316Simp if (error != 0) 9071316Simp goto bad; 9171316Simp error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, 9271316Simp csintr, sc, &sc->irq_handle); 9371316Simp if (error != 0) 9471316Simp goto bad; 9571316Simp 9671316Simp return (cs_attach(sc, device_get_unit(dev), flags)); 9771316Simpbad: 9871316Simp cs_release_resources(dev); 9971316Simp return (error); 10071316Simp} 10171316Simp 10271316Simpstatic device_method_t cs_pccard_methods[] = { 10371316Simp /* Device interface */ 10471316Simp DEVMETHOD(device_probe, pccard_compat_probe), 10571316Simp DEVMETHOD(device_attach, pccard_compat_attach), 10671316Simp#ifdef CS_HAS_DETACH 10771316Simp DEVMETHOD(device_detach, cs_detach), 10871316Simp#endif 10971316Simp 11071316Simp /* Card interface */ 11171316Simp DEVMETHOD(card_compat_match, cs_pccard_match), 11271316Simp DEVMETHOD(card_compat_probe, cs_pccard_probe), 11371316Simp DEVMETHOD(card_compat_attach, cs_pccard_attach), 11471316Simp 11571316Simp { 0, 0 } 11671316Simp}; 11771316Simp 11871316Simpstatic driver_t cs_pccard_driver = { 11971316Simp "cs", 12071316Simp cs_pccard_methods, 12171316Simp sizeof(struct cs_softc), 12271316Simp}; 12371316Simp 12471316Simpextern devclass_t cs_devclass; 12571316Simp 12671316SimpDRIVER_MODULE(if_cs, pccard, cs_pccard_driver, cs_devclass, 0, 0); 12771316SimpMODULE_DEPEND(if_cs, pccard, 1, 1, 1); 128