1 /* $NetBSD: pccons_jazzio.c,v 1.8 2008/07/05 08:46:25 tsutsui Exp $ */
2 /* NetBSD: vga_isa.c,v 1.4 2000/08/14 20:14:51 thorpej Exp */
5 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
8 * Author: Chris G. Demetriou
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.
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.
20 * Carnegie Mellon requests users of this software to return to
22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
27 * any improvements or extensions that they make and grant Carnegie the
28 * rights to redistribute these changes.
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: pccons_jazzio.c,v 1.8 2008/07/05 08:46:25 tsutsui Exp $");
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/device.h>
37 #include <uvm/uvm_extern.h>
39 #include <machine/autoconf.h>
40 #include <machine/bus.h>
41 #include <machine/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>
50 #define PCKBD_INTR 6 /* XXX - should be obtained from firmware */
52 static int pccons_jazzio_match(device_t
, cfdata_t
, void *);
53 static void pccons_jazzio_attach(device_t
, device_t
, void *);
55 CFATTACH_DECL_NEW(pc_jazzio
, sizeof(struct pc_softc
),
56 pccons_jazzio_match
, pccons_jazzio_attach
, NULL
, NULL
);
59 * chipset-dependent pccons configuration
62 static void pccons_jazzio_init(void);
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 */
72 pccons_jazzio_init(void)
78 static int pccons_jazzio_init_tag(const char *, bus_space_tag_t
*,
82 pccons_jazzio_init_tag(const char *name
, bus_space_tag_t
*iotp
,
83 bus_space_tag_t
*memtp
)
85 static int initialized
= 0;
86 static struct arc_bus_space vga_io
, vga_mem
;
88 if (strcmp(name
, "ALI_S3") != 0)
94 arc_bus_space_init(&vga_io
, "vga_jazzio_io",
95 PICA_P_LOCAL_VIDEO_CTRL
, PICA_V_LOCAL_VIDEO_CTRL
,
96 0, PICA_S_LOCAL_VIDEO_CTRL
);
97 arc_bus_space_init(&vga_mem
, "vga_jazzio_mem",
98 PICA_P_LOCAL_VIDEO
, PICA_V_LOCAL_VIDEO
,
99 0, PICA_S_LOCAL_VIDEO
);
101 arc_wired_enter_page(
102 PICA_V_LOCAL_VIDEO_CTRL
,
103 PICA_P_LOCAL_VIDEO_CTRL
,
104 PICA_S_LOCAL_VIDEO_CTRL
/ 2);
105 arc_wired_enter_page(
106 PICA_V_LOCAL_VIDEO_CTRL
+ PICA_S_LOCAL_VIDEO_CTRL
/ 2,
107 PICA_P_LOCAL_VIDEO_CTRL
+ PICA_S_LOCAL_VIDEO_CTRL
/ 2,
108 PICA_S_LOCAL_VIDEO_CTRL
/ 2);
110 arc_wired_enter_page(PICA_V_LOCAL_VIDEO
,
112 PICA_S_LOCAL_VIDEO
/ 2);
113 arc_wired_enter_page(
114 PICA_V_LOCAL_VIDEO
+ PICA_S_LOCAL_VIDEO
/ 2,
115 PICA_P_LOCAL_VIDEO
+ PICA_S_LOCAL_VIDEO
/ 2,
116 PICA_S_LOCAL_VIDEO
/ 2);
118 arc_wired_enter_page(PICA_V_EXTND_VIDEO_CTRL
,
119 PICA_P_EXTND_VIDEO_CTRL
,
120 PICA_S_EXTND_VIDEO_CTRL
/ 2);
121 arc_wired_enter_page(
122 PICA_V_EXTND_VIDEO_CTRL
+ PICA_S_EXTND_VIDEO_CTRL
/ 2,
123 PICA_P_EXTND_VIDEO_CTRL
+ PICA_S_EXTND_VIDEO_CTRL
/ 2,
124 PICA_S_EXTND_VIDEO_CTRL
/ 2);
133 pccons_jazzio_match(device_t parent
, cfdata_t cf
, void *aux
)
135 struct jazzio_attach_args
*ja
= aux
;
136 bus_space_tag_t crt_iot
, crt_memt
;
138 if (pccons_jazzio_init_tag(ja
->ja_name
, &crt_iot
, &crt_memt
))
141 if (!pccons_common_match(crt_iot
, crt_memt
, ja
->ja_bust
,
142 &pccons_jazzio_conf
))
149 pccons_jazzio_attach(device_t parent
, device_t self
, void *aux
)
151 struct pc_softc
*sc
= device_private(self
);
152 struct jazzio_attach_args
*ja
= aux
;
153 bus_space_tag_t crt_iot
, crt_memt
;
155 pccons_jazzio_init_tag(ja
->ja_name
, &crt_iot
, &crt_memt
);
156 jazzio_intr_establish(PCKBD_INTR
, pcintr
, sc
);
157 pccons_common_attach(sc
, crt_iot
, crt_memt
, ja
->ja_bust
,
158 &pccons_jazzio_conf
);
162 pccons_jazzio_cnattach(char *name
, bus_space_tag_t kbd_iot
)
164 bus_space_tag_t crt_iot
, crt_memt
;
166 if (pccons_jazzio_init_tag(name
, &crt_iot
, &crt_memt
))
168 pccons_common_cnattach(crt_iot
, crt_memt
, kbd_iot
,
169 &pccons_jazzio_conf
);