Subject: Indigo2 patch

From: "Andrew R. Baker" <[email-masked]>
Date: Sun, 2 May 1999 11:24:54 -0500 (CDT)

OK, since this is my first time making a patch I am not sure I got
everything quite right.  This will let people with an Indigo2 actually
boot into Linux.  However, they probably won't be able to do much
thereafter (I get the kernel to die while doing a 'cat README' in the root
directory).  Unfortunately, this won't print the console boot messages to
the screen either.  To do this, I replaced the printk code in
kernel/printk.c with the printf code in arch/mips/arc/printf.c.  I'm sure
there is a better way, but I haven't found it yet.  These were made
against the yesterday's (1999.05.01) version of the CVS tree. 

-Andrew

P.S.  It would be nice to get someone to make sure this doesn't break
anything on the Indy.  I don't have one to test things on.
 
diff --exclude=*CVS* -r -u src/linux/arch/mips/Makefile src2/linux/arch/mips/Makefile
--- src/linux/arch/mips/Makefile	Tue Feb  9 17:11:30 1999
+++ src2/linux/arch/mips/Makefile	Sat May  1 21:35:01 1999
@@ -6,6 +6,7 @@
 #
 # Copyright (C) 1994, 1995, 1996 by Ralf Baechle
 # DECStation modifications by Paul M. Antoine, 1996
+# LINKFLAGS changed by Andrew R. Baker, 1999
 #
 # This file is included by the global makefile so that you can add your own
 # architecture-specific flags and dependencies. Remember to do have actions
@@ -36,7 +37,8 @@
 CROSS_COMPILE  = $(tool-prefix)
 endif
 
-LINKFLAGS	= -static -N
+# having -N in LINKFLAGS causes my Indigo2 not to boot
+LINKFLAGS	= -static
 MODFLAGS	+= -mlong-calls
 
 #
diff --exclude=*CVS* -r -u src/linux/arch/mips/sgi/kernel/indy_hpc.c src2/linux/arch/mips/sgi/kernel/indy_hpc.c
--- src/linux/arch/mips/sgi/kernel/indy_hpc.c	Tue Aug 25 04:14:48 1998
+++ src2/linux/arch/mips/sgi/kernel/indy_hpc.c	Sat May  1 21:50:42 1999
@@ -43,7 +43,8 @@
 	prom_printf("sgihpc_init: ");
 #endif
 
-	if(sid & 1) {
+	/* This test works now thanks to William J. Earl */
+	if ((sid & 1) == 0 ) {
 #ifdef DEBUG_SGIHPC
 		prom_printf("GUINESS ");
 #endif
diff --exclude=*CVS* -r -u src/linux/arch/mips/sgi/kernel/indy_int.c src2/linux/arch/mips/sgi/kernel/indy_int.c
--- src/linux/arch/mips/sgi/kernel/indy_int.c	Mon Jan  4 10:03:56 1999
+++ src2/linux/arch/mips/sgi/kernel/indy_int.c	Sat May  1 21:43:15 1999
@@ -5,6 +5,7 @@
  *
  * Copyright (C) 1996 David S. Miller ([email-masked])
  * Copyright (C) 1997, 1998 Ralf Baechle ([email-masked])
+ * Copyright (C) 1999 Andrew R. Baker ([email-masked]) - Indigo2 changes
  */
 #include <linux/config.h>
 #include <linux/init.h>
@@ -563,9 +564,16 @@
 		}
 	}
 
-	ioc_icontrol = &sgi_i3regs->ints;
-	ioc_timers = &sgi_i3regs->timers;
-	ioc_tclear = &sgi_i3regs->tclear;
+	/* Indy uses an INT3, Indigo2 uses an INT2 */
+	if (sgi_guiness) {
+		ioc_icontrol = &sgi_i3regs->ints;
+		ioc_timers = &sgi_i3regs->timers;
+		ioc_tclear = &sgi_i3regs->tclear;
+	} else {
+		ioc_icontrol = &sgi_i2regs->ints;
+		ioc_timers = &sgi_i2regs->timers;
+		ioc_tclear = &sgi_i2regs->tclear;
+	}
 
 	/* Mask out all interrupts. */
 	ioc_icontrol->imask0 = 0;
diff --exclude=*CVS* -r -u src/linux/arch/mips/sgi/kernel/indy_mc.c src2/linux/arch/mips/sgi/kernel/indy_mc.c
--- src/linux/arch/mips/sgi/kernel/indy_mc.c	Mon May  4 04:12:57 1998
+++ src2/linux/arch/mips/sgi/kernel/indy_mc.c	Sat May  1 21:39:09 1999
@@ -2,6 +2,7 @@
  * indy_mc.c: Routines for manipulating the INDY memory controller.
  *
  * Copyright (C) 1996 David S. Miller ([email-masked])
