xref: /netbsd-src/sys/arch/sgimips/mace/lpt_mace.c (revision cf10107d5d3746e98e37d403b996f1965f67f255)
1*cf10107dSdyoung /*	$NetBSD: lpt_mace.c,v 1.9 2011/07/01 18:53:47 dyoung Exp $	*/
263b59c4dSsekiya 
363b59c4dSsekiya /*
463b59c4dSsekiya  * Copyright (c) 2003 Christopher SEKIYA
563b59c4dSsekiya  * Copyright (c) 2000 Soren S. Jorvang
663b59c4dSsekiya  * All rights reserved.
763b59c4dSsekiya  *
863b59c4dSsekiya  * Redistribution and use in source and binary forms, with or without
963b59c4dSsekiya  * modification, are permitted provided that the following conditions
1063b59c4dSsekiya  * are met:
1163b59c4dSsekiya  * 1. Redistributions of source code must retain the above copyright
1263b59c4dSsekiya  *    notice, this list of conditions and the following disclaimer.
1363b59c4dSsekiya  * 2. Redistributions in binary form must reproduce the above copyright
1463b59c4dSsekiya  *    notice, this list of conditions and the following disclaimer in the
1563b59c4dSsekiya  *    documentation and/or other materials provided with the distribution.
1663b59c4dSsekiya  * 3. All advertising materials mentioning features or use of this software
1763b59c4dSsekiya  *    must display the following acknowledgement:
1863b59c4dSsekiya  *          This product includes software developed for the
1963b59c4dSsekiya  *          NetBSD Project.  See http://www.NetBSD.org/ for
2063b59c4dSsekiya  *          information about NetBSD.
2163b59c4dSsekiya  * 4. The name of the author may not be used to endorse or promote products
2263b59c4dSsekiya  *    derived from this software without specific prior written permission.
2363b59c4dSsekiya  *
2463b59c4dSsekiya  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2563b59c4dSsekiya  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2663b59c4dSsekiya  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2763b59c4dSsekiya  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2863b59c4dSsekiya  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2963b59c4dSsekiya  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3063b59c4dSsekiya  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3163b59c4dSsekiya  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3263b59c4dSsekiya  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3363b59c4dSsekiya  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3463b59c4dSsekiya  */
3563b59c4dSsekiya 
3663b59c4dSsekiya #include <sys/cdefs.h>
37*cf10107dSdyoung __KERNEL_RCSID(0, "$NetBSD: lpt_mace.c,v 1.9 2011/07/01 18:53:47 dyoung Exp $");
3863b59c4dSsekiya 
3963b59c4dSsekiya #include <sys/param.h>
4063b59c4dSsekiya #include <sys/systm.h>
4163b59c4dSsekiya #include <sys/ioctl.h>
4263b59c4dSsekiya #include <sys/select.h>
4363b59c4dSsekiya #include <sys/tty.h>
4463b59c4dSsekiya #include <sys/proc.h>
4563b59c4dSsekiya #include <sys/file.h>
4663b59c4dSsekiya #include <sys/uio.h>
4763b59c4dSsekiya #include <sys/kernel.h>
4863b59c4dSsekiya #include <sys/syslog.h>
4963b59c4dSsekiya #include <sys/types.h>
5063b59c4dSsekiya #include <sys/device.h>
5163b59c4dSsekiya 
5263b59c4dSsekiya #include <machine/cpu.h>
5363b59c4dSsekiya #include <machine/locore.h>
5463b59c4dSsekiya #include <machine/autoconf.h>
55*cf10107dSdyoung #include <sys/bus.h>
5663b59c4dSsekiya #include <machine/machtype.h>
5763b59c4dSsekiya 
5863b59c4dSsekiya #include <sgimips/mace/macevar.h>
5963b59c4dSsekiya 
6063b59c4dSsekiya #include <dev/ic/lptreg.h>
6163b59c4dSsekiya #include <dev/ic/lptvar.h>
6263b59c4dSsekiya 
6363b59c4dSsekiya struct lpt_mace_softc {
6463b59c4dSsekiya 	struct lpt_softc sc_lpt;
6563b59c4dSsekiya 
6663b59c4dSsekiya 	/* XXX intr cookie */
6763b59c4dSsekiya };
6863b59c4dSsekiya 
698ecf8999Scube static int	lpt_mace_match(device_t, cfdata_t , void *);
708ecf8999Scube static void	lpt_mace_attach(device_t, device_t, void *);
7163b59c4dSsekiya 
728ecf8999Scube CFATTACH_DECL_NEW(lpt_mace, sizeof(struct lpt_mace_softc),
7363b59c4dSsekiya     lpt_mace_match, lpt_mace_attach, NULL, NULL);
7463b59c4dSsekiya 
7563b59c4dSsekiya static int
lpt_mace_match(device_t parent,cfdata_t match,void * aux)768ecf8999Scube lpt_mace_match(device_t parent, cfdata_t match, void *aux)
7763b59c4dSsekiya {
78c2de4256Stsutsui 
79c2de4256Stsutsui 	return 1;
8063b59c4dSsekiya }
8163b59c4dSsekiya 
8263b59c4dSsekiya static void
lpt_mace_attach(device_t parent,device_t self,void * aux)838ecf8999Scube lpt_mace_attach(device_t parent, device_t self, void *aux)
8463b59c4dSsekiya {
858ecf8999Scube 	struct lpt_mace_softc *msc = device_private(self);
8663b59c4dSsekiya 	struct lpt_softc *sc = &msc->sc_lpt;
8763b59c4dSsekiya 	struct mace_attach_args *maa = aux;
8863b59c4dSsekiya 
898ecf8999Scube 	sc->sc_dev = self;
9063b59c4dSsekiya 	sc->sc_iot = maa->maa_st;
9163b59c4dSsekiya 
9263b59c4dSsekiya 	/* XXX should use bus_space_map() */
9363b59c4dSsekiya 	if (bus_space_subregion(sc->sc_iot, maa->maa_sh,
9463b59c4dSsekiya 	    maa->maa_offset, LPT_NPORTS, &sc->sc_ioh) != 0) {
958ecf8999Scube 		aprint_error(": can't map i/o space\n");
9663b59c4dSsekiya 		return;
9763b59c4dSsekiya 	}
9863b59c4dSsekiya 
998ecf8999Scube 	aprint_normal("\n");
10063b59c4dSsekiya 
10163b59c4dSsekiya 	lpt_attach_subr(sc);
10263b59c4dSsekiya 
10363b59c4dSsekiya 	cpu_intr_establish(maa->maa_intr, maa->maa_intrmask, lptintr, sc);
10463b59c4dSsekiya 
10563b59c4dSsekiya 	return;
10663b59c4dSsekiya }
107