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/dpaa/fman_fdt.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) 2012 Semihalf.
    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/12.0/sys/dev/dpaa/fman_fdt.c 325204 2017-10-31 02:53:50Z jhibbits $");
   29 
   30 #include <sys/param.h>
   31 #include <sys/systm.h>
   32 #include <sys/kernel.h>
   33 #include <sys/bus.h>
   34 #include <sys/module.h>
   35 
   36 #include <dev/fdt/simplebus.h>
   37 #include <dev/ofw/ofw_bus.h>
   38 #include <dev/ofw/ofw_bus_subr.h>
   39 
   40 #include <contrib/ncsw/inc/ncsw_ext.h>
   41 #include <contrib/ncsw/inc/enet_ext.h>
   42 
   43 #include "fman.h"
   44 
   45 #define FFMAN_DEVSTR    "Freescale Frame Manager"
   46 
   47 static int      fman_fdt_probe(device_t dev);
   48 
   49 static device_method_t fman_methods[] = {
   50         /* Device interface */
   51         DEVMETHOD(device_probe,         fman_fdt_probe),
   52         DEVMETHOD(device_attach,        fman_attach),
   53         DEVMETHOD(device_detach,        fman_detach),
   54 
   55         DEVMETHOD(device_shutdown,      fman_shutdown),
   56         DEVMETHOD(device_suspend,       fman_suspend),
   57         DEVMETHOD(device_resume,        fman_resume_dev),
   58 
   59         DEVMETHOD(bus_alloc_resource,   fman_alloc_resource),
   60         DEVMETHOD(bus_activate_resource,        fman_activate_resource),
   61         DEVMETHOD(bus_release_resource, fman_release_resource),
   62         { 0, 0 }
   63 };
   64 
   65 DEFINE_CLASS_1(fman, fman_driver, fman_methods,
   66     sizeof(struct fman_softc), simplebus_driver);
   67 static devclass_t fman_devclass;
   68 EARLY_DRIVER_MODULE(fman, simplebus, fman_driver, fman_devclass, 0, 0,
   69     BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
   70 
   71 
   72 static int
   73 fman_fdt_probe(device_t dev)
   74 {
   75 
   76         if (!ofw_bus_is_compatible(dev, "fsl,fman"))
   77                 return (ENXIO);
   78 
   79         device_set_desc(dev, FFMAN_DEVSTR);
   80 
   81         return (BUS_PROBE_DEFAULT);
   82 }
   83 
   84 uint32_t
   85 fman_get_clock(struct fman_softc *sc)
   86 {
   87         device_t dev;
   88         phandle_t node;
   89         pcell_t fman_clock;
   90 
   91         dev = sc->sc_base.dev;
   92         node = ofw_bus_get_node(dev);
   93 
   94         if ((OF_getprop(node, "clock-frequency", &fman_clock,
   95             sizeof(fman_clock)) <= 0) || (fman_clock == 0)) {
   96                 device_printf(dev, "could not acquire correct frequency "
   97                     "from DTS\n");
   98 
   99                 return (0);
  100         }
  101 
  102         return ((uint32_t)fman_clock);
  103 }
  104 

Cache object: e32e43778328562cdab6d965dbb8cf29


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