1/*	$NetBSD: lpt_mace.c,v 1.8 2009/11/21 17:40:28 rmind 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.8 2009/11/21 17:40:28 rmind 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/file.h>
46#include <sys/uio.h>
47#include <sys/kernel.h>
48#include <sys/syslog.h>
49#include <sys/types.h>
50#include <sys/device.h>
51
52#include <machine/cpu.h>
53#include <machine/locore.h>
54#include <machine/autoconf.h>
55#include <sys/bus.h>
56#include <machine/machtype.h>
57
58#include <sgimips/mace/macevar.h>
59
60#include <dev/ic/lptreg.h>
61#include <dev/ic/lptvar.h>
62
63struct lpt_mace_softc {
64	struct lpt_softc sc_lpt;
65
66	/* XXX intr cookie */
67};
68
69static int	lpt_mace_match(device_t, cfdata_t , void *);
70static void	lpt_mace_attach(device_t, device_t, void *);
71
72CFATTACH_DECL_NEW(lpt_mace, sizeof(struct lpt_mace_softc),
73    lpt_mace_match, lpt_mace_attach, NULL, NULL);
74
75static int
76lpt_mace_match(device_t parent, cfdata_t match, void *aux)
77{
78
79	return 1;
80}
81
82static void
83lpt_mace_attach(device_t parent, device_t self, void *aux)
84{
85	struct lpt_mace_softc *msc = device_private(self);
86	struct lpt_softc *sc = &msc->sc_lpt;
87	struct mace_attach_args *maa = aux;
88
89	sc->sc_dev = self;
90	sc->sc_iot = maa->maa_st;
91
92	/* XXX should use bus_space_map() */
93	if (bus_space_subregion(sc->sc_iot, maa->maa_sh,
94	    maa->maa_offset, LPT_NPORTS, &sc->sc_ioh) != 0) {
95		aprint_error(": can't map i/o space\n");
96		return;
97	}
98
99	aprint_normal("\n");
100
101	lpt_attach_subr(sc);
102
103	cpu_intr_establish(maa->maa_intr, maa->maa_intrmask, lptintr, sc);
104
105	return;
106}
107