1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
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 */
21 for (i
= 0; i
< 100; i
++) {
22 seq_printf(m
, "product info[%d] : 0x%08x\n", i
, cur
);
26 /* some CPU only has one id reg */
32 /* cpid index is 31-28, reset */
34 while ((mfcr("cr13") >> 28) != i
);
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());
46 static int c_show(struct seq_file
*m
, void *v
)
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
);
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
)
72 static void c_stop(struct seq_file
*m
, void *v
) {}
74 const struct seq_operations cpuinfo_op
= {