summaryrefslogtreecommitdiff
path: root/arch/loongarch/kernel/proc.c
blob: a8127e83da65681c54ad4a8a386b5eee316ac78e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
 */
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/seq_file.h>
#include <asm/bootinfo.h>
#include <asm/cpu.h>
#include <asm/cpu-features.h>
#include <asm/idle.h>
#include <asm/processor.h>
#include <asm/time.h>

static int show_cpuinfo(struct seq_file *m, void *v)
{
	unsigned long n = (unsigned long) v - 1;
	unsigned int isa = cpu_data[n].isa_level;
	unsigned int prid = cpu_data[n].processor_id;
	unsigned int version = cpu_data[n].processor_id & 0xff;
	unsigned int fp_version = cpu_data[n].fpu_vers;
	u64 freq = cpu_clock_freq, bogomips = lpj_fine * cpu_clock_freq;

#ifdef CONFIG_SMP
	if (!cpu_online(n))
		return 0;
#endif
	do_div(freq, 10000);
	do_div(bogomips, const_clock_freq * (5000/HZ));

	/*
	 * For the first processor also print the system type
	 */
	if (n == 0)
		seq_printf(m, "system type\t\t: %s\n\n", get_system_type());

	seq_printf(m, "processor\t\t: %ld\n", n);
	seq_printf(m, "package\t\t\t: %d\n", cpu_data[n].package);
	seq_printf(m, "core\t\t\t: %d\n", cpu_data[n].core);
	seq_printf(m, "global_id\t\t: %d\n", cpu_data[n].global_id);
	seq_printf(m, "CPU Family\t\t: %s\n", __cpu_family[n]);
	seq_printf(m, "Model Name\t\t: %s\n", __cpu_full_name[n]);
	seq_printf(m, "PRID\t\t\t: %s (%08x)\n", id_to_core_name(prid), prid);
	seq_printf(m, "CPU Revision\t\t: 0x%02x\n", version);
	seq_printf(m, "FPU Revision\t\t: 0x%02x\n", fp_version);
	seq_printf(m, "CPU MHz\t\t\t: %u.%02u\n", (u32)freq / 100, (u32)freq % 100);
	seq_printf(m, "BogoMIPS\t\t: %u.%02u\n", (u32)bogomips / 100, (u32)bogomips % 100);
	seq_printf(m, "TLB Entries\t\t: %d\n", cpu_data[n].tlbsize);
	seq_printf(m, "Address Sizes\t\t: %d bits physical, %d bits virtual\n",
		      cpu_pabits + 1, cpu_vabits + 1);

	seq_puts(m, "ISA\t\t\t:");
	if (isa & LOONGARCH_CPU_ISA_LA32R)
		seq_puts(m, " loongarch32r");
	if (isa & LOONGARCH_CPU_ISA_LA32S)
		seq_puts(m, " loongarch32s");
	if (isa & LOONGARCH_CPU_ISA_LA64)
		seq_puts(m, " loongarch64");
	seq_puts(m, "\n");

	seq_puts(m, "Features\t\t:");
	if (cpu_has_cpucfg)
		seq_puts(m, " cpucfg");
	if (cpu_has_lam)
		seq_puts(m, " lam");
	if (cpu_has_scq)
		seq_puts(m, " scq");
	if (cpu_has_ual)
		seq_puts(m, " ual");
	if (cpu_has_fpu)
		seq_puts(m, " fpu");
	if (cpu_has_lsx)
		seq_puts(m, " lsx");
	if (cpu_has_lasx)
		seq_puts(m, " lasx");
	if (cpu_has_crc32)
		seq_puts(m, " crc32");
	if (cpu_has_complex)
		seq_puts(m, " complex");
	if (cpu_has_crypto)
		seq_puts(m, " crypto");
	if (cpu_has_ptw)
		seq_puts(m, " ptw");
	if (cpu_has_lspw)
		seq_puts(m, " lspw");
	if (cpu_has_lvz)
		seq_puts(m, " lvz");
	if (cpu_has_lbt_x86)
		seq_puts(m, " lbt_x86");
	if (cpu_has_lbt_arm)
		seq_puts(m, " lbt_arm");
	if (cpu_has_lbt_mips)
		seq_puts(m, " lbt_mips");
	seq_puts(m, "\n");

	seq_printf(m, "Hardware Watchpoint\t: %s", str_yes_no(cpu_has_watch));
	if (cpu_has_watch) {
		seq_printf(m, ", iwatch count: %d, dwatch count: %d",
		      cpu_data[n].watch_ireg_count, cpu_data[n].watch_dreg_count);
	}

	seq_puts(m, "\n\n");

	return 0;
}

static void *c_start(struct seq_file *m, loff_t *pos)
{
	unsigned long i = *pos;

	return i < nr_cpu_ids ? (void *)(i + 1) : NULL;
}

static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{
	++*pos;
	return c_start(m, pos);
}

static void c_stop(struct seq_file *m, void *v)
{
}

const struct seq_operations cpuinfo_op = {
	.start	= c_start,
	.next	= c_next,
	.stop	= c_stop,
	.show	= show_cpuinfo,
};