xref: /openbsd/sys/dev/isa/vga_isa.c (revision 17df1aa7)
1 /* $OpenBSD: vga_isa.c,v 1.8 2002/03/14 01:26:56 millert Exp $ */
2 /* $NetBSD: vga_isa.c,v 1.3 1998/06/12 18:45:48 drochner Exp $ */
3 
4 /*
5  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
6  * All rights reserved.
7  *
8  * Author: Chris G. Demetriou
9  *
10  * Permission to use, copy, modify and distribute this software and
11  * its documentation is hereby granted, provided that both the copyright
12  * notice and this permission notice appear in all copies of the
13  * software, derivative works or modified versions, and any portions
14  * thereof, and that both notices appear in supporting documentation.
15  *
16  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19  *
20  * Carnegie Mellon requests users of this software to return to
21  *
22  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
23  *  School of Computer Science
24  *  Carnegie Mellon University
25  *  Pittsburgh PA 15213-3890
26  *
27  * any improvements or extensions that they make and grant Carnegie the
28  * rights to redistribute these changes.
29  */
30 
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/kernel.h>
34 #include <sys/device.h>
35 #include <sys/malloc.h>
36 
37 #include <dev/isa/isavar.h>
38 
39 #include <dev/ic/mc6845reg.h>
40 #include <dev/ic/pcdisplayvar.h>
41 #include <dev/ic/vgareg.h>
42 #include <dev/ic/vgavar.h>
43 #include <dev/isa/vga_isavar.h>
44 
45 #include <dev/wscons/wsconsio.h>
46 #include <dev/wscons/wsdisplayvar.h>
47 
48 struct vga_isa_softc {
49 	struct device sc_dev;
50 #if 0
51 	struct vga_config *sc_vc;	/* VGA configuration */
52 #endif
53 };
54 
55 int	vga_isa_match(struct device *, void *, void *);
56 void	vga_isa_attach(struct device *, struct device *, void *);
57 
58 struct cfattach vga_isa_ca = {
59 	sizeof(struct vga_isa_softc), vga_isa_match, vga_isa_attach,
60 };
61 
62 int
63 vga_isa_match(parent, match, aux)
64 	struct device *parent;
65 	void *match;
66 	void *aux;
67 {
68 	struct isa_attach_args *ia = aux;
69 
70 	/* If values are hardwired to something that they can't be, punt. */
71 	if ((ia->ia_iobase != IOBASEUNK && ia->ia_iobase != 0x3b0) ||
72 	    /* ia->ia_iosize != 0 || XXX isa.c */
73 	    (ia->ia_maddr != MADDRUNK && ia->ia_maddr != 0xa0000) ||
74 	    (ia->ia_msize != 0 && ia->ia_msize != 0x20000) ||
75 	    ia->ia_irq != IRQUNK || ia->ia_drq != DRQUNK)
76 		return (0);
77 
78 	if (!vga_is_console(ia->ia_iot, WSDISPLAY_TYPE_ISAVGA) &&
79 	    !vga_common_probe(ia->ia_iot, ia->ia_memt))
80 		return (0);
81 
82 	ia->ia_iobase = 0x3b0;	/* XXX mono 0x3b0 color 0x3c0 */
83 	ia->ia_iosize = 0x30;	/* XXX 0x20 */
84 	ia->ia_maddr = 0xa0000;
85 	ia->ia_msize = 0x20000;
86 	return (2);	/* more than generic pcdisplay */
87 }
88 
89 void
90 vga_isa_attach(parent, self, aux)
91 	struct device *parent, *self;
92 	void *aux;
93 {
94 	struct isa_attach_args *ia = aux;
95 #if 0
96 	struct vga_isa_softc *sc = (struct vga_isa_softc *)self;
97 #endif
98 
99 	printf("\n");
100 
101 	vga_common_attach(self, ia->ia_iot, ia->ia_memt,
102 			  WSDISPLAY_TYPE_ISAVGA);
103 }
104 
105 int
106 vga_isa_cnattach(iot, memt)
107 	bus_space_tag_t iot, memt;
108 {
109 	return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_ISAVGA, 1));
110 }
111