2 * arch/sh/kernel/cpu/sh4/probe.c
4 * CPU Subtype Probing for SH-4.
6 * Copyright (C) 2001 - 2006 Paul Mundt
7 * Copyright (C) 2003 Richard Curnow
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
13 #include <linux/init.h>
15 #include <asm/processor.h>
16 #include <asm/cache.h>
18 int __init detect_cpu_and_cache_system(void)
20 unsigned long pvr, prr, cvr;
23 static unsigned long sizes[16] = {
31 pvr = (ctrl_inl(CCN_PVR) >> 8) & 0xffffff;
32 prr = (ctrl_inl(CCN_PRR) >> 4) & 0xff;
33 cvr = (ctrl_inl(CCN_CVR));
36 * Setup some sane SH-4 defaults for the icache
38 current_cpu_data.icache.way_incr = (1 << 13);
39 current_cpu_data.icache.entry_shift = 5;
40 current_cpu_data.icache.sets = 256;
41 current_cpu_data.icache.ways = 1;
42 current_cpu_data.icache.linesz = L1_CACHE_BYTES;
45 * And again for the dcache ..
47 current_cpu_data.dcache.way_incr = (1 << 14);
48 current_cpu_data.dcache.entry_shift = 5;
49 current_cpu_data.dcache.sets = 512;
50 current_cpu_data.dcache.ways = 1;
51 current_cpu_data.dcache.linesz = L1_CACHE_BYTES;
54 * Setup some generic flags we can probe
55 * (L2 and DSP detection only work on SH-4A)
57 if (((pvr >> 16) & 0xff) == 0x10) {
58 if ((cvr & 0x02000000) == 0)
59 current_cpu_data.flags |= CPU_HAS_L2_CACHE;
60 if ((cvr & 0x10000000) == 0)
61 current_cpu_data.flags |= CPU_HAS_DSP;
63 current_cpu_data.flags |= CPU_HAS_LLSC;
66 /* FPU detection works for everyone */
67 if ((cvr & 0x20000000) == 1)
68 current_cpu_data.flags |= CPU_HAS_FPU;
70 /* Mask off the upper chip ID */
74 * Probe the underlying processor version/revision and
75 * adjust cpu_data setup accordingly.
79 current_cpu_data.type = CPU_SH7750;
80 current_cpu_data.flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU |
84 current_cpu_data.type = CPU_SH7750S;
85 current_cpu_data.flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU |
89 current_cpu_data.type = CPU_SH7751;
90 current_cpu_data.flags |= CPU_HAS_FPU;
93 current_cpu_data.type = CPU_SH73180;
94 current_cpu_data.icache.ways = 4;
95 current_cpu_data.dcache.ways = 4;
96 current_cpu_data.flags |= CPU_HAS_LLSC;
100 current_cpu_data.type = CPU_SH7770;
101 current_cpu_data.icache.ways = 4;
102 current_cpu_data.dcache.ways = 4;
104 current_cpu_data.flags |= CPU_HAS_FPU | CPU_HAS_LLSC;
109 current_cpu_data.type = CPU_SH7781;
111 current_cpu_data.type = CPU_SH7780;
113 current_cpu_data.icache.ways = 4;
114 current_cpu_data.dcache.ways = 4;
116 current_cpu_data.flags |= CPU_HAS_FPU | CPU_HAS_PERF_COUNTER |
122 current_cpu_data.type = CPU_SH7343;
123 current_cpu_data.icache.ways = 4;
124 current_cpu_data.dcache.ways = 4;
125 current_cpu_data.flags |= CPU_HAS_LLSC;
129 current_cpu_data.type = CPU_SH7722;
130 current_cpu_data.icache.ways = 4;
131 current_cpu_data.dcache.ways = 4;
132 current_cpu_data.flags |= CPU_HAS_LLSC;
136 current_cpu_data.type = CPU_ST40RA;
137 current_cpu_data.flags |= CPU_HAS_FPU;
140 current_cpu_data.type = CPU_ST40GX1;
141 current_cpu_data.flags |= CPU_HAS_FPU;
144 current_cpu_data.type = CPU_SH4_501;
145 current_cpu_data.icache.ways = 2;
146 current_cpu_data.dcache.ways = 2;
149 current_cpu_data.type = CPU_SH4_202;
150 current_cpu_data.icache.ways = 2;
151 current_cpu_data.dcache.ways = 2;
152 current_cpu_data.flags |= CPU_HAS_FPU;
154 case 0x500 ... 0x501:
157 current_cpu_data.type = CPU_SH7750R;
160 current_cpu_data.type = CPU_SH7751R;
163 current_cpu_data.type = CPU_SH7760;
167 current_cpu_data.icache.ways = 2;
168 current_cpu_data.dcache.ways = 2;
170 current_cpu_data.flags |= CPU_HAS_FPU;
174 current_cpu_data.type = CPU_SH_NONE;
178 #ifdef CONFIG_SH_DIRECT_MAPPED
179 current_cpu_data.icache.ways = 1;
180 current_cpu_data.dcache.ways = 1;
183 #ifdef CONFIG_CPU_HAS_PTEA
184 current_cpu_data.flags |= CPU_HAS_PTEA;
188 * On anything that's not a direct-mapped cache, look to the CVR
189 * for I/D-cache specifics.
191 if (current_cpu_data.icache.ways > 1) {
192 size = sizes[(cvr >> 20) & 0xf];
193 current_cpu_data.icache.way_incr = (size >> 1);
194 current_cpu_data.icache.sets = (size >> 6);
198 /* Setup the rest of the I-cache info */
199 current_cpu_data.icache.entry_mask = current_cpu_data.icache.way_incr -
200 current_cpu_data.icache.linesz;
202 current_cpu_data.icache.way_size = current_cpu_data.icache.sets *
203 current_cpu_data.icache.linesz;
205 /* And the rest of the D-cache */
206 if (current_cpu_data.dcache.ways > 1) {
207 size = sizes[(cvr >> 16) & 0xf];
208 current_cpu_data.dcache.way_incr = (size >> 1);
209 current_cpu_data.dcache.sets = (size >> 6);
212 current_cpu_data.dcache.entry_mask = current_cpu_data.dcache.way_incr -
213 current_cpu_data.dcache.linesz;
215 current_cpu_data.dcache.way_size = current_cpu_data.dcache.sets *
216 current_cpu_data.dcache.linesz;
219 * Setup the L2 cache desc
221 * SH-4A's have an optional PIPT L2.
223 if (current_cpu_data.flags & CPU_HAS_L2_CACHE) {
225 * Size calculation is much more sensible
226 * than it is for the L1.
228 * Sizes are 128KB, 258KB, 512KB, and 1MB.
230 size = (cvr & 0xf) << 17;
234 current_cpu_data.scache.way_incr = (1 << 16);
235 current_cpu_data.scache.entry_shift = 5;
236 current_cpu_data.scache.ways = 4;
237 current_cpu_data.scache.linesz = L1_CACHE_BYTES;
239 current_cpu_data.scache.entry_mask =
240 (current_cpu_data.scache.way_incr -
241 current_cpu_data.scache.linesz);
243 current_cpu_data.scache.sets = size /
244 (current_cpu_data.scache.linesz *
245 current_cpu_data.scache.ways);
247 current_cpu_data.scache.way_size =
248 (current_cpu_data.scache.sets *
249 current_cpu_data.scache.linesz);