blob: b4048af026158e79c1422b0553d540d30f53da13 [file] [log] [blame]
Michal Simekb0c62722009-03-27 14:25:18 +01001/*
2 * CPU-version specific code
3 *
4 * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
5 * Copyright (C) 2006-2009 PetaLogix
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
11
12#include <linux/init.h>
13#include <linux/string.h>
14#include <linux/seq_file.h>
15#include <linux/cpu.h>
16#include <linux/initrd.h>
17
18#include <linux/bug.h>
19#include <asm/cpuinfo.h>
20#include <linux/delay.h>
21#include <linux/io.h>
22#include <asm/page.h>
23#include <linux/param.h>
24#include <asm/pvr.h>
25#include <asm/sections.h>
26#include <asm/setup.h>
27
28static int show_cpuinfo(struct seq_file *m, void *v)
29{
30 int count = 0;
31 char *fpga_family = "Unknown";
32 char *cpu_ver = "Unknown";
33 int i;
34
35 /* Denormalised to get the fpga family string */
36 for (i = 0; family_string_lookup[i].s != NULL; i++) {
37 if (cpuinfo.fpga_family_code == family_string_lookup[i].k) {
38 fpga_family = (char *)family_string_lookup[i].s;
39 break;
40 }
41 }
42
43 /* Denormalised to get the hw version string */
44 for (i = 0; cpu_ver_lookup[i].s != NULL; i++) {
45 if (cpuinfo.ver_code == cpu_ver_lookup[i].k) {
46 cpu_ver = (char *)cpu_ver_lookup[i].s;
47 break;
48 }
49 }
50
51 count = seq_printf(m,
52 "CPU-Family: MicroBlaze\n"
53 "FPGA-Arch: %s\n"
Michal Simek8e2ad012010-08-13 12:47:42 +020054 "CPU-Ver: %s, %s endian\n"
Michal Simekb0c62722009-03-27 14:25:18 +010055 "CPU-MHz: %d.%02d\n"
56 "BogoMips: %lu.%02lu\n",
57 fpga_family,
58 cpu_ver,
Michal Simek8e2ad012010-08-13 12:47:42 +020059 cpuinfo.endian ? "little" : "big",
Michal Simekb0c62722009-03-27 14:25:18 +010060 cpuinfo.cpu_clock_freq /
61 1000000,
62 cpuinfo.cpu_clock_freq %
63 1000000,
64 loops_per_jiffy / (500000 / HZ),
65 (loops_per_jiffy / (5000 / HZ)) % 100);
66
67 count += seq_printf(m,
68 "HW:\n Shift:\t\t%s\n"
69 " MSR:\t\t%s\n"
70 " PCMP:\t\t%s\n"
71 " DIV:\t\t%s\n",
72 (cpuinfo.use_instr & PVR0_USE_BARREL_MASK) ? "yes" : "no",
73 (cpuinfo.use_instr & PVR2_USE_MSR_INSTR) ? "yes" : "no",
74 (cpuinfo.use_instr & PVR2_USE_PCMP_INSTR) ? "yes" : "no",
75 (cpuinfo.use_instr & PVR0_USE_DIV_MASK) ? "yes" : "no");
76
77 count += seq_printf(m,
78 " MMU:\t\t%x\n",
79 cpuinfo.mmu);
80
81 count += seq_printf(m,
82 " MUL:\t\t%s\n"
83 " FPU:\t\t%s\n",
84 (cpuinfo.use_mult & PVR2_USE_MUL64_MASK) ? "v2" :
85 (cpuinfo.use_mult & PVR0_USE_HW_MUL_MASK) ? "v1" : "no",
86 (cpuinfo.use_fpu & PVR2_USE_FPU2_MASK) ? "v2" :
87 (cpuinfo.use_fpu & PVR0_USE_FPU_MASK) ? "v1" : "no");
88
89 count += seq_printf(m,
90 " Exc:\t\t%s%s%s%s%s%s%s%s\n",
91 (cpuinfo.use_exc & PVR2_OPCODE_0x0_ILL_MASK) ? "op0x0 " : "",
92 (cpuinfo.use_exc & PVR2_UNALIGNED_EXC_MASK) ? "unal " : "",
93 (cpuinfo.use_exc & PVR2_ILL_OPCODE_EXC_MASK) ? "ill " : "",
94 (cpuinfo.use_exc & PVR2_IOPB_BUS_EXC_MASK) ? "iopb " : "",
95 (cpuinfo.use_exc & PVR2_DOPB_BUS_EXC_MASK) ? "dopb " : "",
96 (cpuinfo.use_exc & PVR2_DIV_ZERO_EXC_MASK) ? "zero " : "",
97 (cpuinfo.use_exc & PVR2_FPU_EXC_MASK) ? "fpu " : "",
98 (cpuinfo.use_exc & PVR2_USE_FSL_EXC) ? "fsl " : "");
99
100 if (cpuinfo.use_icache)
101 count += seq_printf(m,
Michal Simek77543ce2010-04-26 13:53:04 +0200102 "Icache:\t\t%ukB\tline length:\t%dB\n",
103 cpuinfo.icache_size >> 10,
104 cpuinfo.icache_line_length);
Michal Simekb0c62722009-03-27 14:25:18 +0100105 else
106 count += seq_printf(m, "Icache:\t\tno\n");
107
Michal Simeke051af52009-10-14 11:12:50 +0200108 if (cpuinfo.use_dcache) {
Michal Simekb0c62722009-03-27 14:25:18 +0100109 count += seq_printf(m,
Michal Simek77543ce2010-04-26 13:53:04 +0200110 "Dcache:\t\t%ukB\tline length:\t%dB\n",
111 cpuinfo.dcache_size >> 10,
112 cpuinfo.dcache_line_length);
Michal Simeke051af52009-10-14 11:12:50 +0200113 if (cpuinfo.dcache_wb)
114 count += seq_printf(m, "\t\twrite-back\n");
115 else
116 count += seq_printf(m, "\t\twrite-through\n");
117 } else
Michal Simekb0c62722009-03-27 14:25:18 +0100118 count += seq_printf(m, "Dcache:\t\tno\n");
119
120 count += seq_printf(m,
121 "HW-Debug:\t%s\n",
122 cpuinfo.hw_debug ? "yes" : "no");
123
124 count += seq_printf(m,
Michal Simek79533fd2009-04-21 14:04:39 +0200125 "PVR-USR1:\t%02x\n"
126 "PVR-USR2:\t%08x\n",
Michal Simekb0c62722009-03-27 14:25:18 +0100127 cpuinfo.pvr_user1,
128 cpuinfo.pvr_user2);
129
Steven J. Magnaniba9c4f82010-05-13 10:48:27 -0500130 count += seq_printf(m, "Page size:\t%lu\n", PAGE_SIZE);
Michal Simekb0c62722009-03-27 14:25:18 +0100131 return 0;
132}
133
134static void *c_start(struct seq_file *m, loff_t *pos)
135{
136 int i = *pos;
137
138 return i < NR_CPUS ? (void *) (i + 1) : NULL;
139}
140
141static void *c_next(struct seq_file *m, void *v, loff_t *pos)
142{
143 ++*pos;
144 return c_start(m, pos);
145}
146
147static void c_stop(struct seq_file *m, void *v)
148{
149}
150
151const struct seq_operations cpuinfo_op = {
152 .start = c_start,
153 .next = c_next,
154 .stop = c_stop,
155 .show = show_cpuinfo,
156};