xref: /netbsd-src/sys/arch/alpha/jensenio/lpt_jensenio.c (revision b7b2b8a3d89bfee25ca9324638c59a92666e2e4e)
1*b7b2b8a3Sthorpej /* $NetBSD: lpt_jensenio.c,v 1.14 2021/05/07 16:58:34 thorpej Exp $ */
2a66c3e66Sthorpej 
3a66c3e66Sthorpej /*-
4a66c3e66Sthorpej  * Copyright (c) 1999 The NetBSD Foundation, Inc.
5a66c3e66Sthorpej  * All rights reserved.
6a66c3e66Sthorpej  *
7a66c3e66Sthorpej  * This code is derived from software contributed to The NetBSD Foundation
8a66c3e66Sthorpej  * by Jason R. Thorpe.
9a66c3e66Sthorpej  *
10a66c3e66Sthorpej  * Redistribution and use in source and binary forms, with or without
11a66c3e66Sthorpej  * modification, are permitted provided that the following conditions
12a66c3e66Sthorpej  * are met:
13a66c3e66Sthorpej  * 1. Redistributions of source code must retain the above copyright
14a66c3e66Sthorpej  *    notice, this list of conditions and the following disclaimer.
15a66c3e66Sthorpej  * 2. Redistributions in binary form must reproduce the above copyright
16a66c3e66Sthorpej  *    notice, this list of conditions and the following disclaimer in the
17a66c3e66Sthorpej  *    documentation and/or other materials provided with the distribution.
18a66c3e66Sthorpej  *
19a66c3e66Sthorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20a66c3e66Sthorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21a66c3e66Sthorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22a66c3e66Sthorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23a66c3e66Sthorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24a66c3e66Sthorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25a66c3e66Sthorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26a66c3e66Sthorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27a66c3e66Sthorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28a66c3e66Sthorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29a66c3e66Sthorpej  * POSSIBILITY OF SUCH DAMAGE.
30a66c3e66Sthorpej  */
31a66c3e66Sthorpej 
32a66c3e66Sthorpej #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
33a66c3e66Sthorpej 
34*b7b2b8a3Sthorpej __KERNEL_RCSID(0, "$NetBSD: lpt_jensenio.c,v 1.14 2021/05/07 16:58:34 thorpej Exp $");
35a66c3e66Sthorpej 
36a66c3e66Sthorpej #include <sys/param.h>
37a66c3e66Sthorpej #include <sys/systm.h>
38a66c3e66Sthorpej #include <sys/ioctl.h>
39a66c3e66Sthorpej #include <sys/select.h>
40a66c3e66Sthorpej #include <sys/tty.h>
41a66c3e66Sthorpej #include <sys/proc.h>
42a66c3e66Sthorpej #include <sys/conf.h>
43a66c3e66Sthorpej #include <sys/file.h>
44a66c3e66Sthorpej #include <sys/uio.h>
45a66c3e66Sthorpej #include <sys/kernel.h>
46a66c3e66Sthorpej #include <sys/syslog.h>
47a66c3e66Sthorpej #include <sys/types.h>
48a66c3e66Sthorpej #include <sys/device.h>
49a66c3e66Sthorpej 
50a66c3e66Sthorpej #include <machine/intr.h>
51cf10107dSdyoung #include <sys/bus.h>
52a66c3e66Sthorpej 
53a66c3e66Sthorpej #include <dev/ic/lptreg.h>
54a66c3e66Sthorpej #include <dev/ic/lptvar.h>
55a66c3e66Sthorpej 
56a66c3e66Sthorpej #include <dev/eisa/eisavar.h>
57a66c3e66Sthorpej 
58a66c3e66Sthorpej #include <dev/isa/isavar.h>
59a66c3e66Sthorpej 
60a66c3e66Sthorpej #include <alpha/jensenio/jenseniovar.h>
61a66c3e66Sthorpej 
62a66c3e66Sthorpej struct lpt_jensenio_softc {
63a66c3e66Sthorpej 	struct lpt_softc sc_lpt;	/* real "lpt" softc */
64a66c3e66Sthorpej 
65a66c3e66Sthorpej 	/* Jensen-specific goo. */
660d3f4cbfStsutsui 	void	*sc_ih;			/* interrupt handler */
67a66c3e66Sthorpej };
68a66c3e66Sthorpej 
69*b7b2b8a3Sthorpej static int	lpt_jensenio_match(device_t, cfdata_t , void *);
70*b7b2b8a3Sthorpej static void	lpt_jensenio_attach(device_t, device_t, void *);
71a66c3e66Sthorpej 
728ecf8999Scube CFATTACH_DECL_NEW(lpt_jensenio, sizeof(struct lpt_jensenio_softc),
73b96bc0d7Sthorpej     lpt_jensenio_match, lpt_jensenio_attach, NULL, NULL);
74a66c3e66Sthorpej 
75*b7b2b8a3Sthorpej static int
lpt_jensenio_match(device_t parent,cfdata_t match,void * aux)768ecf8999Scube lpt_jensenio_match(device_t parent, cfdata_t match, void *aux)
77a66c3e66Sthorpej {
78a66c3e66Sthorpej 	struct jensenio_attach_args *ja = aux;
79a66c3e66Sthorpej 
80a66c3e66Sthorpej 	/* Always present. */
81d1ad2ac4Sthorpej 	if (strcmp(ja->ja_name, match->cf_name) == 0)
82a66c3e66Sthorpej 		return (1);
83a66c3e66Sthorpej 
84a66c3e66Sthorpej 	return (0);
85a66c3e66Sthorpej }
86a66c3e66Sthorpej 
87*b7b2b8a3Sthorpej static void
lpt_jensenio_attach(device_t parent,device_t self,void * aux)888ecf8999Scube lpt_jensenio_attach(device_t parent, device_t self, void *aux)
89a66c3e66Sthorpej {
908ecf8999Scube 	struct lpt_jensenio_softc *jsc = device_private(self);
91a66c3e66Sthorpej 	struct lpt_softc *sc = &jsc->sc_lpt;
92a66c3e66Sthorpej 	struct jensenio_attach_args *ja = aux;
930d3f4cbfStsutsui 	const char *intrstr;
94977edcc0Schristos 	char buf[64];
95a66c3e66Sthorpej 
968ecf8999Scube 	sc->sc_dev = self;
97a66c3e66Sthorpej 	sc->sc_iot = ja->ja_iot;
98a66c3e66Sthorpej 
99a66c3e66Sthorpej 	if (bus_space_map(sc->sc_iot, ja->ja_ioaddr, LPT_NPORTS, 0,
100a66c3e66Sthorpej 	    &sc->sc_ioh) != 0) {
1018ecf8999Scube 		aprint_error(": can't map i/o space\n");
102a66c3e66Sthorpej 		return;
103a66c3e66Sthorpej 	}
104a66c3e66Sthorpej 
1058ecf8999Scube 	aprint_normal("\n");
1068ecf8999Scube 	aprint_naive("\n");
107a66c3e66Sthorpej 
108a66c3e66Sthorpej 	lpt_attach_subr(sc);
109a66c3e66Sthorpej 
110e58a356cSchristos 	intrstr = eisa_intr_string(ja->ja_ec, ja->ja_irq[0],
111977edcc0Schristos 	    buf, sizeof(buf));
1120d3f4cbfStsutsui 	jsc->sc_ih = eisa_intr_establish(ja->ja_ec, ja->ja_irq[0],
1130d3f4cbfStsutsui 	    IST_EDGE, IPL_TTY, lptintr, sc);
1140d3f4cbfStsutsui 	if (jsc->sc_ih == NULL) {
1158ecf8999Scube 		aprint_error_dev(self, "unable to establish interrupt");
1160d3f4cbfStsutsui 		if (intrstr != NULL)
1178ecf8999Scube 			aprint_error(" at %s", intrstr);
1188ecf8999Scube 		aprint_error("\n");
1190d3f4cbfStsutsui 		return;
120a66c3e66Sthorpej 	}
1218ecf8999Scube 	aprint_normal_dev(self, "interrupting at %s\n", intrstr);
122a66c3e66Sthorpej }
123