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