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