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/vme_two.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: vme_two.c,v 1.3.2.1 2004/04/02 14:52:38 tron 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  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *        This product includes software developed by the NetBSD
   21  *        Foundation, Inc. and its contributors.
   22  * 4. Neither the name of The NetBSD Foundation nor the names of its
   23  *    contributors may be used to endorse or promote products derived
   24  *    from this software without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36  * POSSIBILITY OF SUCH DAMAGE.
   37  */
   38 
   39 /*
   40  * VME support specific to the VMEchip2 found on all high-end MVME boards
   41  */
   42 
   43 #include <sys/cdefs.h>
   44 __KERNEL_RCSID(0, "$NetBSD: vme_two.c,v 1.3.2.1 2004/04/02 14:52:38 tron Exp $");
   45 
   46 #include "vmetwo.h"
   47 
   48 #include <sys/param.h>
   49 #include <sys/kernel.h>
   50 #include <sys/systm.h>
   51 #include <sys/device.h>
   52 
   53 #include <machine/cpu.h>
   54 #include <machine/bus.h>
   55 
   56 #include <dev/vme/vmereg.h>
   57 #include <dev/vme/vmevar.h>
   58 
   59 #include <dev/mvme/mvmebus.h>
   60 #include <dev/mvme/vme_tworeg.h>
   61 #include <dev/mvme/vme_twovar.h>
   62 
   63 void vmetwo_master_range(struct vmetwo_softc *, int, struct mvmebus_range *);
   64 void vmetwo_slave_range(struct vmetwo_softc *, int, vme_am_t,
   65         struct mvmebus_range *);
   66 
   67 /* ARGSUSED */
   68 void
   69 vmetwo_init(sc)
   70         struct vmetwo_softc *sc;
   71 {
   72         u_int32_t reg;
   73         int i;
   74 
   75         /* Initialise stuff for the common mvmebus front-end */
   76         sc->sc_mvmebus.sc_chip = sc;
   77         sc->sc_mvmebus.sc_nmasters = VME2_NMASTERS;
   78         sc->sc_mvmebus.sc_masters = &sc->sc_master[0];
   79         sc->sc_mvmebus.sc_nslaves = VME2_NSLAVES;
   80         sc->sc_mvmebus.sc_slaves = &sc->sc_slave[0];
   81         sc->sc_mvmebus.sc_intr_establish = vmetwo_intr_establish;
   82         sc->sc_mvmebus.sc_intr_disestablish = vmetwo_intr_disestablish;
   83 
   84         /* Initialise interrupts */
   85         vmetwo_intr_init(sc);
   86 
   87         reg = vme2_lcsr_read(sc, VME2LCSR_BOARD_CONTROL);
   88         printf(": Type 2 VMEchip, scon jumper %s\n",
   89             (reg & VME2_BOARD_CONTROL_SCON) ? "enabled" : "disabled");
   90 
   91         /*
   92          * Figure out what bits of the VMEbus we can access.
   93          * First record the `fixed' maps (if they're enabled)
   94          */
   95         reg = vme2_lcsr_read(sc, VME2LCSR_IO_CONTROL);
   96         if (reg & VME2_IO_CONTROL_I1EN) {
   97                 /* This range is fixed to A16, DATA */
   98                 sc->sc_master[0].vr_am = VME_AM_A16 | MVMEBUS_AM_CAP_DATA;
   99 
  100                 /* However, SUPER/USER is selectable... */
  101                 if (reg & VME2_IO_CONTROL_I1SU)
  102                         sc->sc_master[0].vr_am |= MVMEBUS_AM_CAP_SUPER;
  103                 else
  104                         sc->sc_master[0].vr_am |= MVMEBUS_AM_CAP_USER;
  105 
  106                 /* As is the datasize */
  107                 sc->sc_master[0].vr_datasize = VME_D32 | VME_D16;
  108                 if (reg & VME2_IO_CONTROL_I1D16)
  109                         sc->sc_master[0].vr_datasize &= ~VME_D32;
  110 
  111                 sc->sc_master[0].vr_locstart = VME2_IO0_LOCAL_START;
  112                 sc->sc_master[0].vr_mask = VME2_IO0_MASK;
  113                 sc->sc_master[0].vr_vmestart = VME2_IO0_VME_START;
  114                 sc->sc_master[0].vr_vmeend = VME2_IO0_VME_END;
  115         } else
  116                 sc->sc_master[0].vr_am = MVMEBUS_AM_DISABLED;
  117 
  118         if (reg & VME2_IO_CONTROL_I2EN) {
  119                 /* These two ranges are fixed to A24D16 and A32D16 */
  120                 sc->sc_master[1].vr_am = VME_AM_A24;
  121                 sc->sc_master[1].vr_datasize = VME_D16;
  122                 sc->sc_master[2].vr_am = VME_AM_A32;
  123                 sc->sc_master[2].vr_datasize = VME_D16;
  124 
  125                 /* However, SUPER/USER is selectable */
  126                 if (reg & VME2_IO_CONTROL_I2SU) {
  127                         sc->sc_master[1].vr_am |= MVMEBUS_AM_CAP_SUPER;
  128                         sc->sc_master[2].vr_am |= MVMEBUS_AM_CAP_SUPER;
  129                 } else {
  130                         sc->sc_master[1].vr_am |= MVMEBUS_AM_CAP_USER;
  131                         sc->sc_master[2].vr_am |= MVMEBUS_AM_CAP_USER;
  132                 }
  133 
  134                 /* As is PROGRAM/DATA */
  135                 if (reg & VME2_IO_CONTROL_I2PD) {
  136                         sc->sc_master[1].vr_am |= MVMEBUS_AM_CAP_PROG;
  137                         sc->sc_master[2].vr_am |= MVMEBUS_AM_CAP_PROG;
  138                 } else {
  139                         sc->sc_master[1].vr_am |= MVMEBUS_AM_CAP_DATA;
  140                         sc->sc_master[2].vr_am |= MVMEBUS_AM_CAP_DATA;
  141                 }
  142 
  143                 sc->sc_master[1].vr_locstart = VME2_IO1_LOCAL_START;
  144                 sc->sc_master[1].vr_mask = VME2_IO1_MASK;
  145                 sc->sc_master[1].vr_vmestart = VME2_IO1_VME_START;
  146                 sc->sc_master[1].vr_vmeend = VME2_IO1_VME_END;
  147 
  148                 sc->sc_master[2].vr_locstart = VME2_IO2_LOCAL_START;
  149                 sc->sc_master[2].vr_mask = VME2_IO2_MASK;
  150                 sc->sc_master[2].vr_vmestart = VME2_IO2_VME_START;
  151                 sc->sc_master[2].vr_vmeend = VME2_IO2_VME_END;
  152         } else {
  153                 sc->sc_master[1].vr_am = MVMEBUS_AM_DISABLED;
  154                 sc->sc_master[2].vr_am = MVMEBUS_AM_DISABLED;
  155         }
  156 
  157         /*
  158          * Now read the progammable maps
  159          */
  160         for (i = 0; i < VME2_MASTER_WINDOWS; i++)
  161                 vmetwo_master_range(sc, i,
  162                     &(sc->sc_master[i + VME2_MASTER_PROG_START]));
  163 
  164         /* XXX: No A16 slave yet :XXX */
  165         sc->sc_slave[VME2_SLAVE_A16].vr_am = MVMEBUS_AM_DISABLED;
  166 
  167         for (i = 0; i < VME2_SLAVE_WINDOWS; i++) {
  168                 vmetwo_slave_range(sc, i, VME_AM_A32,
  169                     &sc->sc_slave[i + VME2_SLAVE_PROG_START]);
  170                 vmetwo_slave_range(sc, i, VME_AM_A24,
  171                     &sc->sc_slave[i + VME2_SLAVE_PROG_START + 2]);
  172         }
  173 
  174         mvmebus_attach(&sc->sc_mvmebus);
  175 }
  176 
  177 void
  178 vmetwo_master_range(sc, range, vr)
  179         struct vmetwo_softc *sc;
  180         int range;
  181         struct mvmebus_range *vr;
  182 {
  183         u_int32_t start, end, attr;
  184         u_int32_t reg;
  185 
  186         /*
  187          * First, check if the range is actually enabled...
  188          */
  189         reg = vme2_lcsr_read(sc, VME2LCSR_MASTER_ENABLE);
  190         if ((reg & VME2_MASTER_ENABLE(range)) == 0) {
  191                 vr->vr_am = MVMEBUS_AM_DISABLED;
  192                 return;
  193         }
  194 
  195         /*
  196          * Fetch and record the range's attributes
  197          */
  198         attr = vme2_lcsr_read(sc, VME2LCSR_MASTER_ATTR);
  199         attr >>= VME2_MASTER_ATTR_AM_SHIFT(range);
  200 
  201         /*
  202          * Fix up the datasizes available through this range
  203          */
  204         vr->vr_datasize = VME_D32 | VME_D16;
  205         if (attr & VME2_MASTER_ATTR_D16)
  206                 vr->vr_datasize &= ~VME_D32;
  207         attr &= VME2_MASTER_ATTR_AM_MASK;
  208 
  209         vr->vr_am = (attr & VME_AM_ADRSIZEMASK) | MVMEBUS_AM2CAP(attr);
  210         switch (vr->vr_am & VME_AM_ADRSIZEMASK) {
  211         case VME_AM_A32:
  212         default:
  213                 vr->vr_mask = 0xffffffffu;
  214                 break;
  215 
  216         case VME_AM_A24:
  217                 vr->vr_mask = 0x00ffffffu;
  218                 break;
  219 
  220         case VME_AM_A16:
  221                 vr->vr_mask = 0x0000ffffu;
  222                 break;
  223         }
  224 
  225         /*
  226          * XXX
  227          * It would be nice if users of the MI VMEbus code could pass down
  228          * whether they can tolerate Write-Posting to their device(s).
  229          * XXX
  230          */
  231 
  232         /*
  233          * Fetch the local-bus start and end addresses for the range
  234          */
  235         reg = vme2_lcsr_read(sc, VME2LCSR_MASTER_ADDRESS(range));
  236         start = (reg & VME2_MAST_ADDRESS_START_MASK);
  237         start <<= VME2_MAST_ADDRESS_START_SHIFT;
  238         vr->vr_locstart = start & ~vr->vr_mask;
  239         end = (reg & VME2_MAST_ADDRESS_END_MASK);
  240         end <<= VME2_MAST_ADDRESS_END_SHIFT;
  241         end |= 0xffffu;
  242         end += 1;
  243 
  244         /*
  245          * Local->VMEbus map '4' has optional translation bits, so
  246          * the VMEbus start and end addresses may need to be adjusted.
  247          */
  248         if (range == 3 && (reg = vme2_lcsr_read(sc, VME2LCSR_MAST4_TRANS))!=0) {
  249                 uint32_t addr, sel, len = end - start;
  250 
  251                 reg = vme2_lcsr_read(sc, VME2LCSR_MAST4_TRANS);
  252                 reg &= VME2_MAST4_TRANS_SELECT_MASK;
  253                 sel = reg << VME2_MAST4_TRANS_SELECT_SHIFT;
  254 
  255                 reg = vme2_lcsr_read(sc, VME2LCSR_MAST4_TRANS);
  256                 reg &= VME2_MAST4_TRANS_ADDRESS_MASK;
  257                 addr = reg << VME2_MAST4_TRANS_ADDRESS_SHIFT;
  258 
  259                 start = (addr & sel) | (start & (~sel));
  260                 end = start + len;
  261                 vr->vr_mask &= len - 1;
  262         }
  263 
  264         /* XXX Deal with overlap of onboard RAM address space */
  265         /* XXX Then again, 167-Bug warns about this at setup time ... */
  266 
  267         /*
  268          * Fixup the addresses this range corresponds to
  269          */
  270         vr->vr_vmestart = start & vr->vr_mask;
  271         vr->vr_vmeend = (end - 1) & vr->vr_mask;
  272 }
  273 
  274 void
  275 vmetwo_slave_range(sc, range, am, vr)
  276         struct vmetwo_softc *sc;
  277         int range;
  278         vme_am_t am;
  279         struct mvmebus_range *vr;
  280 {
  281         u_int32_t reg;
  282 
  283         /*
  284          * First, check if the range is actually enabled.
  285          * Note that bit 1 of `range' is used to indicte if we're
  286          * looking for an A24 range (set) or an A32 range (clear).
  287          */
  288         reg = vme2_lcsr_read(sc, VME2LCSR_SLAVE_CTRL);
  289 
  290         if (am == VME_AM_A32 && (reg & VME2_SLAVE_AMSEL_A32(range))) {
  291                 vr->vr_am = VME_AM_A32;
  292                 vr->vr_mask = 0xffffffffu;
  293         } else
  294         if (am == VME_AM_A24 && (reg & VME2_SLAVE_AMSEL_A24(range))) {
  295                 vr->vr_am = VME_AM_A24;
  296                 vr->vr_mask = 0x00ffffffu;
  297         } else {
  298                 /* The range is not enabled */
  299                 vr->vr_am = MVMEBUS_AM_DISABLED;
  300                 return;
  301         }
  302 
  303         if ((reg & VME2_SLAVE_AMSEL_DAT(range)) != 0)
  304                 vr->vr_am |= MVMEBUS_AM_CAP_DATA;
  305 
  306         if ((reg & VME2_SLAVE_AMSEL_PGM(range)) != 0)
  307                 vr->vr_am |= MVMEBUS_AM_CAP_PROG;
  308 
  309         if ((reg & VME2_SLAVE_AMSEL_USR(range)) != 0)
  310                 vr->vr_am |= MVMEBUS_AM_CAP_USER;
  311 
  312         if ((reg & VME2_SLAVE_AMSEL_SUP(range)) != 0)
  313                 vr->vr_am |= MVMEBUS_AM_CAP_SUPER;
  314 
  315         if ((reg & VME2_SLAVE_AMSEL_BLK(range)) != 0)
  316                 vr->vr_am |= MVMEBUS_AM_CAP_BLK;
  317 
  318         if ((reg & VME2_SLAVE_AMSEL_BLKD64(range)) != 0)
  319                 vr->vr_am |= MVMEBUS_AM_CAP_BLKD64;
  320 
  321         vr->vr_datasize = VME_D32 | VME_D16 | VME_D8;
  322 
  323         /*
  324          * Record the VMEbus start and end addresses of the slave image
  325          */
  326         reg = vme2_lcsr_read(sc, VME2LCSR_SLAVE_ADDRESS(range));
  327         vr->vr_vmestart = reg & VME2_SLAVE_ADDRESS_START_MASK;
  328         vr->vr_vmestart <<= VME2_SLAVE_ADDRESS_START_SHIFT;
  329         vr->vr_vmestart &= vr->vr_mask;
  330         vr->vr_vmeend = reg & VME2_SLAVE_ADDRESS_END_MASK;
  331         vr->vr_vmeend <<= VME2_SLAVE_ADDRESS_END_SHIFT;
  332         vr->vr_vmeend &= vr->vr_mask;
  333         vr->vr_vmeend |= 0xffffu;
  334 
  335         /*
  336          * Now figure out the local-bus address
  337          */
  338         reg = vme2_lcsr_read(sc, VME2LCSR_SLAVE_CTRL);
  339         if ((reg & VME2_SLAVE_CTRL_ADDER(range)) != 0) {
  340                 reg = vme2_lcsr_read(sc, VME2LCSR_SLAVE_TRANS(range));
  341                 reg &= VME2_SLAVE_TRANS_ADDRESS_MASK;
  342                 reg <<= VME2_SLAVE_TRANS_ADDRESS_SHIFT;
  343                 vr->vr_locstart = vr->vr_vmestart + reg;
  344         } else {
  345                 u_int32_t sel, addr;
  346 
  347                 reg = vme2_lcsr_read(sc, VME2LCSR_SLAVE_TRANS(range));
  348                 sel = reg & VME2_SLAVE_TRANS_SELECT_MASK;
  349                 sel <<= VME2_SLAVE_TRANS_SELECT_SHIFT;
  350                 addr = reg & VME2_SLAVE_TRANS_ADDRESS_MASK;
  351                 addr <<= VME2_SLAVE_TRANS_ADDRESS_SHIFT;
  352 
  353                 vr->vr_locstart = addr & sel;
  354                 vr->vr_locstart |= vr->vr_vmestart & (~sel);
  355         }
  356 }

Cache object: d70e80ad170a30cb466f733f79eb61e4


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