• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Display CPU info in /proc/cpuinfo.
4  *
5  * Copyright (C) 2003, Axis Communications AB.
6  */
7 
8 #include <linux/seq_file.h>
9 #include <linux/proc_fs.h>
10 #include <linux/delay.h>
11 #include <linux/param.h>
12 
13 #include <linux/i2c.h>
14 #include <linux/platform_device.h>
15 
16 #ifdef CONFIG_PROC_FS
17 
18 #define HAS_FPU         0x0001
19 #define HAS_MMU         0x0002
20 #define HAS_ETHERNET100 0x0004
21 #define HAS_TOKENRING   0x0008
22 #define HAS_SCSI        0x0010
23 #define HAS_ATA         0x0020
24 #define HAS_USB         0x0040
25 #define HAS_IRQ_BUG     0x0080
26 #define HAS_MMU_BUG     0x0100
27 
28 struct cpu_info {
29 	char *cpu_model;
30 	unsigned short rev;
31 	unsigned short cache_size;
32 	unsigned short flags;
33 };
34 
35 /* Some of these model are here for historical reasons only. */
36 static struct cpu_info cpinfo[] = {
37 	{"ETRAX 1", 0, 0, 0},
38 	{"ETRAX 2", 1, 0, 0},
39 	{"ETRAX 3", 2, 0, 0},
40 	{"ETRAX 4", 3, 0, 0},
41 	{"Simulator", 7, 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA},
42 	{"ETRAX 100", 8, 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA | HAS_IRQ_BUG},
43 	{"ETRAX 100", 9, 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA},
44 
45 	{"ETRAX 100LX", 10, 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA | HAS_USB
46 			     | HAS_MMU | HAS_MMU_BUG},
47 
48 	{"ETRAX 100LX v2", 11, 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA | HAS_USB
49 			        | HAS_MMU},
50 #ifdef CONFIG_ETRAXFS
51 	{"ETRAX FS", 32, 32, HAS_ETHERNET100 | HAS_ATA | HAS_MMU},
52 #else
53 	{"ARTPEC-3", 32, 32, HAS_ETHERNET100 | HAS_MMU},
54 #endif
55 	{"Unknown", 0, 0, 0}
56 };
57 
show_cpuinfo(struct seq_file * m,void * v)58 int show_cpuinfo(struct seq_file *m, void *v)
59 {
60 	int i;
61 	int cpu = (int)v - 1;
62 	unsigned long revision;
63 	struct cpu_info *info;
64 
65 	info = &cpinfo[ARRAY_SIZE(cpinfo) - 1];
66 
67 	revision = rdvr();
68 
69 	for (i = 0; i < ARRAY_SIZE(cpinfo); i++) {
70 		if (cpinfo[i].rev == revision) {
71 			info = &cpinfo[i];
72 			break;
73 		}
74 	}
75 
76 	seq_printf(m,
77 		   "processor\t: %d\n"
78 		   "cpu\t\t: CRIS\n"
79 		   "cpu revision\t: %lu\n"
80 		   "cpu model\t: %s\n"
81 		   "cache size\t: %d KB\n"
82 		   "fpu\t\t: %s\n"
83 		   "mmu\t\t: %s\n"
84 		   "mmu DMA bug\t: %s\n"
85 		   "ethernet\t: %s Mbps\n"
86 		   "token ring\t: %s\n"
87 		   "scsi\t\t: %s\n"
88 		   "ata\t\t: %s\n"
89 		   "usb\t\t: %s\n"
90 		   "bogomips\t: %lu.%02lu\n\n",
91 
92 		   cpu,
93 		   revision,
94 		   info->cpu_model,
95 		   info->cache_size,
96 		   info->flags & HAS_FPU ? "yes" : "no",
97 		   info->flags & HAS_MMU ? "yes" : "no",
98 		   info->flags & HAS_MMU_BUG ? "yes" : "no",
99 		   info->flags & HAS_ETHERNET100 ? "10/100" : "10",
100 		   info->flags & HAS_TOKENRING ? "4/16 Mbps" : "no",
101 		   info->flags & HAS_SCSI ? "yes" : "no",
102 		   info->flags & HAS_ATA ? "yes" : "no",
103 		   info->flags & HAS_USB ? "yes" : "no",
104 		   (loops_per_jiffy * HZ + 500) / 500000,
105 		   ((loops_per_jiffy * HZ + 500) / 5000) % 100);
106 
107 	return 0;
108 }
109 
110 #endif /* CONFIG_PROC_FS */
111 
show_etrax_copyright(void)112 void show_etrax_copyright(void)
113 {
114 #ifdef CONFIG_ETRAXFS
115 	printk(KERN_INFO "Linux/CRISv32 port on ETRAX FS "
116 		"(C) 2003, 2004 Axis Communications AB\n");
117 #else
118 	printk(KERN_INFO "Linux/CRISv32 port on ARTPEC-3 "
119 		"(C) 2003-2009 Axis Communications AB\n");
120 #endif
121 }
122 
123 static struct i2c_board_info __initdata i2c_info[] = {
124 	{I2C_BOARD_INFO("camblock", 0x43)},
125 	{I2C_BOARD_INFO("tmp100", 0x48)},
126 	{I2C_BOARD_INFO("tmp100", 0x4A)},
127 	{I2C_BOARD_INFO("tmp100", 0x4C)},
128 	{I2C_BOARD_INFO("tmp100", 0x4D)},
129 	{I2C_BOARD_INFO("tmp100", 0x4E)},
130 #ifdef CONFIG_RTC_DRV_PCF8563
131 	{I2C_BOARD_INFO("pcf8563", 0x51)},
132 #endif
133 	{I2C_BOARD_INFO("pca9536", 0x41)},
134 	{I2C_BOARD_INFO("fnp300", 0x40)},
135 	{I2C_BOARD_INFO("fnp300", 0x42)},
136 	{I2C_BOARD_INFO("adc101", 0x54)},
137 };
138 
139 static struct i2c_board_info __initdata i2c_info2[] = {
140 	{I2C_BOARD_INFO("camblock", 0x43)},
141 	{I2C_BOARD_INFO("tmp100", 0x48)},
142 	{I2C_BOARD_INFO("tmp100", 0x4A)},
143 	{I2C_BOARD_INFO("tmp100", 0x4C)},
144 	{I2C_BOARD_INFO("tmp100", 0x4D)},
145 	{I2C_BOARD_INFO("tmp100", 0x4E)},
146 	{I2C_BOARD_INFO("pca9536", 0x41)},
147 	{I2C_BOARD_INFO("fnp300", 0x40)},
148 	{I2C_BOARD_INFO("fnp300", 0x42)},
149 	{I2C_BOARD_INFO("adc101", 0x54)},
150 };
151 
152 static struct i2c_board_info __initdata i2c_info3[] = {
153 	{I2C_BOARD_INFO("adc101", 0x54)},
154 };
155 
etrax_init(void)156 static int __init etrax_init(void)
157 {
158 	i2c_register_board_info(0, i2c_info, ARRAY_SIZE(i2c_info));
159 	i2c_register_board_info(1, i2c_info2, ARRAY_SIZE(i2c_info2));
160 	i2c_register_board_info(2, i2c_info3, ARRAY_SIZE(i2c_info3));
161 	return 0;
162 }
163 arch_initcall(etrax_init);
164