[BACK]Return to com_lbus.c CVS log [TXT][DIR] Up to [local] / sys / arch / sgi / localbus

Annotation of sys/arch/sgi/localbus/com_lbus.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: com_lbus.c,v 1.4 2004/10/20 12:49:15 pefo Exp $ */
                      2:
                      3: /*
                      4:  * Copyright (c) 2001-2004 Opsycon AB  (www.opsycon.se / www.opsycon.com)
                      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:  *
                     15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
                     16:  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     18:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
                     19:  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     20:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     21:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     22:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     23:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     24:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     25:  * SUCH DAMAGE.
                     26:  *
                     27:  */
                     28:
                     29: #include <sys/param.h>
                     30: #include <sys/systm.h>
                     31: #include <sys/device.h>
                     32: #include <sys/tty.h>
                     33:
                     34: #include <machine/autoconf.h>
                     35: #include <mips64/archtype.h>
                     36: #include <machine/bus.h>
                     37: #include <machine/intr.h>
                     38:
                     39: #include <dev/ic/comreg.h>
                     40: #include <dev/ic/comvar.h>
                     41: #include <dev/ic/ns16550reg.h>
                     42:
                     43: int    com_localbus_probe(struct device *, void *, void *);
                     44: void   com_localbus_attach(struct device *, struct device *, void *);
                     45:
                     46:
                     47: struct cfattach com_localbus_ca = {
                     48:        sizeof(struct com_softc), com_localbus_probe, com_localbus_attach
                     49: };
                     50:
                     51: struct cfattach com_xbow_ca = {
                     52:        sizeof(struct com_softc), com_localbus_probe, com_localbus_attach
                     53: };
                     54:
                     55: extern void com_raisedtr(void *);
                     56: extern struct timeout compoll_to;
                     57:
                     58: int
                     59: com_localbus_probe(parent, match, aux)
                     60:        struct device *parent;
                     61:        void *match, *aux;
                     62: {
                     63:        bus_space_tag_t iot;
                     64:        bus_space_handle_t ioh;
                     65:        struct cfdata *cf = match;
                     66:        struct confargs *ca = aux;
                     67:        bus_addr_t iobase, rv = 0;
                     68:
                     69:        /*
                     70:         *  Check if this is our com. If low nibble is 0 match
                     71:         *  against system CLASS. Else a perfect match is checked.
                     72:         */
                     73:        if ((ca->ca_sys & 0x000f) == 0) {
                     74:                if (ca->ca_sys != (sys_config.system_type & 0xfff0))
                     75:                        return 0;
                     76:        } else if (ca->ca_sys != sys_config.system_type)
                     77:                return 0;
                     78:
                     79:        iobase = (bus_addr_t)sys_config.cons_ioaddr[cf->cf_unit];
                     80:        if (iobase) {
                     81:                iot = sys_config.cons_iot;
                     82:                /* if it's in use as console, it's there. */
                     83:                if (!(iobase == comconsaddr && !comconsattached)) {
                     84:                        bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh);
                     85:                        rv = comprobe1(iot, ioh);
                     86:                } else {
                     87:                        rv = 1;
                     88:                }
                     89:        }
                     90:        return (rv);
                     91: }
                     92:
                     93: void
                     94: com_localbus_attach(parent, self, aux)
                     95:        struct device *parent, *self;
                     96:        void *aux;
                     97: {
                     98:        struct com_softc *sc = (void *)self;
                     99:        int intr;
                    100:        bus_addr_t iobase;
                    101:        bus_space_handle_t ioh;
                    102:        struct confargs *ca = aux;
                    103:
                    104:        sc->sc_hwflags = 0;
                    105:        sc->sc_swflags = 0;
                    106:        iobase = (bus_addr_t)sys_config.cons_ioaddr[sc->sc_dev.dv_unit];
                    107:        intr = ca->ca_intr;
                    108:        sc->sc_iobase = iobase;
                    109:        sc->sc_frequency = sys_config.cons_baudclk;
                    110:
                    111:        sc->sc_iot = sys_config.cons_iot;
                    112:
                    113:        /* if it's in use as console, it's there. */
                    114:        if (!(iobase == comconsaddr && !comconsattached)) {
                    115:                if (bus_space_map(sc->sc_iot, iobase, COM_NPORTS, 0, &ioh)) {
                    116:                        panic("unexpected bus_space_map failure");
                    117:                }
                    118:        }
                    119:        else {
                    120:                ioh = comconsioh;
                    121:        }
                    122:
                    123:        sc->sc_ioh = ioh;
                    124:
                    125:        com_attach_subr(sc);
                    126:
                    127:        /* Enable IE pin. Some boards are not edge sensitive */
                    128:        SET(sc->sc_mcr, MCR_IENABLE);
                    129:        bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_mcr, sc->sc_mcr);
                    130:
                    131:        BUS_INTR_ESTABLISH(ca, NULL, intr, IST_EDGE, IPL_TTY,
                    132:                                comintr, (void *)sc, sc->sc_dev.dv_xname);
                    133:
                    134: }

CVSweb