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*fac6c2a8SMagnus Damm [CPU_SH7372] = "SH7372", [CPU_SH_NONE] = "Unknown" 29a9b27bccSPaul Mundt }; 30a9b27bccSPaul Mundt 31a9b27bccSPaul Mundt const char *get_cpu_subtype(struct sh_cpuinfo *c) 32a9b27bccSPaul Mundt { 33a9b27bccSPaul Mundt return cpu_name[c->type]; 34a9b27bccSPaul Mundt } 35a9b27bccSPaul Mundt EXPORT_SYMBOL(get_cpu_subtype); 36a9b27bccSPaul Mundt 37a9b27bccSPaul Mundt #ifdef CONFIG_PROC_FS 38a9b27bccSPaul Mundt /* Symbolic CPU flags, keep in sync with asm/cpu-features.h */ 39a9b27bccSPaul Mundt static const char *cpu_flags[] = { 40a9b27bccSPaul Mundt "none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr", 41a9b27bccSPaul Mundt "ptea", "llsc", "l2", "op32", "pteaex", NULL 42a9b27bccSPaul Mundt }; 43a9b27bccSPaul Mundt 44a9b27bccSPaul Mundt static void show_cpuflags(struct seq_file *m, struct sh_cpuinfo *c) 45a9b27bccSPaul Mundt { 46a9b27bccSPaul Mundt unsigned long i; 47a9b27bccSPaul Mundt 48a9b27bccSPaul Mundt seq_printf(m, "cpu flags\t:"); 49a9b27bccSPaul Mundt 50a9b27bccSPaul Mundt if (!c->flags) { 51a9b27bccSPaul Mundt seq_printf(m, " %s\n", cpu_flags[0]); 52a9b27bccSPaul Mundt return; 53a9b27bccSPaul Mundt } 54a9b27bccSPaul Mundt 55a9b27bccSPaul Mundt for (i = 0; cpu_flags[i]; i++) 56a9b27bccSPaul Mundt if ((c->flags & (1 << i))) 57a9b27bccSPaul Mundt seq_printf(m, " %s", cpu_flags[i+1]); 58a9b27bccSPaul Mundt 59a9b27bccSPaul Mundt seq_printf(m, "\n"); 60a9b27bccSPaul Mundt } 61a9b27bccSPaul Mundt 62a9b27bccSPaul Mundt static void show_cacheinfo(struct seq_file *m, const char *type, 63a9b27bccSPaul Mundt struct cache_info info) 64a9b27bccSPaul Mundt { 65a9b27bccSPaul Mundt unsigned int cache_size; 66a9b27bccSPaul Mundt 67a9b27bccSPaul Mundt cache_size = info.ways * info.sets * info.linesz; 68a9b27bccSPaul Mundt 69a9b27bccSPaul Mundt seq_printf(m, "%s size\t: %2dKiB (%d-way)\n", 70a9b27bccSPaul Mundt type, cache_size >> 10, info.ways); 71a9b27bccSPaul Mundt } 72a9b27bccSPaul Mundt 73a9b27bccSPaul Mundt /* 74a9b27bccSPaul Mundt * Get CPU information for use by the procfs. 75a9b27bccSPaul Mundt */ 76a9b27bccSPaul Mundt static int show_cpuinfo(struct seq_file *m, void *v) 77a9b27bccSPaul Mundt { 78a9b27bccSPaul Mundt struct sh_cpuinfo *c = v; 79a9b27bccSPaul Mundt unsigned int cpu = c - cpu_data; 80a9b27bccSPaul Mundt 81a9b27bccSPaul Mundt if (!cpu_online(cpu)) 82a9b27bccSPaul Mundt return 0; 83a9b27bccSPaul Mundt 84a9b27bccSPaul Mundt if (cpu == 0) 85a9b27bccSPaul Mundt seq_printf(m, "machine\t\t: %s\n", get_system_type()); 86a9b27bccSPaul Mundt else 87a9b27bccSPaul Mundt seq_printf(m, "\n"); 88a9b27bccSPaul Mundt 89a9b27bccSPaul Mundt seq_printf(m, "processor\t: %d\n", cpu); 90a9b27bccSPaul Mundt seq_printf(m, "cpu family\t: %s\n", init_utsname()->machine); 91a9b27bccSPaul Mundt seq_printf(m, "cpu type\t: %s\n", get_cpu_subtype(c)); 92a9b27bccSPaul Mundt if (c->cut_major == -1) 93a9b27bccSPaul Mundt seq_printf(m, "cut\t\t: unknown\n"); 94a9b27bccSPaul Mundt else if (c->cut_minor == -1) 95a9b27bccSPaul Mundt seq_printf(m, "cut\t\t: %d.x\n", c->cut_major); 96a9b27bccSPaul Mundt else 97a9b27bccSPaul Mundt seq_printf(m, "cut\t\t: %d.%d\n", c->cut_major, c->cut_minor); 98a9b27bccSPaul Mundt 99a9b27bccSPaul Mundt show_cpuflags(m, c); 100a9b27bccSPaul Mundt 101a9b27bccSPaul Mundt seq_printf(m, "cache type\t: "); 102a9b27bccSPaul Mundt 103a9b27bccSPaul Mundt /* 104a9b27bccSPaul Mundt * Check for what type of cache we have, we support both the 105a9b27bccSPaul Mundt * unified cache on the SH-2 and SH-3, as well as the harvard 106a9b27bccSPaul Mundt * style cache on the SH-4. 107a9b27bccSPaul Mundt */ 108a9b27bccSPaul Mundt if (c->icache.flags & SH_CACHE_COMBINED) { 109a9b27bccSPaul Mundt seq_printf(m, "unified\n"); 110a9b27bccSPaul Mundt show_cacheinfo(m, "cache", c->icache); 111a9b27bccSPaul Mundt } else { 112a9b27bccSPaul Mundt seq_printf(m, "split (harvard)\n"); 113a9b27bccSPaul Mundt show_cacheinfo(m, "icache", c->icache); 114a9b27bccSPaul Mundt show_cacheinfo(m, "dcache", c->dcache); 115a9b27bccSPaul Mundt } 116a9b27bccSPaul Mundt 117a9b27bccSPaul Mundt /* Optional secondary cache */ 118a9b27bccSPaul Mundt if (c->flags & CPU_HAS_L2_CACHE) 119a9b27bccSPaul Mundt show_cacheinfo(m, "scache", c->scache); 120a9b27bccSPaul Mundt 121a9b27bccSPaul Mundt seq_printf(m, "address sizes\t: %u bits physical\n", c->phys_bits); 122a9b27bccSPaul Mundt 123a9b27bccSPaul Mundt seq_printf(m, "bogomips\t: %lu.%02lu\n", 124a9b27bccSPaul Mundt c->loops_per_jiffy/(500000/HZ), 125a9b27bccSPaul Mundt (c->loops_per_jiffy/(5000/HZ)) % 100); 126a9b27bccSPaul Mundt 127a9b27bccSPaul Mundt return 0; 128a9b27bccSPaul Mundt } 129a9b27bccSPaul Mundt 130a9b27bccSPaul Mundt static void *c_start(struct seq_file *m, loff_t *pos) 131a9b27bccSPaul Mundt { 132a9b27bccSPaul Mundt return *pos < NR_CPUS ? cpu_data + *pos : NULL; 133a9b27bccSPaul Mundt } 134a9b27bccSPaul Mundt static void *c_next(struct seq_file *m, void *v, loff_t *pos) 135a9b27bccSPaul Mundt { 136a9b27bccSPaul Mundt ++*pos; 137a9b27bccSPaul Mundt return c_start(m, pos); 138a9b27bccSPaul Mundt } 139a9b27bccSPaul Mundt static void c_stop(struct seq_file *m, void *v) 140a9b27bccSPaul Mundt { 141a9b27bccSPaul Mundt } 142a9b27bccSPaul Mundt const struct seq_operations cpuinfo_op = { 143a9b27bccSPaul Mundt .start = c_start, 144a9b27bccSPaul Mundt .next = c_next, 145a9b27bccSPaul Mundt .stop = c_stop, 146a9b27bccSPaul Mundt .show = show_cpuinfo, 147a9b27bccSPaul Mundt }; 148a9b27bccSPaul Mundt #endif /* CONFIG_PROC_FS */ 149