Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
0003 
0004 #include <linux/of.h>
0005 #include <linux/init.h>
0006 #include <linux/seq_file.h>
0007 #include <linux/memblock.h>
0008 
0009 #include <abi/reg_ops.h>
0010 
0011 static void percpu_print(void *arg)
0012 {
0013     struct seq_file *m = (struct seq_file *)arg;
0014     unsigned int cur, next, i;
0015 
0016     seq_printf(m, "processor       : %d\n", smp_processor_id());
0017     seq_printf(m, "C-SKY CPU model : %s\n", CSKYCPU_DEF_NAME);
0018 
0019     /* read processor id, max is 100 */
0020     cur  = mfcr("cr13");
0021     for (i = 0; i < 100; i++) {
0022         seq_printf(m, "product info[%d] : 0x%08x\n", i, cur);
0023 
0024         next = mfcr("cr13");
0025 
0026         /* some CPU only has one id reg */
0027         if (cur == next)
0028             break;
0029 
0030         cur = next;
0031 
0032         /* cpid index is 31-28, reset */
0033         if (!(next >> 28)) {
0034             while ((mfcr("cr13") >> 28) != i);
0035             break;
0036         }
0037     }
0038 
0039     /* CPU feature regs, setup by bootloader or gdbinit */
0040     seq_printf(m, "hint (CPU funcs): 0x%08x\n", mfcr_hint());
0041     seq_printf(m, "ccr  (L1C & MMU): 0x%08x\n", mfcr("cr18"));
0042     seq_printf(m, "ccr2 (L2C)      : 0x%08x\n", mfcr_ccr2());
0043     seq_printf(m, "\n");
0044 }
0045 
0046 static int c_show(struct seq_file *m, void *v)
0047 {
0048     int cpu;
0049 
0050     for_each_online_cpu(cpu)
0051         smp_call_function_single(cpu, percpu_print, m, true);
0052 
0053 #ifdef CSKY_ARCH_VERSION
0054     seq_printf(m, "arch-version : %s\n", CSKY_ARCH_VERSION);
0055     seq_printf(m, "\n");
0056 #endif
0057 
0058     return 0;
0059 }
0060 
0061 static void *c_start(struct seq_file *m, loff_t *pos)
0062 {
0063     return *pos < 1 ? (void *)1 : NULL;
0064 }
0065 
0066 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
0067 {
0068     ++*pos;
0069     return NULL;
0070 }
0071 
0072 static void c_stop(struct seq_file *m, void *v) {}
0073 
0074 const struct seq_operations cpuinfo_op = {
0075     .start  = c_start,
0076     .next   = c_next,
0077     .stop   = c_stop,
0078     .show   = c_show,
0079 };