Home | History | Annotate | Line # | Download | only in jazz
com_jazzio.c revision 1.8.16.1
      1  1.8.16.1  gdamore /*	$NetBSD: com_jazzio.c,v 1.8.16.1 2006/06/15 20:49:23 gdamore 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.6      agc  * 3. Neither the name of the University nor the names of its contributors
     54       1.1       ur  *    may be used to endorse or promote products derived from this software
     55       1.1       ur  *    without specific prior written permission.
     56       1.1       ur  *
     57       1.1       ur  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     58       1.1       ur  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     59       1.1       ur  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     60       1.1       ur  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     61       1.1       ur  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     62       1.1       ur  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     63       1.1       ur  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     64       1.1       ur  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     65       1.1       ur  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     66       1.1       ur  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     67       1.1       ur  * SUCH DAMAGE.
     68       1.1       ur  *
     69       1.1       ur  *	@(#)com.c	7.5 (Berkeley) 5/16/91
     70       1.1       ur  */
     71       1.5    lukem 
     72       1.5    lukem #include <sys/cdefs.h>
     73  1.8.16.1  gdamore __KERNEL_RCSID(0, "$NetBSD: com_jazzio.c,v 1.8.16.1 2006/06/15 20:49:23 gdamore Exp $");
     74       1.1       ur 
     75       1.1       ur #include <sys/param.h>
     76       1.1       ur #include <sys/systm.h>
     77       1.1       ur #include <sys/device.h>
     78       1.1       ur #include <sys/tty.h>
     79       1.1       ur 
     80       1.1       ur #include <machine/autoconf.h>
     81       1.1       ur #include <machine/bus.h>
     82       1.1       ur #include <machine/intr.h>
     83       1.1       ur 
     84       1.1       ur #include <arc/jazz/jazziovar.h>
     85       1.1       ur 
     86       1.1       ur #include <dev/isa/isavar.h>	/* XXX for isa_chipset_tag_t in com_softc */
     87       1.1       ur 
     88       1.1       ur #include <dev/ic/comreg.h>
     89       1.1       ur #include <dev/ic/comvar.h>
     90       1.1       ur #include <dev/ic/ns16550reg.h>
     91       1.1       ur 
     92       1.1       ur extern int com_freq;
     93       1.1       ur 
     94       1.7  tsutsui int	com_jazzio_probe(struct device *, struct cfdata *, void *);
     95       1.7  tsutsui void	com_jazzio_attach(struct device *, struct device *, void *);
     96       1.1       ur 
     97       1.3  thorpej CFATTACH_DECL(com_jazzio, sizeof(struct com_softc),
     98       1.3  thorpej     com_jazzio_probe, com_jazzio_attach, NULL, NULL);
     99       1.1       ur 
    100       1.1       ur int
    101       1.7  tsutsui com_jazzio_probe(struct device *parent, struct cfdata *match, void *aux)
    102       1.1       ur {
    103       1.1       ur 	struct jazzio_attach_args *ja = aux;
    104       1.1       ur 	bus_space_tag_t iot;
    105       1.1       ur 	bus_space_handle_t ioh;
    106       1.1       ur 	int iobase;
    107       1.1       ur 	int rv = 1;
    108       1.1       ur 
    109       1.4  tsutsui 	if (strcmp(ja->ja_name, "COM1") != 0 &&
    110       1.4  tsutsui 	    strcmp(ja->ja_name, "COM2") != 0)
    111       1.7  tsutsui 		return 0;
    112       1.1       ur 
    113       1.1       ur 	iot = ja->ja_bust;
    114       1.1       ur 	iobase = ja->ja_addr;
    115       1.1       ur 
    116       1.1       ur 	/* if it's in use as console, it's there. */
    117       1.1       ur 	if (!com_is_console(iot, iobase, 0)) {
    118       1.1       ur 		if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) {
    119       1.1       ur 			return 0;
    120       1.1       ur 		}
    121       1.1       ur 		rv = comprobe1(iot, ioh);
    122       1.1       ur 		bus_space_unmap(iot, ioh, COM_NPORTS);
    123       1.1       ur 	}
    124       1.7  tsutsui 	return rv;
    125       1.1       ur }
    126       1.1       ur 
    127       1.1       ur void
    128       1.7  tsutsui com_jazzio_attach(struct device *parent, struct device *self, void *aux)
    129       1.1       ur {
    130       1.1       ur 	struct jazzio_attach_args *ja = aux;
    131       1.1       ur 	struct com_softc *sc = (void *)self;
    132       1.1       ur 	int iobase;
    133       1.1       ur 	bus_space_tag_t iot;
    134  1.8.16.1  gdamore 	bus_space_handle_t ioh;
    135       1.1       ur 
    136  1.8.16.1  gdamore 	iobase = ja->ja_addr;
    137  1.8.16.1  gdamore 	iot = ja->ja_bust;
    138       1.1       ur 
    139  1.8.16.1  gdamore 	if (!com_is_console(iot, iobase, &ioh) &&
    140  1.8.16.1  gdamore 	    bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) {
    141       1.1       ur 		printf(": can't map i/o space\n");
    142       1.1       ur 		return;
    143       1.1       ur 	}
    144  1.8.16.1  gdamore 	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);
    145       1.1       ur 	sc->sc_frequency = com_freq;
    146       1.1       ur 	SET(sc->sc_hwflags, COM_HW_TXFIFO_DISABLE); /* XXX - NEC M403 */
    147       1.1       ur 	jazzio_intr_establish(ja->ja_intr, comintr, sc);
    148       1.1       ur 
    149       1.1       ur 	com_attach_subr(sc);
    150       1.1       ur }
    151