[BACK]Return to apci_subr.c CVS log [TXT][DIR] Up to [local] / sys / arch / hp300 / dev

Annotation of sys/arch/hp300/dev/apci_subr.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: apci_subr.c,v 1.1 2005/04/22 11:59:11 miod Exp $      */
        !             2:
        !             3: /*-
        !             4:  * Copyright (c) 1996, 1997, 1999 The NetBSD Foundation, Inc.
        !             5:  * All rights reserved.
        !             6:  *
        !             7:  * This code is derived from software contributed to The NetBSD Foundation
        !             8:  * by Jason R. Thorpe.
        !             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:  * Copyright (c) 1997 Michael Smith.  All rights reserved.
        !            41:  * Copyright (c) 1982, 1986, 1990, 1993
        !            42:  *     The Regents of the University of California.  All rights reserved.
        !            43:  *
        !            44:  * Redistribution and use in source and binary forms, with or without
        !            45:  * modification, are permitted provided that the following conditions
        !            46:  * are met:
        !            47:  * 1. Redistributions of source code must retain the above copyright
        !            48:  *    notice, this list of conditions and the following disclaimer.
        !            49:  * 2. Redistributions in binary form must reproduce the above copyright
        !            50:  *    notice, this list of conditions and the following disclaimer in the
        !            51:  *    documentation and/or other materials provided with the distribution.
        !            52:  * 3. Neither the name of the University nor the names of its contributors
        !            53:  *    may be used to endorse or promote products derived from this software
        !            54:  *    without specific prior written permission.
        !            55:  *
        !            56:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            57:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            58:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            59:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            60:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            61:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            62:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            63:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            64:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            65:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            66:  * SUCH DAMAGE.
        !            67:  *
        !            68:  *      @(#)dca.c       8.2 (Berkeley) 1/12/94
        !            69:  */
        !            70:
        !            71: /*
        !            72:  * Routines shared by the apci and dnkbd drivers.
        !            73:  */
        !            74:
        !            75: #include <sys/param.h>
        !            76: #include <sys/systm.h>
        !            77: #include <sys/tty.h>
        !            78: #include <sys/kernel.h>
        !            79:
        !            80: #include <hp300/dev/apcireg.h>
        !            81: #include <hp300/dev/apcivar.h>
        !            82: #include <hp300/dev/dcareg.h>
        !            83:
        !            84: const struct speedtab apcispeedtab[] = {
        !            85:        { 0,            0               },
        !            86:        { 50,           APCIBRD(50)     },
        !            87:        { 75,           APCIBRD(75)     },
        !            88:        { 110,          APCIBRD(110)    },
        !            89:        { 134,          APCIBRD(134)    },
        !            90:        { 150,          APCIBRD(150)    },
        !            91:        { 200,          APCIBRD(200)    },
        !            92:        { 300,          APCIBRD(300)    },
        !            93:        { 600,          APCIBRD(600)    },
        !            94:        { 1200,         APCIBRD(1200)   },
        !            95:        { 1800,         APCIBRD(1800)   },
        !            96:        { 2400,         APCIBRD(2400)   },
        !            97:        { 4800,         APCIBRD(4800)   },
        !            98:        { 9600,         APCIBRD(9600)   },
        !            99:        { 19200,        APCIBRD(19200)  },
        !           100:        { 38400,        APCIBRD(38400)  },
        !           101:        { -1,           -1              },
        !           102: };
        !           103:
        !           104: int
        !           105: apciinit(struct apciregs *apci, u_int16_t rate, u_int16_t cfcr)
        !           106: {
        !           107:        int s, stat;
        !           108:
        !           109:        s = splhigh();
        !           110:
        !           111:        rate = ttspeedtab(rate, apcispeedtab);
        !           112:
        !           113:        apci->ap_cfcr = CFCR_DLAB;
        !           114:        apci->ap_data = rate & 0xff;
        !           115:        apci->ap_ier = (rate >> 8) & 0xff;
        !           116:        apci->ap_cfcr = cfcr;
        !           117:        apci->ap_ier = IER_ERXRDY | IER_ETXRDY;
        !           118:        apci->ap_fifo =
        !           119:            FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_1;
        !           120:        apci->ap_mcr = MCR_DTR | MCR_RTS;
        !           121:        delay(100);
        !           122:        stat = apci->ap_iir;
        !           123:        splx(s);
        !           124:
        !           125:        return (stat);
        !           126: }

CVSweb