xref: /netbsd-src/sys/arch/arc/isa/opms_isa.c (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1 /* $NetBSD: opms_isa.c,v 1.6 2004/09/14 20:32:48 drochner Exp $ */
2 
3 /*
4  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  *
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  */
29 
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD: opms_isa.c,v 1.6 2004/09/14 20:32:48 drochner Exp $");
32 
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/tty.h>
36 #include <sys/device.h>
37 
38 #include <machine/bus.h>
39 
40 #include <dev/isa/isareg.h>
41 #include <dev/isa/isavar.h>
42 
43 #include <arc/dev/pcconsvar.h>
44 #include <arc/dev/opmsvar.h>
45 
46 int	opms_isa_match __P((struct device *, struct cfdata *, void *));
47 void	opms_isa_attach __P((struct device *, struct device *, void *));
48 
49 CFATTACH_DECL(opms_isa, sizeof(struct opms_softc),
50     opms_isa_match, opms_isa_attach, NULL, NULL);
51 
52 struct pccons_config *pccons_isa_conf;	/* share stroage with pccons_isa.c */
53 
54 int
55 opms_isa_match(parent, match, aux)
56 	struct device *parent;
57 	struct cfdata *match;
58 	void *aux;
59 {
60 	struct isa_attach_args *ia = aux;
61 	bus_addr_t iobase = IO_KBD;
62 	bus_size_t iosize = IO_KBDSIZE;
63 	int irq = 12;
64 
65 	if (ia->ia_nio < 1)
66 		return (0);
67 	if (ia->ia_io[0].ir_addr != ISA_UNKNOWN_PORT)
68 		iobase = ia->ia_io[0].ir_addr;
69 #if 0	/* XXX isa.c */
70 	if (ia->ia_iosize != 0)
71 		iosize = ia->ia_iosize;
72 #endif
73 	if (ia->ia_irq[0].ir_irq != ISA_UNKNOWN_IRQ)
74 		irq = ia->ia_irq[0].ir_irq;
75 
76 #if 0
77 	/* If values are hardwired to something that they can't be, punt. */
78 	if (iobase != IO_KBD || iosize != IO_KBDSIZE ||
79 	    ia->ia_maddr != MADDRUNK || ia->ia_msize != 0 ||
80 	    ia->ia_irq != 1 || ia->ia_drq != DRQUNK)
81 		return (0);
82 #endif
83 
84 	if (pccons_isa_conf == NULL)
85 		return (0);
86 
87 	if (!opms_common_match(ia->ia_iot, pccons_isa_conf))
88 		return (0);
89 
90 	ia->ia_nio = 1;
91 	ia->ia_io[0].ir_addr = iobase;
92 	ia->ia_io[0].ir_size = iosize;
93 
94 	ia->ia_nirq = 1;
95 	ia->ia_irq[0].ir_irq = irq;
96 
97 	ia->ia_niomem = 0;
98 	ia->ia_ndrq = 0;
99 
100 	return (1);
101 }
102 
103 void
104 opms_isa_attach(parent, self, aux)
105 	struct device *parent, *self;
106 	void *aux;
107 {
108 	struct opms_softc *sc = (struct opms_softc *)self;
109 	struct isa_attach_args *ia = aux;
110 
111 	printf("\n");
112 
113 	isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq, IST_EDGE, IPL_TTY,
114 	    pcintr, self);
115 	opms_common_attach(sc, ia->ia_iot, pccons_isa_conf);
116 }
117