vga_isa.c revision 1.4.2.3
1/* $NetBSD: vga_isa.c,v 1.4.2.3 2002/01/11 23:39:14 nathanw 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.4.2.3 2002/01/11 23:39:14 nathanw 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
50int	vga_isa_match __P((struct device *, struct cfdata *, void *));
51void	vga_isa_attach __P((struct device *, struct device *, void *));
52
53struct cfattach vga_isa_ca = {
54	sizeof(struct vga_softc), vga_isa_match, vga_isa_attach,
55};
56
57int
58vga_isa_match(parent, match, aux)
59	struct device *parent;
60	struct cfdata *match;
61	void *aux;
62{
63	struct isa_attach_args *ia = aux;
64
65	if (ISA_DIRECT_CONFIG(ia))
66		return (0);
67
68	/* If values are hardwired to something that they can't be, punt. */
69	if (ia->ia_nio < 1 ||
70	    (ia->ia_io[0].ir_addr != ISACF_PORT_DEFAULT &&
71	     ia->ia_io[0].ir_addr != 0x3b0))
72		return (0);
73
74	if (ia->ia_niomem < 1 ||
75	    (ia->ia_iomem[0].ir_addr != ISACF_IOMEM_DEFAULT &&
76	     ia->ia_iomem[0].ir_addr != 0xa0000))
77		return (0);
78	if (ia->ia_iomem[0].ir_size != 0 &&
79	    ia->ia_iomem[0].ir_size != 0x20000)
80		return (0);
81
82	if (ia->ia_nirq > 0 &&
83	    ia->ia_irq[0].ir_irq != ISACF_IRQ_DEFAULT)
84		return (0);
85
86	if (ia->ia_ndrq > 0 &&
87	    ia->ia_drq[0].ir_drq != ISACF_DRQ_DEFAULT)
88		return (0);
89
90	if (!vga_is_console(ia->ia_iot, WSDISPLAY_TYPE_ISAVGA) &&
91	    !vga_common_probe(ia->ia_iot, ia->ia_memt))
92		return (0);
93
94	ia->ia_nio = 1;
95	ia->ia_io[0].ir_addr = 0x3b0;	/* XXX mono 0x3b0 color 0x3c0 */
96	ia->ia_io[0].ir_size = 0x30;	/* XXX 0x20 */
97
98	ia->ia_niomem = 1;
99	ia->ia_iomem[0].ir_addr = 0xa0000;
100	ia->ia_iomem[0].ir_size = 0x20000;
101
102	ia->ia_nirq = 0;
103	ia->ia_ndrq = 0;
104
105	return (2);	/* more than generic pcdisplay */
106}
107
108void
109vga_isa_attach(parent, self, aux)
110	struct device *parent, *self;
111	void *aux;
112{
113	struct vga_softc *sc = (void *) self;
114	struct isa_attach_args *ia = aux;
115
116	printf("\n");
117
118	vga_common_attach(sc, ia->ia_iot, ia->ia_memt, WSDISPLAY_TYPE_ISAVGA,
119	    NULL);
120}
121
122int
123vga_isa_cnattach(iot, memt)
124	bus_space_tag_t iot, memt;
125{
126	return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_ISAVGA, 1));
127}
128