Home | History | Annotate | Line # | Download | only in pnpbios
com_pnpbios.c revision 1.5.2.2
      1  1.5.2.2  lukem /* $NetBSD: com_pnpbios.c,v 1.5.2.2 2001/11/15 07:03:36 lukem Exp $ */
      2  1.5.2.2  lukem /*
      3  1.5.2.2  lukem  * Copyright (c) 1999
      4  1.5.2.2  lukem  * 	Matthias Drochner.  All rights reserved.
      5  1.5.2.2  lukem  *
      6  1.5.2.2  lukem  * Redistribution and use in source and binary forms, with or without
      7  1.5.2.2  lukem  * modification, are permitted provided that the following conditions
      8  1.5.2.2  lukem  * are met:
      9  1.5.2.2  lukem  * 1. Redistributions of source code must retain the above copyright
     10  1.5.2.2  lukem  *    notice, this list of conditions, and the following disclaimer.
     11  1.5.2.2  lukem  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.5.2.2  lukem  *    notice, this list of conditions and the following disclaimer in the
     13  1.5.2.2  lukem  *    documentation and/or other materials provided with the distribution.
     14  1.5.2.2  lukem  *
     15  1.5.2.2  lukem  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     16  1.5.2.2  lukem  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     17  1.5.2.2  lukem  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     18  1.5.2.2  lukem  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19  1.5.2.2  lukem  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20  1.5.2.2  lukem  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     21  1.5.2.2  lukem  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  1.5.2.2  lukem  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23  1.5.2.2  lukem  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24  1.5.2.2  lukem  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25  1.5.2.2  lukem  * SUCH DAMAGE.
     26  1.5.2.2  lukem  */
     27  1.5.2.2  lukem 
     28  1.5.2.2  lukem #include <sys/cdefs.h>
     29  1.5.2.2  lukem __KERNEL_RCSID(0, "$NetBSD: com_pnpbios.c,v 1.5.2.2 2001/11/15 07:03:36 lukem Exp $");
     30  1.5.2.2  lukem 
     31  1.5.2.2  lukem #include <sys/param.h>
     32  1.5.2.2  lukem #include <sys/systm.h>
     33  1.5.2.2  lukem #include <sys/errno.h>
     34  1.5.2.2  lukem #include <sys/ioctl.h>
     35  1.5.2.2  lukem #include <sys/syslog.h>
     36  1.5.2.2  lukem #include <sys/device.h>
     37  1.5.2.2  lukem #include <sys/proc.h>
     38  1.5.2.2  lukem #include <sys/termios.h>
     39  1.5.2.2  lukem 
     40  1.5.2.2  lukem #include <machine/bus.h>
     41  1.5.2.2  lukem 
     42  1.5.2.2  lukem #include <dev/isa/isavar.h>
     43  1.5.2.2  lukem #include <dev/isa/isadmavar.h>
     44  1.5.2.2  lukem 
     45  1.5.2.2  lukem #include <i386/pnpbios/pnpbiosvar.h>
     46  1.5.2.2  lukem 
     47  1.5.2.2  lukem #include <dev/ic/comvar.h>
     48  1.5.2.2  lukem 
     49  1.5.2.2  lukem struct com_pnpbios_softc {
     50  1.5.2.2  lukem 	struct	com_softc sc_com;
     51  1.5.2.2  lukem 	void	*sc_ih;
     52  1.5.2.2  lukem };
     53  1.5.2.2  lukem 
     54  1.5.2.2  lukem int com_pnpbios_match __P((struct device *, struct cfdata *, void *));
     55  1.5.2.2  lukem void com_pnpbios_attach __P((struct device *, struct device *, void *));
     56  1.5.2.2  lukem 
     57  1.5.2.2  lukem struct cfattach com_pnpbios_ca = {
     58  1.5.2.2  lukem 	sizeof(struct com_pnpbios_softc), com_pnpbios_match, com_pnpbios_attach
     59  1.5.2.2  lukem };
     60  1.5.2.2  lukem 
     61  1.5.2.2  lukem int
     62  1.5.2.2  lukem com_pnpbios_match(parent, match, aux)
     63  1.5.2.2  lukem 	struct device *parent;
     64  1.5.2.2  lukem 	struct cfdata *match;
     65  1.5.2.2  lukem 	void *aux;
     66  1.5.2.2  lukem {
     67  1.5.2.2  lukem 	struct pnpbiosdev_attach_args *aa = aux;
     68  1.5.2.2  lukem 
     69  1.5.2.2  lukem 	if (strcmp(aa->idstr, "PNP0500") &&
     70  1.5.2.2  lukem 	    strcmp(aa->idstr, "PNP0501") &&
     71  1.5.2.2  lukem 	    strcmp(aa->idstr, "PNP0510") &&
     72  1.5.2.2  lukem 	    strcmp(aa->idstr, "PNP0511"))
     73  1.5.2.2  lukem 		return (0);
     74  1.5.2.2  lukem 
     75  1.5.2.2  lukem 	return (1);
     76  1.5.2.2  lukem }
     77  1.5.2.2  lukem 
     78  1.5.2.2  lukem void
     79  1.5.2.2  lukem com_pnpbios_attach(parent, self, aux)
     80  1.5.2.2  lukem 	struct device *parent, *self;
     81  1.5.2.2  lukem 	void *aux;
     82  1.5.2.2  lukem {
     83  1.5.2.2  lukem 	struct com_pnpbios_softc *psc = (void *)self;
     84  1.5.2.2  lukem 	struct com_softc *sc = &psc->sc_com;
     85  1.5.2.2  lukem 	struct pnpbiosdev_attach_args *aa = aux;
     86  1.5.2.2  lukem 	bus_space_tag_t iot;
     87  1.5.2.2  lukem 	int iobase;
     88  1.5.2.2  lukem 
     89  1.5.2.2  lukem 	if (pnpbios_getiobase(aa->pbt, aa->resc, 0, &iot, &iobase)) {
     90  1.5.2.2  lukem 		printf(": can't get iobase\n");
     91  1.5.2.2  lukem 		return;
     92  1.5.2.2  lukem 	}
     93  1.5.2.2  lukem 
     94  1.5.2.2  lukem 	if (com_is_console(iot, iobase, &sc->sc_ioh))
     95  1.5.2.2  lukem 		sc->sc_iot = iot;
     96  1.5.2.2  lukem 	else if (pnpbios_io_map(aa->pbt, aa->resc, 0,
     97  1.5.2.2  lukem 				&sc->sc_iot, &sc->sc_ioh)) {
     98  1.5.2.2  lukem 		printf(": can't map i/o space\n");
     99  1.5.2.2  lukem 		return;
    100  1.5.2.2  lukem 	}
    101  1.5.2.2  lukem 	sc->sc_iobase = iobase;
    102  1.5.2.2  lukem 
    103  1.5.2.2  lukem 	printf("\n");
    104  1.5.2.2  lukem 	pnpbios_print_devres(self, aa);
    105  1.5.2.2  lukem 
    106  1.5.2.2  lukem 	printf("%s", self->dv_xname);
    107  1.5.2.2  lukem 
    108  1.5.2.2  lukem 	/*
    109  1.5.2.2  lukem 	 * if the chip isn't something we recognise skip it.
    110  1.5.2.2  lukem 	 */
    111  1.5.2.2  lukem 	if (comprobe1(sc->sc_iot, sc->sc_ioh) == 0) {
    112  1.5.2.2  lukem 		printf(": com probe failed\n");
    113  1.5.2.2  lukem 		return;
    114  1.5.2.2  lukem 	}
    115  1.5.2.2  lukem 
    116  1.5.2.2  lukem 	sc->sc_frequency = 115200 * 16;
    117  1.5.2.2  lukem 
    118  1.5.2.2  lukem 	com_attach_subr(sc);
    119  1.5.2.2  lukem 
    120  1.5.2.2  lukem 	psc->sc_ih = pnpbios_intr_establish(aa->pbt, aa->resc, 0, IPL_SERIAL,
    121  1.5.2.2  lukem 					    comintr, sc);
    122  1.5.2.2  lukem }
    123