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/rt305x/rt305x_ic.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) 2010 Aleksandr Rybalko.
    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  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  */
   26 
   27 #include <sys/cdefs.h>
   28 __FBSDID("$FreeBSD: releng/10.3/sys/mips/rt305x/rt305x_ic.c 220297 2011-04-03 14:39:55Z adrian $");
   29 
   30 #include <sys/param.h>
   31 #include <sys/systm.h>
   32 #include <sys/bus.h>
   33 #include <sys/interrupt.h>
   34 #include <sys/kernel.h>
   35 #include <sys/module.h>
   36 #include <sys/rman.h>
   37 #include <sys/malloc.h>
   38 
   39 #include <machine/bus.h>
   40 
   41 #include <mips/rt305x/rt305xreg.h>
   42 #include <mips/rt305x/rt305x_icvar.h>
   43 
   44 
   45 static int      rt305x_ic_probe(device_t);
   46 static int      rt305x_ic_attach(device_t);
   47 static int      rt305x_ic_detach(device_t);
   48 
   49 
   50 static struct rt305x_ic_softc *rt305x_ic_softc = NULL;
   51 
   52 static int
   53 rt305x_ic_probe(device_t dev)
   54 {
   55         device_set_desc(dev, "RT305X Interrupt Controller driver");
   56         return (0);
   57 }
   58 
   59 static int
   60 rt305x_ic_attach(device_t dev)
   61 {
   62         struct rt305x_ic_softc *sc = device_get_softc(dev);
   63         int error = 0;
   64 
   65         KASSERT((device_get_unit(dev) == 0),
   66             ("rt305x_ic: Only one Interrupt Controller module supported"));
   67 
   68         if (rt305x_ic_softc != NULL)
   69                 return (ENXIO);
   70         rt305x_ic_softc = sc;
   71 
   72 
   73         /* Map control/status registers. */
   74         sc->mem_rid = 0;
   75         sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
   76             &sc->mem_rid, RF_ACTIVE);
   77 
   78         if (sc->mem_res == NULL) {
   79                 device_printf(dev, "couldn't map memory\n");
   80                 error = ENXIO;
   81                 rt305x_ic_detach(dev);
   82                 return(error);
   83         }
   84         return (bus_generic_attach(dev));
   85 }
   86 
   87 static int
   88 rt305x_ic_detach(device_t dev)
   89 {
   90         struct rt305x_ic_softc *sc = device_get_softc(dev);
   91 
   92         bus_generic_detach(dev);
   93 
   94         if (sc->mem_res)
   95                 bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid,
   96                     sc->mem_res);
   97         return(0);
   98 }
   99 
  100 
  101 uint32_t
  102 rt305x_ic_get(uint32_t reg)
  103 {
  104         struct rt305x_ic_softc *sc = rt305x_ic_softc;
  105 
  106         if (!sc)
  107                 return (0);
  108 
  109         return (bus_read_4(sc->mem_res, reg));
  110 }
  111 
  112 void
  113 rt305x_ic_set(uint32_t reg, uint32_t val)
  114 {
  115         struct rt305x_ic_softc *sc = rt305x_ic_softc;
  116 
  117         if (!sc)
  118                 return;
  119 
  120         bus_write_4(sc->mem_res, reg, val);
  121 
  122         return;
  123 }
  124 
  125 
  126 static device_method_t rt305x_ic_methods[] = {
  127         DEVMETHOD(device_probe,                 rt305x_ic_probe),
  128         DEVMETHOD(device_attach,                rt305x_ic_attach),
  129         DEVMETHOD(device_detach,                rt305x_ic_detach),
  130 
  131         {0, 0},
  132 };
  133 
  134 static driver_t rt305x_ic_driver = {
  135         "rt305x_ic",
  136         rt305x_ic_methods,
  137         sizeof(struct rt305x_ic_softc),
  138 };
  139 static devclass_t rt305x_ic_devclass;
  140 
  141 DRIVER_MODULE(rt305x_ic, obio, rt305x_ic_driver, rt305x_ic_devclass, 0, 0);

Cache object: 6ea7e23fb0c8abaddac2b671e42720fb


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