1b0c62724SMichal Simek /* 2b0c62724SMichal Simek * CPU-version specific code 3b0c62724SMichal Simek * 4b0c62724SMichal Simek * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu> 5b0c62724SMichal Simek * Copyright (C) 2006-2009 PetaLogix 6b0c62724SMichal Simek * 7b0c62724SMichal Simek * This file is subject to the terms and conditions of the GNU General Public 8b0c62724SMichal Simek * License. See the file "COPYING" in the main directory of this archive 9b0c62724SMichal Simek * for more details. 10b0c62724SMichal Simek */ 11b0c62724SMichal Simek 12b0c62724SMichal Simek #include <linux/init.h> 13b0c62724SMichal Simek #include <linux/string.h> 14b0c62724SMichal Simek #include <linux/seq_file.h> 15b0c62724SMichal Simek #include <linux/cpu.h> 16b0c62724SMichal Simek #include <linux/initrd.h> 17b0c62724SMichal Simek 18b0c62724SMichal Simek #include <linux/bug.h> 19b0c62724SMichal Simek #include <asm/cpuinfo.h> 20b0c62724SMichal Simek #include <linux/delay.h> 21b0c62724SMichal Simek #include <linux/io.h> 22b0c62724SMichal Simek #include <asm/page.h> 23b0c62724SMichal Simek #include <linux/param.h> 24b0c62724SMichal Simek #include <asm/pvr.h> 25b0c62724SMichal Simek #include <asm/sections.h> 26b0c62724SMichal Simek #include <asm/setup.h> 27b0c62724SMichal Simek 28b0c62724SMichal Simek static int show_cpuinfo(struct seq_file *m, void *v) 29b0c62724SMichal Simek { 30b0c62724SMichal Simek char *fpga_family = "Unknown"; 31b0c62724SMichal Simek char *cpu_ver = "Unknown"; 32b0c62724SMichal Simek int i; 33b0c62724SMichal Simek 34b0c62724SMichal Simek /* Denormalised to get the fpga family string */ 35b0c62724SMichal Simek for (i = 0; family_string_lookup[i].s != NULL; i++) { 36b0c62724SMichal Simek if (cpuinfo.fpga_family_code == family_string_lookup[i].k) { 37b0c62724SMichal Simek fpga_family = (char *)family_string_lookup[i].s; 38b0c62724SMichal Simek break; 39b0c62724SMichal Simek } 40b0c62724SMichal Simek } 41b0c62724SMichal Simek 42b0c62724SMichal Simek /* Denormalised to get the hw version string */ 43b0c62724SMichal Simek for (i = 0; cpu_ver_lookup[i].s != NULL; i++) { 44b0c62724SMichal Simek if (cpuinfo.ver_code == cpu_ver_lookup[i].k) { 45b0c62724SMichal Simek cpu_ver = (char *)cpu_ver_lookup[i].s; 46b0c62724SMichal Simek break; 47b0c62724SMichal Simek } 48b0c62724SMichal Simek } 49b0c62724SMichal Simek 50*81f0cd97SJoe Perches seq_printf(m, 51b0c62724SMichal Simek "CPU-Family: MicroBlaze\n" 52b0c62724SMichal Simek "FPGA-Arch: %s\n" 538e2ad016SMichal Simek "CPU-Ver: %s, %s endian\n" 54b0c62724SMichal Simek "CPU-MHz: %d.%02d\n" 55b0c62724SMichal Simek "BogoMips: %lu.%02lu\n", 56b0c62724SMichal Simek fpga_family, 57b0c62724SMichal Simek cpu_ver, 588e2ad016SMichal Simek cpuinfo.endian ? "little" : "big", 59*81f0cd97SJoe Perches cpuinfo.cpu_clock_freq / 1000000, 60*81f0cd97SJoe Perches cpuinfo.cpu_clock_freq % 1000000, 61b0c62724SMichal Simek loops_per_jiffy / (500000 / HZ), 62b0c62724SMichal Simek (loops_per_jiffy / (5000 / HZ)) % 100); 63b0c62724SMichal Simek 64*81f0cd97SJoe Perches seq_printf(m, 65b0c62724SMichal Simek "HW:\n Shift:\t\t%s\n" 66b0c62724SMichal Simek " MSR:\t\t%s\n" 67b0c62724SMichal Simek " PCMP:\t\t%s\n" 68b0c62724SMichal Simek " DIV:\t\t%s\n", 69b0c62724SMichal Simek (cpuinfo.use_instr & PVR0_USE_BARREL_MASK) ? "yes" : "no", 70b0c62724SMichal Simek (cpuinfo.use_instr & PVR2_USE_MSR_INSTR) ? "yes" : "no", 71b0c62724SMichal Simek (cpuinfo.use_instr & PVR2_USE_PCMP_INSTR) ? "yes" : "no", 72b0c62724SMichal Simek (cpuinfo.use_instr & PVR0_USE_DIV_MASK) ? "yes" : "no"); 73b0c62724SMichal Simek 74*81f0cd97SJoe Perches seq_printf(m, " MMU:\t\t%x\n", cpuinfo.mmu); 75b0c62724SMichal Simek 76*81f0cd97SJoe Perches seq_printf(m, 77b0c62724SMichal Simek " MUL:\t\t%s\n" 78b0c62724SMichal Simek " FPU:\t\t%s\n", 79b0c62724SMichal Simek (cpuinfo.use_mult & PVR2_USE_MUL64_MASK) ? "v2" : 80b0c62724SMichal Simek (cpuinfo.use_mult & PVR0_USE_HW_MUL_MASK) ? "v1" : "no", 81b0c62724SMichal Simek (cpuinfo.use_fpu & PVR2_USE_FPU2_MASK) ? "v2" : 82b0c62724SMichal Simek (cpuinfo.use_fpu & PVR0_USE_FPU_MASK) ? "v1" : "no"); 83b0c62724SMichal Simek 84*81f0cd97SJoe Perches seq_printf(m, 85b0c62724SMichal Simek " Exc:\t\t%s%s%s%s%s%s%s%s\n", 86b0c62724SMichal Simek (cpuinfo.use_exc & PVR2_OPCODE_0x0_ILL_MASK) ? "op0x0 " : "", 87b0c62724SMichal Simek (cpuinfo.use_exc & PVR2_UNALIGNED_EXC_MASK) ? "unal " : "", 88b0c62724SMichal Simek (cpuinfo.use_exc & PVR2_ILL_OPCODE_EXC_MASK) ? "ill " : "", 89b0c62724SMichal Simek (cpuinfo.use_exc & PVR2_IOPB_BUS_EXC_MASK) ? "iopb " : "", 90b0c62724SMichal Simek (cpuinfo.use_exc & PVR2_DOPB_BUS_EXC_MASK) ? "dopb " : "", 91b0c62724SMichal Simek (cpuinfo.use_exc & PVR2_DIV_ZERO_EXC_MASK) ? "zero " : "", 92b0c62724SMichal Simek (cpuinfo.use_exc & PVR2_FPU_EXC_MASK) ? "fpu " : "", 93b0c62724SMichal Simek (cpuinfo.use_exc & PVR2_USE_FSL_EXC) ? "fsl " : ""); 94b0c62724SMichal Simek 95*81f0cd97SJoe Perches seq_printf(m, 968904976eSJohn A. Williams "Stream-insns:\t%sprivileged\n", 978904976eSJohn A. Williams cpuinfo.mmu_privins ? "un" : ""); 988904976eSJohn A. Williams 99b0c62724SMichal Simek if (cpuinfo.use_icache) 100*81f0cd97SJoe Perches seq_printf(m, 10177543cebSMichal Simek "Icache:\t\t%ukB\tline length:\t%dB\n", 10277543cebSMichal Simek cpuinfo.icache_size >> 10, 10377543cebSMichal Simek cpuinfo.icache_line_length); 104b0c62724SMichal Simek else 105*81f0cd97SJoe Perches seq_puts(m, "Icache:\t\tno\n"); 106b0c62724SMichal Simek 107e051af57SMichal Simek if (cpuinfo.use_dcache) { 108*81f0cd97SJoe Perches seq_printf(m, 10977543cebSMichal Simek "Dcache:\t\t%ukB\tline length:\t%dB\n", 11077543cebSMichal Simek cpuinfo.dcache_size >> 10, 11177543cebSMichal Simek cpuinfo.dcache_line_length); 112*81f0cd97SJoe Perches seq_puts(m, "Dcache-Policy:\t"); 113e051af57SMichal Simek if (cpuinfo.dcache_wb) 114*81f0cd97SJoe Perches seq_puts(m, "write-back\n"); 115b0c62724SMichal Simek else 116*81f0cd97SJoe Perches seq_puts(m, "write-through\n"); 117*81f0cd97SJoe Perches } else { 118*81f0cd97SJoe Perches seq_puts(m, "Dcache:\t\tno\n"); 119*81f0cd97SJoe Perches } 120b0c62724SMichal Simek 121*81f0cd97SJoe Perches seq_printf(m, 122b0c62724SMichal Simek "HW-Debug:\t%s\n", 123b0c62724SMichal Simek cpuinfo.hw_debug ? "yes" : "no"); 124b0c62724SMichal Simek 125*81f0cd97SJoe Perches seq_printf(m, 12679533fd4SMichal Simek "PVR-USR1:\t%02x\n" 12779533fd4SMichal Simek "PVR-USR2:\t%08x\n", 128b0c62724SMichal Simek cpuinfo.pvr_user1, 129b0c62724SMichal Simek cpuinfo.pvr_user2); 130b0c62724SMichal Simek 131*81f0cd97SJoe Perches seq_printf(m, "Page size:\t%lu\n", PAGE_SIZE); 132*81f0cd97SJoe Perches 133b0c62724SMichal Simek return 0; 134b0c62724SMichal Simek } 135b0c62724SMichal Simek 136b0c62724SMichal Simek static void *c_start(struct seq_file *m, loff_t *pos) 137b0c62724SMichal Simek { 138b0c62724SMichal Simek int i = *pos; 139b0c62724SMichal Simek 140b0c62724SMichal Simek return i < NR_CPUS ? (void *) (i + 1) : NULL; 141b0c62724SMichal Simek } 142b0c62724SMichal Simek 143b0c62724SMichal Simek static void *c_next(struct seq_file *m, void *v, loff_t *pos) 144b0c62724SMichal Simek { 145b0c62724SMichal Simek ++*pos; 146b0c62724SMichal Simek return c_start(m, pos); 147b0c62724SMichal Simek } 148b0c62724SMichal Simek 149b0c62724SMichal Simek static void c_stop(struct seq_file *m, void *v) 150b0c62724SMichal Simek { 151b0c62724SMichal Simek } 152b0c62724SMichal Simek 153b0c62724SMichal Simek const struct seq_operations cpuinfo_op = { 154b0c62724SMichal Simek .start = c_start, 155b0c62724SMichal Simek .next = c_next, 156b0c62724SMichal Simek .stop = c_stop, 157b0c62724SMichal Simek .show = show_cpuinfo, 158b0c62724SMichal Simek }; 159