root/dev/puc/com_puc.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. com_puc_match
  2. com_puc_attach
  3. com_puc_detach

    1 /*      $OpenBSD: com_puc.c,v 1.14 2006/11/05 17:18:14 martin Exp $     */
    2 
    3 /*
    4  * Copyright (c) 1997 - 1999, Jason Downs.  All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 3. Neither the name(s) of the author(s) nor the name OpenBSD
   15  *    may be used to endorse or promote products derived from this software
   16  *    without specific prior written permission.
   17  *
   18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
   19  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   21  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
   22  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   24  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   25  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   28  * SUCH DAMAGE.
   29  */
   30 
   31 #include <sys/param.h>
   32 #include <sys/systm.h>
   33 #include <sys/ioctl.h>
   34 #include <sys/selinfo.h>
   35 #include <sys/tty.h>
   36 #include <sys/proc.h>
   37 #include <sys/user.h>
   38 #include <sys/conf.h>
   39 #include <sys/file.h>
   40 #include <sys/uio.h>
   41 #include <sys/kernel.h>
   42 #include <sys/syslog.h>
   43 #include <sys/device.h>
   44 
   45 #include <machine/intr.h>
   46 #include <machine/bus.h>
   47 
   48 #include <dev/pci/pucvar.h>
   49 
   50 #include "com.h"
   51 #ifdef i386
   52 #include "pccom.h"
   53 #endif
   54 
   55 #include <dev/ic/comreg.h>
   56 #if NPCCOM > 0
   57 #include <i386/isa/pccomvar.h>
   58 #endif
   59 #if NCOM > 0
   60 #include <dev/ic/comvar.h>
   61 #endif
   62 #include <dev/ic/ns16550reg.h>
   63 
   64 #define com_lcr         com_cfcr
   65 
   66 int com_puc_match(struct device *, void *, void *);
   67 void com_puc_attach(struct device *, struct device *, void *);
   68 int com_puc_detach(struct device *, int );
   69 
   70 #if NCOM > 0
   71 struct cfattach com_puc_ca = {
   72         sizeof(struct com_softc), com_puc_match, com_puc_attach, com_puc_detach
   73 };
   74 #endif
   75 
   76 #if NPCCOM > 0
   77 struct cfattach pccom_puc_ca = {
   78         sizeof(struct com_softc), com_puc_match, com_puc_attach, com_puc_detach
   79 };
   80 #endif
   81 
   82 int
   83 com_puc_match(parent, match, aux)
   84         struct device *parent;
   85         void *match, *aux;
   86 {
   87         struct puc_attach_args *pa = aux;
   88 
   89         if (pa->type == PUC_PORT_TYPE_COM)
   90                 return(1);
   91 
   92         return(0);
   93 }
   94 
   95 void
   96 com_puc_attach(parent, self, aux)
   97         struct device *parent, *self;
   98         void *aux;
   99 {
  100         struct com_softc *sc = (void *)self;
  101         struct puc_attach_args *pa = aux;
  102         const char *intrstr;
  103 
  104         /* Grab a PCI interrupt. */
  105         intrstr = pa->intr_string(pa);
  106         sc->sc_ih = pa->intr_establish(pa, IPL_TTY, comintr, sc,
  107             sc->sc_dev.dv_xname);
  108         if (sc->sc_ih == NULL) {
  109                 printf(": couldn't establish interrupt");
  110                 if (intrstr != NULL)
  111                         printf(" at %s", intrstr);
  112                 printf("\n");
  113                 return;
  114         }
  115         printf(" %s", intrstr);
  116 
  117         sc->sc_iot = pa->t;
  118         sc->sc_ioh = pa->h;
  119         sc->sc_iobase = pa->a;
  120         sc->sc_frequency = COM_FREQ;
  121 
  122         if (pa->flags)
  123                 sc->sc_frequency = pa->flags & PUC_COM_CLOCKMASK;
  124         if (pa->hwtype)
  125                 sc->sc_uarttype = pa->hwtype;
  126 
  127         sc->sc_hwflags = 0;
  128         sc->sc_swflags = 0;
  129 
  130         com_attach_subr(sc);
  131 }
  132 
  133 int
  134 com_puc_detach(struct device *self, int flags)
  135 {
  136         /* struct com_softc *sc = (void *)self; */
  137         int error;
  138 
  139         if ((error = com_detach(self, flags)) != 0)
  140                 return (error);
  141 
  142         /* cardbus_intr_disestablish(psc->sc_cc, psc->sc_cf, csc->cc_ih); */
  143 
  144         return (0);
  145 }

/* [<][>][^][v][top][bottom][index][help] */