Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * CPU-version specific code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2006-2009 PetaLogix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * License. See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/cpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/initrd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/bug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <asm/cpuinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/param.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <asm/pvr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <asm/sections.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <asm/setup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static int show_cpuinfo(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	char *fpga_family = "Unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	char *cpu_ver = "Unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	/* Denormalised to get the fpga family string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	for (i = 0; family_string_lookup[i].s != NULL; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		if (cpuinfo.fpga_family_code == family_string_lookup[i].k) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 			fpga_family = (char *)family_string_lookup[i].s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	/* Denormalised to get the hw version string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	for (i = 0; cpu_ver_lookup[i].s != NULL; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		if (cpuinfo.ver_code == cpu_ver_lookup[i].k) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			cpu_ver = (char *)cpu_ver_lookup[i].s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		   "CPU-Family:	MicroBlaze\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		   "FPGA-Arch:	%s\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		   "CPU-Ver:	%s, %s endian\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		   "CPU-MHz:	%d.%02d\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		   "BogoMips:	%lu.%02lu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		   fpga_family,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		   cpu_ver,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		   cpuinfo.endian ? "little" : "big",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		   cpuinfo.cpu_clock_freq / 1000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		   cpuinfo.cpu_clock_freq % 1000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		   loops_per_jiffy / (500000 / HZ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		   (loops_per_jiffy / (5000 / HZ)) % 100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		   "HW:\n Shift:\t\t%s\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		   " MSR:\t\t%s\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		   " PCMP:\t\t%s\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		   " DIV:\t\t%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		   (cpuinfo.use_instr & PVR0_USE_BARREL_MASK) ? "yes" : "no",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		   (cpuinfo.use_instr & PVR2_USE_MSR_INSTR) ? "yes" : "no",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		   (cpuinfo.use_instr & PVR2_USE_PCMP_INSTR) ? "yes" : "no",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		   (cpuinfo.use_instr & PVR0_USE_DIV_MASK) ? "yes" : "no");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	seq_printf(m, " MMU:\t\t%x\n", cpuinfo.mmu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		   " MUL:\t\t%s\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		   " FPU:\t\t%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		   (cpuinfo.use_mult & PVR2_USE_MUL64_MASK) ? "v2" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		   (cpuinfo.use_mult & PVR0_USE_HW_MUL_MASK) ? "v1" : "no",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		   (cpuinfo.use_fpu & PVR2_USE_FPU2_MASK) ? "v2" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		   (cpuinfo.use_fpu & PVR0_USE_FPU_MASK) ? "v1" : "no");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		   " Exc:\t\t%s%s%s%s%s%s%s%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		   (cpuinfo.use_exc & PVR2_OPCODE_0x0_ILL_MASK) ? "op0x0 " : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		   (cpuinfo.use_exc & PVR2_UNALIGNED_EXC_MASK) ? "unal " : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		   (cpuinfo.use_exc & PVR2_ILL_OPCODE_EXC_MASK) ? "ill " : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		   (cpuinfo.use_exc & PVR2_IOPB_BUS_EXC_MASK) ? "iopb " : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		   (cpuinfo.use_exc & PVR2_DOPB_BUS_EXC_MASK) ? "dopb " : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		   (cpuinfo.use_exc & PVR2_DIV_ZERO_EXC_MASK) ? "zero " : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		   (cpuinfo.use_exc & PVR2_FPU_EXC_MASK) ? "fpu " : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		   (cpuinfo.use_exc & PVR2_USE_FSL_EXC) ? "fsl " : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		   "Stream-insns:\t%sprivileged\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		   cpuinfo.mmu_privins ? "un" : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	if (cpuinfo.use_icache)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			   "Icache:\t\t%ukB\tline length:\t%dB\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			   cpuinfo.icache_size >> 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			   cpuinfo.icache_line_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		seq_puts(m, "Icache:\t\tno\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	if (cpuinfo.use_dcache) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			   "Dcache:\t\t%ukB\tline length:\t%dB\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			   cpuinfo.dcache_size >> 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			   cpuinfo.dcache_line_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		seq_puts(m, "Dcache-Policy:\t");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		if (cpuinfo.dcache_wb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 			seq_puts(m, "write-back\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			seq_puts(m, "write-through\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		seq_puts(m, "Dcache:\t\tno\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		   "HW-Debug:\t%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		   cpuinfo.hw_debug ? "yes" : "no");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		   "PVR-USR1:\t%02x\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		   "PVR-USR2:\t%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		   cpuinfo.pvr_user1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		   cpuinfo.pvr_user2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	seq_printf(m, "Page size:\t%lu\n", PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static void *c_start(struct seq_file *m, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	int i = *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	return i < NR_CPUS ? (void *) (i + 1) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static void *c_next(struct seq_file *m, void *v, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	++*pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	return c_start(m, pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) static void c_stop(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) const struct seq_operations cpuinfo_op = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	.start = c_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	.next = c_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	.stop = c_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	.show = show_cpuinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) };