Skip to contentSkip to conversation

MIPS: import CPU and cache detection code from Linux 3.4

PATCH New Antony Pavlov 1 participant 4 messages May 22, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover MIPS: import CPU and cache detection code from Linux 3.4

This patch series introduces MIPS cache support to barebox. It adds functions to detect CPU capabilities.

As compared with the [RFC] series this series adds Ingenic and Broadcom CPU support. The patches tested on all supported by barebox MIPS boards.

[PATCH v2 1/3] MIPS: introduce C architecture-specific low-level [PATCH v2 2/3] MIPS: import CPU and cache detection code from Linux 3.4 [PATCH v2 3/3] MIPS: cpuinfo: import CPU message from Linux 3.4

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

PATCH v2 1/3 MIPS: introduce C architecture-specific low-level init

---
 arch/mips/boot/Makefile     |    1 +
 arch/mips/boot/main_entry.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 arch/mips/boot/start.S      |   14 ++------------
 3 files changed, 46 insertions(+), 12 deletions(-)
 create mode 100644 arch/mips/boot/main_entry.c
arch/mips/boot/Makefile +1 -0
index f9151d2..d6d28ce 100644
@@ -1 +1,2 @@
 obj-y += start.o
+obj-y += main_entry.o
arch/mips/boot/main_entry.c new file +43 -0

43 lines not on this page · raw message

arch/mips/boot/start.S +2 -12
index e8868e1..dd302fc 100644
@@ -79,7 +79,7 @@ __start:
 
 	la	a1, _start	/* link (RAM) _start address */
 
-	beq	a0, a1, clear_bss
+	beq	a0, a1, stack_setup
 	 nop
 
 	la	t0, _start
@@ -105,16 +105,6 @@ copy_loop:
 	blez		t3, copy_loop
 	addi		a1, LONGSIZE * 4
 
-clear_bss:
-	la	t0, __bss_start
-	sw	zero, (t0)
-	la	t1, _end - 4
-1:
-	addiu	t0, LONGSIZE
-	sw	zero, (t0)
-	bne	t0, t1, 1b
-	 nop
-
 	/*
 	 * Dominic Sweetman, See MIPS Run, Morgan Kaufmann, 2nd edition, 2006
 	 *
@@ -144,7 +134,7 @@ stack_setup:
 	/* reserve four 32-bit argument slots */
 	addiu	sp, -16
 
-	la	v0, start_barebox
+	la	v0, main_entry
 	jal     v0
 	 nop
 
Signature · 7 lines
1.7.10


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH v2 3/3 MIPS: cpuinfo: import CPU message from Linux 3.4

In reply to Antony Pavlov
---
 arch/mips/lib/cpuinfo.c |   27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
arch/mips/lib/cpuinfo.c +25 -2
index fc8fb00..c0bb87a 100644
@@ -23,11 +23,34 @@
 #include <common.h>
 #include <command.h>
 #include <asm/mipsregs.h>
+#include <asm/cpu-info.h>
+
+static char *way_string[] = { NULL, "direct mapped", "2-way",
+	"3-way", "4-way", "5-way", "6-way", "7-way", "8-way"
+};
 
 static int do_cpuinfo(int argc, char *argv[])
 {
-	printf("CP0_PRID = 0x%08x\n", read_c0_prid());
-	printf("CP0_CONFIG = 0x%08x\n", read_c0_config());
+	unsigned int icache_size, dcache_size;
+	struct cpuinfo_mips *c = &current_cpu_data;
+
+	printk(KERN_INFO "CPU revision is: %08x (%s)\n",
+		current_cpu_data.processor_id, __cpu_name);
+
+	icache_size = c->icache.sets * c->icache.ways * c->icache.linesz;
+	dcache_size = c->dcache.sets * c->dcache.ways * c->dcache.linesz;
+
+	printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n",
+	       icache_size >> 10,
+	       c->icache.flags & MIPS_CACHE_VTAG ? "VIVT" : "VIPT",
+	       way_string[c->icache.ways], c->icache.linesz);
+
+	printk("Primary data cache %ldkB, %s, %s, %s, linesize %d bytes\n",
+	       dcache_size >> 10, way_string[c->dcache.ways],
+	       (c->dcache.flags & MIPS_CACHE_PINDEX) ? "PIPT" : "VIPT",
+	       (c->dcache.flags & MIPS_CACHE_ALIASES) ?
+			"cache aliases" : "no aliases",
+	       c->dcache.linesz);
 
 	return 0;
 }
