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