Home | History | Annotate | Line # | Download | only in jazz
com_jazzio.c revision 1.3
      1 /*	$NetBSD: com_jazzio.c,v 1.3 2002/10/02 04:59:48 thorpej Exp $	*/
      2 /*	$OpenBSD: com_lbus.c,v 1.7 1998/03/16 09:38:41 pefo Exp $	*/
      3 /*	NetBSD: com_isa.c,v 1.12 1998/08/15 17:47:17 mycroft Exp 	*/
      4 
      5 /*-
      6  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      7  * All rights reserved.
      8  *
      9  * This code is derived from software contributed to The NetBSD Foundation
     10  * by Charles M. Hannum.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  *        This product includes software developed by the NetBSD
     23  *        Foundation, Inc. and its contributors.
     24  * 4. Neither the name of The NetBSD Foundation nor the names of its
     25  *    contributors may be used to endorse or promote products derived
     26  *    from this software without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     29  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     31  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     32  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     33  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     36  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     37  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     38  * POSSIBILITY OF SUCH DAMAGE.
     39  */
     40 
     41 /*-
     42  * Copyright (c) 1991 The Regents of the University of California.
     43  * All rights reserved.
     44  *
     45  * Redistribution and use in source and binary forms, with or without
     46  * modification, are permitted provided that the following conditions
     47  * are met:
     48  * 1. Redistributions of source code must retain the above copyright
     49  *    notice, this list of conditions and the following disclaimer.
     50  * 2. Redistributions in binary form must reproduce the above copyright
     51  *    notice, this list of conditions and the following disclaimer in the
     52  *    documentation and/or other materials provided with the distribution.
     53  * 3. All advertising materials mentioning features or use of this software
     54  *    must display the following acknowledgement:
     55  *	This product includes software developed by the University of
     56  *	California, Berkeley and its contributors.
     57  * 4. Neither the name of the University nor the names of its contributors
     58  *    may be used to endorse or promote products derived from this software
     59  *    without specific prior written permission.
     60  *
     61  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     62  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     63  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     64  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     65  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     66  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     67  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     68  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     69  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     70  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     71  * SUCH DAMAGE.
     72  *
     73  *	@(#)com.c	7.5 (Berkeley) 5/16/91
     74  */
     75 
     76 #include <sys/param.h>
     77 #include <sys/systm.h>
     78 #include <sys/device.h>
     79 #include <sys/tty.h>
     80 
     81 #include <machine/autoconf.h>
     82 #include <machine/bus.h>
     83 #include <machine/intr.h>
     84 
     85 #include <arc/jazz/jazziovar.h>
     86 
     87 #include <dev/isa/isavar.h>	/* XXX for isa_chipset_tag_t in com_softc */
     88 
     89 #include <dev/ic/comreg.h>
     90 #include <dev/ic/comvar.h>
     91 #include <dev/ic/ns16550reg.h>
     92 
     93 extern int com_freq;
     94 
     95 int	com_jazzio_probe __P((struct device *, struct cfdata *, void *));
     96 void	com_jazzio_attach __P((struct device *, struct device *, void *));
     97 
     98 CFATTACH_DECL(com_jazzio, sizeof(struct com_softc),
     99     com_jazzio_probe, com_jazzio_attach, NULL, NULL);
    100 
    101 int
    102 com_jazzio_probe(parent, match, aux)
    103 	struct device *parent;
    104 	struct cfdata *match;
    105 	void *aux;
    106 {
    107 	struct jazzio_attach_args *ja = aux;
    108 	bus_space_tag_t iot;
    109 	bus_space_handle_t ioh;
    110 	int iobase;
    111 	int rv = 1;
    112 
    113 	if(strcmp(ja->ja_name, "com") != 0)
    114 		return (0);
    115 
    116 	iot = ja->ja_bust;
    117 	iobase = ja->ja_addr;
    118 
    119 	/* if it's in use as console, it's there. */
    120 	if (!com_is_console(iot, iobase, 0)) {
    121 		if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) {
    122 			return 0;
    123 		}
    124 		rv = comprobe1(iot, ioh);
    125 		bus_space_unmap(iot, ioh, COM_NPORTS);
    126 	}
    127 	return (rv);
    128 }
    129 
    130 void
    131 com_jazzio_attach(parent, self, aux)
    132 	struct device *parent, *self;
    133 	void *aux;
    134 {
    135 	struct jazzio_attach_args *ja = aux;
    136 	struct com_softc *sc = (void *)self;
    137 	int iobase;
    138 	bus_space_tag_t iot;
    139 
    140 	sc->sc_iobase = iobase = ja->ja_addr;
    141 	sc->sc_iot = iot = ja->ja_bust;
    142 
    143 	if (!com_is_console(iot, iobase, &sc->sc_ioh) &&
    144 	    bus_space_map(iot, iobase, COM_NPORTS, 0, &sc->sc_ioh)) {
    145 		printf(": can't map i/o space\n");
    146 		return;
    147 	}
    148 
    149 	sc->sc_frequency = com_freq;
    150 	SET(sc->sc_hwflags, COM_HW_TXFIFO_DISABLE); /* XXX - NEC M403 */
    151 	jazzio_intr_establish(ja->ja_intr, comintr, sc);
    152 
    153 	com_attach_subr(sc);
    154 }
    155