pccons_jazzio.c revision 1.4 1 /* $NetBSD: pccons_jazzio.c,v 1.4 2003/07/15 00:04:50 lukem Exp $ */
2 /* NetBSD: vga_isa.c,v 1.4 2000/08/14 20:14:51 thorpej 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/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: pccons_jazzio.c,v 1.4 2003/07/15 00:04:50 lukem Exp $");
33
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/device.h>
37 #include <uvm/uvm_extern.h>
38
39 #include <machine/autoconf.h>
40 #include <machine/bus.h>
41
42 #include <mips/pte.h>
43
44 #include <arc/arc/wired_map.h>
45 #include <arc/dev/pcconsvar.h>
46 #include <arc/jazz/jazziovar.h>
47 #include <arc/jazz/pica.h>
48 #include <arc/jazz/pccons_jazziovar.h>
49
50 #define PCKBD_INTR 6 /* XXX - should be obtained from firmware */
51
52 int pccons_jazzio_match __P((struct device *, struct cfdata *, void *));
53 void pccons_jazzio_attach __P((struct device *, struct device *, void *));
54
55 CFATTACH_DECL(pc_jazzio, sizeof(struct pc_softc),
56 pccons_jazzio_match, pccons_jazzio_attach, NULL, NULL);
57
58 /*
59 * chipset-dependent pccons configuration
60 */
61
62 void pccons_jazzio_init __P((void));
63
64 struct pccons_config pccons_jazzio_conf = {
65 0x3b4, 0xb0000, /* mono: iobase, memaddr */
66 0x3d4, 0xb8000, /* cga: iobase, memaddr */
67 PICA_SYS_KBD + 0x61, PICA_SYS_KBD + 0x60, /* kbdc: cmdport, dataport */
68 pccons_jazzio_init
69 };
70
71 void
72 pccons_jazzio_init()
73 {
74 /* nothing to do */
75 }
76
77 int pccons_jazzio_init_tag __P((char*, bus_space_tag_t*,bus_space_tag_t*));
78
79 int
80 pccons_jazzio_init_tag(name, iotp, memtp)
81 char *name;
82 bus_space_tag_t *iotp, *memtp;
83 {
84 static int initialized = 0;
85 static struct arc_bus_space vga_io, vga_mem;
86
87 if (strcmp(name, "ALI_S3") != 0)
88 return(ENXIO);
89
90 if (!initialized) {
91 initialized = 1;
92
93 arc_bus_space_init(&vga_io, "vga_jazzio_io",
94 PICA_P_LOCAL_VIDEO_CTRL, PICA_V_LOCAL_VIDEO_CTRL,
95 0, PICA_S_LOCAL_VIDEO_CTRL);
96 arc_bus_space_init(&vga_mem, "vga_jazzio_mem",
97 PICA_P_LOCAL_VIDEO, PICA_V_LOCAL_VIDEO,
98 0, PICA_S_LOCAL_VIDEO);
99
100 arc_enter_wired(PICA_V_LOCAL_VIDEO_CTRL,
101 PICA_P_LOCAL_VIDEO_CTRL,
102 PICA_P_LOCAL_VIDEO_CTRL + PICA_S_LOCAL_VIDEO_CTRL/2,
103 MIPS3_PG_SIZE_1M);
104 arc_enter_wired(PICA_V_LOCAL_VIDEO,
105 PICA_P_LOCAL_VIDEO,
106 PICA_P_LOCAL_VIDEO + PICA_S_LOCAL_VIDEO/2,
107 MIPS3_PG_SIZE_4M);
108 #if 0
109 arc_enter_wired(PICA_V_EXTND_VIDEO_CTRL,
110 PICA_P_EXTND_VIDEO_CTRL,
111 PICA_P_EXTND_VIDEO_CTRL + PICA_S_EXTND_VIDEO_CTRL/2,
112 MIPS3_PG_SIZE_1M);
113 #endif
114 }
115 *iotp = &vga_io;
116 *memtp = &vga_mem;
117 return (0);
118 }
119
120 int
121 pccons_jazzio_match(parent, match, aux)
122 struct device *parent;
123 struct cfdata *match;
124 void *aux;
125 {
126 struct jazzio_attach_args *ja = aux;
127 bus_space_tag_t crt_iot, crt_memt;
128
129 if (pccons_jazzio_init_tag(ja->ja_name, &crt_iot, &crt_memt))
130 return (0);
131
132 if (!pccons_common_match(crt_iot, crt_memt, ja->ja_bust,
133 &pccons_jazzio_conf))
134 return (0);
135
136 return (1);
137 }
138
139 void
140 pccons_jazzio_attach(parent, self, aux)
141 struct device *parent, *self;
142 void *aux;
143 {
144 struct pc_softc *sc = (struct pc_softc *)self;
145 struct jazzio_attach_args *ja = aux;
146 bus_space_tag_t crt_iot, crt_memt;
147
148 pccons_jazzio_init_tag(ja->ja_name, &crt_iot, &crt_memt);
149 jazzio_intr_establish(PCKBD_INTR, pcintr, self);
150 pccons_common_attach(sc, crt_iot, crt_memt, ja->ja_bust,
151 &pccons_jazzio_conf);
152 }
153
154 int
155 pccons_jazzio_cnattach(name, kbd_iot)
156 char *name;
157 bus_space_tag_t kbd_iot;
158 {
159 bus_space_tag_t crt_iot, crt_memt;
160
161 if (pccons_jazzio_init_tag(name, &crt_iot, &crt_memt))
162 return (ENXIO);
163 pccons_common_cnattach(crt_iot, crt_memt, kbd_iot,
164 &pccons_jazzio_conf);
165 return (0);
166 }
167
168