No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / arc / jazz / vga_jazzio.c
blob57490e48c03c63589343cbbcbaa6a6bce7919cf3
1 /* $NetBSD: vga_jazzio.c,v 1.14 2005/12/11 12:16:39 christos Exp $ */
2 /* NetBSD: vga_isa.c,v 1.3 1998/06/12 18:45:48 drochner Exp */
4 /*
5 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
6 * All rights reserved.
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.
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: vga_jazzio.c,v 1.14 2005/12/11 12:16:39 christos Exp $");
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
37 #include <sys/device.h>
38 #include <sys/malloc.h>
39 #include <uvm/uvm_extern.h>
41 #include <machine/autoconf.h>
42 #include <machine/bus.h>
43 #include <machine/wired_map.h>
45 #include <mips/pte.h>
47 #include <dev/ic/mc6845reg.h>
48 #include <dev/ic/pcdisplayvar.h>
49 #include <dev/ic/vgareg.h>
50 #include <dev/ic/vgavar.h>
52 #include <arc/jazz/jazziovar.h>
53 #include <arc/jazz/pica.h>
54 #include <arc/jazz/vga_jazziovar.h>
56 #include <dev/wscons/wsconsio.h>
57 #include <dev/wscons/wsdisplayvar.h>
59 #define WSDISPLAY_TYPE_JAZZVGA WSDISPLAY_TYPE_PCIVGA /* XXX not really */
61 int vga_jazzio_init_tag(const char *, bus_space_tag_t *, bus_space_tag_t *);
62 paddr_t vga_jazzio_mmap(void *, off_t, int);
63 int vga_jazzio_match(device_t, cfdata_t, void *);
64 void vga_jazzio_attach(device_t, device_t, void *);
66 CFATTACH_DECL_NEW(vga_jazzio, sizeof(struct vga_softc),
67 vga_jazzio_match, vga_jazzio_attach, NULL, NULL);
69 const struct vga_funcs vga_jazzio_funcs = {
70 NULL,
71 vga_jazzio_mmap,
74 int
75 vga_jazzio_init_tag(const char *name, bus_space_tag_t *iotp,
76 bus_space_tag_t *memtp)
78 static int initialized = 0;
79 static struct arc_bus_space vga_io, vga_mem;
81 if (strcmp(name, "ALI_S3") != 0)
82 return ENXIO;
84 if (!initialized) {
85 initialized = 1;
87 arc_bus_space_init(&vga_io, "vga_jazzio_io",
88 PICA_P_LOCAL_VIDEO_CTRL, PICA_V_LOCAL_VIDEO_CTRL,
89 0, PICA_S_LOCAL_VIDEO_CTRL);
90 arc_bus_space_init(&vga_mem, "vga_jazzio_mem",
91 PICA_P_LOCAL_VIDEO, PICA_V_LOCAL_VIDEO,
92 0, PICA_S_LOCAL_VIDEO);
94 arc_wired_enter_page(PICA_V_LOCAL_VIDEO_CTRL,
95 PICA_P_LOCAL_VIDEO_CTRL,
96 PICA_S_LOCAL_VIDEO_CTRL / 2);
97 arc_wired_enter_page(
98 PICA_V_LOCAL_VIDEO_CTRL + PICA_S_LOCAL_VIDEO_CTRL/2,
99 PICA_P_LOCAL_VIDEO_CTRL + PICA_S_LOCAL_VIDEO_CTRL/2,
100 PICA_S_LOCAL_VIDEO_CTRL / 2);
102 arc_wired_enter_page(PICA_V_LOCAL_VIDEO,
103 PICA_P_LOCAL_VIDEO,
104 PICA_S_LOCAL_VIDEO / 2);
105 arc_wired_enter_page(
106 PICA_V_LOCAL_VIDEO + PICA_S_LOCAL_VIDEO / 2,
107 PICA_P_LOCAL_VIDEO + PICA_S_LOCAL_VIDEO / 2,
108 PICA_S_LOCAL_VIDEO / 2);
109 #if 0
110 arc_wired_enter_page(PICA_V_EXTND_VIDEO_CTRL,
111 PICA_P_EXTND_VIDEO_CTRL,
112 PICA_S_EXTND_VIDEO_CTRL / 2);
113 arc_wired_enter_page(
114 PICA_V_EXTND_VIDEO_CTRL + PICA_S_EXTND_VIDEO_CTRL / 2,
115 PICA_P_EXTND_VIDEO_CTRL + PICA_S_EXTND_VIDEO_CTRL / 2,
116 PICA_S_EXTND_VIDEO_CTRL / 2);
117 #endif
119 *iotp = &vga_io;
120 *memtp = &vga_mem;
121 return 0;
124 paddr_t
125 vga_jazzio_mmap(void *v, off_t offset, int prot)
128 if (offset >= 0xa0000 && offset < 0xc0000)
129 return mips_btop(PICA_P_LOCAL_VIDEO + offset);
130 if (offset >= 0x0000 && offset < 0x10000)
131 return mips_btop(PICA_P_LOCAL_VIDEO_CTRL + offset);
132 if (offset >= 0x40000000 && offset < 0x40800000)
133 return mips_btop(PICA_P_LOCAL_VIDEO + offset - 0x40000000);
134 return -1;
138 vga_jazzio_match(device_t parent, cfdata_t match, void *aux)
140 struct jazzio_attach_args *ja = aux;
141 bus_space_tag_t iot, memt;
143 if (vga_jazzio_init_tag(ja->ja_name, &iot, &memt))
144 return 0;
146 if (!vga_is_console(iot, WSDISPLAY_TYPE_JAZZVGA) &&
147 !vga_common_probe(iot, memt))
148 return 0;
150 return 1;
153 void
154 vga_jazzio_attach(device_t parent, device_t self, void *aux)
156 struct vga_softc *sc = device_private(self);
157 struct jazzio_attach_args *ja = aux;
158 bus_space_tag_t iot, memt;
160 aprint_normal("\n");
162 sc->sc_dev = self;
163 vga_jazzio_init_tag(ja->ja_name, &iot, &memt);
164 vga_common_attach(sc, iot, memt, WSDISPLAY_TYPE_JAZZVGA, 0,
165 &vga_jazzio_funcs);
169 vga_jazzio_cnattach(char *name)
171 bus_space_tag_t iot, memt;
173 if (vga_jazzio_init_tag(name, &iot, &memt))
174 return ENXIO;
175 return vga_cnattach(iot, memt, WSDISPLAY_TYPE_JAZZVGA, 1);