WIP FPC-III support
[linux/fpc-iii.git] / arch / csky / kernel / cpu-probe.c
blob5f15ca31d3e83ebf73f7372bfcf7eb115b010c4a
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #include <linux/of.h>
5 #include <linux/init.h>
6 #include <linux/seq_file.h>
7 #include <linux/memblock.h>
9 #include <abi/reg_ops.h>
11 static void percpu_print(void *arg)
13 struct seq_file *m = (struct seq_file *)arg;
14 unsigned int cur, next, i;
16 seq_printf(m, "processor : %d\n", smp_processor_id());
17 seq_printf(m, "C-SKY CPU model : %s\n", CSKYCPU_DEF_NAME);
19 /* read processor id, max is 100 */
20 cur = mfcr("cr13");
21 for (i = 0; i < 100; i++) {
22 seq_printf(m, "product info[%d] : 0x%08x\n", i, cur);
24 next = mfcr("cr13");
26 /* some CPU only has one id reg */
27 if (cur == next)
28 break;
30 cur = next;
32 /* cpid index is 31-28, reset */
33 if (!(next >> 28)) {
34 while ((mfcr("cr13") >> 28) != i);
35 break;
39 /* CPU feature regs, setup by bootloader or gdbinit */
40 seq_printf(m, "hint (CPU funcs): 0x%08x\n", mfcr_hint());
41 seq_printf(m, "ccr (L1C & MMU): 0x%08x\n", mfcr("cr18"));
42 seq_printf(m, "ccr2 (L2C) : 0x%08x\n", mfcr_ccr2());
43 seq_printf(m, "\n");
46 static int c_show(struct seq_file *m, void *v)
48 int cpu;
50 for_each_online_cpu(cpu)
51 smp_call_function_single(cpu, percpu_print, m, true);
53 #ifdef CSKY_ARCH_VERSION
54 seq_printf(m, "arch-version : %s\n", CSKY_ARCH_VERSION);
55 seq_printf(m, "\n");
56 #endif
58 return 0;
61 static void *c_start(struct seq_file *m, loff_t *pos)
63 return *pos < 1 ? (void *)1 : NULL;
66 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
68 ++*pos;
69 return NULL;
72 static void c_stop(struct seq_file *m, void *v) {}
74 const struct seq_operations cpuinfo_op = {
75 .start = c_start,
76 .next = c_next,
77 .stop = c_stop,
78 .show = c_show,