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