| 1 | |
| 2 | |
| 3 | * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
|
| 4 |
|
| 5 | #include <linux/delay.h>
|
| 6 | #include <linux/kernel.h>
|
| 7 | #include <linux/sched.h>
|
| 8 | #include <linux/seq_file.h>
|
| 9 | #include <asm/bootinfo.h>
|
| 10 | #include <asm/cpu.h>
|
| 11 | #include <asm/cpu-features.h>
|
| 12 | #include <asm/idle.h>
|
| 13 | #include <asm/processor.h>
|
| 14 | #include <asm/time.h>
|
| 15 |
|
| 16 | static int show_cpuinfo(struct seq_file *m, void *v)
|
| 17 | {
|
| 18 | unsigned long n = (unsigned long) v - 1;
|
| 19 | unsigned int isa = cpu_data[n].isa_level;
|
| 20 | unsigned int prid = cpu_data[n].processor_id;
|
| 21 | unsigned int version = cpu_data[n].processor_id & 0xff;
|
| 22 | unsigned int fp_version = cpu_data[n].fpu_vers;
|
| 23 | u64 freq = cpu_clock_freq, bogomips = lpj_fine * cpu_clock_freq;
|
| 24 |
|
| 25 | #ifdef CONFIG_SMP
|
| 26 | if (!cpu_online(n))
|
| 27 | return 0;
|
| 28 | #endif
|
| 29 | do_div(freq, 10000);
|
| 30 | do_div(bogomips, const_clock_freq * (5000/HZ));
|
| 31 |
|
| 32 | |
| 33 | * For the first processor also print the system type
|
| 34 |
|
| 35 | if (n == 0)
|
| 36 | seq_printf(m, "system type\t\t: %s\n\n", get_system_type());
|
| 37 |
|
| 38 | seq_printf(m, "processor\t\t: %ld\n", n);
|
| 39 | seq_printf(m, "package\t\t\t: %d\n", cpu_data[n].package);
|
| 40 | seq_printf(m, "core\t\t\t: %d\n", cpu_data[n].core);
|
| 41 | seq_printf(m, "global_id\t\t: %d\n", cpu_data[n].global_id);
|
| 42 | seq_printf(m, "CPU Family\t\t: %s\n", __cpu_family[n]);
|
| 43 | seq_printf(m, "Model Name\t\t: %s\n", __cpu_full_name[n]);
|
| 44 | seq_printf(m, "PRID\t\t\t: %s (%08x)\n", id_to_core_name(prid), prid);
|
| 45 | seq_printf(m, "CPU Revision\t\t: 0x%02x\n", version);
|
| 46 | seq_printf(m, "FPU Revision\t\t: 0x%02x\n", fp_version);
|
| 47 | seq_printf(m, "CPU MHz\t\t\t: %u.%02u\n", (u32)freq / 100, (u32)freq % 100);
|
| 48 | seq_printf(m, "BogoMIPS\t\t: %u.%02u\n", (u32)bogomips / 100, (u32)bogomips % 100);
|
| 49 | seq_printf(m, "TLB Entries\t\t: %d\n", cpu_data[n].tlbsize);
|
| 50 | seq_printf(m, "Address Sizes\t\t: %d bits physical, %d bits virtual\n",
|
| 51 | cpu_pabits + 1, cpu_vabits + 1);
|
| 52 |
|
| 53 | seq_puts(m, "ISA\t\t\t:");
|
| 54 | if (isa & LOONGARCH_CPU_ISA_LA32R)
|
| 55 | seq_puts(m, " loongarch32r");
|
| 56 | if (isa & LOONGARCH_CPU_ISA_LA32S)
|
| 57 | seq_puts(m, " loongarch32s");
|
| 58 | if (isa & LOONGARCH_CPU_ISA_LA64)
|
| 59 | seq_puts(m, " loongarch64");
|
| 60 | seq_puts(m, "\n");
|
| 61 |
|
| 62 | seq_puts(m, "Features\t\t:");
|
| 63 | if (cpu_has_cpucfg)
|
| 64 | seq_puts(m, " cpucfg");
|
| 65 | if (cpu_has_lam)
|
| 66 | seq_puts(m, " lam");
|
| 67 | if (cpu_has_lam_bh)
|
| 68 | seq_puts(m, " lam_bh");
|
| 69 | if (cpu_has_scq)
|
| 70 | seq_puts(m, " scq");
|
| 71 | if (cpu_has_ual)
|
| 72 | seq_puts(m, " ual");
|
| 73 | if (cpu_has_fpu)
|
| 74 | seq_puts(m, " fpu");
|
| 75 | if (cpu_has_lsx)
|
| 76 | seq_puts(m, " lsx");
|
| 77 | if (cpu_has_lasx)
|
| 78 | seq_puts(m, " lasx");
|
| 79 | if (cpu_has_crc32)
|
| 80 | seq_puts(m, " crc32");
|
| 81 | if (cpu_has_complex)
|
| 82 | seq_puts(m, " complex");
|
| 83 | if (cpu_has_crypto)
|
| 84 | seq_puts(m, " crypto");
|
| 85 | if (cpu_has_ptw)
|
| 86 | seq_puts(m, " ptw");
|
| 87 | if (cpu_has_lspw)
|
| 88 | seq_puts(m, " lspw");
|
| 89 | if (cpu_has_lvz)
|
| 90 | seq_puts(m, " lvz");
|
| 91 | if (cpu_has_lbt_x86)
|
| 92 | seq_puts(m, " lbt_x86");
|
| 93 | if (cpu_has_lbt_arm)
|
| 94 | seq_puts(m, " lbt_arm");
|
| 95 | if (cpu_has_lbt_mips)
|
| 96 | seq_puts(m, " lbt_mips");
|
| 97 | seq_puts(m, "\n");
|
| 98 |
|
| 99 | seq_printf(m, "Hardware Watchpoint\t: %s", str_yes_no(cpu_has_watch));
|
| 100 | if (cpu_has_watch) {
|
| 101 | seq_printf(m, ", iwatch count: %d, dwatch count: %d",
|
| 102 | cpu_data[n].watch_ireg_count, cpu_data[n].watch_dreg_count);
|
| 103 | }
|
| 104 |
|
| 105 | seq_puts(m, "\n\n");
|
| 106 |
|
| 107 | return 0;
|
| 108 | }
|
| 109 |
|
| 110 | static void *c_start(struct seq_file *m, loff_t *pos)
|
| 111 | {
|
| 112 | unsigned long i = *pos;
|
| 113 |
|
| 114 | return i < nr_cpu_ids ? (void *)(i + 1) : NULL;
|
| 115 | }
|
| 116 |
|
| 117 | static void *c_next(struct seq_file *m, void *v, loff_t *pos)
|
| 118 | {
|
| 119 | ++*pos;
|
| 120 | return c_start(m, pos);
|
| 121 | }
|
| 122 |
|
| 123 | static void c_stop(struct seq_file *m, void *v)
|
| 124 | {
|
| 125 | }
|
| 126 |
|
| 127 | const struct seq_operations cpuinfo_op = {
|
| 128 | .start = c_start,
|
| 129 | .next = c_next,
|
| 130 | .stop = c_stop,
|
| 131 | .show = show_cpuinfo,
|
| 132 | };
|