Home | History | Annotate | Line # | Download | only in mace
lpt_mace.c revision 1.4
      1  1.4  tsutsui /*	$NetBSD: lpt_mace.c,v 1.4 2004/07/12 13:45:40 tsutsui Exp $	*/
      2  1.1   sekiya 
      3  1.1   sekiya /*
      4  1.1   sekiya  * Copyright (c) 2003 Christopher SEKIYA
      5  1.1   sekiya  * Copyright (c) 2000 Soren S. Jorvang
      6  1.1   sekiya  * All rights reserved.
      7  1.1   sekiya  *
      8  1.1   sekiya  * Redistribution and use in source and binary forms, with or without
      9  1.1   sekiya  * modification, are permitted provided that the following conditions
     10  1.1   sekiya  * are met:
     11  1.1   sekiya  * 1. Redistributions of source code must retain the above copyright
     12  1.1   sekiya  *    notice, this list of conditions and the following disclaimer.
     13  1.1   sekiya  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1   sekiya  *    notice, this list of conditions and the following disclaimer in the
     15  1.1   sekiya  *    documentation and/or other materials provided with the distribution.
     16  1.1   sekiya  * 3. All advertising materials mentioning features or use of this software
     17  1.1   sekiya  *    must display the following acknowledgement:
     18  1.1   sekiya  *          This product includes software developed for the
     19  1.1   sekiya  *          NetBSD Project.  See http://www.NetBSD.org/ for
     20  1.1   sekiya  *          information about NetBSD.
     21  1.1   sekiya  * 4. The name of the author may not be used to endorse or promote products
     22  1.1   sekiya  *    derived from this software without specific prior written permission.
     23  1.1   sekiya  *
     24  1.1   sekiya  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     25  1.1   sekiya  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     26  1.1   sekiya  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     27  1.1   sekiya  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     28  1.1   sekiya  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     29  1.1   sekiya  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     30  1.1   sekiya  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     31  1.1   sekiya  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     32  1.1   sekiya  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     33  1.1   sekiya  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     34  1.1   sekiya  */
     35  1.1   sekiya 
     36  1.1   sekiya #include <sys/cdefs.h>
     37  1.4  tsutsui __KERNEL_RCSID(0, "$NetBSD: lpt_mace.c,v 1.4 2004/07/12 13:45:40 tsutsui Exp $");
     38  1.1   sekiya 
     39  1.1   sekiya #include <sys/param.h>
     40  1.1   sekiya #include <sys/systm.h>
     41  1.1   sekiya #include <sys/ioctl.h>
     42  1.1   sekiya #include <sys/select.h>
     43  1.1   sekiya #include <sys/tty.h>
     44  1.1   sekiya #include <sys/proc.h>
     45  1.1   sekiya #include <sys/user.h>
     46  1.1   sekiya #include <sys/file.h>
     47  1.1   sekiya #include <sys/uio.h>
     48  1.1   sekiya #include <sys/kernel.h>
     49  1.1   sekiya #include <sys/syslog.h>
     50  1.1   sekiya #include <sys/types.h>
     51  1.1   sekiya #include <sys/device.h>
     52  1.1   sekiya 
     53  1.1   sekiya #include <machine/cpu.h>
     54  1.1   sekiya #include <machine/locore.h>
     55  1.1   sekiya #include <machine/autoconf.h>
     56  1.1   sekiya #include <machine/bus.h>
     57  1.1   sekiya #include <machine/machtype.h>
     58  1.1   sekiya 
     59  1.1   sekiya #include <sgimips/mace/macevar.h>
     60  1.1   sekiya 
     61  1.1   sekiya #include <dev/ic/lptreg.h>
     62  1.1   sekiya #include <dev/ic/lptvar.h>
     63  1.1   sekiya 
     64  1.1   sekiya struct lpt_mace_softc {
     65  1.1   sekiya 	struct lpt_softc sc_lpt;
     66  1.1   sekiya 
     67  1.1   sekiya 	/* XXX intr cookie */
     68  1.1   sekiya };
     69  1.1   sekiya 
     70  1.1   sekiya static int	lpt_mace_match(struct device *, struct cfdata *, void *);
     71  1.1   sekiya static void	lpt_mace_attach(struct device *, struct device *, void *);
     72  1.1   sekiya 
     73  1.1   sekiya CFATTACH_DECL(lpt_mace, sizeof(struct lpt_mace_softc),
     74  1.1   sekiya     lpt_mace_match, lpt_mace_attach, NULL, NULL);
     75  1.1   sekiya 
     76  1.1   sekiya static int
     77  1.1   sekiya lpt_mace_match(parent, match, aux)
     78  1.1   sekiya 	struct device *parent;
     79  1.1   sekiya 	struct cfdata *match;
     80  1.1   sekiya 	void *aux;
     81  1.1   sekiya {
     82  1.4  tsutsui 
     83  1.4  tsutsui 	return 1;
     84  1.1   sekiya }
     85  1.1   sekiya 
     86  1.1   sekiya static void
     87  1.1   sekiya lpt_mace_attach(parent, self, aux)
     88  1.1   sekiya 	struct device *parent;
     89  1.1   sekiya 	struct device *self;
     90  1.1   sekiya 	void *aux;
     91  1.1   sekiya {
     92  1.1   sekiya 	struct lpt_mace_softc *msc = (void *)self;
     93  1.1   sekiya 	struct lpt_softc *sc = &msc->sc_lpt;
     94  1.1   sekiya 	struct mace_attach_args *maa = aux;
     95  1.1   sekiya 
     96  1.1   sekiya 	sc->sc_iot = maa->maa_st;
     97  1.1   sekiya 
     98  1.1   sekiya 	/* XXX should use bus_space_map() */
     99  1.1   sekiya 	if (bus_space_subregion(sc->sc_iot, maa->maa_sh,
    100  1.1   sekiya 	    maa->maa_offset, LPT_NPORTS, &sc->sc_ioh) != 0) {
    101  1.1   sekiya 		printf(": can't map i/o space\n");
    102  1.1   sekiya 		return;
    103  1.1   sekiya 	}
    104  1.1   sekiya 
    105  1.1   sekiya 	printf("\n");
    106  1.1   sekiya 
    107  1.1   sekiya 	lpt_attach_subr(sc);
    108  1.1   sekiya 
    109  1.1   sekiya 	cpu_intr_establish(maa->maa_intr, maa->maa_intrmask, lptintr, sc);
    110  1.1   sekiya 
    111  1.1   sekiya 	return;
    112  1.1   sekiya }
    113