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/clmpcc_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: clmpcc_pcctwo.c,v 1.20 2014/03/25 15:52:16 christos 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  * Cirrus Logic CD2401 4-channel serial chip. PCCchip2 Front-end.
   34  */
   35 
   36 #include <sys/cdefs.h>
   37 __KERNEL_RCSID(0, "$NetBSD: clmpcc_pcctwo.c,v 1.20 2014/03/25 15:52:16 christos Exp $");
   38 
   39 #include <sys/param.h>
   40 #include <sys/systm.h>
   41 #include <sys/proc.h>
   42 #include <sys/device.h>
   43 #include <sys/conf.h>
   44 #include <sys/file.h>
   45 #include <sys/ioctl.h>
   46 #include <sys/tty.h>
   47 #include <sys/time.h>
   48 #include <sys/kernel.h>
   49 #include <sys/syslog.h>
   50 
   51 #include <dev/cons.h>
   52 
   53 #include <sys/cpu.h>
   54 #include <sys/bus.h>
   55 #include <sys/intr.h>
   56 
   57 #include <dev/ic/clmpccvar.h>
   58 
   59 #include <dev/mvme/pcctwovar.h>
   60 #include <dev/mvme/pcctworeg.h>
   61 
   62 /* XXXXSCW: Fixme */
   63 #ifdef MVME68K
   64 #include <mvme68k/dev/mainbus.h>
   65 #else
   66 #error Need consiack hook
   67 #endif
   68 
   69 
   70 /* Definition of the driver for autoconfig. */
   71 int clmpcc_pcctwo_match(device_t, cfdata_t, void *);
   72 void clmpcc_pcctwo_attach(device_t, device_t, void *);
   73 void clmpcc_pcctwo_iackhook(struct clmpcc_softc *, int);
   74 void clmpcc_pcctwo_consiackhook(struct clmpcc_softc *, int);
   75 
   76 CFATTACH_DECL_NEW(clmpcc_pcctwo, sizeof(struct clmpcc_softc),
   77     clmpcc_pcctwo_match, clmpcc_pcctwo_attach, NULL, NULL);
   78 
   79 extern struct cfdriver clmpcc_cd;
   80 
   81 extern const struct cdevsw clmpcc_cdevsw;
   82 
   83 /*
   84  * For clmpcccn*()
   85  */
   86 cons_decl(clmpcc);
   87 
   88 
   89 /*
   90  * Is the CD2401 chip present?
   91  */
   92 int
   93 clmpcc_pcctwo_match(device_t parent, cfdata_t cf, void *aux)
   94 {
   95         struct pcctwo_attach_args *pa;
   96 
   97         pa = aux;
   98 
   99         if (strcmp(pa->pa_name, clmpcc_cd.cd_name))
  100                 return (0);
  101 
  102         pa->pa_ipl = cf->pcctwocf_ipl;
  103 
  104         return (1);
  105 }
  106 
  107 /*
  108  * Attach a found CD2401.
  109  */
  110 void
  111 clmpcc_pcctwo_attach(device_t parent, device_t self, void *aux)
  112 {
  113         struct clmpcc_softc *sc;
  114         struct pcctwo_attach_args *pa = aux;
  115         int level = pa->pa_ipl;
  116 
  117         sc = device_private(self);
  118         sc->sc_dev = self;
  119         level = pa->pa_ipl;
  120         sc->sc_iot = pa->pa_bust;
  121         bus_space_map(pa->pa_bust, pa->pa_offset, 0x100, 0, &sc->sc_ioh);
  122 
  123         sc->sc_clk = 20000000;
  124         sc->sc_byteswap = CLMPCC_BYTESWAP_LOW;
  125         sc->sc_swaprtsdtr = 1;
  126         sc->sc_iackhook = clmpcc_pcctwo_iackhook;
  127         sc->sc_vector_base = PCCTWO_SCC_VECBASE;
  128         sc->sc_rpilr = 0x03;
  129         sc->sc_tpilr = 0x02;
  130         sc->sc_mpilr = 0x01;
  131         sc->sc_evcnt = pcctwointr_evcnt(level);
  132 
  133         /* Do common parts of CD2401 configuration. */
  134         clmpcc_attach(sc);
  135 
  136         /* Hook the interrupts */
  137         pcctwointr_establish(PCCTWOV_SCC_RX, clmpcc_rxintr, level, sc, NULL);
  138         pcctwointr_establish(PCCTWOV_SCC_RX_EXCEP, clmpcc_rxintr, level, sc,
  139             NULL);
  140         pcctwointr_establish(PCCTWOV_SCC_TX, clmpcc_txintr, level, sc, NULL);
  141         pcctwointr_establish(PCCTWOV_SCC_MODEM, clmpcc_mdintr, level, sc, NULL);
  142 }
  143 
  144 void
  145 clmpcc_pcctwo_iackhook(struct clmpcc_softc *sc, int which)
  146 {
  147         bus_size_t offset;
  148         volatile u_char foo;
  149 
  150         switch (which) {
  151         case CLMPCC_IACK_MODEM:
  152                 offset = PCC2REG_SCC_MODEM_PIACK;
  153                 break;
  154 
  155         case CLMPCC_IACK_RX:
  156                 offset = PCC2REG_SCC_RX_PIACK;
  157                 break;
  158 
  159         case CLMPCC_IACK_TX:
  160                 offset = PCC2REG_SCC_TX_PIACK;
  161                 break;
  162         default:
  163 #ifdef DEBUG
  164                 printf("%s: Invalid IACK number '%d'\n",
  165                     device_xname(sc->sc_dev), which);
  166 #endif
  167                 panic("clmpcc_pcctwo_iackhook %d", which);
  168         }
  169 
  170         foo = pcc2_reg_read(sys_pcctwo, offset);
  171         __USE(foo);
  172 }
  173 
  174 /*
  175  * This routine is only used prior to clmpcc_attach() being called
  176  */
  177 void
  178 clmpcc_pcctwo_consiackhook(struct clmpcc_softc *sc, int which)
  179 {
  180         bus_space_handle_t bush;
  181         bus_size_t offset;
  182         volatile u_char foo;
  183 
  184         switch (which) {
  185         case CLMPCC_IACK_MODEM:
  186                 offset = PCC2REG_SCC_MODEM_PIACK;
  187                 break;
  188 
  189         case CLMPCC_IACK_RX:
  190                 offset = PCC2REG_SCC_RX_PIACK;
  191                 break;
  192 
  193         case CLMPCC_IACK_TX:
  194                 offset = PCC2REG_SCC_TX_PIACK;
  195                 break;
  196         default:
  197 #ifdef DEBUG
  198                 printf("%s: Invalid IACK number '%d'\n",
  199                     device_xname(sc->sc_dev), which);
  200                 panic("clmpcc_pcctwo_consiackhook");
  201 #endif
  202                 panic("clmpcc_pcctwo_iackhook %d", which);
  203         }
  204 
  205 #ifdef MVME68K
  206         /*
  207          * We need to fake the tag and handle since 'sys_pcctwo' will
  208          * be NULL during early system startup...
  209          */
  210         bush = (bus_space_handle_t) & (intiobase[MAINBUS_PCCTWO_OFFSET +
  211                 PCCTWO_REG_OFF]);
  212 
  213         foo = bus_space_read_1(&_mainbus_space_tag, bush, offset);
  214         __USE(foo);
  215 #else
  216 #error Need consiack hook
  217 #endif
  218 }
  219 
  220 
  221 /****************************************************************
  222  * Console support functions (MVME PCCchip2 specific!)
  223  ****************************************************************/
  224 
  225 /*
  226  * Check for CD2401 console.
  227  */
  228 void
  229 clmpcccnprobe(struct consdev *cp)
  230 {
  231         int maj;
  232 
  233 #if defined(MVME68K)
  234         if (machineid != MVME_167 && machineid != MVME_177)
  235 #elif defined(MVME88K)
  236         if (machineid != MVME_187)
  237 #endif
  238         {
  239                 cp->cn_pri = CN_DEAD;
  240                 return;
  241         }
  242 
  243         /*
  244          * Locate the major number
  245          */
  246         maj = cdevsw_lookup_major(&clmpcc_cdevsw);
  247 
  248         /* Initialize required fields. */
  249         cp->cn_dev = makedev(maj, 0);
  250         cp->cn_pri = CN_NORMAL;
  251 }
  252 
  253 void
  254 clmpcccninit(struct consdev *cp)
  255 {
  256         static struct clmpcc_softc cons_sc;
  257 
  258         cons_sc.sc_iot = &_mainbus_space_tag;
  259         bus_space_map(&_mainbus_space_tag,
  260             intiobase_phys + MAINBUS_PCCTWO_OFFSET + PCCTWO_SCC_OFF,
  261             PCC2REG_SIZE, 0, &cons_sc.sc_ioh);
  262         cons_sc.sc_clk = 20000000;
  263         cons_sc.sc_byteswap = CLMPCC_BYTESWAP_LOW;
  264         cons_sc.sc_swaprtsdtr = 1;
  265         cons_sc.sc_iackhook = clmpcc_pcctwo_consiackhook;
  266         cons_sc.sc_vector_base = PCCTWO_SCC_VECBASE;
  267         cons_sc.sc_rpilr = 0x03;
  268         cons_sc.sc_tpilr = 0x02;
  269         cons_sc.sc_mpilr = 0x01;
  270 
  271         clmpcc_cnattach(&cons_sc, 0, 9600);
  272 }

Cache object: a961db00287d342fb2ed84a826eaddc7


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