Signature · 7 lines
1.7.10


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH v2 2/3 MIPS: import CPU and cache detection code from Linux 3.4

In reply to Antony Pavlov
---
 arch/mips/boot/main_entry.c          |    9 ++
 arch/mips/include/asm/bitops.h       |    2 +-
 arch/mips/include/asm/cpu-features.h |  254 ++++++++++++++++++++++++++++++++++
 arch/mips/include/asm/cpu-info.h     |   71 ++++++++++
 arch/mips/include/asm/cpu.h          |  143 +++++++++++++++++++
 arch/mips/lib/Makefile               |    4 +
 arch/mips/lib/c-r4k.c                |   97 +++++++++++++
 arch/mips/lib/cpu-probe.c            |  143 +++++++++++++++++++
 8 files changed, 722 insertions(+), 1 deletion(-)
 create mode 100644 arch/mips/include/asm/cpu-features.h
 create mode 100644 arch/mips/include/asm/cpu-info.h
 create mode 100644 arch/mips/include/asm/cpu.h
 create mode 100644 arch/mips/lib/c-r4k.c
 create mode 100644 arch/mips/lib/cpu-probe.c
arch/mips/boot/main_entry.c +9 -0
index 76fa492..8f5f6fc 100644
@@ -24,6 +24,7 @@
 #include <common.h>
 #include <string.h>
 #include <asm/sections.h>
+#include <asm/cpu-features.h>
 
 extern void start_barebox(void);
 
@@ -39,5 +40,13 @@ void main_entry(void)
 	/* clear the BSS first */
 	memset(__bss_start, 0x00, __bss_stop - __bss_start);
 
+	cpu_probe();
+
+	if (cpu_has_4k_cache) {
+		extern void r4k_cache_init(void);
+
+		r4k_cache_init();
+	}
+
 	start_barebox();
 }
arch/mips/include/asm/bitops.h +1 -1
index 36d34b6..001ebf2 100644
@@ -27,6 +27,6 @@
 #ifndef _ASM_MIPS_BITOPS_H_
 #define _ASM_MIPS_BITOPS_H_
 
-/* nothing special yet */
+#include <asm-generic/bitops/__ffs.h>
 
 #endif /* _ASM_MIPS_BITOPS_H_ */
arch/mips/include/asm/cpu-features.h new file +254 -0

254 lines not on this page · raw message

arch/mips/include/asm/cpu-info.h new file +71 -0

71 lines not on this page · raw message

arch/mips/include/asm/cpu.h new file +143 -0

143 lines not on this page · raw message

arch/mips/lib/Makefile +4 -0
index 85aa194..b99bb71 100644
@@ -4,6 +4,10 @@ obj-y += lshrdi3.o
 obj-y += ashldi3.o
 obj-y += ashrdi3.o
 obj-y += memory.o
+obj-y += cpu-probe.o
+
+obj-$(CONFIG_CPU_MIPS32) += c-r4k.o
+obj-$(CONFIG_CPU_MIPS64) += c-r4k.o
 
 obj-$(CONFIG_CMD_MIPS_CPUINFO) += cpuinfo.o
 obj-$(CONFIG_CMD_BOOTM)	+= bootm.o
arch/mips/lib/c-r4k.c new file +97 -0

97 lines not on this page · raw message

arch/mips/lib/cpu-probe.c new file +143 -0

143 lines not on this page · raw message

Signature · 7 lines
1.7.10


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox