1 /* $NetBSD: cgsix_obio.c,v 1.22 2008/04/28 20:23:35 martin Exp $ */
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * color display (cgsix) driver; sun4 obio bus front-end.
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: cgsix_obio.c,v 1.22 2008/04/28 20:23:35 martin Exp $");
39 #include <sys/param.h>
40 #include <sys/systm.h>
42 #include <sys/device.h>
43 #include <sys/ioctl.h>
44 #include <sys/malloc.h>
51 #include <sys/syslog.h>
54 #include <machine/bus.h>
55 #include <machine/autoconf.h>
56 #include <machine/eeprom.h>
58 #include <dev/sun/fbio.h>
59 #include <dev/sun/fbvar.h>
60 #include <dev/sun/btreg.h>
61 #include <dev/sun/btvar.h>
62 #include <dev/sun/cgsixreg.h>
63 #include <dev/sun/cgsixvar.h>
64 #include <dev/sun/pfourreg.h>
66 /* autoconfiguration driver */
67 static int cgsixmatch(device_t
, struct cfdata
*, void *);
68 static void cgsixattach(device_t
, device_t
, void *);
69 static int cg6_pfour_probe(void *, void *);
71 CFATTACH_DECL(cgsix_obio
, sizeof(struct cgsix_softc
),
72 cgsixmatch
, cgsixattach
, NULL
, NULL
);
78 cgsixmatch(device_t parent
, struct cfdata
*cf
, void *aux
)
80 union obio_attach_args
*uoba
= aux
;
81 struct obio4_attach_args
*oba
;
83 if (uoba
->uoba_isobio4
== 0)
86 oba
= &uoba
->uoba_oba4
;
87 return (bus_space_probe(oba
->oba_bustag
,
88 oba
->oba_paddr
+ CGSIX_FHC_OFFSET
,
92 cg6_pfour_probe
, NULL
));
96 cg6_pfour_probe(void *vaddr
, void *arg
)
99 return (fb_pfour_id(vaddr
) == PFOUR_ID_FASTCOLOR
);
107 cgsixattach(device_t parent
, device_t self
, void *aux
)
109 struct cgsix_softc
*sc
= device_private(self
);
110 union obio_attach_args
*uoba
= aux
;
111 struct obio4_attach_args
*oba
;
112 struct eeprom
*eep
= (struct eeprom
*)eeprom_va
;
113 struct fbdevice
*fb
= &sc
->sc_fb
;
114 bus_space_handle_t bh
;
115 int constype
, isconsole
;
119 oba
= &uoba
->uoba_oba4
;
121 /* Remember cookies for cgsix_mmap() */
122 sc
->sc_bustag
= oba
->oba_bustag
;
123 sc
->sc_paddr
= (bus_addr_t
)oba
->oba_paddr
;
125 fb
->fb_device
= sc
->sc_dev
;
126 fb
->fb_type
.fb_type
= FBTYPE_SUNFAST_COLOR
;
127 fb
->fb_flags
= device_cfdata(sc
->sc_dev
)->cf_flags
& FB_USERMASK
;
128 fb
->fb_type
.fb_depth
= 8;
130 fb_setsize_eeprom(fb
, fb
->fb_type
.fb_depth
, 1152, 900);
132 sc
->sc_ramsize
= 1024 * 1024; /* All our cgsix's are 1MB */
135 * Dunno what the PROM has mapped, though obviously it must have
136 * the video RAM mapped. Just map what we care about for ourselves
137 * (the FHC, THC, and Brooktree registers).
139 if (bus_space_map(oba
->oba_bustag
,
140 oba
->oba_paddr
+ CGSIX_BT_OFFSET
,
142 BUS_SPACE_MAP_LINEAR
,
144 printf("%s: cannot map brooktree registers\n", self
->dv_xname
);
147 sc
->sc_bt
= (struct bt_regs
*)bh
;
149 if (bus_space_map(oba
->oba_bustag
,
150 oba
->oba_paddr
+ CGSIX_FHC_OFFSET
,
152 BUS_SPACE_MAP_LINEAR
,
154 printf("%s: cannot map FHC registers\n", self
->dv_xname
);
157 sc
->sc_fhc
= (int *)bh
;
159 if (bus_space_map(oba
->oba_bustag
,
160 oba
->oba_paddr
+ CGSIX_THC_OFFSET
,
162 BUS_SPACE_MAP_LINEAR
,
164 printf("%s: cannot map THC registers\n", self
->dv_xname
);
167 sc
->sc_thc
= (struct cg6_thc
*)bh
;
169 if (bus_space_map(oba
->oba_bustag
,
170 oba
->oba_paddr
+ CGSIX_TEC_OFFSET
,
172 BUS_SPACE_MAP_LINEAR
,
174 printf("%s: cannot map TEC registers\n", self
->dv_xname
);
177 sc
->sc_tec
= (struct cg6_tec_xxx
*)bh
;
179 if (bus_space_map(oba
->oba_bustag
,
180 oba
->oba_paddr
+ CGSIX_FBC_OFFSET
,
182 BUS_SPACE_MAP_LINEAR
,
184 printf("%s: cannot map FBC registers\n", self
->dv_xname
);
187 sc
->sc_fbc
= (struct cg6_fbc
*)bh
;
190 if (fb_pfour_id(sc
->sc_fhc
) == PFOUR_ID_FASTCOLOR
) {
191 fb
->fb_flags
|= FB_PFOUR
;
196 constype
= (fb
->fb_flags
& FB_PFOUR
) ? EE_CONS_P4OPT
: EE_CONS_COLOR
;
199 * Check to see if this is the console if there's no eeprom info
200 * to be found, or if it's the correct framebuffer type.
202 if (eep
== NULL
|| eep
->eeConsole
== constype
)
203 isconsole
= fb_is_console(0);
207 if (isconsole
&& cgsix_use_rasterconsole
) {
208 if (bus_space_map(oba
->oba_bustag
,
209 oba
->oba_paddr
+ CGSIX_RAM_OFFSET
,
211 BUS_SPACE_MAP_LINEAR
,
213 printf("%s: cannot map pixels\n", self
->dv_xname
);
216 sc
->sc_fb
.fb_pixels
= (void *)bh
;
219 cg6attach(sc
, name
, isconsole
);