+ * Copyright (C) 1999 Andrew R. Baker ([email-masked]) - Indigo2 changes
  *
  * $Id: indy_mc.c,v 1.3 1998/05/04 09:12:57 ralf Exp $
  */
@@ -150,6 +151,8 @@
 			tmpreg |= SGIMC_GIOPARM_PLINEEXP0; /* exp[01] pipelined */
 			tmpreg |= SGIMC_GIOPARM_PLINEEXP1;
 			tmpreg |= SGIMC_GIOPARM_MASTEREISA;/* EISA masters */
+			/* someone forgot this poor little guy... */
+			tmpreg |= SGIMC_GIOPARM_GFX64; 	/* GFX at 64 bits */
 		}
 	}
 	mcmisc_regs->gioparm = tmpreg; /* poof */
diff --exclude=*CVS* -r -u src/linux/include/asm-mips/sgint23.h src2/linux/include/asm-mips/sgint23.h
--- src/linux/include/asm-mips/sgint23.h	Wed Mar 11 09:21:45 1998
+++ src2/linux/include/asm-mips/sgint23.h	Sat May  1 21:44:56 1999
@@ -2,6 +2,7 @@
  * sgint23.h: Defines for the SGI INT2 and INT3 chipsets.
  *
  * Copyright (C) 1996 David S. Miller ([email-masked])
+ * Copyright (C) 1999 Andrew R. Baker ([email-masked]) - INT2 corrections
  */
 #ifndef _MIPS_SGINT23_H
 #define _MIPS_SGINT23_H
@@ -20,7 +21,7 @@
 #define SGINT_END      52  /* End of 'spaces' */
 
 /* INT2 occupies HPC PBUS slot 4, INT3 uses slot 6. */
-#define SGI_INT2_BASE 0x1fb80100 /* physical */
+#define SGI_INT2_BASE 0x1fbd9000 /* physical */
 #define SGI_INT3_BASE 0x1fbd9880 /* physical */
 
 struct sgi_ioc_ints {
@@ -128,6 +129,10 @@
 
 #define SGINT_TCSAMP_COUNTER  10255
 
+/* FIXME: What does this really look like?  It was written to have
+ * 17 registers, but there are only 16 in my Indigo2.
+ * I guessed at which one to remove...  	- andrewb
+ */
 struct sgi_int2_regs {
 	struct sgi_ioc_ints ints;
 
@@ -147,8 +152,11 @@
 #endif
 #define INT2_TCLEAR_T0CLR      0x1        /* Clear timer0 IRQ */
 #define INT2_TCLEAR_T1CLR      0x2        /* Clear timer1 IRQ */
-
-	unsigned long _unused[3];
+/* I am guesing there are only two unused registers here 
+ * but I could be wrong...			- andrewb
+ */
+/*	unsigned long _unused[3]; */
+	unsigned long _unused[2];
 	struct sgi_ioc_timers timers;
 };

---

From: Ulf Carlsson <[email-masked]>
Date: Sun, 2 May 1999 20:53:47 +0200

> boot into Linux.  However, they probably won't be able to do much

Cool!

> there is a better way, but I haven't found it yet.  These were made

Yes, there's a better way. A PROM console can be implemented. I have hacked some
code for this PROM console for this purpose. I can't get it to open the initial
console though. I'll send it to you, maybe you have time to figure out what's
wrong...

> +# having -N in LINKFLAGS causes my Indigo2 not to boot

This is a problem with the cross linker and not with the kernel itself, it's the
same for Indy's. The code in the CVS tree should remain as it is.

- Ulf

---

From: "Andrew R. Baker" <[email-masked]>
Date: Sun, 2 May 1999 20:31:20 -0500 (CDT)

> console though. I'll send it to you, maybe you have time to figure out what's

Great, most of the work has already been done for me. ;)  This is what I
had thought about, I just hadn't tried to figure out where to start yet.
A PROM console would probably be a help on any of the SGIs until some sort
of graphics support is worked out.  

> same for Indy's. The code in the CVS tree should remain as it is.

Any chance on getting the cross linker fixed?

-Andrew

---

From: Ralf Baechle <[email-masked]>
Date: Tue, 4 May 1999 12:59:03 +0200

> Any chance on getting the cross linker fixed?

I'll have the time to work on this soon again.  However just removing -N
does the job; there are no other known kernel build problems with
binutils 2.8.1.

  Ralf

---

From: "Andrew R. Baker" <[email-masked]>
Date: Fri, 7 May 1999 10:11:54 -0500 (CDT)

I am just wondering if anyone has tried out my patch.  I haven't received
much feedback.  Also, has anyone checked to make sure it doesn't break the
anything on the Indy?  If it doesn't than could someone think about
committing the changes to the CVS tree (I don't have CVS commit access).

---

From: Ulf Carlsson <[email-masked]>
Date: Fri, 7 May 1999 19:43:34 +0200

> much feedback.

I have the same problem with the HAL2 sounddriver I think. ;-)

- Ulf