1 #include <linux/seq_file.h> 2 #include <linux/kernel.h> 3 #include <linux/module.h> 4 #include <asm/machvec.h> 5 #include <asm/processor.h> 6 7 static const char *cpu_name[] = { 8 [CPU_SH7201] = "SH7201", 9 [CPU_SH7203] = "SH7203", [CPU_SH7263] = "SH7263", 10 [CPU_SH7264] = "SH7264", [CPU_SH7269] = "SH7269", 11 [CPU_SH7206] = "SH7206", [CPU_SH7619] = "SH7619", 12 [CPU_SH7705] = "SH7705", [CPU_SH7706] = "SH7706", 13 [CPU_SH7707] = "SH7707", [CPU_SH7708] = "SH7708", 14 [CPU_SH7709] = "SH7709", [CPU_SH7710] = "SH7710", 15 [CPU_SH7712] = "SH7712", [CPU_SH7720] = "SH7720", 16 [CPU_SH7721] = "SH7721", [CPU_SH7729] = "SH7729", 17 [CPU_SH7750] = "SH7750", [CPU_SH7750S] = "SH7750S", 18 [CPU_SH7750R] = "SH7750R", [CPU_SH7751] = "SH7751", 19 [CPU_SH7751R] = "SH7751R", [CPU_SH7760] = "SH7760", 20 [CPU_SH4_202] = "SH4-202", [CPU_SH4_501] = "SH4-501", 21 [CPU_SH7763] = "SH7763", [CPU_SH7770] = "SH7770", 22 [CPU_SH7780] = "SH7780", [CPU_SH7781] = "SH7781", 23 [CPU_SH7343] = "SH7343", [CPU_SH7785] = "SH7785", 24 [CPU_SH7786] = "SH7786", [CPU_SH7757] = "SH7757", 25 [CPU_SH7722] = "SH7722", [CPU_SHX3] = "SH-X3", 26 [CPU_SH5_101] = "SH5-101", [CPU_SH5_103] = "SH5-103", 27 [CPU_MXG] = "MX-G", [CPU_SH7723] = "SH7723", 28 [CPU_SH7366] = "SH7366", [CPU_SH7724] = "SH7724", 29 [CPU_SH7372] = "SH7372", [CPU_SH_NONE] = "Unknown" 30 }; 31 32 const char *get_cpu_subtype(struct sh_cpuinfo *c) 33 { 34 return cpu_name[c->type]; 35 } 36 EXPORT_SYMBOL(get_cpu_subtype); 37 38 #ifdef CONFIG_PROC_FS 39 /* Symbolic CPU flags, keep in sync with asm/cpu-features.h */ 40 static const char *cpu_flags[] = { 41 "none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr", 42 "ptea", "llsc", "l2", "op32", "pteaex", NULL 43 }; 44 45 static void show_cpuflags(struct seq_file *m, struct sh_cpuinfo *c) 46 { 47 unsigned long i; 48 49 seq_printf(m, "cpu flags\t:"); 50 51 if (!c->flags) { 52 seq_printf(m, " %s\n", cpu_flags[0]); 53 return; 54 } 55 56 for (i = 0; cpu_flags[i]; i++) 57 if ((c->flags & (1 << i))) 58 seq_printf(m, " %s", cpu_flags[i+1]); 59 60 seq_printf(m, "\n"); 61 } 62 63 static void show_cacheinfo(struct seq_file *m, const char *type, 64 struct cache_info info) 65 { 66 unsigned int cache_size; 67 68 cache_size = info.ways * info.sets * info.linesz; 69 70 seq_printf(m, "%s size\t: %2dKiB (%d-way)\n", 71 type, cache_size >> 10, info.ways); 72 } 73 74 /* 75 * Get CPU information for use by the procfs. 76 */ 77 static int show_cpuinfo(struct seq_file *m, void *v) 78 { 79 struct sh_cpuinfo *c = v; 80 unsigned int cpu = c - cpu_data; 81 82 if (!cpu_online(cpu)) 83 return 0; 84 85 if (cpu == 0) 86 seq_printf(m, "machine\t\t: %s\n", get_system_type()); 87 else 88 seq_printf(m, "\n"); 89 90 seq_printf(m, "processor\t: %d\n", cpu); 91 seq_printf(m, "cpu family\t: %s\n", init_utsname()->machine); 92 seq_printf(m, "cpu type\t: %s\n", get_cpu_subtype(c)); 93 if (c->cut_major == -1) 94 seq_printf(m, "cut\t\t: unknown\n"); 95 else if (c->cut_minor == -1) 96 seq_printf(m, "cut\t\t: %d.x\n", c->cut_major); 97 else 98 seq_printf(m, "cut\t\t: %d.%d\n", c->cut_major, c->cut_minor); 99 100 show_cpuflags(m, c); 101 102 seq_printf(m, "cache type\t: "); 103 104 /* 105 * Check for what type of cache we have, we support both the 106 * unified cache on the SH-2 and SH-3, as well as the harvard 107 * style cache on the SH-4. 108 */ 109 if (c->icache.flags & SH_CACHE_COMBINED) { 110 seq_printf(m, "unified\n"); 111 show_cacheinfo(m, "cache", c->icache); 112 } else { 113 seq_printf(m, "split (harvard)\n"); 114 show_cacheinfo(m, "icache", c->icache); 115 show_cacheinfo(m, "dcache", c->dcache); 116 } 117 118 /* Optional secondary cache */ 119 if (c->flags & CPU_HAS_L2_CACHE) 120 show_cacheinfo(m, "scache", c->scache); 121 122 seq_printf(m, "address sizes\t: %u bits physical\n", c->phys_bits); 123 124 seq_printf(m, "bogomips\t: %lu.%02lu\n", 125 c->loops_per_jiffy/(500000/HZ), 126 (c->loops_per_jiffy/(5000/HZ)) % 100); 127 128 return 0; 129 } 130 131 static void *c_start(struct seq_file *m, loff_t *pos) 132 { 133 return *pos < NR_CPUS ? cpu_data + *pos : NULL; 134 } 135 static void *c_next(struct seq_file *m, void *v, loff_t *pos) 136 { 137 ++*pos; 138 return c_start(m, pos); 139 } 140 static void c_stop(struct seq_file *m, void *v) 141 { 142 } 143 const struct seq_operations cpuinfo_op = { 144 .start = c_start, 145 .next = c_next, 146 .stop = c_stop, 147 .show = show_cpuinfo, 148 }; 149 #endif /* CONFIG_PROC_FS */ 150