xref: /openbmc/linux/arch/microblaze/kernel/cpu/mb.c (revision 8904976e)
1b0c62724SMichal Simek /*
2b0c62724SMichal Simek  * CPU-version specific code
3b0c62724SMichal Simek  *
4b0c62724SMichal Simek  * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
5b0c62724SMichal Simek  * Copyright (C) 2006-2009 PetaLogix
6b0c62724SMichal Simek  *
7b0c62724SMichal Simek  * This file is subject to the terms and conditions of the GNU General Public
8b0c62724SMichal Simek  * License. See the file "COPYING" in the main directory of this archive
9b0c62724SMichal Simek  * for more details.
10b0c62724SMichal Simek  */
11b0c62724SMichal Simek 
12b0c62724SMichal Simek #include <linux/init.h>
13b0c62724SMichal Simek #include <linux/string.h>
14b0c62724SMichal Simek #include <linux/seq_file.h>
15b0c62724SMichal Simek #include <linux/cpu.h>
16b0c62724SMichal Simek #include <linux/initrd.h>
17b0c62724SMichal Simek 
18b0c62724SMichal Simek #include <linux/bug.h>
19b0c62724SMichal Simek #include <asm/cpuinfo.h>
20b0c62724SMichal Simek #include <linux/delay.h>
21b0c62724SMichal Simek #include <linux/io.h>
22b0c62724SMichal Simek #include <asm/page.h>
23b0c62724SMichal Simek #include <linux/param.h>
24b0c62724SMichal Simek #include <asm/pvr.h>
25b0c62724SMichal Simek #include <asm/sections.h>
26b0c62724SMichal Simek #include <asm/setup.h>
27b0c62724SMichal Simek 
28b0c62724SMichal Simek static int show_cpuinfo(struct seq_file *m, void *v)
29b0c62724SMichal Simek {
30b0c62724SMichal Simek 	int count = 0;
31b0c62724SMichal Simek 	char *fpga_family = "Unknown";
32b0c62724SMichal Simek 	char *cpu_ver = "Unknown";
33b0c62724SMichal Simek 	int i;
34b0c62724SMichal Simek 
35b0c62724SMichal Simek 	/* Denormalised to get the fpga family string */
36b0c62724SMichal Simek 	for (i = 0; family_string_lookup[i].s != NULL; i++) {
37b0c62724SMichal Simek 		if (cpuinfo.fpga_family_code == family_string_lookup[i].k) {
38b0c62724SMichal Simek 			fpga_family = (char *)family_string_lookup[i].s;
39b0c62724SMichal Simek 			break;
40b0c62724SMichal Simek 		}
41b0c62724SMichal Simek 	}
42b0c62724SMichal Simek 
43b0c62724SMichal Simek 	/* Denormalised to get the hw version string */
44b0c62724SMichal Simek 	for (i = 0; cpu_ver_lookup[i].s != NULL; i++) {
45b0c62724SMichal Simek 		if (cpuinfo.ver_code == cpu_ver_lookup[i].k) {
46b0c62724SMichal Simek 			cpu_ver = (char *)cpu_ver_lookup[i].s;
47b0c62724SMichal Simek 			break;
48b0c62724SMichal Simek 		}
49b0c62724SMichal Simek 	}
50b0c62724SMichal Simek 
51b0c62724SMichal Simek 	count = seq_printf(m,
52b0c62724SMichal Simek 			"CPU-Family:	MicroBlaze\n"
53b0c62724SMichal Simek 			"FPGA-Arch:	%s\n"
548e2ad016SMichal Simek 			"CPU-Ver:	%s, %s endian\n"
55b0c62724SMichal Simek 			"CPU-MHz:	%d.%02d\n"
56b0c62724SMichal Simek 			"BogoMips:	%lu.%02lu\n",
57b0c62724SMichal Simek 			fpga_family,
58b0c62724SMichal Simek 			cpu_ver,
598e2ad016SMichal Simek 			cpuinfo.endian ? "little" : "big",
60b0c62724SMichal Simek 			cpuinfo.cpu_clock_freq /
61b0c62724SMichal Simek 			1000000,
62b0c62724SMichal Simek 			cpuinfo.cpu_clock_freq %
63b0c62724SMichal Simek 			1000000,
64b0c62724SMichal Simek 			loops_per_jiffy / (500000 / HZ),
65b0c62724SMichal Simek 			(loops_per_jiffy / (5000 / HZ)) % 100);
66b0c62724SMichal Simek 
67b0c62724SMichal Simek 	count += seq_printf(m,
68b0c62724SMichal Simek 		"HW:\n Shift:\t\t%s\n"
69b0c62724SMichal Simek 		" MSR:\t\t%s\n"
70b0c62724SMichal Simek 		" PCMP:\t\t%s\n"
71b0c62724SMichal Simek 		" DIV:\t\t%s\n",
72b0c62724SMichal Simek 		(cpuinfo.use_instr & PVR0_USE_BARREL_MASK) ? "yes" : "no",
73b0c62724SMichal Simek 		(cpuinfo.use_instr & PVR2_USE_MSR_INSTR) ? "yes" : "no",
74b0c62724SMichal Simek 		(cpuinfo.use_instr & PVR2_USE_PCMP_INSTR) ? "yes" : "no",
75b0c62724SMichal Simek 		(cpuinfo.use_instr & PVR0_USE_DIV_MASK) ? "yes" : "no");
76b0c62724SMichal Simek 
77b0c62724SMichal Simek 	count += seq_printf(m,
78b0c62724SMichal Simek 			" MMU:\t\t%x\n",
79b0c62724SMichal Simek 			cpuinfo.mmu);
80b0c62724SMichal Simek 
81b0c62724SMichal Simek 	count += seq_printf(m,
82b0c62724SMichal Simek 		" MUL:\t\t%s\n"
83b0c62724SMichal Simek 		" FPU:\t\t%s\n",
84b0c62724SMichal Simek 		(cpuinfo.use_mult & PVR2_USE_MUL64_MASK) ? "v2" :
85b0c62724SMichal Simek 			(cpuinfo.use_mult & PVR0_USE_HW_MUL_MASK) ? "v1" : "no",
86b0c62724SMichal Simek 		(cpuinfo.use_fpu & PVR2_USE_FPU2_MASK) ? "v2" :
87b0c62724SMichal Simek 			(cpuinfo.use_fpu & PVR0_USE_FPU_MASK) ? "v1" : "no");
88b0c62724SMichal Simek 
89b0c62724SMichal Simek 	count += seq_printf(m,
90b0c62724SMichal Simek 		" Exc:\t\t%s%s%s%s%s%s%s%s\n",
91b0c62724SMichal Simek 		(cpuinfo.use_exc & PVR2_OPCODE_0x0_ILL_MASK) ? "op0x0 " : "",
92b0c62724SMichal Simek 		(cpuinfo.use_exc & PVR2_UNALIGNED_EXC_MASK) ? "unal " : "",
93b0c62724SMichal Simek 		(cpuinfo.use_exc & PVR2_ILL_OPCODE_EXC_MASK) ? "ill " : "",
94b0c62724SMichal Simek 		(cpuinfo.use_exc & PVR2_IOPB_BUS_EXC_MASK) ? "iopb " : "",
95b0c62724SMichal Simek 		(cpuinfo.use_exc & PVR2_DOPB_BUS_EXC_MASK) ? "dopb " : "",
96b0c62724SMichal Simek 		(cpuinfo.use_exc & PVR2_DIV_ZERO_EXC_MASK) ? "zero " : "",
97b0c62724SMichal Simek 		(cpuinfo.use_exc & PVR2_FPU_EXC_MASK) ? "fpu " : "",
98b0c62724SMichal Simek 		(cpuinfo.use_exc & PVR2_USE_FSL_EXC) ? "fsl " : "");
99b0c62724SMichal Simek 
1008904976eSJohn A. Williams 	count += seq_printf(m,
1018904976eSJohn A. Williams 			"Stream-insns:\t%sprivileged\n",
1028904976eSJohn A. Williams 			cpuinfo.mmu_privins ? "un" : "");
1038904976eSJohn A. Williams 
104b0c62724SMichal Simek 	if (cpuinfo.use_icache)
105b0c62724SMichal Simek 		count += seq_printf(m,
10677543cebSMichal Simek 				"Icache:\t\t%ukB\tline length:\t%dB\n",
10777543cebSMichal Simek 				cpuinfo.icache_size >> 10,
10877543cebSMichal Simek 				cpuinfo.icache_line_length);
109b0c62724SMichal Simek 	else
110b0c62724SMichal Simek 		count += seq_printf(m, "Icache:\t\tno\n");
111b0c62724SMichal Simek 
112e051af57SMichal Simek 	if (cpuinfo.use_dcache) {
113b0c62724SMichal Simek 		count += seq_printf(m,
11477543cebSMichal Simek 				"Dcache:\t\t%ukB\tline length:\t%dB\n",
11577543cebSMichal Simek 				cpuinfo.dcache_size >> 10,
11677543cebSMichal Simek 				cpuinfo.dcache_line_length);
117e051af57SMichal Simek 		if (cpuinfo.dcache_wb)
118e051af57SMichal Simek 			count += seq_printf(m, "\t\twrite-back\n");
119b0c62724SMichal Simek 		else
120e051af57SMichal Simek 			count += seq_printf(m, "\t\twrite-through\n");
121e051af57SMichal Simek 	} else
122b0c62724SMichal Simek 		count += seq_printf(m, "Dcache:\t\tno\n");
123b0c62724SMichal Simek 
124b0c62724SMichal Simek 	count += seq_printf(m,
125b0c62724SMichal Simek 			"HW-Debug:\t%s\n",
126b0c62724SMichal Simek 			cpuinfo.hw_debug ? "yes" : "no");
127b0c62724SMichal Simek 
128b0c62724SMichal Simek 	count += seq_printf(m,
12979533fd4SMichal Simek 			"PVR-USR1:\t%02x\n"
13079533fd4SMichal Simek 			"PVR-USR2:\t%08x\n",
131b0c62724SMichal Simek 			cpuinfo.pvr_user1,
132b0c62724SMichal Simek 			cpuinfo.pvr_user2);
133b0c62724SMichal Simek 
134ba9c4f88SSteven J. Magnani 	count += seq_printf(m, "Page size:\t%lu\n", PAGE_SIZE);
135b0c62724SMichal Simek 	return 0;
136b0c62724SMichal Simek }
137b0c62724SMichal Simek 
138b0c62724SMichal Simek static void *c_start(struct seq_file *m, loff_t *pos)
139b0c62724SMichal Simek {
140b0c62724SMichal Simek 	int i = *pos;
141b0c62724SMichal Simek 
142b0c62724SMichal Simek 	return i < NR_CPUS ? (void *) (i + 1) : NULL;
143b0c62724SMichal Simek }
144b0c62724SMichal Simek 
145b0c62724SMichal Simek static void *c_next(struct seq_file *m, void *v, loff_t *pos)
146b0c62724SMichal Simek {
147b0c62724SMichal Simek 	++*pos;
148b0c62724SMichal Simek 	return c_start(m, pos);
149b0c62724SMichal Simek }
150b0c62724SMichal Simek 
151b0c62724SMichal Simek static void c_stop(struct seq_file *m, void *v)
152b0c62724SMichal Simek {
153b0c62724SMichal Simek }
154b0c62724SMichal Simek 
155b0c62724SMichal Simek const struct seq_operations cpuinfo_op = {
156b0c62724SMichal Simek 	.start = c_start,
157b0c62724SMichal Simek 	.next = c_next,
158b0c62724SMichal Simek 	.stop = c_stop,
159b0c62724SMichal Simek 	.show = show_cpuinfo,
160b0c62724SMichal Simek };
161