diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2012-04-18 17:28:25 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2012-04-18 17:28:25 +0000 |
commit | 7733653e71155e17cac84345e1c8dbd080f6c0b2 (patch) | |
tree | 518bb2772904bfacde0e404039349c3413931749 /sys/arch | |
parent | 6f87851cb7fdd0607b5acf0225911e4b319d6e0d (diff) |
Split the existing impact@xbow attachment into generic impact routines, and
bus-specific attachment; impactreg.h and impactvar.h move from sgi/xbow/ to
sgi/dev/.
Teach the generic impact code how to code with pre-ImpactSR boards, which have
a slightly different register layout (information obtained from Peter Fuerst's
Linux IP28 patches).
Add an impact@gio attachment (unfortunately untested, no Impact GIO boards
here). All Indigo 2 graphics options should be supported now (assuming the
Extreme/Ultra will actually work with grtwo(4) out of the box).
Tested not to disturb operation on IP30.
** ATTENTION! If you are building IP27 or IP30 kernels, be sure to rm impact.d
** before building a new kernel.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/sgi/conf/GENERIC-IP22 | 10 | ||||
-rw-r--r-- | sys/arch/sgi/conf/RAMDISK-IP22 | 10 | ||||
-rw-r--r-- | sys/arch/sgi/conf/files.sgi | 6 | ||||
-rw-r--r-- | sys/arch/sgi/dev/impact.c (renamed from sys/arch/sgi/xbow/impact.c) | 235 | ||||
-rw-r--r-- | sys/arch/sgi/dev/impactreg.h (renamed from sys/arch/sgi/xbow/impactreg.h) | 53 | ||||
-rw-r--r-- | sys/arch/sgi/dev/impactvar.h (renamed from sys/arch/sgi/xbow/impactvar.h) | 22 | ||||
-rw-r--r-- | sys/arch/sgi/gio/files.gio | 19 | ||||
-rw-r--r-- | sys/arch/sgi/gio/gio.c | 88 | ||||
-rw-r--r-- | sys/arch/sgi/gio/impact_gio.c | 142 | ||||
-rw-r--r-- | sys/arch/sgi/sgi/wscons_machdep.c | 10 | ||||
-rw-r--r-- | sys/arch/sgi/xbow/files.xbow | 10 | ||||
-rw-r--r-- | sys/arch/sgi/xbow/impact_xbow.c | 169 |
12 files changed, 545 insertions, 229 deletions
diff --git a/sys/arch/sgi/conf/GENERIC-IP22 b/sys/arch/sgi/conf/GENERIC-IP22 index ee76fc83c49..1fbdf0512a5 100644 --- a/sys/arch/sgi/conf/GENERIC-IP22 +++ b/sys/arch/sgi/conf/GENERIC-IP22 @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC-IP22,v 1.10 2012/04/18 11:01:55 miod Exp $ +# $OpenBSD: GENERIC-IP22,v 1.11 2012/04/18 17:28:24 miod Exp $ # # THIS KERNEL IS FOR INDIGO (IP20), INDY (IP22) AND INDIGO2 (IP24) SYSTEMS ONLY. # @@ -28,8 +28,8 @@ option EISAVERBOSE # Define what targets to support option TGT_INDIGO # R4x00 Indigo (IP20) -option TGT_INDIGO2 # Indigo2 (IP22) -option TGT_INDY # Indy (IP24) +option TGT_INDIGO2 # Indigo2, Challenge M (IP22) +option TGT_INDY # Indy, Challenge S (IP24) option ARCBIOS # mandatory option CPU_R4000 # R4000/R4400 support (IP20/IP22/IP24) option CPU_R4600 # R4600 support (IP22/IP24) @@ -74,8 +74,10 @@ wskbd* at pckbd? mux 1 pms* at pckbc? wsmouse* at pms? mux 0 -grtwo* at gio? # Express (GR2) graphics +grtwo* at gio? # Express (GR2/GR3) graphics wsdisplay* at grtwo? +impact* at gio? # Impact graphics +wsdisplay* at impact? light* at gio? # Light/Starter/Entry (LG1/LG2) graphics wsdisplay* at light? newport* at gio? # Indy Newport and Indigo2 XL graphics diff --git a/sys/arch/sgi/conf/RAMDISK-IP22 b/sys/arch/sgi/conf/RAMDISK-IP22 index 1ebd7cfd542..bbde666f28b 100644 --- a/sys/arch/sgi/conf/RAMDISK-IP22 +++ b/sys/arch/sgi/conf/RAMDISK-IP22 @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK-IP22,v 1.7 2012/04/18 11:01:55 miod Exp $ +# $OpenBSD: RAMDISK-IP22,v 1.8 2012/04/18 17:28:24 miod Exp $ # # THIS KERNEL IS FOR INDIGO (IP20), INDY (IP22) AND INDIGO2 (IP24) SYSTEMS ONLY. @@ -36,8 +36,8 @@ option RAMDISK_HOOKS # Define what targets to support option TGT_INDIGO # R4x00 Indigo (IP20) -option TGT_INDIGO2 # Indigo2 (IP22/IP26/IP28) -option TGT_INDY # Indy (IP24) +option TGT_INDIGO2 # Indigo2, Challenge M (IP22) +option TGT_INDY # Indy, Challenge S (IP24) option ARCBIOS # mandatory option CPU_R4000 # R4000/R4400 support (IP20/IP22/IP24) option CPU_R4600 # R4600 support (IP22/IP24) @@ -81,8 +81,10 @@ wskbd* at pckbd? mux 1 #pms* at pckbc? #wsmouse* at pms? mux 0 -grtwo* at gio? # Express (GR2) graphics +grtwo* at gio? # Express (GR2/GR3) graphics wsdisplay* at grtwo? +impact* at gio? # Impact graphics +wsdisplay* at impact? light* at gio? # Light/Starter/Entry (LG1/LG2) graphics wsdisplay* at light? newport* at gio? # Indy Newport and Indigo2 XL graphics diff --git a/sys/arch/sgi/conf/files.sgi b/sys/arch/sgi/conf/files.sgi index 4707ba9bf1e..d9ce8fd9872 100644 --- a/sys/arch/sgi/conf/files.sgi +++ b/sys/arch/sgi/conf/files.sgi @@ -1,4 +1,4 @@ -# $OpenBSD: files.sgi,v 1.48 2012/04/16 22:31:34 miod Exp $ +# $OpenBSD: files.sgi,v 1.49 2012/04/18 17:28:24 miod Exp $ # # maxpartitions must be first item in files.${ARCH} # @@ -59,6 +59,10 @@ attach cpu at mainbus device clock attach clock at mainbus +# Impact/ImpactSR common code +device impact: wsemuldisplaydev, rasops32 +file arch/sgi/dev/impact.c impact needs-flag + # # IP20/22/24 specific devices # diff --git a/sys/arch/sgi/xbow/impact.c b/sys/arch/sgi/dev/impact.c index 1bd7fe38f04..ca4b9229056 100644 --- a/sys/arch/sgi/xbow/impact.c +++ b/sys/arch/sgi/dev/impact.c @@ -1,4 +1,4 @@ -/* $OpenBSD: impact.c,v 1.7 2012/04/16 22:17:16 miod Exp $ */ +/* $OpenBSD: impact.c,v 1.1 2012/04/18 17:28:24 miod Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -18,19 +18,22 @@ */ /* - * Driver for the SGI ImpactSR graphics board. + * Driver for the SGI Impact and ImpactSR graphics board. */ /* * The details regarding the design and operation of this hardware, along with * the necessary magic numbers, are only available thanks to the reverse * engineering work undertaken by Stanislaw Skowronek <skylark@linux-mips.org>. + * + * Differences between ImpactSR and Impact researched by Peter Fuerst + * <post@pfrst.de>. */ /* - * This driver currently lacks support for the HQ4 DMA engine, which could be - * used to speed up rasops `copy' operations a lot by doing framebuffer to - * memory, then memory to framebuffer operations. + * This driver currently lacks support for the HQ3 and HQ4 DMA engines, which + * could be used to speed up rasops `copy' operations a lot by doing + * framebuffer to memory, then memory to framebuffer operations. * * Of course, in an ideal world, these operations would be done with * framebuffer to framebuffer operations, but according to Skowronek, these @@ -49,51 +52,34 @@ #include <sys/types.h> #include <sys/malloc.h> -#include <machine/autoconf.h> - -#include <mips64/arcbios.h> +#include <machine/bus.h> #include <sgi/dev/gl.h> -#include <sgi/xbow/impactreg.h> -#include <sgi/xbow/impactvar.h> -#include <sgi/xbow/widget.h> -#include <sgi/xbow/xbow.h> -#include <sgi/xbow/xbowdevs.h> +#include <sgi/dev/impactreg.h> +#include <sgi/dev/impactvar.h> #include <dev/wscons/wsconsio.h> #include <dev/wscons/wsdisplayvar.h> #include <dev/rasops/rasops.h> -#define IMPACT_WIDTH 1280 -#define IMPACT_HEIGHT 1024 -#define IMPACT_DEPTH 32 - -struct impact_screen; - -struct impact_softc { - struct device sc_dev; - struct impact_screen *curscr; - int console; - int nscreens; -}; - -int impact_match(struct device *, void *, void *); -void impact_attach(struct device *, struct device *, void *); - -const struct cfattach impact_ca = { - sizeof(struct impact_softc), impact_match, impact_attach, -}; - struct cfdriver impact_cd = { NULL, "impact", DV_DULL, }; +#define IMPACT_WIDTH 1280 +#define IMPACT_HEIGHT 1024 +#define IMPACT_DEPTH 32 + struct impact_screen { struct rasops_info ri; long defattr; struct wsdisplay_charcell *bs; struct impact_softc *sc; + int has_hq4; + + bus_addr_t fifo_status; + bus_addr_t cfifo; bus_space_tag_t iot; bus_space_handle_t ioh; @@ -101,17 +87,13 @@ struct impact_screen { struct wsscreen_descr wsd; struct wsscreen_list wsl; struct wsscreen_descr *scrlist[1]; - - struct mips_bus_space iot_store; }; -int impact_is_console(struct xbow_attach_args *); - static inline void impact_cmd_fifo_write(struct impact_screen *, uint64_t, uint32_t, int); int impact_cmd_fifo_wait(struct impact_screen *); -void impact_setup(struct impact_screen *); +void impact_setup(struct impact_screen *, int); int impact_init_screen(struct impact_screen *); /* @@ -153,33 +135,13 @@ struct wsdisplay_accessops impact_accessops = { }; int -impact_match(struct device *parent, void *match, void *aux) -{ - struct xbow_attach_args *xaa = aux; - - if (xaa->xaa_vendor == XBOW_VENDOR_SGI5 && - xaa->xaa_product == XBOW_PRODUCT_SGI5_IMPACT) - return 1; - - return 0; -} - -void -impact_attach(struct device *parent, struct device *self, void *aux) +impact_attach_common(struct impact_softc *sc, bus_space_tag_t iot, + bus_space_handle_t ioh, int console, int has_hq4) { - struct xbow_attach_args *xaa = aux; struct wsemuldisplaydev_attach_args waa; - struct impact_softc *sc = (void *)self; struct impact_screen *scr; - if (strncmp(bios_graphics, "alive", 5) != 0) { - printf(" device has not been setup by firmware!\n"); - return; - } - - printf(" revision %d\n", xaa->xaa_revision); - - if (impact_is_console(xaa)) { + if (console) { /* * Setup has already been done via impact_cnattach(). */ @@ -195,34 +157,20 @@ impact_attach(struct device *parent, struct device *self, void *aux) M_NOWAIT | M_ZERO); if (scr == NULL) { printf("failed to allocate screen memory!\n"); - return; - } - - /* - * Create a copy of the bus space tag. - */ - bcopy(xaa->xaa_iot, &scr->iot_store, - sizeof(struct mips_bus_space)); - scr->iot = &scr->iot_store; - - /* Setup bus space mappings. */ - if (bus_space_map(scr->iot, IMPACTSR_REG_OFFSET, - IMPACTSR_REG_SIZE, 0, &scr->ioh)) { - printf("failed to map registers\n"); - free(scr, M_DEVBUF); - return; + return ENOMEM; } + scr->iot = iot; + scr->ioh = ioh; scr->sc = sc; sc->curscr = scr; /* Setup hardware and clear screen. */ - impact_setup(scr); + impact_setup(scr, has_hq4); if (impact_init_screen(scr) != 0) { printf("failed to allocate memory\n"); - bus_space_unmap(scr->iot, scr->ioh, IMPACTSR_REG_SIZE); free(scr, M_DEVBUF); - return; + return ENOMEM; } } @@ -236,7 +184,9 @@ impact_attach(struct device *parent, struct device *self, void *aux) waa.accesscookie = scr; waa.defaultscreens = 0; - config_found(self, &waa, wsemuldisplaydevprint); + config_found(&sc->sc_dev, &waa, wsemuldisplaydevprint); + + return 0; } int @@ -296,19 +246,58 @@ impact_init_screen(struct impact_screen *scr) */ void -impact_setup(struct impact_screen *scr) +impact_setup(struct impact_screen *scr, int has_hq4) { - /* HQ4 initialization */ - bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_CFIFO_HW, 0x00000047); - bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_CFIFO_LW, 0x00000014); - bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_CFIFO_DELAY, 0x00000064); - bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_DFIFO_HW, 0x00000040); - bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_DFIFO_LW, 0x00000010); - bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_DFIFO_DELAY, 0x00000000); + bus_addr_t xmap_base; + bus_addr_t vc3_base; + + scr->has_hq4 = has_hq4; + + if (has_hq4) { + xmap_base = IMPACTSR_XMAP_BASE; + vc3_base = IMPACTSR_VC3_BASE; + scr->fifo_status = IMPACTSR_FIFOSTATUS; + scr->cfifo = IMPACTSR_CFIFO; + } else { + xmap_base = IMPACT_XMAP_BASE; + vc3_base = IMPACT_VC3_BASE; + scr->fifo_status = IMPACT_FIFOSTATUS; + scr->cfifo = IMPACT_CFIFO; + } + + if (has_hq4) { + /* HQ4 initialization */ + bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_CFIFO_HW, + 0x00000047); + bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_CFIFO_LW, + 0x00000014); + bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_CFIFO_DELAY, + 0x00000064); + bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_DFIFO_HW, + 0x00000040); + bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_DFIFO_LW, + 0x00000010); + bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_DFIFO_DELAY, + 0x00000000); + } else { + /* HQ3 initialization */ + bus_space_write_4(scr->iot, scr->ioh, IMPACT_CFIFO_HW, + 0x00000020); + bus_space_write_4(scr->iot, scr->ioh, IMPACT_CFIFO_LW, + 0x00000014); + bus_space_write_4(scr->iot, scr->ioh, IMPACT_CFIFO_DELAY, + 0x00000064); + bus_space_write_4(scr->iot, scr->ioh, IMPACT_DFIFO_HW, + 0x00000028); + bus_space_write_4(scr->iot, scr->ioh, IMPACT_DFIFO_LW, + 0x00000014); + bus_space_write_4(scr->iot, scr->ioh, IMPACT_DFIFO_DELAY, + 0x00000fff); + } /* VC3 initialization: disable hardware cursor */ - bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_VC3_INDEXDATA, - 0x1d000100); + bus_space_write_4(scr->iot, scr->ioh, + vc3_base + IMPACTSR_VC3_INDEXDATA, 0x1d000100); /* RSS initialization */ impact_cmd_fifo_write(scr, IMPACTSR_CMD_COLORMASKLSBSA, 0xffffff, 0); @@ -322,10 +311,12 @@ impact_setup(struct impact_screen *scr) IMPACTSR_YXCOORDS(0, 0x3ff), 0); /* XMAP initialization */ - bus_space_write_1(scr->iot, scr->ioh, IMPACTSR_XMAP_PP1SELECT, 0x01); - bus_space_write_1(scr->iot, scr->ioh, IMPACTSR_XMAP_INDEX, 0x00); - bus_space_write_4(scr->iot, scr->ioh, IMPACTSR_XMAP_MAIN_MODE, - 0x000007a4); + bus_space_write_1(scr->iot, scr->ioh, + xmap_base + IMPACTSR_XMAP_PP1SELECT, 0x01); + bus_space_write_1(scr->iot, scr->ioh, + xmap_base + IMPACTSR_XMAP_INDEX, 0x00); + bus_space_write_4(scr->iot, scr->ioh, + xmap_base + IMPACTSR_XMAP_MAIN_MODE, 0x000007a4); } /* @@ -340,7 +331,7 @@ impact_cmd_fifo_write(struct impact_screen *scr, uint64_t reg, uint32_t val, cmd = IMPACTSR_CFIFO_WRITE | (reg << IMPACTSR_CFIFO_REG_SHIFT); if (exec) cmd |= IMPACTSR_CFIFO_EXEC; - bus_space_write_8(scr->iot, scr->ioh, IMPACTSR_CFIFO, cmd | val); + bus_space_write_8(scr->iot, scr->ioh, scr->cfifo, cmd | val); } /* @@ -354,7 +345,7 @@ impact_cmd_fifo_wait(struct impact_screen *scr) struct impact_softc *sc = scr->sc; #endif - val = bus_space_read_4(scr->iot, scr->ioh, IMPACTSR_FIFOSTATUS); + val = bus_space_read_4(scr->iot, scr->ioh, scr->fifo_status); while ((val & IMPACTSR_FIFO_MASK) != 0) { delay(1); if (--timeout == 0) { @@ -366,7 +357,7 @@ impact_cmd_fifo_wait(struct impact_screen *scr) #endif return ETIMEDOUT; } - val = bus_space_read_4(scr->iot, scr->ioh, IMPACTSR_FIFOSTATUS); + val = bus_space_read_4(scr->iot, scr->ioh, scr->fifo_status); } return 0; @@ -782,60 +773,22 @@ static struct wsdisplay_charcell impact_cons_bs[(IMPACT_WIDTH / 8) * (IMPACT_HEIGHT / 16)]; int -impact_cnprobe() -{ - u_int32_t wid, vendor, product; - - if (xbow_widget_id(console_output.nasid, console_output.widget, - &wid) != 0) - return 0; - - vendor = WIDGET_ID_VENDOR(wid); - product = WIDGET_ID_PRODUCT(wid); - - if (vendor != XBOW_VENDOR_SGI5 || product != XBOW_PRODUCT_SGI5_IMPACT) - return 0; - - if (strncmp(bios_graphics, "alive", 5) != 0) - return 0; - - return 1; -} - -int -impact_cnattach() +impact_cnattach_common(bus_space_tag_t iot, bus_space_handle_t ioh, int has_hq4) { struct impact_screen *scr = &impact_cons; struct rasops_info *ri = &scr->ri; int rc; - /* Build bus space accessor. */ - xbow_build_bus_space(&scr->iot_store, console_output.nasid, - console_output.widget); - scr->iot = &scr->iot_store; - - rc = bus_space_map(scr->iot, IMPACTSR_REG_OFFSET, IMPACTSR_REG_SIZE, - 0, &scr->ioh); - if (rc != 0) - return rc; - - impact_setup(scr); + scr->iot = iot; + scr->ioh = ioh; + impact_setup(scr, has_hq4); scr->bs = impact_cons_bs; rc = impact_init_screen(scr); - if (rc != 0) { - bus_space_unmap(scr->iot, scr->ioh, IMPACTSR_REG_SIZE); + if (rc != 0) return rc; - } ri->ri_ops.alloc_attr(ri, 0, 0, 0, &scr->defattr); wsdisplay_cnattach(&scr->wsd, ri, 0, 0, scr->defattr); return 0; } - -int -impact_is_console(struct xbow_attach_args *xaa) -{ - return xaa->xaa_nasid == console_output.nasid && - xaa->xaa_widget == console_output.widget; -} diff --git a/sys/arch/sgi/xbow/impactreg.h b/sys/arch/sgi/dev/impactreg.h index 199bbe7305f..15b6f909b2d 100644 --- a/sys/arch/sgi/xbow/impactreg.h +++ b/sys/arch/sgi/dev/impactreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: impactreg.h,v 1.2 2012/04/16 22:17:16 miod Exp $ */ +/* $OpenBSD: impactreg.h,v 1.1 2012/04/18 17:28:24 miod Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. * Copyright (c) 2009, 2010 Joel Sing <jsing@openbsd.org> @@ -17,12 +17,9 @@ */ /* - * ImpactSR registers + * Impact and ImpactSR registers */ -#define IMPACTSR_REG_OFFSET 0x00000000 -#define IMPACTSR_REG_SIZE 0x00200000 - #define IMPACTSR_STATUS 0x020000 #define IMPACTSR_FIFOSTATUS 0x020008 #define IMPACTSR_FIFO_MASK 0x000000ff @@ -30,28 +27,46 @@ #define IMPACTSR_DMABUSY 0x020200 #define IMPACTSR_CFIFO 0x020400 +#define IMPACT_STATUS 0x070000 +#define IMPACT_FIFOSTATUS 0x070004 +#define IMPACT_GIOSTATUS 0x070100 +#define IMPACT_DMABUSY 0x070104 +#define IMPACT_CFIFO 0x070080 + #define IMPACTSR_CFIFO_HW 0x040000 #define IMPACTSR_CFIFO_LW 0x040008 #define IMPACTSR_CFIFO_DELAY 0x040010 #define IMPACTSR_DFIFO_HW 0x040020 #define IMPACTSR_DFIFO_LW 0x040028 #define IMPACTSR_DFIFO_DELAY 0x040030 +#define IMPACT_CFIFO_HW 0x050020 +#define IMPACT_CFIFO_LW 0x050024 +#define IMPACT_CFIFO_DELAY 0x050028 +#define IMPACT_DFIFO_HW 0x05002c +#define IMPACT_DFIFO_LW 0x050030 +#define IMPACT_DFIFO_DELAY 0x050034 + +#define IMPACTSR_XMAP_BASE 0x071c00 +#define IMPACT_XMAP_BASE 0x061c00 + +#define IMPACTSR_XMAP_PP1SELECT 0x000008 +#define IMPACTSR_XMAP_INDEX 0x000088 +#define IMPACTSR_XMAP_CONFIG 0x000100 +#define IMPACTSR_XMAP_CONFIGB 0x000108 +#define IMPACTSR_XMAP_BUF_SELECT 0x000180 +#define IMPACTSR_XMAP_MAIN_MODE 0x000200 +#define IMPACTSR_XMAP_OVERLAY_MODE 0x000280 +#define IMPACTSR_XMAP_DIB 0x000300 +#define IMPACTSR_XMAP_DIB_DW 0x000340 +#define IMPACTSR_XMAP_RE_RAC 0x000380 -#define IMPACTSR_XMAP_PP1SELECT 0x071c08 -#define IMPACTSR_XMAP_INDEX 0x071c88 -#define IMPACTSR_XMAP_CONFIG 0x071d00 -#define IMPACTSR_XMAP_CONFIGB 0x071d08 -#define IMPACTSR_XMAP_BUF_SELECT 0x071d80 -#define IMPACTSR_XMAP_MAIN_MODE 0x071e00 -#define IMPACTSR_XMAP_OVERLAY_MODE 0x071e80 -#define IMPACTSR_XMAP_DIB 0x071f00 -#define IMPACTSR_XMAP_DIB_DW 0x071f40 -#define IMPACTSR_XMAP_RE_RAC 0x071f80 +#define IMPACTSR_VC3_BASE 0x072000 +#define IMPACT_VC3_BASE 0x062000 -#define IMPACTSR_VC3_INDEX 0x072008 -#define IMPACTSR_VC3_INDEXDATA 0x072038 -#define IMPACTSR_VC3_DATA 0x0720b0 -#define IMPACTSR_VC3_RAM 0x072190 +#define IMPACTSR_VC3_INDEX 0x000008 +#define IMPACTSR_VC3_INDEXDATA 0x000038 +#define IMPACTSR_VC3_DATA 0x0000b0 +#define IMPACTSR_VC3_RAM 0x000190 /* * Command FIFO instruction encoding diff --git a/sys/arch/sgi/xbow/impactvar.h b/sys/arch/sgi/dev/impactvar.h index a7a7fb723fd..cc88b38a44c 100644 --- a/sys/arch/sgi/xbow/impactvar.h +++ b/sys/arch/sgi/dev/impactvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: impactvar.h,v 1.2 2010/04/06 19:12:34 miod Exp $ */ +/* $OpenBSD: impactvar.h,v 1.1 2012/04/18 17:28:24 miod Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -16,5 +16,21 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -int impact_cnprobe(void); -int impact_cnattach(void); +struct impact_screen; + +struct impact_softc { + struct device sc_dev; + struct impact_screen *curscr; + int console; + int nscreens; +}; + +int impact_attach_common(struct impact_softc *, bus_space_tag_t, + bus_space_handle_t, int, int); +int impact_cnattach_common(bus_space_tag_t, bus_space_handle_t, int); + +struct gio_attach_args; +int impact_gio_cnprobe(struct gio_attach_args *); +int impact_gio_cnattach(struct gio_attach_args *); +int impact_xbow_cnprobe(void); +int impact_xbow_cnattach(void); diff --git a/sys/arch/sgi/gio/files.gio b/sys/arch/sgi/gio/files.gio index f8131536844..e915bdd4cb8 100644 --- a/sys/arch/sgi/gio/files.gio +++ b/sys/arch/sgi/gio/files.gio @@ -1,31 +1,36 @@ -# $OpenBSD: files.gio,v 1.2 2012/04/17 15:36:55 miod Exp $ +# $OpenBSD: files.gio,v 1.3 2012/04/18 17:28:24 miod Exp $ # $NetBSD: files.gio,v 1.11 2009/02/12 06:33:57 rumble Exp $ device gio {[slot = -1], [addr = -1]} attach gio at giobus -file arch/sgi/gio/gio.c gio needs-flag +file arch/sgi/gio/gio.c gio needs-flag device hpc {[offset = -1]}: smc93cx6 attach hpc at gio -file arch/sgi/hpc/hpc.c hpc +file arch/sgi/hpc/hpc.c hpc # XL graphics device newport: wsemuldisplaydev, rasops8 attach newport at gio -file arch/sgi/gio/newport.c newport needs-flag +file arch/sgi/gio/newport.c newport needs-flag # GR2 graphics device grtwo: wsemuldisplaydev, rasops8 attach grtwo at gio -file arch/sgi/gio/grtwo.c grtwo needs-flag +file arch/sgi/gio/grtwo.c grtwo needs-flag # LG1/LG2 graphics device light: wsemuldisplaydev, rasops8 attach light at gio -file arch/sgi/gio/light.c light needs-flag +file arch/sgi/gio/light.c light needs-flag + +# Impact graphics +attach impact at gio with impact_gio +file arch/sgi/gio/impact_gio.c impact & + impact_gio needs-flag # PCI cards glued to the GIO bus device giopci: pcibus attach giopci at gio -file arch/sgi/gio/pci_gio.c giopci +file arch/sgi/gio/pci_gio.c giopci diff --git a/sys/arch/sgi/gio/gio.c b/sys/arch/sgi/gio/gio.c index 039d7202e16..e2d42e50ff4 100644 --- a/sys/arch/sgi/gio/gio.c +++ b/sys/arch/sgi/gio/gio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gio.c,v 1.4 2012/04/18 10:59:45 miod Exp $ */ +/* $OpenBSD: gio.c,v 1.5 2012/04/18 17:28:24 miod Exp $ */ /* $NetBSD: gio.c,v 1.32 2011/07/01 18:53:46 dyoung Exp $ */ /* @@ -59,6 +59,7 @@ #include <sgi/gio/gioreg.h> #include <sgi/gio/giovar.h> +#include <sgi/gio/giodevs.h> #include <sgi/gio/giodevs_data.h> #include <sgi/gio/grtworeg.h> @@ -68,12 +69,16 @@ #include <sgi/sgi/ip22.h> #include "grtwo.h" +#include "impact.h" #include "light.h" #include "newport.h" #if NGRTWO > 0 #include <sgi/gio/grtwovar.h> #endif +#if NIMPACT_GIO > 0 +#include <sgi/dev/impactvar.h> +#endif #if NLIGHT > 0 #include <sgi/gio/lightvar.h> #endif @@ -273,9 +278,6 @@ gio_attach(struct device *parent, struct device *self, void *aux) slot_bases[i].mach_subtype != sys_config.system_subtype) continue; - if (slot_bases[i].base == giofb_consaddr) - continue; - for (j = 0; j < ngfx; j++) { if (slot_bases[i].base == gfx[j]) { skip = 1; @@ -367,7 +369,7 @@ gio_id(vaddr_t va, paddr_t pa, int maybe_gfx) /* * If there is a frame buffer device, then either we have hit a * device register (light, grtwo), or we did not fault because - * the slot is pipelined (impact, newport). + * the slot is pipelined (newport). * In the latter case, we attempt to probe a known register * offset. */ @@ -376,17 +378,8 @@ gio_id(vaddr_t va, paddr_t pa, int maybe_gfx) if (id32 != 4 || id16 != 2 || id8 != 1) return GIO_FAKE_FB_ID; - /* could be impact(4) */ - va += 0x70000; - if (guarded_read_4(va, &id32) == 0 && - guarded_read_2(va | 2, &id16) == 0 && - guarded_read_1(va | 3, &id8) == 0) { - if (id32 != 4 || id16 != 2 || id8 != 1) - return GIO_FAKE_FB_ID; - } - /* could be newport(4) */ - va += 0x80000; + va += 0xf0000; if (guarded_read_4(va, &id32) == 0 && guarded_read_2(va | 2, &id16) == 0 && guarded_read_1(va | 3, &id8) == 0) { @@ -522,21 +515,29 @@ giofb_cnprobe() ga.ga_product = -1; ga.ga_descr = NULL; - if (gio_id(ga.ga_ioh, ga.ga_addr, 1) != GIO_FAKE_FB_ID) - continue; - + switch (gio_id(ga.ga_ioh, ga.ga_addr, 1)) { + case GIO_PRODUCT_IMPACT: +#if NIMPACT_GIO > 0 + ga.ga_product = GIO_PRODUCT_IMPACT; + if (impact_gio_cnprobe(&ga) != 0) + return 0; +#endif + break; + case GIO_FAKE_FB_ID: #if NGRTWO > 0 - if (grtwo_cnprobe(&ga) != 0) - return 0; + if (grtwo_cnprobe(&ga) != 0) + return 0; #endif #if NLIGHT > 0 - if (light_cnprobe(&ga) != 0) - return 0; + if (light_cnprobe(&ga) != 0) + return 0; #endif #if NNEWPORT > 0 - if (newport_cnprobe(&ga) != 0) - return 0; + if (newport_cnprobe(&ga) != 0) + return 0; #endif + break; + } } return ENXIO; @@ -569,28 +570,35 @@ giofb_cnattach() ga.ga_product = -1; ga.ga_descr = NULL; - if (gio_id(ga.ga_ioh, ga.ga_addr, 1) != GIO_FAKE_FB_ID) - continue; - - /* - * We still need to probe before attach since we don't - * know the frame buffer type here. - */ + switch (gio_id(ga.ga_ioh, ga.ga_addr, 1)) { + case GIO_PRODUCT_IMPACT: +#if NIMPACT_GIO > 0 + if (impact_gio_cnattach(&ga) == 0) + return 0; +#endif + break; + case GIO_FAKE_FB_ID: + /* + * We still need to probe before attach since we don't + * know the frame buffer type here. + */ #if NGRTWO > 0 - if (grtwo_cnprobe(&ga) != 0 && - grtwo_cnattach(&ga) == 0) - return 0; + if (grtwo_cnprobe(&ga) != 0 && + grtwo_cnattach(&ga) == 0) + return 0; #endif #if NLIGHT > 0 - if (light_cnprobe(&ga) != 0 && - light_cnattach(&ga) == 0) - return 0; + if (light_cnprobe(&ga) != 0 && + light_cnattach(&ga) == 0) + return 0; #endif #if NNEWPORT > 0 - if (newport_cnprobe(&ga) != 0 && - newport_cnattach(&ga) == 0) - return 0; + if (newport_cnprobe(&ga) != 0 && + newport_cnattach(&ga) == 0) + return 0; #endif + break; + } } giofb_consaddr = 0; diff --git a/sys/arch/sgi/gio/impact_gio.c b/sys/arch/sgi/gio/impact_gio.c new file mode 100644 index 00000000000..4fb2f2b6ee3 --- /dev/null +++ b/sys/arch/sgi/gio/impact_gio.c @@ -0,0 +1,142 @@ +/* $OpenBSD: impact_gio.c,v 1.1 2012/04/18 17:28:24 miod Exp $ */ + +/* + * Copyright (c) 2012 Miodrag Vallat. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Driver for the SGI Impact graphics board (GIO attachment). + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/device.h> +#include <sys/types.h> + +#include <machine/autoconf.h> +#include <mips64/archtype.h> + +#include <mips64/arcbios.h> + +#include <sgi/dev/impactreg.h> +#include <sgi/dev/impactvar.h> +#include <sgi/gio/giodevs.h> +#include <sgi/gio/gioreg.h> +#include <sgi/gio/giovar.h> +#include <sgi/sgi/ip22.h> + +#define IMPACT_REG_OFFSET 0x00000000 +#define IMPACT_REG_SIZE 0x00080000 + +int impact_gio_match(struct device *, void *, void *); +void impact_gio_attach(struct device *, struct device *, void *); + +const struct cfattach impact_gio_ca = { + sizeof(struct impact_softc), impact_gio_match, impact_gio_attach +}; + +int +impact_gio_match(struct device *parent, void *match, void *aux) +{ + struct gio_attach_args *ga = aux; + + /* Impact only exists on Indigo 2 systems */ + if (sys_config.system_type != SGI_IP22 || + sys_config.system_subtype != IP22_INDIGO2) + return 0; + + /* not looking for a frame buffer */ + if (ga->ga_slot != -1) + return 0; + + /* EXP1 does not exist on Indigo2 */ + if (ga->ga_addr != GIO_ADDR_GFX && ga->ga_addr != GIO_ADDR_EXP0) + return 0; + + /* Impact has a real GIO ID */ + if (ga->ga_product != GIO_PRODUCT_IMPACT) + return 0; + + return 1; +} + +void +impact_gio_attach(struct device *parent, struct device *self, void *aux) +{ + struct gio_attach_args *ga = aux; + struct impact_softc *sc = (struct impact_softc *)self; + bus_space_tag_t iot; + bus_space_handle_t ioh; + int console; + + if (strncmp(bios_graphics, "alive", 5) != 0) { + printf(" device has not been setup by firmware!\n"); + return; + } + + console = giofb_consaddr == ga->ga_addr; + + if (console != 0) { + iot = NULL; + ioh = 0; + } else { + iot = ga->ga_iot; + + /* Setup bus space mappings. */ + if (bus_space_map(iot, ga->ga_addr + IMPACT_REG_OFFSET, + IMPACT_REG_SIZE, 0, &ioh)) { + printf("failed to map registers\n"); + return; + } + } + + if (impact_attach_common(sc, iot, ioh, console, 0) != 0) { + if (console == 0) + bus_space_unmap(iot, ioh, IMPACT_REG_SIZE); + } +} + +/* + * Console support. + */ + +int +impact_gio_cnprobe(struct gio_attach_args *ga) +{ + return impact_gio_match(NULL, NULL, ga); +} + +int +impact_gio_cnattach(struct gio_attach_args *ga) +{ + bus_space_tag_t iot; + bus_space_handle_t ioh; + int rc; + + iot = ga->ga_iot; + rc = bus_space_map(iot, ga->ga_addr + IMPACT_REG_OFFSET, + IMPACT_REG_SIZE, 0, &ioh); + if (rc != 0) + return rc; + + rc = impact_cnattach_common(iot, ioh, 0); + if (rc != 0) { + bus_space_unmap(iot, ioh, IMPACT_REG_SIZE); + return rc; + } + + return 0; +} diff --git a/sys/arch/sgi/sgi/wscons_machdep.c b/sys/arch/sgi/sgi/wscons_machdep.c index e33db0b947c..d30f6c82372 100644 --- a/sys/arch/sgi/sgi/wscons_machdep.c +++ b/sys/arch/sgi/sgi/wscons_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wscons_machdep.c,v 1.10 2012/04/16 22:28:15 miod Exp $ */ +/* $OpenBSD: wscons_machdep.c,v 1.11 2012/04/18 17:28:24 miod Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -67,6 +67,7 @@ #include <dev/wscons/wsdisplayvar.h> #include <sgi/dev/gbereg.h> +#include <sgi/dev/impactvar.h> #include <sgi/dev/iockbcvar.h> #include <sgi/dev/mkbcreg.h> #include <sgi/gio/giovar.h> @@ -76,7 +77,6 @@ #include <sgi/localbus/crimebus.h> #include <sgi/localbus/macebus.h> #include <sgi/localbus/macebusvar.h> -#include <sgi/xbow/impactvar.h> #include <sgi/xbow/odysseyvar.h> #if defined(TGT_OCTANE) @@ -329,9 +329,9 @@ widget_cnprobe() * Try supported frame buffers in no particular order. */ -#if NIMPACT > 0 - if (impact_cnprobe() != 0) { - output_widget_cninit = impact_cnattach; +#if NIMPACT_XBOW > 0 + if (impact_xbow_cnprobe() != 0) { + output_widget_cninit = impact_xbow_cnattach; goto success; } #endif diff --git a/sys/arch/sgi/xbow/files.xbow b/sys/arch/sgi/xbow/files.xbow index 1dc26b43539..111c6c398a9 100644 --- a/sys/arch/sgi/xbow/files.xbow +++ b/sys/arch/sgi/xbow/files.xbow @@ -1,4 +1,4 @@ -# $OpenBSD: files.xbow,v 1.7 2010/03/07 21:26:24 miod Exp $ +# $OpenBSD: files.xbow,v 1.8 2012/04/18 17:28:24 miod Exp $ # IP30 and IP27 planar XBow bus define xbow {[widget = -1], [vendor = -1], [product = -1]} @@ -19,11 +19,11 @@ attach xbpci at xbridge file arch/sgi/xbow/xbridge.c xbridge # Odyssey graphics -device odyssey: wsemuldisplaydev, rasops8, rasops16, rasops32 +device odyssey: wsemuldisplaydev, rasops32 attach odyssey at xbow file arch/sgi/xbow/odyssey.c odyssey needs-flag # ImpactSR graphics -device impact: wsemuldisplaydev, rasops32 -attach impact at xbow -file arch/sgi/xbow/impact.c impact needs-flag +attach impact at xbow with impact_xbow +file arch/sgi/xbow/impact_xbow.c impact & + impact_xbow needs-flag diff --git a/sys/arch/sgi/xbow/impact_xbow.c b/sys/arch/sgi/xbow/impact_xbow.c new file mode 100644 index 00000000000..53e637b1282 --- /dev/null +++ b/sys/arch/sgi/xbow/impact_xbow.c @@ -0,0 +1,169 @@ +/* $OpenBSD: impact_xbow.c,v 1.1 2012/04/18 17:28:24 miod Exp $ */ + +/* + * Copyright (c) 2010, 2012 Miodrag Vallat. + * Copyright (c) 2009, 2010 Joel Sing <jsing@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Driver for the SGI ImpactSR graphics board (XBow attachment). + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/device.h> +#include <sys/types.h> + +#include <machine/autoconf.h> + +#include <mips64/arcbios.h> + +#include <sgi/dev/impactvar.h> +#include <sgi/xbow/widget.h> +#include <sgi/xbow/xbow.h> +#include <sgi/xbow/xbowdevs.h> + +#define IMPACTSR_REG_OFFSET 0x00000000 +#define IMPACTSR_REG_SIZE 0x00200000 + +struct impact_xbow_softc { + struct impact_softc sc_base; + + struct mips_bus_space iot_store; +}; + +int impact_xbow_match(struct device *, void *, void *); +void impact_xbow_attach(struct device *, struct device *, void *); + +const struct cfattach impact_xbow_ca = { + sizeof(struct impact_xbow_softc), impact_xbow_match, impact_xbow_attach +}; + +int impact_xbow_is_console(struct xbow_attach_args *); + +int +impact_xbow_match(struct device *parent, void *match, void *aux) +{ + struct xbow_attach_args *xaa = aux; + + if (xaa->xaa_vendor == XBOW_VENDOR_SGI5 && + xaa->xaa_product == XBOW_PRODUCT_SGI5_IMPACT) + return 1; + + return 0; +} + +void +impact_xbow_attach(struct device *parent, struct device *self, void *aux) +{ + struct xbow_attach_args *xaa = aux; + struct impact_xbow_softc *sc = (struct impact_xbow_softc *)self; + bus_space_tag_t iot; + bus_space_handle_t ioh; + int console; + + if (strncmp(bios_graphics, "alive", 5) != 0) { + printf(" device has not been setup by firmware!\n"); + return; + } + + printf(" revision %d\n", xaa->xaa_revision); + + console = impact_xbow_is_console(xaa); + + if (console != 0) { + iot = NULL; + ioh = 0; + } else { + /* + * Create a copy of the bus space tag. + */ + bcopy(xaa->xaa_iot, &sc->iot_store, + sizeof(struct mips_bus_space)); + iot = &sc->iot_store; + + /* Setup bus space mappings. */ + if (bus_space_map(iot, IMPACTSR_REG_OFFSET, + IMPACTSR_REG_SIZE, 0, &ioh)) { + printf("failed to map registers\n"); + return; + } + } + + if (impact_attach_common(&sc->sc_base, iot, ioh, console, 1) != 0) { + if (console == 0) + bus_space_unmap(iot, ioh, IMPACTSR_REG_SIZE); + } +} + +/* + * Console support. + */ + +int +impact_xbow_cnprobe() +{ + u_int32_t wid, vendor, product; + + if (xbow_widget_id(console_output.nasid, console_output.widget, + &wid) != 0) + return 0; + + vendor = WIDGET_ID_VENDOR(wid); + product = WIDGET_ID_PRODUCT(wid); + + if (vendor != XBOW_VENDOR_SGI5 || product != XBOW_PRODUCT_SGI5_IMPACT) + return 0; + + if (strncmp(bios_graphics, "alive", 5) != 0) + return 0; + + return 1; +} + +int +impact_xbow_cnattach() +{ + static struct mips_bus_space impact_iot_store; + bus_space_tag_t iot; + bus_space_handle_t ioh; + int rc; + + /* Build bus space accessor. */ + xbow_build_bus_space(&impact_iot_store, console_output.nasid, + console_output.widget); + iot = &impact_iot_store; + + rc = bus_space_map(iot, IMPACTSR_REG_OFFSET, IMPACTSR_REG_SIZE, + 0, &ioh); + if (rc != 0) + return rc; + + rc = impact_cnattach_common(iot, ioh, 1); + if (rc != 0) { + bus_space_unmap(iot, ioh, IMPACTSR_REG_SIZE); + return rc; + } + + return 0; +} + +int +impact_xbow_is_console(struct xbow_attach_args *xaa) +{ + return xaa->xaa_nasid == console_output.nasid && + xaa->xaa_widget == console_output.widget; +} |