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/mvme/pcctwo.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 /*      $NetBSD: pcctwo.c,v 1.8 2008/04/28 20:23:54 martin Exp $        */
    2 
    3 /*-
    4  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Steve C. Woodford.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 /*
   33  * PCCchip2 and MCchip Driver
   34  */
   35 
   36 #include <sys/cdefs.h>
   37 __KERNEL_RCSID(0, "$NetBSD: pcctwo.c,v 1.8 2008/04/28 20:23:54 martin Exp $");
   38 
   39 #include <sys/param.h>
   40 #include <sys/kernel.h>
   41 #include <sys/systm.h>
   42 #include <sys/device.h>
   43 
   44 #include <sys/cpu.h>
   45 #include <sys/bus.h>
   46 
   47 #include <dev/mvme/pcctworeg.h>
   48 #include <dev/mvme/pcctwovar.h>
   49 
   50 /*
   51  * Global Pointer to the PCCChip2/MCchip soft state, and chip ID
   52  */
   53 struct pcctwo_softc *sys_pcctwo;
   54 
   55 int pcctwoprint(void *, const char *);
   56 
   57 
   58 /* ARGSUSED */
   59 void
   60 pcctwo_init(sc, pd, devoff)
   61         struct pcctwo_softc *sc;
   62         const struct pcctwo_device *pd;
   63         int devoff;
   64 {
   65         struct pcctwo_attach_args npa;
   66         u_int8_t cid;
   67 
   68         /*
   69          * Fix up the vector base for PCCChip2 Interrupts
   70          */
   71         pcc2_reg_write(sc, PCC2REG_VECTOR_BASE, sc->sc_vecbase);
   72 
   73         /*
   74          * Enable PCCChip2 Interrupts
   75          */
   76         pcc2_reg_write(sc, PCC2REG_GENERAL_CONTROL,
   77             pcc2_reg_read(sc, PCC2REG_GENERAL_CONTROL) | PCCTWO_GEN_CTRL_MIEN);
   78 
   79         /* What are we? */
   80         cid = pcc2_reg_read(sc, PCC2REG_CHIP_ID);
   81 
   82         /*
   83          * Announce ourselves to the world in general
   84          */
   85         if (cid == PCCTWO_CHIP_ID_PCC2)
   86                 printf(": Peripheral Channel Controller (PCCchip2), Rev %d\n",
   87                     pcc2_reg_read(sc, PCC2REG_CHIP_REVISION));
   88         else
   89         if (cid == PCCTWO_CHIP_ID_MCCHIP)
   90                 printf(": Memory Controller ASIC (MCchip), Rev %d\n",
   91                     pcc2_reg_read(sc, PCC2REG_CHIP_REVISION));
   92 
   93         /*
   94          * Attach configured children.
   95          */
   96         npa._pa_base = devoff;
   97         while (pd->pcc_name != NULL) {
   98                 /*
   99                  * Note that IPL is filled in by match function.
  100                  */
  101                 npa.pa_name = pd->pcc_name;
  102                 npa.pa_ipl = -1;
  103                 npa.pa_dmat = sc->sc_dmat;
  104                 npa.pa_bust = sc->sc_bust;
  105                 npa.pa_offset = pd->pcc_offset + devoff;
  106                 pd++;
  107 
  108                 /* Attach the device if configured. */
  109                 (void) config_found(&sc->sc_dev, &npa, pcctwoprint);
  110         }
  111 }
  112 
  113 int
  114 pcctwoprint(aux, cp)
  115         void *aux;
  116         const char *cp;
  117 {
  118         struct pcctwo_attach_args *pa;
  119 
  120         pa = aux;
  121 
  122         if (cp)
  123                 aprint_normal("%s at %s", pa->pa_name, cp);
  124 
  125         aprint_normal(" offset 0x%lx", pa->pa_offset - pa->_pa_base);
  126         if (pa->pa_ipl != -1)
  127                 aprint_normal(" ipl %d", pa->pa_ipl);
  128 
  129         return (UNCONF);
  130 }
  131 
  132 /*
  133  * pcctwointr_establish: Establish PCCChip2 Interrupt
  134  */
  135 void
  136 pcctwointr_establish(vec, hand, lvl, arg, evcnt)
  137         int vec;
  138         int (*hand)(void *), lvl;
  139         void *arg;
  140         struct evcnt *evcnt;
  141 {
  142         int vec2icsr;
  143 
  144 #ifdef DEBUG
  145         if (vec < 0 || vec >= PCCTWOV_MAX) {
  146                 printf("pcctwo: illegal vector offset: 0x%x\n", vec);
  147                 panic("pcctwointr_establish");
  148         }
  149         if (lvl < 1 || lvl > 7) {
  150                 printf("pcctwo: illegal interrupt level: %d\n", lvl);
  151                 panic("pcctwointr_establish");
  152         }
  153         if (sys_pcctwo->sc_vec2icsr[vec] == -1) {
  154                 printf("pcctwo: unsupported vector: %d\n", vec);
  155                 panic("pcctwointr_establish");
  156         }
  157 #endif
  158 
  159         vec2icsr = sys_pcctwo->sc_vec2icsr[vec];
  160         pcc2_reg_write(sys_pcctwo, VEC2ICSR_REG(vec2icsr), 0);
  161 
  162         /* Hook the interrupt */
  163         (*sys_pcctwo->sc_isrlink)(sys_pcctwo->sc_isrcookie, hand, arg,
  164             lvl, vec + sys_pcctwo->sc_vecbase, evcnt);
  165 
  166         /* Enable it in hardware */
  167         pcc2_reg_write(sys_pcctwo, VEC2ICSR_REG(vec2icsr),
  168             VEC2ICSR_INIT(vec2icsr) | lvl);
  169 }
  170 
  171 void
  172 pcctwointr_disestablish(vec)
  173         int vec;
  174 {
  175 
  176 #ifdef DEBUG
  177         if (vec < 0 || vec >= PCCTWOV_MAX) {
  178                 printf("pcctwo: illegal vector offset: 0x%x\n", vec);
  179                 panic("pcctwointr_disestablish");
  180         }
  181         if (sys_pcctwo->sc_vec2icsr[vec] == -1) {
  182                 printf("pcctwo: unsupported vector: %d\n", vec);
  183                 panic("pcctwointr_establish");
  184         }
  185 #endif
  186 
  187         /* Disable it in hardware */
  188         pcc2_reg_write(sys_pcctwo, sys_pcctwo->sc_vec2icsr[vec], 0);
  189 
  190         (*sys_pcctwo->sc_isrunlink)(sys_pcctwo->sc_isrcookie,
  191             vec + sys_pcctwo->sc_vecbase);
  192 }
  193 
  194 struct evcnt *
  195 pcctwointr_evcnt(lev)
  196         int lev;
  197 {
  198 
  199         return ((*sys_pcctwo->sc_isrevcnt)(sys_pcctwo->sc_isrcookie, lev));
  200 }

Cache object: 8d724bc5648148a68305ea41282d38ff


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