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/altera/dwc/if_dwc_socfpga.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  * SPDX-License-Identifier: BSD-2-Clause
    3  *
    4  * Copyright (c) 2019 Ruslan Bukin <br@bsdpad.com>
    5  *
    6  * This software was developed by SRI International and the University of
    7  * Cambridge Computer Laboratory (Department of Computer Science and
    8  * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the
    9  * DARPA SSITH research programme.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  */
   32 
   33 #include <sys/cdefs.h>
   34 __FBSDID("$FreeBSD$");
   35 
   36 #include <sys/param.h>
   37 #include <sys/systm.h>
   38 #include <sys/bus.h>
   39 #include <sys/kernel.h>
   40 #include <sys/module.h>
   41 
   42 #include <machine/bus.h>
   43 
   44 #include <dev/dwc/if_dwc.h>
   45 #include <dev/dwc/if_dwcvar.h>
   46 #include <dev/ofw/ofw_bus.h>
   47 #include <dev/ofw/ofw_bus_subr.h>
   48 
   49 #include "if_dwc_if.h"
   50 
   51 static int
   52 if_dwc_socfpga_probe(device_t dev)
   53 {
   54 
   55         if (!ofw_bus_status_okay(dev))
   56                 return (ENXIO);
   57 
   58         if (!ofw_bus_is_compatible(dev, "altr,socfpga-stmmac"))
   59                 return (ENXIO);
   60 
   61         device_set_desc(dev, "Altera SOCFPGA Ethernet MAC");
   62 
   63         return (BUS_PROBE_DEFAULT);
   64 }
   65 
   66 static int
   67 if_dwc_socfpga_init(device_t dev)
   68 {
   69 
   70         return (0);
   71 }
   72 
   73 static int
   74 if_dwc_socfpga_mac_type(device_t dev)
   75 {
   76 
   77         return (DWC_GMAC_EXT_DESC);
   78 }
   79 
   80 static int
   81 if_dwc_socfpga_mii_clk(device_t dev)
   82 {
   83         phandle_t root;
   84 
   85         root = OF_finddevice("/");
   86 
   87         if (ofw_bus_node_is_compatible(root, "altr,socfpga-stratix10"))
   88                 return (GMAC_MII_CLK_35_60M_DIV26);
   89 
   90         /* Default value. */
   91         return (GMAC_MII_CLK_25_35M_DIV16);
   92 }
   93 
   94 static device_method_t dwc_socfpga_methods[] = {
   95         DEVMETHOD(device_probe,         if_dwc_socfpga_probe),
   96 
   97         DEVMETHOD(if_dwc_init,          if_dwc_socfpga_init),
   98         DEVMETHOD(if_dwc_mac_type,      if_dwc_socfpga_mac_type),
   99         DEVMETHOD(if_dwc_mii_clk,       if_dwc_socfpga_mii_clk),
  100 
  101         DEVMETHOD_END
  102 };
  103 
  104 extern driver_t dwc_driver;
  105 
  106 DEFINE_CLASS_1(dwc, dwc_socfpga_driver, dwc_socfpga_methods,
  107     sizeof(struct dwc_softc), dwc_driver);
  108 EARLY_DRIVER_MODULE(dwc_socfpga, simplebus, dwc_socfpga_driver, 0, 0,
  109     BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_MIDDLE);
  110 
  111 MODULE_DEPEND(dwc_socfpga, dwc, 1, 1, 1);

Cache object: 514c1e0d365028e474e79bfabd7b2c20


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