The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/vx/if_vx_pci.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp>
    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  * 3. Neither the name of the author nor the names of any co-contributors
   14  *    may be used to endorse or promote products derived from this software
   15  *    without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  * $FreeBSD: releng/5.0/sys/dev/vx/if_vx_pci.c 68417 2000-11-07 00:56:14Z wpaul $
   30  */
   31 
   32 #include <sys/param.h>
   33 #include <sys/systm.h>
   34 #include <sys/kernel.h>
   35 #include <sys/socket.h>
   36 
   37 #include <net/if.h>
   38 #include <net/if_arp.h>
   39 
   40 #include <machine/bus_pio.h>
   41 #include <machine/bus.h>
   42 #include <machine/resource.h>
   43 #include <sys/bus.h>
   44 #include <sys/rman.h>
   45 
   46 #include <pci/pcivar.h>
   47 #include <pci/pcireg.h>
   48 
   49 #include <dev/vx/if_vxreg.h>
   50 
   51 static void vx_pci_shutdown(device_t);
   52 static int vx_pci_probe(device_t);
   53 static int vx_pci_attach(device_t);
   54 
   55 static device_method_t vx_methods[] = {
   56         /* Device interface */
   57         DEVMETHOD(device_probe,         vx_pci_probe),
   58         DEVMETHOD(device_attach,        vx_pci_attach),
   59         DEVMETHOD(device_shutdown,      vx_pci_shutdown),
   60 
   61         { 0, 0 }
   62 };
   63 
   64 static driver_t vx_driver = {
   65         "vx",
   66         vx_methods,
   67         sizeof(struct vx_softc)
   68 };
   69 
   70 static devclass_t vx_devclass;
   71 
   72 DRIVER_MODULE(if_vx, pci, vx_driver, vx_devclass, 0, 0);
   73 
   74 static void
   75 vx_pci_shutdown(
   76         device_t dev)
   77 {
   78    struct vx_softc      *sc;
   79 
   80    sc = device_get_softc(dev);
   81    vxstop(sc); 
   82    return;
   83 }
   84 
   85 static int
   86 vx_pci_probe(
   87         device_t dev)
   88 {
   89    u_int32_t            device_id;
   90 
   91    device_id = pci_read_config(dev, PCIR_DEVVENDOR, 4);
   92 
   93    if(device_id == 0x590010b7ul) {
   94       device_set_desc(dev, "3COM 3C590 Etherlink III PCI");
   95       return(0);
   96    }
   97    if(device_id == 0x595010b7ul || device_id == 0x595110b7ul ||
   98         device_id == 0x595210b7ul) {
   99       device_set_desc(dev, "3COM 3C595 Etherlink III PCI");
  100       return(0);
  101    }
  102         /*
  103          * The (Fast) Etherlink XL adapters are now supported by
  104          * the xl driver, which uses bus master DMA and is much
  105          * faster. (And which also supports the 3c905B.
  106          */
  107 #ifdef VORTEX_ETHERLINK_XL
  108    if(device_id == 0x900010b7ul || device_id == 0x900110b7ul) {
  109       device_set_desc(dev, "3COM 3C900 Etherlink XL PCI");
  110       return(0);
  111    }
  112    if(device_id == 0x905010b7ul || device_id == 0x905110b7ul) {
  113       device_set_desc(dev, "3COM 3C905 Etherlink XL PCI");
  114       return(0);
  115    }
  116 #endif
  117    return (ENXIO);
  118 }
  119 
  120 static int 
  121 vx_pci_attach(
  122         device_t dev)
  123 {
  124     struct vx_softc *sc;
  125     int rid;
  126 
  127     sc = device_get_softc(dev);
  128 
  129     rid = PCIR_MAPS;
  130     sc->vx_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
  131         0, ~0, 1, RF_ACTIVE);
  132 
  133     if (sc->vx_res == NULL)
  134         goto bad;
  135 
  136     sc->vx_btag = rman_get_bustag(sc->vx_res);
  137     sc->vx_bhandle = rman_get_bushandle(sc->vx_res);
  138 
  139     rid = 0;
  140     sc->vx_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
  141         RF_SHAREABLE | RF_ACTIVE);
  142 
  143     if (sc->vx_irq == NULL)
  144         goto bad;
  145 
  146     if (bus_setup_intr(dev, sc->vx_irq, INTR_TYPE_NET,
  147         vxintr, sc, &sc->vx_intrhand))
  148         goto bad;
  149 
  150     if (vxattach(sc) == 0) {
  151         goto bad;
  152     }
  153 
  154     /* defect check for 3C590 */
  155     if ((pci_read_config(dev, PCIR_DEVVENDOR, 4) >> 16) == 0x5900) {
  156         GO_WINDOW(0);
  157         if (vxbusyeeprom(sc))
  158             goto bad;
  159         CSR_WRITE_2(sc, VX_W0_EEPROM_COMMAND,
  160             EEPROM_CMD_RD | EEPROM_SOFT_INFO_2);
  161         if (vxbusyeeprom(sc))
  162             goto bad;
  163         if (!(CSR_READ_2(sc, VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY)) {
  164             printf("Warning! Defective early revision adapter!\n");
  165         }
  166     }
  167 
  168     return(0);
  169 
  170 bad:
  171     if (sc->vx_intrhand != NULL)
  172         bus_teardown_intr(dev, sc->vx_irq, sc->vx_intrhand);
  173     if (sc->vx_res != NULL)
  174         bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->vx_res);
  175     if (sc->vx_irq != NULL)
  176         bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vx_irq);
  177     return(ENXIO);
  178 }

Cache object: ffaa5dc19d1ee463e177228abf63a018


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.