Subject: [PATCH] sc-ip22.c cleanup

From: Ladislav Michl <[email-masked]>
Date: Wed, 7 May 2003 22:22:29 +0200

use serial eeprom access functions to detect scache size

diff -Naur linux_2_4/arch/mips/mm/sc-ip22.c linux_2_4-fucked/arch/mips/mm/sc-ip22.c
--- linux_2_4/arch/mips/mm/sc-ip22.c	Thu Apr 17 02:29:14 2003
+++ linux_2_4-fucked/arch/mips/mm/sc-ip22.c	Wed May  7 20:10:22 2003
@@ -14,9 +14,7 @@
 #include <asm/pgtable.h>
 #include <asm/system.h>
 #include <asm/bootinfo.h>
-#include <asm/mmu_context.h>
-#include <asm/sgialib.h>
-#include <asm/sgi/sgi.h>
+#include <asm/sgi/ip22.h>
 #include <asm/sgi/mc.h>
 
 /* Secondary cache size in bytes, if present.  */
@@ -149,60 +147,14 @@
 
 static inline int __init indy_sc_probe(void)
 {
-	volatile unsigned int *cpu_control;
-	unsigned short cmd = 0xc220;
-	unsigned long data = 0;
-	int i, n;
-
-#ifdef __MIPSEB__
-	cpu_control = (volatile unsigned int *) KSEG1ADDR(0x1fa00034);
-#else
-	cpu_control = (volatile unsigned int *) KSEG1ADDR(0x1fa00030);
-#endif
-#define DEASSERT(bit) (*(cpu_control) &= (~(bit)))
-#define ASSERT(bit) (*(cpu_control) |= (bit))
-#define DELAY  for(n = 0; n < 100000; n++) __asm__ __volatile__("")
-	DEASSERT(SGIMC_EEPROM_PRE);
-	DEASSERT(SGIMC_EEPROM_SDATAO);
-	DEASSERT(SGIMC_EEPROM_SECLOCK);
-	DEASSERT(SGIMC_EEPROM_PRE);
-	DELAY;
-	ASSERT(SGIMC_EEPROM_CSEL); ASSERT(SGIMC_EEPROM_SECLOCK);
-	for(i = 0; i < 11; i++) {
-		if(cmd & (1<<15))
-			ASSERT(SGIMC_EEPROM_SDATAO);
-		else
-			DEASSERT(SGIMC_EEPROM_SDATAO);
-		DEASSERT(SGIMC_EEPROM_SECLOCK);
-		ASSERT(SGIMC_EEPROM_SECLOCK);
-		cmd <<= 1;
-	}
-	DEASSERT(SGIMC_EEPROM_SDATAO);
-	for(i = 0; i < (sizeof(unsigned short) * 8); i++) {
-		unsigned int tmp;
-
-		DEASSERT(SGIMC_EEPROM_SECLOCK);
-		DELAY;
-		ASSERT(SGIMC_EEPROM_SECLOCK);
-		DELAY;
-		data <<= 1;
-		tmp = *cpu_control;
-		if(tmp & SGIMC_EEPROM_SDATAI)
-			data |= 1;
-	}
-	DEASSERT(SGIMC_EEPROM_SECLOCK);
-	DEASSERT(SGIMC_EEPROM_CSEL);
-	ASSERT(SGIMC_EEPROM_PRE);
-	ASSERT(SGIMC_EEPROM_SECLOCK);
-
-	data <<= PAGE_SHIFT;
-	if (data == 0)
+	unsigned long size = ip22_eeprom_read(&sgimc->eeprom, 17);
+	size <<= PAGE_SHIFT;
+	if (size == 0)
 		return 0;
 
-	scache_size = data;
-
 	printk(KERN_INFO "R4600/R5000 SCACHE size %ldK, linesize 32 bytes.\n",
-	       scache_size >> 10);
+	       size >> 10);
+	scache_size = size;
 
 	return 1;
 }
