vga_jazzio.c revision 1.4 1 /* $NetBSD: vga_jazzio.c,v 1.4 2000/12/24 09:25:30 ur 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 (at) 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 <machine/autoconf.h>
38 #include <machine/bus.h>
39
40 #include <dev/ic/mc6845reg.h>
41 #include <dev/ic/pcdisplayvar.h>
42 #include <dev/ic/vgareg.h>
43 #include <dev/ic/vgavar.h>
44 #include <arc/jazz/jazziovar.h>
45 #include <arc/jazz/pica.h>
46 #include <arc/jazz/vga_jazziovar.h>
47
48 #include <dev/wscons/wsconsio.h>
49 #include <dev/wscons/wsdisplayvar.h>
50
51 #define WSDISPLAY_TYPE_JAZZVGA WSDISPLAY_TYPE_PCIVGA /* XXX not really */
52
53 struct vga_jazzio_softc {
54 struct device sc_dev;
55 #if 0
56 struct vga_config *sc_vc; /* VGA configuration */
57 #endif
58 };
59
60 void vga_jazzio_init_tag __P((bus_space_tag_t *, bus_space_tag_t *));
61 paddr_t vga_jazzio_mmap __P((void *, off_t, int));
62 int vga_jazzio_match __P((struct device *, struct cfdata *, void *));
63 void vga_jazzio_attach __P((struct device *, struct device *, void *));
64
65 struct cfattach vga_jazzio_ca = {
66 sizeof(struct vga_jazzio_softc), vga_jazzio_match, vga_jazzio_attach,
67 };
68
69 void
70 vga_jazzio_init_tag(iotp, memtp)
71 bus_space_tag_t *iotp, *memtp;
72 {
73 static int initialized = 0;
74 static struct arc_bus_space vga_io, vga_mem;
75
76 if (!initialized) {
77 initialized = 1;
78 arc_bus_space_init(&vga_io, "vga_jazzio_io",
79 PICA_P_LOCAL_VIDEO_CTRL, PICA_V_LOCAL_VIDEO_CTRL,
80 0, PICA_S_LOCAL_VIDEO_CTRL);
81 arc_bus_space_init(&vga_mem, "vga_jazzio_mem",
82 PICA_P_LOCAL_VIDEO, PICA_V_LOCAL_VIDEO,
83 0, PICA_S_LOCAL_VIDEO);
84 }
85 *iotp = &vga_io;
86 *memtp = &vga_mem;
87 }
88
89 paddr_t
90 vga_jazzio_mmap(v, offset, prot)
91 void *v;
92 off_t offset;
93 int prot;
94 {
95 if (offset >= 0xa0000 && offset < 0xc0000)
96 return mips_btop(PICA_P_LOCAL_VIDEO + offset);
97 if (offset >= 0x0000 && offset < 0x10000)
98 return mips_btop(PICA_P_LOCAL_VIDEO_CTRL + offset);
99 if (offset >= 0x40000000 && offset < 0x40800000)
100 return mips_btop(PICA_P_LOCAL_VIDEO + offset - 0x40000000);
101 return -1;
102 }
103
104 int
105 vga_jazzio_match(parent, match, aux)
106 struct device *parent;
107 struct cfdata *match;
108 void *aux;
109 {
110 struct jazzio_attach_args *ja = aux;
111 bus_space_tag_t iot, memt;
112
113 if(strcmp(ja->ja_name, "vga") != 0)
114 return(0);
115
116 vga_jazzio_init_tag(&iot, &memt);
117 if (!vga_is_console(iot, WSDISPLAY_TYPE_JAZZVGA) &&
118 !vga_common_probe(iot, memt))
119 return (0);
120
121 return (1);
122 }
123
124 void
125 vga_jazzio_attach(parent, self, aux)
126 struct device *parent, *self;
127 void *aux;
128 {
129 #if 0
130 struct vga_jazzio_softc *sc = (struct vga_jazzio_softc *)self;
131 #endif
132 bus_space_tag_t iot, memt;
133
134 printf("\n");
135
136 vga_jazzio_init_tag(&iot, &memt);
137 vga_common_attach(self, iot, memt, WSDISPLAY_TYPE_JAZZVGA,
138 vga_jazzio_mmap);
139 }
140
141 int
142 vga_jazzio_cnattach()
143 {
144 bus_space_tag_t iot, memt;
145
146 vga_jazzio_init_tag(&iot, &memt);
147 return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_JAZZVGA, 1));
148 }
149