summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2002-06-11 06:53:04 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2002-06-11 06:53:04 +0000
commitde34a43cd23fb0127b21e66425164a48091078e6 (patch)
tree1064fea2d3750b2883222ca78af997a1d43bd9f9 /sys/arch/sparc64
parent70493de8041d17c76809e0574b54ed423b12b321 (diff)
split creator driver into bus specific and common code.
requested and ok by jason@
Diffstat (limited to 'sys/arch/sparc64')
-rw-r--r--sys/arch/sparc64/conf/files.sparc646
-rw-r--r--sys/arch/sparc64/dev/creator.c121
-rw-r--r--sys/arch/sparc64/dev/creator_mainbus.c119
-rw-r--r--sys/arch/sparc64/dev/creatorvar.h73
4 files changed, 209 insertions, 110 deletions
diff --git a/sys/arch/sparc64/conf/files.sparc64 b/sys/arch/sparc64/conf/files.sparc64
index b3c59bb42c7..9f15169c691 100644
--- a/sys/arch/sparc64/conf/files.sparc64
+++ b/sys/arch/sparc64/conf/files.sparc64
@@ -1,4 +1,4 @@
-# $OpenBSD: files.sparc64,v 1.36 2002/06/08 21:56:02 jason Exp $
+# $OpenBSD: files.sparc64,v 1.37 2002/06/11 06:53:03 fgsch Exp $
# $NetBSD: files.sparc64,v 1.50 2001/08/10 20:53:50 eeh Exp $
# maxpartitions must be first item in files.${ARCH}
@@ -40,9 +40,11 @@ attach sbus at mainbus
file arch/sparc64/dev/sbus.c sbus
device creator: wsemuldisplaydev, rasops8, rasops16, rasops24, rasops32
-attach creator at mainbus
file arch/sparc64/dev/creator.c creator
+attach creator at mainbus with creator_mainbus
+file arch/sparc64/dev/creator_mainbus.c creator_mainbus
+
include "dev/pci/files.pci"
device psycho: pcibus
diff --git a/sys/arch/sparc64/dev/creator.c b/sys/arch/sparc64/dev/creator.c
index b950955fce4..c7e30a9659c 100644
--- a/sys/arch/sparc64/dev/creator.c
+++ b/sys/arch/sparc64/dev/creator.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: creator.c,v 1.11 2002/06/03 16:32:04 fgsch Exp $ */
+/* $OpenBSD: creator.c,v 1.12 2002/06/11 06:53:03 fgsch Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -48,34 +48,7 @@
#include <dev/wscons/wscons_raster.h>
#include <dev/rasops/rasops.h>
-/* Number of register sets */
-#define FFB_NREGS 24
-
-/* Register set numbers */
-#define FFB_REG_PROM 0
-#define FFB_REG_DAC 1
-#define FFB_REG_FBC 2
-#define FFB_REG_DFB8R 3
-#define FFB_REG_DFB8G 4
-#define FFB_REG_DFB8B 5
-#define FFB_REG_DFB8X 6
-#define FFB_REG_DFB24 7
-#define FFB_REG_DFB32 8
-#define FFB_REG_SFB8R 9
-#define FFB_REG_SFB8G 10
-#define FFB_REG_SFB8B 11
-#define FFB_REG_SFB8X 12
-#define FFB_REG_SFB32 13
-#define FFB_REG_SFB64 14
-#define FFB_REG_DFB422A 15
-#define FFB_REG_DFB422AD 16
-#define FFB_REG_DFB24B 17
-#define FFB_REG_DFB422B 18
-#define FFB_REG_DFB422BD 19
-#define FFB_REG_SFB8Z 20
-#define FFB_REG_SFB16Z 21
-#define FFB_REG_SFB422 22
-#define FFB_REG_SFB422D 23
+#include <sparc64/dev/creatorvar.h>
struct wsscreen_descr creator_stdscreen = {
"std",
@@ -110,70 +83,28 @@ struct wsdisplay_accessops creator_accessops = {
creator_alloc_screen,
creator_free_screen,
creator_show_screen,
- NULL, /* load_font */
+ NULL, /* load font */
NULL, /* scrollback */
NULL, /* getchar */
NULL, /* burner */
};
-struct creator_softc {
- struct device sc_dv;
- bus_space_tag_t sc_bt;
- bus_space_handle_t sc_pixel_h;
- bus_addr_t sc_addrs[FFB_NREGS];
- bus_size_t sc_sizes[FFB_NREGS];
- int sc_height, sc_width, sc_linebytes, sc_depth;
- int sc_nscreens, sc_nreg;
- u_int sc_mode;
- struct rasops_info sc_rasops;
-};
-
-int creator_match(struct device *, void *, void *);
-void creator_attach(struct device *, struct device *, void *);
-
-struct cfattach creator_ca = {
- sizeof(struct creator_softc), creator_match, creator_attach
-};
-
struct cfdriver creator_cd = {
NULL, "creator", DV_DULL
};
-int
-creator_match(parent, match, aux)
- struct device *parent;
- void *match, *aux;
-{
- struct mainbus_attach_args *ma = aux;
-
- if (strcmp(ma->ma_name, "SUNW,ffb") == 0 ||
- strcmp(ma->ma_name, "SUNW,afb") == 0)
- return (1);
- return (0);
-}
-
void
-creator_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+creator_attach(struct creator_softc *sc)
{
- struct creator_softc *sc = (struct creator_softc *)self;
- struct mainbus_attach_args *ma = aux;
struct wsemuldisplaydev_attach_args waa;
long defattr;
- extern int fbnode;
- int i, btype, console, nregs;
char *model;
-
- sc->sc_bt = ma->ma_bustag;
-
- nregs = min(ma->ma_nreg, FFB_NREGS);
+ int btype;
printf(":");
- if (strcmp(ma->ma_name, "SUNW,afb") != 0) {
- btype = getpropint(ma->ma_node, "board_type", 0);
-
+ if (sc->sc_type == FFB_CREATOR) {
+ btype = getpropint(sc->sc_node, "board_type", 0);
if ((btype & 7) == 3)
printf(" Creator3D");
else
@@ -181,35 +112,16 @@ creator_attach(parent, self, aux)
} else
printf(" Elite3D");
- model = getpropstring(ma->ma_node, "model");
+ model = getpropstring(sc->sc_node, "model");
if (model == NULL || strlen(model) == 0)
model = "unknown";
printf(", model %s\n", model);
- if (nregs < FFB_REG_DFB24) {
- printf(": no dfb24 regs found\n");
- goto fail;
- }
-
- if (bus_space_map2(sc->sc_bt, 0, ma->ma_reg[FFB_REG_DFB24].ur_paddr,
- ma->ma_reg[FFB_REG_DFB24].ur_len, 0, NULL, &sc->sc_pixel_h)) {
- printf("%s: failed to map dfb24\n", sc->sc_dv.dv_xname);
- goto fail;
- }
-
- for (i = 0; i < nregs; i++) {
- sc->sc_addrs[i] = ma->ma_reg[i].ur_paddr;
- sc->sc_sizes[i] = ma->ma_reg[i].ur_len;
- }
- sc->sc_nreg = nregs;
-
- console = (fbnode == ma->ma_node);
-
sc->sc_depth = 24;
sc->sc_linebytes = 8192;
- sc->sc_height = getpropint(ma->ma_node, "height", 0);
- sc->sc_width = getpropint(ma->ma_node, "width", 0);
+ sc->sc_height = getpropint(sc->sc_node, "height", 0);
+ sc->sc_width = getpropint(sc->sc_node, "width", 0);
sc->sc_rasops.ri_depth = 32;
sc->sc_rasops.ri_stride = sc->sc_linebytes;
@@ -230,7 +142,7 @@ creator_attach(parent, self, aux)
creator_stdscreen.textops = &sc->sc_rasops.ri_ops;
sc->sc_rasops.ri_ops.alloc_attr(&sc->sc_rasops, 0, 0, 0, &defattr);
- if (console) {
+ if (sc->sc_console) {
int *ccolp, *crowp;
if (romgetcursoraddr(&crowp, &ccolp))
@@ -244,18 +156,11 @@ creator_attach(parent, self, aux)
sc->sc_rasops.ri_ccol, sc->sc_rasops.ri_crow, defattr);
}
- waa.console = console;
+ waa.console = sc->sc_console;
waa.scrdata = &creator_screenlist;
waa.accessops = &creator_accessops;
waa.accesscookie = sc;
- config_found(self, &waa, wsemuldisplaydevprint);
-
- return;
-
-fail:
- if (sc->sc_pixel_h != 0)
- bus_space_unmap(sc->sc_bt, sc->sc_pixel_h,
- ma->ma_reg[FFB_REG_DFB24].ur_len);
+ config_found(&sc->sc_dv, &waa, wsemuldisplaydevprint);
}
int
diff --git a/sys/arch/sparc64/dev/creator_mainbus.c b/sys/arch/sparc64/dev/creator_mainbus.c
new file mode 100644
index 00000000000..113cc4562ab
--- /dev/null
+++ b/sys/arch/sparc64/dev/creator_mainbus.c
@@ -0,0 +1,119 @@
+/* $OpenBSD: creator_mainbus.c,v 1.1 2002/06/11 06:53:03 fgsch Exp $ */
+
+/*
+ * Copyright (c) 2002 Jason L. Wright (jason@thought.net)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jason L. Wright
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/conf.h>
+#include <sys/timeout.h>
+
+#include <machine/bus.h>
+#include <machine/autoconf.h>
+#include <machine/openfirm.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wscons/wscons_raster.h>
+#include <dev/rasops/rasops.h>
+
+#include <sparc64/dev/creatorvar.h>
+
+int creator_mainbus_match(struct device *, void *, void *);
+void creator_mainbus_attach(struct device *, struct device *, void *);
+
+struct cfattach creator_mainbus_ca = {
+ sizeof(struct creator_softc), creator_mainbus_match,
+ creator_mainbus_attach
+};
+
+int
+creator_mainbus_match(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct mainbus_attach_args *ma = aux;
+
+ if (strcmp(ma->ma_name, "SUNW,ffb") == 0 ||
+ strcmp(ma->ma_name, "SUNW,afb") == 0)
+ return (1);
+ return (0);
+}
+
+void
+creator_mainbus_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct creator_softc *sc = (struct creator_softc *)self;
+ struct mainbus_attach_args *ma = aux;
+ extern int fbnode;
+ int i, nregs;
+
+ sc->sc_bt = ma->ma_bustag;
+
+ nregs = min(ma->ma_nreg, FFB_NREGS);
+
+ if (nregs < FFB_REG_DFB24) {
+ printf(": no dfb24 regs found\n");
+ goto fail;
+ }
+
+ if (bus_space_map2(sc->sc_bt, 0, ma->ma_reg[FFB_REG_DFB24].ur_paddr,
+ ma->ma_reg[FFB_REG_DFB24].ur_len, 0, NULL, &sc->sc_pixel_h)) {
+ printf("%s: failed to map dfb24\n", sc->sc_dv.dv_xname);
+ goto fail;
+ }
+
+ for (i = 0; i < nregs; i++) {
+ sc->sc_addrs[i] = ma->ma_reg[i].ur_paddr;
+ sc->sc_sizes[i] = ma->ma_reg[i].ur_len;
+ }
+ sc->sc_nreg = nregs;
+
+ sc->sc_console = (fbnode == ma->ma_node);
+ sc->sc_node = ma->ma_node;
+
+ if (strcmp(ma->ma_name, "SUNW,afb") == 0)
+ sc->sc_type = FFB_AFB;
+
+ creator_attach(sc);
+
+ return;
+
+fail:
+ if (sc->sc_pixel_h != 0)
+ bus_space_unmap(sc->sc_bt, sc->sc_pixel_h,
+ ma->ma_reg[FFB_REG_DFB24].ur_len);
+}
diff --git a/sys/arch/sparc64/dev/creatorvar.h b/sys/arch/sparc64/dev/creatorvar.h
new file mode 100644
index 00000000000..933385c7d97
--- /dev/null
+++ b/sys/arch/sparc64/dev/creatorvar.h
@@ -0,0 +1,73 @@
+/* $OpenBSD: creatorvar.h,v 1.1 2002/06/11 06:53:03 fgsch Exp $ */
+
+/*
+ * Copyright (c) 2002 Jason L. Wright (jason@thought.net)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Jason L. Wright
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Number of register sets */
+#define FFB_NREGS 24
+
+/* Register set numbers */
+#define FFB_REG_PROM 0
+#define FFB_REG_DAC 1
+#define FFB_REG_FBC 2
+#define FFB_REG_DFB8R 3
+#define FFB_REG_DFB8G 4
+#define FFB_REG_DFB8B 5
+#define FFB_REG_DFB8X 6
+#define FFB_REG_DFB24 7
+#define FFB_REG_DFB32 8
+#define FFB_REG_SFB8R 9
+#define FFB_REG_SFB8G 10
+#define FFB_REG_SFB8B 11
+#define FFB_REG_SFB8X 12
+#define FFB_REG_SFB32 13
+#define FFB_REG_SFB64 14
+#define FFB_REG_DFB422A 15
+
+#define FFB_CREATOR 0
+#define FFB_AFB 1
+
+struct creator_softc {
+ struct device sc_dv;
+ bus_space_tag_t sc_bt;
+ bus_space_handle_t sc_pixel_h;
+ bus_addr_t sc_addrs[FFB_NREGS];
+ bus_size_t sc_sizes[FFB_NREGS];
+ int sc_height, sc_width, sc_linebytes, sc_depth;
+ int sc_nscreens, sc_nreg;
+ int sc_console;
+ int sc_node;
+ int sc_type;
+ u_int sc_mode;
+ struct rasops_info sc_rasops;
+};
+
+void creator_attach(struct creator_softc *);