xref: /netbsd-src/sys/arch/arc/isa/opms_isa.c (revision ca37b980c32e30dffa228264e158cd25f98311af)
1*ca37b980Sandvar /* $NetBSD: opms_isa.c,v 1.13 2023/08/30 09:17:46 andvar Exp $ */
2b7abba77Ssoda 
3b7abba77Ssoda /*
4b7abba77Ssoda  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5b7abba77Ssoda  * All rights reserved.
6b7abba77Ssoda  *
7b7abba77Ssoda  * Author: Chris G. Demetriou
8b7abba77Ssoda  *
9b7abba77Ssoda  * Permission to use, copy, modify and distribute this software and
10b7abba77Ssoda  * its documentation is hereby granted, provided that both the copyright
11b7abba77Ssoda  * notice and this permission notice appear in all copies of the
12b7abba77Ssoda  * software, derivative works or modified versions, and any portions
13b7abba77Ssoda  * thereof, and that both notices appear in supporting documentation.
14b7abba77Ssoda  *
15b7abba77Ssoda  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16b7abba77Ssoda  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17b7abba77Ssoda  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18b7abba77Ssoda  *
19b7abba77Ssoda  * Carnegie Mellon requests users of this software to return to
20b7abba77Ssoda  *
21b7abba77Ssoda  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22b7abba77Ssoda  *  School of Computer Science
23b7abba77Ssoda  *  Carnegie Mellon University
24b7abba77Ssoda  *  Pittsburgh PA 15213-3890
25b7abba77Ssoda  *
26b7abba77Ssoda  * any improvements or extensions that they make and grant Carnegie the
27b7abba77Ssoda  * rights to redistribute these changes.
28b7abba77Ssoda  */
29b7abba77Ssoda 
30a4183603Slukem #include <sys/cdefs.h>
31*ca37b980Sandvar __KERNEL_RCSID(0, "$NetBSD: opms_isa.c,v 1.13 2023/08/30 09:17:46 andvar Exp $");
32a4183603Slukem 
33b7abba77Ssoda #include <sys/param.h>
34b7abba77Ssoda #include <sys/systm.h>
35b7abba77Ssoda #include <sys/tty.h>
36b7abba77Ssoda #include <sys/device.h>
37b7abba77Ssoda 
38cf10107dSdyoung #include <sys/bus.h>
39b7abba77Ssoda 
40b7abba77Ssoda #include <dev/isa/isareg.h>
41b7abba77Ssoda #include <dev/isa/isavar.h>
42b7abba77Ssoda 
43b7abba77Ssoda #include <arc/dev/pcconsvar.h>
44b7abba77Ssoda #include <arc/dev/opmsvar.h>
45*ca37b980Sandvar #include <arc/isa/pccons_isavar.h>
46b7abba77Ssoda 
470f31d9deStsutsui static int	opms_isa_match(device_t, cfdata_t, void *);
480f31d9deStsutsui static void	opms_isa_attach(device_t, device_t, void *);
49b7abba77Ssoda 
500f31d9deStsutsui CFATTACH_DECL_NEW(opms_isa, sizeof(struct opms_softc),
51c5e91d44Sthorpej     opms_isa_match, opms_isa_attach, NULL, NULL);
52b7abba77Ssoda 
530f31d9deStsutsui static int
opms_isa_match(device_t parent,cfdata_t cf,void * aux)540f31d9deStsutsui opms_isa_match(device_t parent, cfdata_t cf, void *aux)
55b7abba77Ssoda {
56b7abba77Ssoda 	struct isa_attach_args *ia = aux;
57b7abba77Ssoda 	bus_addr_t iobase = IO_KBD;
58b7abba77Ssoda 	bus_size_t iosize = IO_KBDSIZE;
59b7abba77Ssoda 	int irq = 12;
60b7abba77Ssoda 
613835413bSthorpej 	if (ia->ia_nio < 1)
627fe2a5a0Stsutsui 		return 0;
632db68840Sdrochner 	if (ia->ia_io[0].ir_addr != ISA_UNKNOWN_PORT)
643835413bSthorpej 		iobase = ia->ia_io[0].ir_addr;
65b7abba77Ssoda #if 0	/* XXX isa.c */
66b7abba77Ssoda 	if (ia->ia_iosize != 0)
67b7abba77Ssoda 		iosize = ia->ia_iosize;
68b7abba77Ssoda #endif
692db68840Sdrochner 	if (ia->ia_irq[0].ir_irq != ISA_UNKNOWN_IRQ)
703835413bSthorpej 		irq = ia->ia_irq[0].ir_irq;
71b7abba77Ssoda 
72b7abba77Ssoda #if 0
73b7abba77Ssoda 	/* If values are hardwired to something that they can't be, punt. */
74b7abba77Ssoda 	if (iobase != IO_KBD || iosize != IO_KBDSIZE ||
75b7abba77Ssoda 	    ia->ia_maddr != MADDRUNK || ia->ia_msize != 0 ||
76b7abba77Ssoda 	    ia->ia_irq != 1 || ia->ia_drq != DRQUNK)
777fe2a5a0Stsutsui 		return 0;
78b7abba77Ssoda #endif
79b7abba77Ssoda 
80b7abba77Ssoda 	if (pccons_isa_conf == NULL)
817fe2a5a0Stsutsui 		return 0;
82b7abba77Ssoda 
83b7abba77Ssoda 	if (!opms_common_match(ia->ia_iot, pccons_isa_conf))
847fe2a5a0Stsutsui 		return 0;
85b7abba77Ssoda 
863835413bSthorpej 	ia->ia_nio = 1;
873835413bSthorpej 	ia->ia_io[0].ir_addr = iobase;
883835413bSthorpej 	ia->ia_io[0].ir_size = iosize;
893835413bSthorpej 
903835413bSthorpej 	ia->ia_nirq = 1;
913835413bSthorpej 	ia->ia_irq[0].ir_irq = irq;
923835413bSthorpej 
933835413bSthorpej 	ia->ia_niomem = 0;
943835413bSthorpej 	ia->ia_ndrq = 0;
953835413bSthorpej 
967fe2a5a0Stsutsui 	return 1;
97b7abba77Ssoda }
98b7abba77Ssoda 
990f31d9deStsutsui static void
opms_isa_attach(device_t parent,device_t self,void * aux)1000f31d9deStsutsui opms_isa_attach(device_t parent, device_t self, void *aux)
101b7abba77Ssoda {
1020f31d9deStsutsui 	struct opms_softc *sc = device_private(self);
103b7abba77Ssoda 	struct isa_attach_args *ia = aux;
104b7abba77Ssoda 
1050f31d9deStsutsui 	sc->sc_dev = self;
1060f31d9deStsutsui 
1070f31d9deStsutsui 	aprint_normal("\n");
108b7abba77Ssoda 
1093835413bSthorpej 	isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_TTY,
110abe73f3aStsutsui 	    pcintr, sc);
111b7abba77Ssoda 	opms_common_attach(sc, ia->ia_iot, pccons_isa_conf);
112b7abba77Ssoda }
113