1139749Simp/*- 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 */ 2671316Simp 27119418Sobrien#include <sys/cdefs.h> 28119418Sobrien__FBSDID("$FreeBSD: releng/10.2/sys/dev/cs/if_cs_pccard.c 179618 2008-06-06 16:10:10Z imp $"); 29119418Sobrien 3071316Simp#include <sys/param.h> 3171316Simp#include <sys/systm.h> 3271316Simp#include <sys/kernel.h> 3371316Simp#include <sys/socket.h> 3471316Simp 3571316Simp#include <sys/module.h> 3671316Simp#include <sys/bus.h> 3771316Simp 3871316Simp#include <machine/bus.h> 3971316Simp#include <machine/resource.h> 4071316Simp 4171316Simp#include <net/ethernet.h> 4271316Simp#include <net/if.h> 4371316Simp#include <net/if_arp.h> 4471316Simp 4571316Simp#include <dev/cs/if_csvar.h> 4672940Simp#include <dev/cs/if_csreg.h> 4771316Simp#include <dev/pccard/pccardvar.h> 48140524Simp#include <dev/pccard/pccard_cis.h> 4971316Simp 5071316Simp#include "card_if.h" 51129764Simp#include "pccarddevs.h" 5271316Simp 5371316Simpstatic const struct pccard_product cs_pccard_products[] = { 54147580Simp PCMCIA_CARD(IBM, ETHERJET), 5571316Simp { NULL } 5671316Simp}; 5771316Simpstatic int 58150394Simpcs_pccard_probe(device_t dev) 5971316Simp{ 6071316Simp const struct pccard_product *pp; 61140524Simp uint32_t fcn = PCCARD_FUNCTION_UNSPEC; 6271316Simp 63140524Simp /* Make sure we're a network function */ 64179594Simp pccard_get_function(dev, &fcn); 65140524Simp if (fcn != PCCARD_FUNCTION_NETWORK) 66140524Simp return (ENXIO); 67140524Simp 6871316Simp if ((pp = pccard_product_lookup(dev, cs_pccard_products, 6971316Simp sizeof(cs_pccard_products[0]), NULL)) != NULL) { 70113315Simp if (pp->pp_name != NULL) 71113315Simp device_set_desc(dev, pp->pp_name); 7271316Simp return 0; 7371316Simp } 7471316Simp return EIO; 7571316Simp} 7671316Simp 7771316Simpstatic int 78150394Simpcs_pccard_attach(device_t dev) 7971316Simp{ 80140926Simp struct cs_softc *sc = device_get_softc(dev); 8171316Simp int error; 8271316Simp 83140926Simp sc->flags |= CS_NO_IRQ; 8471316Simp error = cs_cs89x0_probe(dev); 8572940Simp if (error != 0) 86150394Simp return (error); 87179618Simp error = cs_alloc_irq(dev, sc->irq_rid); 8871316Simp if (error != 0) 8971316Simp goto bad; 9071316Simp 91140927Simp return (cs_attach(dev)); 9271316Simpbad: 9371316Simp cs_release_resources(dev); 9471316Simp return (error); 9571316Simp} 9671316Simp 9771316Simpstatic device_method_t cs_pccard_methods[] = { 9871316Simp /* Device interface */ 99150394Simp DEVMETHOD(device_probe, cs_pccard_probe), 100150394Simp DEVMETHOD(device_attach, cs_pccard_attach), 10171316Simp DEVMETHOD(device_detach, cs_detach), 10271316Simp 10371316Simp { 0, 0 } 10471316Simp}; 10571316Simp 10671316Simpstatic driver_t cs_pccard_driver = { 10771316Simp "cs", 10871316Simp cs_pccard_methods, 10971316Simp sizeof(struct cs_softc), 11071316Simp}; 11171316Simp 11271316Simpextern devclass_t cs_devclass; 11371316Simp 114113506SmdoddDRIVER_MODULE(cs, pccard, cs_pccard_driver, cs_devclass, 0, 0); 115113506SmdoddMODULE_DEPEND(cs, ether, 1, 1, 1); 116