Subject: port-sparc/1415: bwtwo driver doesn't work on Sun 4.
To: None <gnats-bugs@gnats.netbsd.org>
From: Jason R. Thorpe <thorpej@SJ.Xenotropic.COM>
List: netbsd-bugs
Date: 08/28/1995 10:59:10
>Number:         1415
>Category:       port-sparc
>Synopsis:       bwtwo driver doesn't work on Sun 4.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 28 14:05:01 1995
>Last-Modified:
>Originator:     
>Organization:
Just me and my collection of obsolete computer gear(s).
>Release:        -current, August 22 1995
>Environment:
	
System: NetBSD bigsby 1.0A NetBSD 1.0A (BIGSBY) #45: Sun Aug 27 18:07:09 PDT 1995 thorpej@bamboo:/tmp_mnt/antie/work/netbsd/src/sys/arch/sparc/compile/BIGSBY sparc


>Description:
	Pretty simple.  The bwtwo driver only has glue for sbus in it.
>How-To-Repeat:
	Try to configure a bwtwo on a Sun 4.
>Fix:
	Attached below are diffs to files.sparc, eeprom.h, clock.c,
	and bwtwo.c.  The eeprom address needs to be exported, hence
	the changes to eeprom.h and clock.c (it's currently static).

	Kernel config lines look like this:

bwtwo0		at obio0 addr 0xfd000000 level 4	# 4/260
#bwtwo0		at obio0 addr 0xfb300000 level 4	# 4/{300/400} ??

	These were sufficient for me to run Xsun.  It appeared that the
	screen was mapped correctly (popped up several apps in the `correct'
	places on my 1600x1280 display).  Note that Xsun still doesn't run
	`perfectly' ... I'm having problems with the mouse, but I doubt
	they're framebuffer-related :-)

Index: bwtwo.c
===================================================================
RCS file: /mastersrc/netbsd/src/sys/arch/sparc/dev/bwtwo.c,v
retrieving revision 1.1.1.1
retrieving revision 1.5
diff -c -r1.1.1.1 -r1.5
*** bwtwo.c	1995/05/02 22:54:12	1.1.1.1
--- bwtwo.c	1995/08/28 17:35:21	1.5
***************
*** 63,68 ****
--- 63,71 ----
  #include <machine/autoconf.h>
  #include <machine/pmap.h>
  #include <machine/fbvar.h>
+ #if defined(SUN4)
+ #include <machine/eeprom.h>
+ #endif
  
  #include <sparc/dev/bwtworeg.h>
  #include <sparc/dev/sbusvar.h>
***************
*** 110,120 ****
--- 113,129 ----
  	struct confargs *ca = aux;
  	struct romaux *ra = &ca->ca_ra;
  
+ #if defined(SUN4)
+ 	if (cputyp == CPU_SUN4 && cf->cf_unit != 0)
+ 		return (0);
+ #endif
+ 
  	if (strcmp(cf->cf_driver->cd_name, ra->ra_name))
  		return (0);
  	if (ca->ca_bustype == BUS_SBUS)
  		return(1);
  	ra->ra_len = NBPG;
+ 
  	return (probeget(ra->ra_vaddr, 4) != -1);
  }
  
***************
*** 150,166 ****
  		sbus = node = 0;
  		sc->sc_fb.fb_type.fb_width = 1152;
  		sc->sc_fb.fb_type.fb_height = 900;
! 		sc->sc_fb.fb_linebytes = 1152;
  		nam = "bwtwo";
  
- 		/*
- 		 * XXX: some frame buffers can be in 1600x1280 or
- 		 * 1024x1024 mode, and we need to figure out how
- 		 * to determine which.
- 		 */
  #if defined(SUN4)
  		if (cputyp==CPU_SUN4) {
! 			/* XXX: need code to find sun4 (oldrom) screen size */
  		}
  #endif
  #if defined(SUN4M)
--- 159,203 ----
  		sbus = node = 0;
  		sc->sc_fb.fb_type.fb_width = 1152;
  		sc->sc_fb.fb_type.fb_height = 900;
! 		sc->sc_fb.fb_linebytes = 144;
  		nam = "bwtwo";
  
  #if defined(SUN4)
  		if (cputyp==CPU_SUN4) {
! 			struct eeprom *eep = (struct eeprom *)eeprom_va;
! 			if (eep != NULL) {
! 				switch (eep->eeScreenSize) {
! 				case EE_SCR_1152X900:
! 					/* Handled above. */
! 					break;
! 
! 				case EE_SCR_1024X1024:
! 					sc->sc_fb.fb_type.fb_width = 1024;
! 					sc->sc_fb.fb_type.fb_height = 1024;
! 					sc->sc_fb.fb_linebytes = 128;
! 					break;
! 
! 				case EE_SCR_1600X1280:
! 					sc->sc_fb.fb_type.fb_width = 1600;
! 					sc->sc_fb.fb_type.fb_height = 1280;
! 					sc->sc_fb.fb_linebytes = 200;
! 					break;
! 
! 				case EE_SCR_1440X1440:
! 					sc->sc_fb.fb_type.fb_width = 1440;
! 					sc->sc_fb.fb_type.fb_height = 1440;
! 					sc->sc_fb.fb_linebytes = 180;
! 					break;
! 
! 				default:
! 					/*
! 					 * XXX: Do nothing, I guess.
! 					 * Should we print a warning about
! 					 * an unknown value? --thorpej
! 					 */
! 					break;
! 				}
! 			}
  		}
  #endif
  #if defined(SUN4M)
***************
*** 170,175 ****
--- 207,213 ----
  #endif
  
  		break;
+ 
  	case BUS_SBUS:
  		sc->sc_fb.fb_type.fb_width = getpropint(node, "width", 1152);
  		sc->sc_fb.fb_type.fb_height = getpropint(node, "height", 900);
***************
*** 191,197 ****
  	 * registers ourselves.  We only need the video RAM if we are
  	 * going to print characters via rconsole.
  	 */
! 	isconsole = node == fbnode && fbconstty != NULL;
  	p = (struct bwtwo_all *)ca->ca_ra.ra_paddr;
  	if ((sc->sc_fb.fb_pixels = ca->ca_ra.ra_vaddr) == NULL && isconsole) {
  		/* this probably cannot happen, but what the heck */
--- 229,249 ----
  	 * registers ourselves.  We only need the video RAM if we are
  	 * going to print characters via rconsole.
  	 */
! #if defined(SUN4)
! 	if (cputyp == CPU_SUN4) {
! 		struct eeprom *eep = (struct eeprom *)eeprom_va;
! 		/*
! 		 * Assume this is the console if there's no eeprom info
! 		 * to be found.
! 		 */
! 		if (eep == NULL || eep->eeConsole == EE_CONS_BW)
! 			isconsole = (fbconstty != NULL);
! 	}
! #endif
! #if defined(SUN4C) || defined(SUN4M)
! 	if (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
! 		isconsole = node == fbnode && fbconstty != NULL;
! #endif
  	p = (struct bwtwo_all *)ca->ca_ra.ra_paddr;
  	if ((sc->sc_fb.fb_pixels = ca->ca_ra.ra_vaddr) == NULL && isconsole) {
  		/* this probably cannot happen, but what the heck */
***************
*** 207,219 ****
  	if (isconsole) {
  		printf(" (console)\n");
  #ifdef RCONSOLE
! 		rcons_init(&sc->sc_fb);
  #endif
  	} else
  		printf("\n");
  	if (sbus)
  		sbus_establish(&sc->sc_sd, &sc->sc_dev);
! 	if (node == fbnode)
  		fb_attach(&sc->sc_fb);
  }
  
--- 259,279 ----
  	if (isconsole) {
  		printf(" (console)\n");
  #ifdef RCONSOLE
! 		/* XXX: doesn't work (??) on Sun 4 yet. */
! 		if (cputyp != CPU_SUN4)
! 			rcons_init(&sc->sc_fb);
  #endif
  	} else
  		printf("\n");
+ #if defined(SUN4C) || defined(SUN4M)
  	if (sbus)
  		sbus_establish(&sc->sc_sd, &sc->sc_dev);
! #endif
! 	/*
! 	 * XXX: this could cause a panic in fb_attach() if more
! 	 * than one frame buffer device is found on a Sun 4.
! 	 */
! 	if (node == fbnode || cputyp == CPU_SUN4)
  		fb_attach(&sc->sc_fb);
  }
  
Index: eeprom.h
===================================================================
RCS file: /mastersrc/netbsd/src/sys/arch/sparc/include/eeprom.h,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 eeprom.h
*** eeprom.h	1995/06/02 19:05:31	1.1.1.1
--- eeprom.h	1995/08/23 16:30:23
***************
*** 177,182 ****
--- 177,183 ----
  #define EEPROM_SIZE		0x500
  
  #ifdef	_KERNEL
+ extern	char *eeprom_va;
  int	eeprom_uio __P((struct uio *));
  #endif	/* _KERNEL */
  
Index: clock.c
===================================================================
RCS file: /mastersrc/netbsd/src/sys/arch/sparc/sparc/clock.c,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 clock.c
*** clock.c	1995/06/02 19:05:39	1.1.1.2
--- clock.c	1995/08/23 16:35:02
***************
*** 132,138 ****
   * On the 300/400 models, the eeprom will be dealt with when the clock is
   * attached.
   */
! static char	*eeprom_va = NULL;
  static int	eeprom_busy = 0;
  static int	eeprom_wanted = 0;
  static int	eeprom_nvram = 0;	/* non-zero if eeprom is on Mostek */
--- 132,138 ----
   * On the 300/400 models, the eeprom will be dealt with when the clock is
   * attached.
   */
! char		*eeprom_va = NULL;
  static int	eeprom_busy = 0;
  static int	eeprom_wanted = 0;
  static int	eeprom_nvram = 0;	/* non-zero if eeprom is on Mostek */

Index: files.sparc
===================================================================
RCS file: /mastersrc/netbsd/src/sys/arch/sparc/conf/files.sparc,v
retrieving revision 1.1.1.6
retrieving revision 1.4
diff -c -r1.1.1.6 -r1.4
*** files.sparc	1995/07/09 00:55:18	1.1.1.6
--- files.sparc	1995/07/10 17:28:03	1.4
***************
*** 61,67 ****
  device esp at sbus, espdma, obio: scsi
  file	arch/sparc/dev/esp.c		esp needs-flag
  
! device bwtwo at sbus
  file	arch/sparc/dev/bwtwo.c		bwtwo needs-flag
  
  device cgthree at sbus
--- 61,67 ----
  device esp at sbus, espdma, obio: scsi
  file	arch/sparc/dev/esp.c		esp needs-flag
  
! device bwtwo at sbus, obio, vmes, vmel
  file	arch/sparc/dev/bwtwo.c		bwtwo needs-flag
  
  device cgthree at sbus
>Audit-Trail:
>Unformatted: