Subject: port-sparc/1672: on-board bwtwo isn't enabled/disabled properly on Sun 4
To: None <gnats-bugs@gnats.netbsd.org>
From: Jason R. Thorpe <thorpej@SJ.Xenotropic.COM>
List: netbsd-bugs
Date: 10/22/1995 22:18:47
>Number:         1672
>Category:       port-sparc
>Synopsis:       on-board bwtwo isn't enabled/disabled properly on Sun 4
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 23 01:35:01 1995
>Last-Modified:
>Originator:     
>Organization:
Just me and my collection of obsolete computer gear(s).
>Release:        NetBSD 1.0A, October 15, 1995
>Environment:
	
System: NetBSD bigsby 1.0A NetBSD 1.0A (BIGSBY) #82: Sun Oct 22 21:47:50 PDT 1995 thorpej@bigsby:/tmp_mnt/basalt/work/netbsd/src/sys/arch/sparc/compile/BIGSBY sparc


>Description:
	On the Sun 4 (in my case, a Sun 4/260), the bwtwo isn't
	enabled/disabled properly.  The bwtwo driver currently
	assumes that the bw_ctl register is used, as in the case of
	Sun 4c sbus bwtwo framebuffers.  However, the Sun 4, being so
	Sun 3-like in nature, chooses to enable/disable video with a
	bit in the system enable register.
>How-To-Repeat:
	Run screenblank(8) or Xsun on a Sun 4 with bwtwo on obio.  You will
	no doubt note that the screen saver just doesn't work.
>Fix:
	The following patch defines the SYSEN_VIDEO bit in the system
	enable register, and teaches bwtwo.c how to use it.  It makes
	screenblank(8) and Xsun blank the screen properly on my 4/260.

	(Patch to sparc/include/ctlreg.h and sparc/dev/bwtwo.c follows)

Index: ctlreg.h
===================================================================
RCS file: /usr/og/devsrc/netbsd/src/sys/arch/sparc/include/ctlreg.h,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 ctlreg.h
*** ctlreg.h	1995/08/03 07:11:48	1.1.1.1
--- ctlreg.h	1995/10/23 04:32:18
***************
*** 173,178 ****
--- 173,179 ----
  #define	SYSEN_DVMA	0x20		/* Enable dvma */
  #define	SYSEN_CACHE	0x10		/* Enable cache */
  #define	SYSEN_IOCACHE	0x40		/* Enable IO cache */
+ #define	SYSEN_VIDEO	0x08		/* Enable on-board video */
  #define	SYSEN_RESET	0x04		/* Reset the hardware */
  #define	SYSEN_RESETVME	0x02		/* Reset the VME bus */
  #endif
Index: bwtwo.c
===================================================================
RCS file: /usr/og/devsrc/netbsd/src/sys/arch/sparc/dev/bwtwo.c,v
retrieving revision 1.9
diff -c -r1.9 bwtwo.c
*** bwtwo.c	1995/10/10 01:18:52	1.9
--- bwtwo.c	1995/10/23 05:04:34
***************
*** 65,70 ****
--- 65,72 ----
  #include <machine/fbvar.h>
  #if defined(SUN4)
  #include <machine/eeprom.h>
+ #include <machine/ctlreg.h>
+ #include <sparc/sparc/asm.h>
  #endif
  
  #include <sparc/dev/bwtworeg.h>
***************
*** 77,82 ****
--- 79,85 ----
  	struct	fbdevice sc_fb;		/* frame buffer device */
  	volatile struct bwtworeg *sc_reg;/* control registers */
  	caddr_t	sc_phys;		/* display RAM (phys addr) */
+ 	int	sc_bustype;		/* type of bus we live on */
  };
  
  /* autoconfiguration driver */
***************
*** 165,171 ****
  #endif
  		break;
  	}
! 
  
  	sc->sc_fb.fb_type.fb_depth = 1;
  	fb_setsize(&sc->sc_fb, sc->sc_fb.fb_type.fb_depth,
--- 168,174 ----
  #endif
  		break;
  	}
! 	sc->sc_bustype = ca->ca_bustype;
  
  	sc->sc_fb.fb_type.fb_depth = 1;
  	fb_setsize(&sc->sc_fb, sc->sc_fb.fb_type.fb_depth,
***************
*** 210,216 ****
  	sc->sc_phys = p->ba_ram;
  
  	/* Insure video is enabled */
! 	sc->sc_reg->bw_ctl |= CTL_VE;
  
  	if (isconsole) {
  		printf(" (console)\n");
--- 213,225 ----
  	sc->sc_phys = p->ba_ram;
  
  	/* Insure video is enabled */
! #if defined(SUN4)
! 	if ((cputyp == CPU_SUN4) && (sc->sc_bustype == BUS_OBIO))
! 		stba(AC_SYSENABLE, ASI_CONTROL,
! 		    lduba(AC_SYSENABLE, ASI_CONTROL) | SYSEN_VIDEO);
! 	else
! #endif
! 		sc->sc_reg->bw_ctl |= CTL_VE;
  
  	if (isconsole) {
  		printf(" (console)\n");
***************
*** 271,284 ****
  		break;
  
  	case FBIOGVIDEO:
! 		*(int *)data = (sc->sc_reg->bw_ctl & CTL_VE) != 0;
  		break;
  
  	case FBIOSVIDEO:
! 		if (*(int *)data)
! 			sc->sc_reg->bw_ctl |= CTL_VE;
  		else
! 			sc->sc_reg->bw_ctl &= ~CTL_VE;
  		break;
  
  	default:
--- 280,311 ----
  		break;
  
  	case FBIOGVIDEO:
! #if defined(SUN4)
! 		if ((cputyp == CPU_SUN4) && (sc->sc_bustype == BUS_OBIO))
! 			*(int *)data =
! 			 (lduba(AC_SYSENABLE, ASI_CONTROL) & SYSEN_VIDEO) != 0;
! 		else
! #endif
! 			*(int *)data = (sc->sc_reg->bw_ctl & CTL_VE) != 0;
  		break;
  
  	case FBIOSVIDEO:
! #if defined(SUN4)
! 		if ((cputyp == CPU_SUN4) && (sc->sc_bustype == BUS_OBIO))
! 			if (*(int *)data)
! 				stba(AC_SYSENABLE, ASI_CONTROL,
! 				    lduba(AC_SYSENABLE, ASI_CONTROL) |
! 				    SYSEN_VIDEO);
! 			else
! 				stba(AC_SYSENABLE, ASI_CONTROL,
! 				    lduba(AC_SYSENABLE, ASI_CONTROL) &
! 				    ~SYSEN_VIDEO);
  		else
! #endif
! 			if (*(int *)data)
! 				sc->sc_reg->bw_ctl |= CTL_VE;
! 			else
! 				sc->sc_reg->bw_ctl &= ~CTL_VE;
  		break;
  
  	default:
>Audit-Trail:
>Unformatted: