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/mips/cavium/octeon_pmc.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  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org>
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  *
   28  * $FreeBSD: stable/12/sys/mips/cavium/octeon_pmc.c 367957 2020-11-23 16:26:49Z jhibbits $
   29  */
   30 
   31 #include <sys/cdefs.h>
   32 __FBSDID("$FreeBSD: stable/12/sys/mips/cavium/octeon_pmc.c 367957 2020-11-23 16:26:49Z jhibbits $");
   33 
   34 #include <sys/param.h>
   35 #include <sys/systm.h>
   36 #include <sys/bus.h>
   37 #include <sys/interrupt.h>
   38 #include <sys/kernel.h>
   39 #include <sys/module.h>
   40 #include <sys/rman.h>
   41 #include <sys/malloc.h>
   42 #include <sys/smp.h>
   43 #include <sys/pmc.h>
   44 #include <sys/pmckern.h>
   45 
   46 #include <machine/bus.h>
   47 #include <machine/intr_machdep.h>
   48 
   49 #include <contrib/octeon-sdk/cvmx.h>
   50 #include <mips/cavium/octeon_irq.h>
   51 
   52 struct octeon_pmc_softc {
   53         struct rman irq_rman;
   54         struct resource *octeon_pmc_irq;
   55 };
   56 
   57 static void             octeon_pmc_identify(driver_t *, device_t);
   58 static int              octeon_pmc_probe(device_t);
   59 static int              octeon_pmc_attach(device_t);
   60 static int              octeon_pmc_intr(void *);
   61 
   62 static void
   63 octeon_pmc_identify(driver_t *drv, device_t parent)
   64 {
   65         if (octeon_has_feature(OCTEON_FEATURE_USB))
   66                 BUS_ADD_CHILD(parent, 0, "pmc", 0);
   67 }
   68 
   69 static int
   70 octeon_pmc_probe(device_t dev)
   71 {
   72         if (device_get_unit(dev) != 0)
   73                 return (ENXIO);
   74 
   75         device_set_desc(dev, "Cavium Octeon Performance Counters");
   76         return (BUS_PROBE_NOWILDCARD);
   77 }
   78 
   79 static int
   80 octeon_pmc_attach(device_t dev)
   81 {
   82         struct octeon_pmc_softc *sc;
   83         int error;
   84         int rid;
   85 
   86         sc = device_get_softc(dev);
   87 
   88         rid = 0;
   89         sc->octeon_pmc_irq = bus_alloc_resource(dev, 
   90             SYS_RES_IRQ, &rid, OCTEON_PMC_IRQ,
   91             OCTEON_PMC_IRQ, 1, RF_ACTIVE);
   92 
   93         if (sc->octeon_pmc_irq == NULL) {
   94                 device_printf(dev, "could not allocate irq%d\n", OCTEON_PMC_IRQ);
   95                 return (ENXIO);
   96         }
   97 
   98         error = bus_setup_intr(dev, sc->octeon_pmc_irq, 
   99             INTR_TYPE_MISC, octeon_pmc_intr, NULL, sc, NULL);
  100         if (error != 0) {
  101                 device_printf(dev, "bus_setup_intr failed: %d\n", error);
  102                 return (error);
  103         }
  104 
  105         return (0);
  106 }
  107 
  108 static int
  109 octeon_pmc_intr(void *arg)
  110 {
  111         struct trapframe *tf = PCPU_GET(curthread)->td_intr_frame;
  112 
  113         if (pmc_intr)
  114                 (*pmc_intr)(tf);
  115 
  116         return (FILTER_HANDLED);
  117 }
  118 
  119 static device_method_t octeon_pmc_methods[] = {
  120         DEVMETHOD(device_identify,      octeon_pmc_identify),
  121         DEVMETHOD(device_probe,         octeon_pmc_probe),
  122         DEVMETHOD(device_attach,        octeon_pmc_attach),
  123         { 0, 0 }
  124 };
  125 
  126 static driver_t octeon_pmc_driver = {
  127         "pmc",
  128         octeon_pmc_methods,
  129         sizeof(struct octeon_pmc_softc),
  130 };
  131 static devclass_t octeon_pmc_devclass;
  132 DRIVER_MODULE(octeon_pmc, nexus, octeon_pmc_driver, octeon_pmc_devclass, 0, 0);

Cache object: df97cf8bf744cc69fdb652754ab79c5e


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