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