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