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/pdq/if_fpa.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1995, 1996 Matt Thomas <matt@3am-software.com>
    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. The name of the author may not be used to endorse or promote products
   11  *    derived from this software without specific prior written permission
   12  *
   13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   19  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   20  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   22  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   23  *
   24  *
   25  */
   26 
   27 #include <sys/cdefs.h>
   28 __FBSDID("$FreeBSD: releng/11.2/sys/dev/pdq/if_fpa.c 331882 2018-04-02 16:11:49Z brooks $");
   29 
   30 /*
   31  * DEC PDQ FDDI Controller; code for BSD derived operating systems
   32  *
   33  *   This module supports the DEC DEFPA PCI FDDI Controller
   34  */
   35 
   36 #include <sys/param.h>
   37 #include <sys/systm.h>
   38 #include <sys/kernel.h>
   39 #include <sys/socket.h>
   40 
   41 #include <sys/module.h>
   42 #include <sys/bus.h>
   43 
   44 #include <machine/bus.h>
   45 #include <machine/resource.h>
   46 #include <sys/rman.h> 
   47 
   48 #include <net/if.h>
   49 #include <net/if_var.h>
   50 #include <net/if_media.h> 
   51 #include <net/fddi.h>
   52 
   53 #include <dev/pci/pcivar.h>
   54 #include <dev/pci/pcireg.h>
   55 
   56 #include <dev/pdq/pdq_freebsd.h>
   57 #include <dev/pdq/pdqreg.h>
   58 
   59 #define DEC_VENDORID            0x1011
   60 #define DEFPA_CHIPID            0x000F
   61 
   62 #define DEFPA_LATENCY   0x88
   63 
   64 #define PCI_CFLT        0x0C    /* Configuration Latency */
   65 #define PCI_CBMA        0x10    /* Configuration Base Memory Address */
   66 #define PCI_CBIO        0x14    /* Configuration Base I/O Address */
   67 
   68 static int      pdq_pci_probe           (device_t);
   69 static int      pdq_pci_attach          (device_t);
   70 static int      pdq_pci_detach          (device_t);
   71 static int      pdq_pci_shutdown        (device_t);
   72 static void     pdq_pci_ifintr          (void *);
   73 
   74 static void
   75 pdq_pci_ifintr(void *arg)
   76 {
   77     pdq_softc_t *sc;
   78 
   79     sc = arg;
   80 
   81     PDQ_LOCK(sc);
   82     (void) pdq_interrupt(sc->sc_pdq);
   83     PDQ_UNLOCK(sc);
   84 
   85     return;
   86 }
   87 
   88 /*
   89  * This is the PCI configuration support.
   90  */
   91 static int
   92 pdq_pci_probe(device_t dev)
   93 {
   94     if (pci_get_vendor(dev) == DEC_VENDORID &&
   95             pci_get_device(dev) == DEFPA_CHIPID) {
   96         device_set_desc(dev, "Digital DEFPA PCI FDDI Controller");
   97         return (BUS_PROBE_DEFAULT);
   98     }
   99 
  100     return (ENXIO);
  101 }
  102 
  103 static int
  104 pdq_pci_attach(device_t dev)
  105 {
  106     pdq_softc_t *sc;
  107     u_int32_t command;
  108     int error;
  109 
  110     sc = device_get_softc(dev);
  111 
  112     sc->dev = dev;
  113 
  114     /*
  115      * Map control/status registers.
  116      */
  117     pci_enable_busmaster(dev);
  118 
  119     command = pci_read_config(dev, PCIR_LATTIMER, 1);
  120     if (command < DEFPA_LATENCY) {
  121         command = DEFPA_LATENCY;
  122         pci_write_config(dev, PCIR_LATTIMER, command, 1);
  123     }
  124 
  125     sc->mem_rid = PCI_CBMA;
  126     sc->mem_type = SYS_RES_MEMORY;
  127     sc->mem = bus_alloc_resource_any(dev, sc->mem_type, &sc->mem_rid,
  128                                      RF_ACTIVE);
  129     if (!sc->mem) {
  130         device_printf(dev, "Unable to allocate I/O space resource.\n");
  131         error = ENXIO;
  132         goto bad;
  133     }
  134     sc->mem_bsh = rman_get_bushandle(sc->mem);
  135     sc->mem_bst = rman_get_bustag(sc->mem);
  136 
  137     sc->irq_rid = 0;
  138     sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irq_rid,
  139                                      RF_SHAREABLE | RF_ACTIVE);
  140     if (!sc->irq) {
  141         device_printf(dev, "Unable to allocate interrupt resource.\n");
  142         error = ENXIO;
  143         goto bad;
  144     }
  145 
  146     error = pdq_ifattach(sc, sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, PDQ_DEFPA);
  147     if (error)
  148         goto bad;
  149     
  150     error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE, NULL,
  151                            pdq_pci_ifintr, sc, &sc->irq_ih);
  152     if (error) {
  153         device_printf(dev, "Failed to setup interrupt handler.\n");
  154         pdq_ifdetach(sc);
  155         return (error);
  156     }
  157 
  158 
  159     gone_in_dev(dev, 12, "fpa(4) driver");
  160     return (0);
  161 bad:
  162     pdq_free(dev);
  163     return (error);
  164 }
  165 
  166 static int
  167 pdq_pci_detach (dev)
  168     device_t    dev;
  169 {
  170     pdq_softc_t *sc;
  171 
  172     sc = device_get_softc(dev);
  173     pdq_ifdetach(sc);
  174 
  175     return (0);
  176 }
  177 
  178 static int
  179 pdq_pci_shutdown(device_t dev)
  180 {
  181     pdq_softc_t *sc;
  182 
  183     sc = device_get_softc(dev);
  184     PDQ_LOCK(sc);
  185     pdq_hwreset(sc->sc_pdq);
  186     PDQ_UNLOCK(sc);
  187 
  188     return (0);
  189 }
  190 
  191 static device_method_t pdq_pci_methods[] = {
  192     /* Device interface */
  193     DEVMETHOD(device_probe,     pdq_pci_probe),
  194     DEVMETHOD(device_attach,    pdq_pci_attach),
  195     DEVMETHOD(device_detach,    pdq_pci_detach),
  196     DEVMETHOD(device_shutdown,  pdq_pci_shutdown),
  197 
  198     { 0, 0 }
  199 };
  200 
  201 static driver_t pdq_pci_driver = {
  202     "fpa",
  203     pdq_pci_methods,
  204     sizeof(pdq_softc_t),
  205 };
  206 
  207 DRIVER_MODULE(fpa, pci, pdq_pci_driver, pdq_devclass, 0, 0);
  208 MODULE_DEPEND(fpa, pci, 1, 1, 1);
  209 MODULE_DEPEND(fpa, fddi, 1, 1, 1);

Cache object: 73177939a24a9eb140461ae1cc2c98dd


[ 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.