diff -Naur linux_2_4/arch/mips/mm/sc-ip22.c linux_2_4-fucked/arch/mips/mm/sc-ip22.c
--- linux_2_4/arch/mips/mm/sc-ip22.c	Thu Apr 17 02:29:14 2003
+++ linux_2_4-fucked/arch/mips/mm/sc-ip22.c	Wed May  7 20:10:22 2003
@@ -14,9 +14,7 @@
 #include <asm/pgtable.h>
 #include <asm/system.h>
 #include <asm/bootinfo.h>
-#include <asm/mmu_context.h>
-#include <asm/sgialib.h>
-#include <asm/sgi/sgi.h>
+#include <asm/sgi/ip22.h>
 #include <asm/sgi/mc.h>
 
 /* Secondary cache size in bytes, if present.  */
@@ -149,60 +147,14 @@
 
 static inline int __init indy_sc_probe(void)
 {
-	volatile unsigned int *cpu_control;
-	unsigned short cmd = 0xc220;
-	unsigned long data = 0;
-	int i, n;
-
-#ifdef __MIPSEB__
-	cpu_control = (volatile unsigned int *) KSEG1ADDR(0x1fa00034);
-#else
-	cpu_control = (volatile unsigned int *) KSEG1ADDR(0x1fa00030);
-#endif
-#define DEASSERT(bit) (*(cpu_control) &= (~(bit)))
-#define ASSERT(bit) (*(cpu_control) |= (bit))
-#define DELAY  for(n = 0; n < 100000; n++) __asm__ __volatile__("")
-	DEASSERT(SGIMC_EEPROM_PRE);
-	DEASSERT(SGIMC_EEPROM_SDATAO);
-	DEASSERT(SGIMC_EEPROM_SECLOCK);
-	DEASSERT(SGIMC_EEPROM_PRE);
-	DELAY;
-	ASSERT(SGIMC_EEPROM_CSEL); ASSERT(SGIMC_EEPROM_SECLOCK);
-	for(i = 0; i < 11; i++) {
-		if(cmd & (1<<15))
-			ASSERT(SGIMC_EEPROM_SDATAO);
-		else
-			DEASSERT(SGIMC_EEPROM_SDATAO);
-		DEASSERT(SGIMC_EEPROM_SECLOCK);
-		ASSERT(SGIMC_EEPROM_SECLOCK);
-		cmd <<= 1;
-	}
-	DEASSERT(SGIMC_EEPROM_SDATAO);
-	for(i = 0; i < (sizeof(unsigned short) * 8); i++) {
-		unsigned int tmp;
-
-		DEASSERT(SGIMC_EEPROM_SECLOCK);
-		DELAY;
-		ASSERT(SGIMC_EEPROM_SECLOCK);
-		DELAY;
-		data <<= 1;
-		tmp = *cpu_control;
-		if(tmp & SGIMC_EEPROM_SDATAI)
-			data |= 1;
-	}
-	DEASSERT(SGIMC_EEPROM_SECLOCK);
-	DEASSERT(SGIMC_EEPROM_CSEL);
-	ASSERT(SGIMC_EEPROM_PRE);
-	ASSERT(SGIMC_EEPROM_SECLOCK);
-
-	data <<= PAGE_SHIFT;
-	if (data == 0)
+	unsigned long size = ip22_eeprom_read(&sgimc->eeprom, 17);
+	size <<= PAGE_SHIFT;
+	if (size == 0)
 		return 0;
 
-	scache_size = data;
-
 	printk(KERN_INFO "R4600/R5000 SCACHE size %ldK, linesize 32 bytes.\n",
-	       scache_size >> 10);
+	       size >> 10);
+	scache_size = size;
 
 	return 1;
 }

---

From: Juan Quintela <[email-masked]>
Date: Thu, 08 May 2003 00:17:18 +0200

>>>>> "ladis" == Ladislav Michl <[email-masked]> writes:

Hi

ladis> +	unsigned long size = ip22_eeprom_read(&sgimc->eeprom, 17);

Defining somewhere what 17 mean could be a good idea :)

Except for that looks like a good gain, you remove a lot fo code :)

Later, Juan.

-- 
In theory, practice and theory are the same, but in practice they 
are different -- Larry McVoy