xref: /netbsd-src/sys/dev/isa/vga_isa.c (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1 /* $NetBSD: vga_isa.c,v 1.20 2006/11/16 01:33:00 christos 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: vga_isa.c,v 1.20 2006/11/16 01:33:00 christos Exp $");
32 
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/device.h>
37 #include <sys/malloc.h>
38 
39 #include <dev/isa/isavar.h>
40 
41 #include <dev/ic/mc6845reg.h>
42 #include <dev/ic/pcdisplayvar.h>
43 #include <dev/ic/vgareg.h>
44 #include <dev/ic/vgavar.h>
45 #include <dev/isa/vga_isavar.h>
46 
47 #include <dev/wscons/wsconsio.h>
48 #include <dev/wscons/wsdisplayvar.h>
49 
50 int	vga_isa_match(struct device *, struct cfdata *, void *);
51 void	vga_isa_attach(struct device *, struct device *, void *);
52 
53 CFATTACH_DECL(vga_isa, sizeof(struct vga_softc),
54     vga_isa_match, vga_isa_attach, NULL, NULL);
55 
56 int
57 vga_isa_match(struct device *parent, struct cfdata *match,
58     void *aux)
59 {
60 	struct isa_attach_args *ia = aux;
61 
62 	if (ISA_DIRECT_CONFIG(ia))
63 		return (0);
64 
65 	/* If values are hardwired to something that they can't be, punt. */
66 	if (ia->ia_nio < 1 ||
67 	    (ia->ia_io[0].ir_addr != ISA_UNKNOWN_PORT &&
68 	     ia->ia_io[0].ir_addr != 0x3b0))
69 		return (0);
70 
71 	if (ia->ia_niomem < 1 ||
72 	    (ia->ia_iomem[0].ir_addr != ISA_UNKNOWN_IOMEM &&
73 	     ia->ia_iomem[0].ir_addr != 0xa0000))
74 		return (0);
75 	if (ia->ia_iomem[0].ir_size != 0 &&
76 	    ia->ia_iomem[0].ir_size != 0x20000)
77 		return (0);
78 
79 	if (ia->ia_nirq > 0 &&
80 	    ia->ia_irq[0].ir_irq != ISA_UNKNOWN_IRQ)
81 		return (0);
82 
83 	if (ia->ia_ndrq > 0 &&
84 	    ia->ia_drq[0].ir_drq != ISA_UNKNOWN_DRQ)
85 		return (0);
86 
87 	if (!vga_is_console(ia->ia_iot, WSDISPLAY_TYPE_ISAVGA) &&
88 	    !vga_common_probe(ia->ia_iot, ia->ia_memt))
89 		return (0);
90 
91 	ia->ia_nio = 1;
92 	ia->ia_io[0].ir_addr = 0x3b0;	/* XXX mono 0x3b0 color 0x3c0 */
93 	ia->ia_io[0].ir_size = 0x30;	/* XXX 0x20 */
94 
95 	ia->ia_niomem = 1;
96 	ia->ia_iomem[0].ir_addr = 0xa0000;
97 	ia->ia_iomem[0].ir_size = 0x20000;
98 
99 	ia->ia_nirq = 0;
100 	ia->ia_ndrq = 0;
101 
102 	return (2);	/* more than generic pcdisplay */
103 }
104 
105 void
106 vga_isa_attach(struct device *parent, struct device *self, void *aux)
107 {
108 	struct vga_softc *sc = (void *) self;
109 	struct isa_attach_args *ia = aux;
110 
111 	printf("\n");
112 
113 	vga_common_attach(sc, ia->ia_iot, ia->ia_memt, WSDISPLAY_TYPE_ISAVGA,
114 	    0, NULL);
115 }
116 
117 int
118 vga_isa_cnattach(bus_space_tag_t iot, bus_space_tag_t memt)
119 {
120 
121 	return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_ISAVGA, 1));
122 }
123