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/sparc64/sparc64/eeprom_ebus.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) 1992, 1993
    3  *      The Regents of the University of California.  All rights reserved.
    4  * Copyright (c) 1994 Gordon W. Ross
    5  * Copyright (c) 1993 Adam Glass
    6  * Copyright (c) 1996 Paul Kranenburg
    7  * Copyright (c) 1996
    8  *      The President and Fellows of Harvard College. All rights reserved.
    9  *
   10  * This software was developed by the Computer Systems Engineering group
   11  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
   12  * contributed to Berkeley.
   13  *
   14  * All advertising materials mentioning features or use of this software
   15  * must display the following acknowledgement:
   16  *      This product includes software developed by Harvard University.
   17  *      This product includes software developed by the University of
   18  *      California, Lawrence Berkeley Laboratory.
   19  *
   20  * Redistribution and use in source and binary forms, with or without
   21  * modification, are permitted provided that the following conditions
   22  * are met:
   23  *
   24  * 1. Redistributions of source code must retain the above copyright
   25  *    notice, this list of conditions and the following disclaimer.
   26  * 2. Redistributions in binary form must reproduce the above copyright
   27  *    notice, this list of conditions and the following disclaimer in the
   28  *    documentation and/or other materials provided with the distribution.
   29  * 3. All advertising materials mentioning features or use of this software
   30  *    must display the following acknowledgement:
   31  *      This product includes software developed by the University of
   32  *      California, Berkeley and its contributors.
   33  *      This product includes software developed by Paul Kranenburg.
   34  *      This product includes software developed by Harvard University.
   35  * 4. Neither the name of the University nor the names of its contributors
   36  *    may be used to endorse or promote products derived from this software
   37  *    without specific prior written permission.
   38  *
   39  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   40  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   41  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   42  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   43  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   44  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   45  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   46  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   48  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   49  * SUCH DAMAGE.
   50  *
   51  *      from: @(#)clock.c       8.1 (Berkeley) 6/11/93
   52  *      from: NetBSD: clock.c,v 1.41 2001/07/24 19:29:25 eeh Exp
   53  *
   54  * $FreeBSD: releng/5.2/sys/sparc64/sparc64/eeprom_ebus.c 119352 2003-08-23 05:56:58Z marcel $
   55  */
   56 
   57 #include <sys/param.h>
   58 #include <sys/systm.h>
   59 #include <sys/bus.h>
   60 #include <sys/kernel.h>
   61 #include <sys/malloc.h>
   62 #include <sys/resource.h>
   63 
   64 #include <machine/bus.h>
   65 #include <machine/idprom.h>
   66 #include <machine/resource.h>
   67 
   68 #include <sys/rman.h>
   69 
   70 #include <dev/ofw/openfirm.h>
   71 
   72 #include <machine/eeprom.h>
   73 
   74 #include <dev/mk48txx/mk48txxreg.h>
   75 
   76 #include <sparc64/ebus/ebusvar.h>
   77 
   78 #include "clock_if.h"
   79 
   80 /*
   81  * clock (eeprom) attaches at the sbus or the ebus
   82  */
   83 
   84 static int eeprom_ebus_probe(device_t);
   85 static int eeprom_ebus_attach(device_t);
   86 
   87 static device_method_t eeprom_ebus_methods[] = {
   88         /* Device interface */
   89         DEVMETHOD(device_probe,         eeprom_ebus_probe),
   90         DEVMETHOD(device_attach,        eeprom_ebus_attach),
   91 
   92         /* clock interface */
   93         DEVMETHOD(clock_gettime,        mk48txx_gettime),
   94         DEVMETHOD(clock_settime,        mk48txx_settime),
   95 
   96         { 0, 0 }
   97 };
   98 
   99 static driver_t eeprom_ebus_driver = {
  100         "eeprom",
  101         eeprom_ebus_methods,
  102         0,
  103 };
  104 
  105 DRIVER_MODULE(eeprom, ebus, eeprom_ebus_driver, eeprom_devclass, 0, 0);
  106 
  107 
  108 static int
  109 eeprom_ebus_probe(device_t dev)
  110 {
  111 
  112         if (strcmp("eeprom", ebus_get_name(dev)) == 0) {
  113                 device_set_desc(dev, "EBus EEPROM/clock");
  114                 return (0);
  115         }
  116         return (ENXIO);
  117 }
  118 
  119 /*
  120  * Attach a clock (really `eeprom') to the ebus.
  121  *
  122  * This is mapped read-only on NetBSD for safety, but this is not possible
  123  * with the current FreeBSD bus code.
  124  *
  125  * the MK48T02 is 2K.  the MK48T08 is 8K, and the MK48T59 is supposed to be
  126  * identical to it.
  127  */
  128 static int
  129 eeprom_ebus_attach(device_t dev)
  130 {
  131         struct resource *res;
  132         int rid, error;
  133 
  134         rid = 0;
  135         res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0UL, ~0UL, 1,
  136             RF_ACTIVE);
  137         if (res == NULL) {
  138                 device_printf(dev, "could not allocate resources\n");
  139                 return (ENXIO);
  140         }
  141         error = eeprom_attach(dev, ebus_get_node(dev), rman_get_bustag(res),
  142             rman_get_bushandle(res));
  143         return (error);
  144 }

Cache object: 15dd0ca2cdbe62efbc7ceef8a008f632


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